aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards/xd004/keymaps/system_and_media
diff options
context:
space:
mode:
authorSidney Bovet <sidney.bovet@gmail.com>2019-07-15 19:35:05 +0200
committerDrashna Jaelre <drashna@live.com>2019-07-15 10:35:05 -0700
commita200f194d14086e2da740ac48bac5ffdf36689d8 (patch)
tree0a8cb1ae1bbd535e70868379c54a643672cf09d4 /keyboards/xd004/keymaps/system_and_media
parentb2fb0ceeef1a3f8ba96184fbeb21b2c89456c06a (diff)
downloadfirmware-a200f194d14086e2da740ac48bac5ffdf36689d8.tar.gz
firmware-a200f194d14086e2da740ac48bac5ffdf36689d8.tar.bz2
firmware-a200f194d14086e2da740ac48bac5ffdf36689d8.zip
[Keyboard] Add support for XD004 macro keyboard (#6337)
* Add support for XD004 Also applying the following suggested edits: Add hardware availability link in readme Co-Authored-By: Drashna Jaelre <drashna@live.com> Enable lite bootmagic Co-Authored-By: Drashna Jaelre <drashna@live.com> Remove commented out MCU Co-Authored-By: fauxpark <fauxpark@gmail.com> * Add more ellaborate keymap Correcting usage of tap_code_16 for modified key, thanks to @drashna * Add information about bootloader type Co-Authored-By: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'keyboards/xd004/keymaps/system_and_media')
-rw-r--r--keyboards/xd004/keymaps/system_and_media/keymap.c61
-rw-r--r--keyboards/xd004/keymaps/system_and_media/readme.md9
2 files changed, 70 insertions, 0 deletions
diff --git a/keyboards/xd004/keymaps/system_and_media/keymap.c b/keyboards/xd004/keymaps/system_and_media/keymap.c
new file mode 100644
index 000000000..740132639
--- /dev/null
+++ b/keyboards/xd004/keymaps/system_and_media/keymap.c
@@ -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;
+ }
+};
diff --git a/keyboards/xd004/keymaps/system_and_media/readme.md b/keyboards/xd004/keymaps/system_and_media/readme.md
new file mode 100644
index 000000000..0fb3c61b6
--- /dev/null
+++ b/keyboards/xd004/keymaps/system_and_media/readme.md
@@ -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`.