-
-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for XD004 macro keyboard #6337
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"keyboard_name": "XD004", | ||
"maintainer": "", | ||
"width": 4, | ||
"height": 1, | ||
"layouts": { | ||
"LAYOUT_all": { | ||
"layout": [{"label":"L", "x":0, "y":0}, {"label":"O", "x":1, "y":0}, {"label":"V", "x":2, "y":0}, {"label":"E", "x":3, "y":0}] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include QMK_KEYBOARD_H | ||
|
||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
|
||
// 0: Base Layer | ||
LAYOUT_all(KC_L, KC_O, KC_V, KC_E), | ||
|
||
}; | ||
|
||
// Loop | ||
void matrix_scan_user(void){ | ||
// Empty | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Default Keymap for XD004 PCB | ||
|
||
This keymap is not very useful, but it will validate that the board works. | ||
|
||
## Build | ||
|
||
To build the default keymap, simply run `make xd004:default`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include QMK_KEYBOARD_H | ||
|
||
#define _BASE 0 // Base layer | ||
#define _SYSTEM 1 // System actions | ||
#define _VOLUME 2 // Volume actions | ||
|
||
#define SUPER_ALT_F4_TIMER 300 // Timeout on the super alt-f4 key | ||
|
||
/* | ||
The idea of this is pretty simple: base layer has four action, two of which (the outermost) | ||
are regular keystrokes on tap, and a momentary layer switch on hold, sending you to layers 1 and 2. | ||
|
||
The other bit of customization here is the 'Super Alt F4' which does Alt-F4, and then Enter if tapped | ||
again SUPER_ALT_F4_TIMER miliseconds after. This lets you Alt-F4 applications, and finally quickly | ||
double-tap it to Alt-F4+Enter to shut down the PC. | ||
*/ | ||
|
||
bool is_alt_f4_active = false; | ||
uint16_t alt_f4_timer = 0; | ||
|
||
enum custom_keycodes { // Make sure have the awesome keycode ready | ||
SUPER_ALT_F4 = SAFE_RANGE, | ||
}; | ||
|
||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
|
||
// 0: Base Layer | ||
[_BASE] = LAYOUT_all(LT(_SYSTEM, KC_F5), C(G(KC_LEFT)), C(G(KC_RIGHT)), LT(_VOLUME, KC_F7)), | ||
|
||
// 1: System actions | ||
[_SYSTEM] = LAYOUT_all(_______, SUPER_ALT_F4, G(KC_D), G(KC_L)), | ||
|
||
// 2: Volume actions | ||
[_VOLUME] = LAYOUT_all(KC_MEDIA_NEXT_TRACK, KC_AUDIO_VOL_DOWN, KC_AUDIO_VOL_UP, _______), | ||
|
||
}; | ||
|
||
bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
switch (keycode) { // This will do most of the grunt work with the keycodes. | ||
case SUPER_ALT_F4: | ||
if (record->event.pressed) { | ||
if (!is_alt_f4_active) { | ||
is_alt_f4_active = true; | ||
tap_code_16(LALT(KC_F4); // Alt-F4 | ||
} else { | ||
tap_code(KC_ENTER); // Tap enter | ||
} | ||
} else { | ||
unregister_code(KC_TAB); | ||
} | ||
alt_f4_timer = timer_read(); | ||
break; | ||
} | ||
return true; | ||
} | ||
|
||
void matrix_scan_user(void) { | ||
if (is_alt_f4_active && timer_elapsed(alt_f4_timer) > SUPER_ALT_F4_TIMER) { | ||
is_alt_f4_active = false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Default Keymap for XD004 PCB | ||
|
||
A somehow more useful keymap, allowing one to move across virtual desktops on Windows, etc. | ||
|
||
It also has a 'Super Alt-F4' key for Windows that, when tapped does Alt-F4, unless two consecutive taps are less than 300ms apart, in which case the second tap becomes Enter. This allows you to close all apps doing taps, and then when the System shutdown window arrives you do a second quick tap and it will type enter, thus shutting down the computer. | ||
|
||
## Build | ||
|
||
To build the keymap, simply run `make xd004:system_and_media`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
XD004 | ||
== | ||
|
||
4-keys board | ||
|
||
![Top View of a XD004 board](https://ae01.alicdn.com/kf/HTB1_G9IX21H3KVjSZFHq6zKppXa0/xd004-xiudi-4-Custom-Mechanical-Keyboard-4-keys-switch-leds-PCB-programmed-hot-swappable-macro-key.jpg) | ||
|
||
Keyboard Maintainer: QMK Community | ||
Hardware Supported: XD004 PCB v1.0 | ||
SidneyBovet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Hardware Availability: [KPRepublic](https://kprepublic.com/products/xd004-xiudi-4-custom-mechanical-keyboard-4-keys-switch-leds-pcb-programmed-hot-swappable-macro-key-silver-case-micro-port) | ||
|
||
To build with a default keymap (not useful at all, have a look at other keymaps): | ||
|
||
```make xd004/v1:default``` | ||
|
||
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Copyright 2019 Sidney Bovet <[email protected]> | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/* | ||
Note: the following configuration uses 98% of the flash memory, be | ||
careful if you enable anything else. Also have a look at rules.mk | ||
where some things are disabled to save space as well. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "config_common.h" | ||
|
||
/* USB Device descriptor parameter */ | ||
#define VENDOR_ID 0xCDCD | ||
#define PRODUCT_ID 0x0404 | ||
#define DEVICE_VER 0x0001 | ||
// Note: unsure about manufacturer | ||
#define MANUFACTURER XIUDI | ||
#define PRODUCT XD004 v1 | ||
#define DESCRIPTION XD004 v1 Keyboard PCB | ||
|
||
/* key matrix size */ | ||
#define MATRIX_ROWS 1 | ||
#define MATRIX_COLS 4 | ||
|
||
/* | ||
* Keyboard Matrix Assignments | ||
* | ||
* On this board we have direct connection: no diodes. | ||
*/ | ||
#define DIRECT_PINS \ | ||
{ \ | ||
{ D3, D0, C4, B4 } \ | ||
} | ||
#define UNUSED_PINS | ||
|
||
/* Backlight Setup */ | ||
// Looks like each backlight LED is connected to a single output, D5 is the one furtherst away from USB port | ||
#define BACKLIGHT_PIN D5 | ||
#define BACKLIGHT_LEVELS 6 | ||
|
||
/* COL2ROW or ROW2COL */ | ||
#define DIODE_DIRECTION COL2ROW | ||
|
||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
#define DEBOUNCE 5 | ||
|
||
/* RGB Underglow | ||
This will not be used, as RGBLIGHT_ENABLE is set to 'no' in rules.mk | ||
We do not have enough space in the flash for this at the moment, maybe | ||
further optimizations can be done on that side. | ||
*/ | ||
#define RGB_DI_PIN C6 | ||
#define RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
#define RGBLED_NUM 2 | ||
#define RGBLIGHT_HUE_STEP 10 | ||
#define RGBLIGHT_SAT_STEP 17 | ||
#define RGBLIGHT_VAL_STEP 17 | ||
|
||
/* disable action features */ | ||
// #define NO_ACTION_ONESHOT // 462 bytes <- this needs to be un-commented out if Link Time Optimization is disabled, otherwise file is too large | ||
// The two below are implicit since we use LINK_TIME_OPTIMIZATION_ENABLE (in rules.mk) | ||
// #define NO_ACTION_MACRO | ||
// #define NO_ACTION_FUNCTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# MCU name | ||
MCU = atmega16u2 | ||
|
||
|
||
# Processor frequency. | ||
# This will define a symbol, F_CPU, in all source code files equal to the | ||
# processor frequency in Hz. You can then use this symbol in your source code to | ||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
# automatically to create a 32-bit value in your source code. | ||
# | ||
# This will be an integer division of F_USB below, as it is sourced by | ||
# F_USB after it has run through any CPU prescalers. Note that this value | ||
# does not *change* the processor frequency - it should merely be updated to | ||
# reflect the processor speed set externally so that the code can use accurate | ||
# software delays. | ||
F_CPU = 16000000 | ||
|
||
|
||
# LUFA specific | ||
# Target architecture (see library "Board Types" documentation). | ||
ARCH = AVR8 | ||
|
||
|
||
# Input clock frequency. | ||
# This will define a symbol, F_USB, in all source code files equal to the | ||
# input clock frequency (before any prescaling is performed) in Hz. This value may | ||
# differ from F_CPU if prescaling is used on the latter, and is required as the | ||
# raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
# at the end, this will be done automatically to create a 32-bit value in your | ||
# source code. | ||
# | ||
# If no clock division is performed on the input clock inside the AVR (via the | ||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
F_USB = $(F_CPU) | ||
|
||
|
||
# Interrupt driven control endpoint task(+60) | ||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
|
||
|
||
# Boot Section Size in *bytes* | ||
# Teensy halfKay 512 | ||
# Teensy++ halfKay 2048 | ||
# Atmel DFU loader 4096 | ||
# LUFA bootloader 4096 | ||
# USBaspLoader 2048 | ||
OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
SidneyBovet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BOOTLOADER = atmel-dfu | ||
|
||
|
||
# Build Options | ||
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration | ||
MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | ||
CONSOLE_ENABLE = no # Console for debug(+400) | ||
COMMAND_ENABLE = no # Commands for debug and configuration | ||
NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
MIDI_ENABLE = no # MIDI controls | ||
AUDIO_ENABLE = no # Audio output on port C6 | ||
UNICODE_ENABLE = no # Unicode | ||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. | ||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
|
||
# Saves about 5% of space: | ||
LINK_TIME_OPTIMIZATION_ENABLE = yes | ||
|
||
#LAYOUTS = ortho_1x4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "xd004.h" | ||
|
||
void led_set_kb(uint8_t usb_led) { | ||
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here | ||
|
||
led_set_user(usb_led); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include "quantum.h" | ||
//#include "led.h" | ||
|
||
/* XD60 Keymap Definition Macro */ | ||
/* | ||
+--------------------------------+ | ||
| K0 K1 K2 K3 [----- USB | ||
+--------------------------------+ | ||
*/ | ||
#define LAYOUT_all(K00, K01, K02, K03) \ | ||
{ \ | ||
{ K00, K01, K02, K03 } \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include QMK_KEYBOARD_H | ||
|
||
extern keymap_config_t keymap_config; | ||
|
||
// Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
// The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
// Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
// entirely and just use numbers. | ||
|
||
#define _DEFAULT 0 | ||
#define _LOWER 1 | ||
#define LOWER LT(_LOWER, KC_PENT) | ||
|
||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
|
||
[_DEFAULT] = LAYOUT_ortho_1x4 ( | ||
LOWER, KC_P0, KC_PDOT,KC_PAST | ||
), | ||
|
||
/* Lower */ | ||
[_LOWER] = LAYOUT_ortho_1x4 ( | ||
_______,_______,_______,_______ | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["","","",""] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually the default layout it shipped with. Mechanical keyboards, spreading the love 😄