From 6dfff3e8dbbd7d75d974cc1ebda4d5a762c8f8d7 Mon Sep 17 00:00:00 2001 From: lbibass Date: Wed, 2 Jan 2019 12:30:34 -0500 Subject: [PATCH 1/5] initial commit to add launchpad and mission control into QMK. --- .../v2/keymaps/lbibass_625_space/keymap.c | 2 +- tmk_core/common/keycode.h | 17 +++++++++++------ tmk_core/common/report.h | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/lbibass_625_space/keymap.c b/keyboards/mechmini/v2/keymaps/lbibass_625_space/keymap.c index fba582e1b78a..cadfad587e7c 100755 --- a/keyboards/mechmini/v2/keymaps/lbibass_625_space/keymap.c +++ b/keyboards/mechmini/v2/keymaps/lbibass_625_space/keymap.c @@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), [_FN2] = LAYOUT_625_space( - KC_PWR, KC_BRID, KC_BRIU, KC_NO, KC_NO, KC_NO, KC_NO, KC_MRWD, KC_MPLY, KC_MFFD, KC_MUTE, RESET, + KC_PWR, KC_BRID, KC_BRIU, KC_MISSION_CONTROL, KC_LAUNCHPAD, KC_NO, KC_NO, KC_MRWD, KC_MPLY, KC_MFFD, KC_MUTE, RESET, MT(KC_LGUI, KC_ESC), KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, TG(1), KC_TRNS, KC_TRNS, KC_VOLD, KC_VOLU, KC_TRNS, KC_TRNS, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, KC_TRNS, KC_TRNS, KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index ac3edbd21526..2785eee8ddfd 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -173,6 +173,8 @@ along with this program. If not, see . #define KC_MRWD KC_MEDIA_REWIND #define KC_BRIU KC_BRIGHTNESS_UP #define KC_BRID KC_BRIGHTNESS_DOWN +#define KC_MICO KC_MISSION_CONTROL +#define KC_LAUN KC_LAUNCHPAD /* Mouse Keys */ #define KC_MS_U KC_MS_UP @@ -432,9 +434,10 @@ enum hid_keyboard_keypad_usage { }; /* Media and Function keys */ -enum internal_special_keycodes { +enum internal_special_keycodes +{ /* Generic Desktop Page (0x01) */ - KC_SYSTEM_POWER = 0xA5, + KC_SYSTEM_POWER = 0xA5, KC_SYSTEM_SLEEP, KC_SYSTEM_WAKE, @@ -447,7 +450,7 @@ enum internal_special_keycodes { KC_MEDIA_STOP, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_SELECT, - KC_MEDIA_EJECT, //0xB0 + KC_MEDIA_EJECT, //0xB0 KC_MAIL, KC_CALCULATOR, KC_MY_COMPUTER, @@ -462,9 +465,11 @@ enum internal_special_keycodes { KC_MEDIA_REWIND, KC_BRIGHTNESS_UP, KC_BRIGHTNESS_DOWN, + KC_LAUNCHPAD, + KC_MISSION_CONTROL, - /* Fn keys */ - KC_FN0 = 0xC0, + /* Fn keys */ + KC_FN0 = 0xC0, KC_FN1, KC_FN2, KC_FN3, @@ -480,7 +485,7 @@ enum internal_special_keycodes { KC_FN13, KC_FN14, KC_FN15, - KC_FN16, //0xD0 + KC_FN16, //0xD0 KC_FN17, KC_FN18, KC_FN19, diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index eb9afb727e44..d62091869ad3 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -50,6 +50,9 @@ along with this program. If not, see . #define TRANSPORT_PLAY_PAUSE 0x00CD #define BRIGHTNESSUP 0x006F #define BRIGHTNESSDOWN 0x0070 +#define MISSION_CONTROL 0x029F +#define LAUNCHPAD 0x02A0 + /* application launch */ #define AL_CC_CONFIG 0x0183 #define AL_EMAIL 0x018A From 8ae6e5e9940ee88fa530596ae3b4895a4826e3f5 Mon Sep 17 00:00:00 2001 From: lbibass Date: Wed, 2 Jan 2019 14:35:09 -0500 Subject: [PATCH 2/5] attempting to fix by putting in correct keycode --- quantum/keymap_common.c | 6 +++--- tmk_core/common/keycode.h | 6 +++--- tmk_core/common/report.h | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index f6c8b70d28b9..75ad7b1d8cf4 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -64,9 +64,9 @@ action_t action_for_key(uint8_t layer, keypos_t key) case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; - case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN: - action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); - break; + case KC_AUDIO_MUTE ... KC_MISSION_CONTROL: + action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); + break; case KC_MS_UP ... KC_MS_ACCEL2: action.code = ACTION_MOUSEKEY(keycode); break; diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index 2785eee8ddfd..08f5b682af2f 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -33,7 +33,7 @@ along with this program. If not, see . #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) #define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE) -#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_BRID) +#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_LAUN) #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) @@ -468,8 +468,8 @@ enum internal_special_keycodes KC_LAUNCHPAD, KC_MISSION_CONTROL, - /* Fn keys */ - KC_FN0 = 0xC0, + /* Fn keys */ + KC_FN0 = 0xC0, KC_FN1, KC_FN2, KC_FN3, diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index d62091869ad3..a4c854bee640 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -50,8 +50,8 @@ along with this program. If not, see . #define TRANSPORT_PLAY_PAUSE 0x00CD #define BRIGHTNESSUP 0x006F #define BRIGHTNESSDOWN 0x0070 -#define MISSION_CONTROL 0x029F -#define LAUNCHPAD 0x02A0 +#define LAUNCHPAD 0x2a0 +#define MISSION_CONTROL 0x29F /* application launch */ #define AL_CC_CONFIG 0x0183 @@ -174,7 +174,7 @@ typedef struct { (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0))) /* keycode to consumer usage */ -#define KEYCODE2CONSUMER(key) \ +#define KEYCODE2CONSUMER(key) \ (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \ (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \ (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \ @@ -197,6 +197,8 @@ typedef struct { (key == KC_WWW_REFRESH ? AC_REFRESH : \ (key == KC_BRIGHTNESS_UP ? BRIGHTNESSUP : \ (key == KC_BRIGHTNESS_DOWN ? BRIGHTNESSDOWN : \ + (key == KC_LAUNCHPAD ? LAUNCHPAD : \ + (key == KC_MISSION_CONTROL ? MISSION_CONTROL : \ (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))))) uint8_t has_anykey(report_keyboard_t* keyboard_report); From a49b51ff522f007ba9c86cab4830c32212b688bd Mon Sep 17 00:00:00 2001 From: lbibass Date: Wed, 2 Jan 2019 14:50:19 -0500 Subject: [PATCH 3/5] Fixed duplicate case error. --- tmk_core/common/keycode.h | 2 +- tmk_core/common/report.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index 08f5b682af2f..350f8a53b7fc 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -465,8 +465,8 @@ enum internal_special_keycodes KC_MEDIA_REWIND, KC_BRIGHTNESS_UP, KC_BRIGHTNESS_DOWN, - KC_LAUNCHPAD, KC_MISSION_CONTROL, + KC_LAUNCHPAD, /* Fn keys */ KC_FN0 = 0xC0, diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index a4c854bee640..5f31f9a77e51 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -50,8 +50,8 @@ along with this program. If not, see . #define TRANSPORT_PLAY_PAUSE 0x00CD #define BRIGHTNESSUP 0x006F #define BRIGHTNESSDOWN 0x0070 -#define LAUNCHPAD 0x2a0 -#define MISSION_CONTROL 0x29F +#define LAUNCHPAD 0x02a0 +#define MISSION_CONTROL 0x029F /* application launch */ #define AL_CC_CONFIG 0x0183 From a2fc7753682fa1b6b99d640646f7888eb51553e7 Mon Sep 17 00:00:00 2001 From: lbibass Date: Thu, 3 Jan 2019 10:25:57 -0500 Subject: [PATCH 4/5] got it to compile, but mission control and launchpad output wrong keys. --- tmk_core/common/keycode.h | 2 +- tmk_core/common/report.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index 350f8a53b7fc..872c8588b43d 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -33,7 +33,7 @@ along with this program. If not, see . #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) #define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE) -#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_LAUN) +#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_MICO) #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 5f31f9a77e51..b3c4a7cf06f9 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h @@ -199,7 +199,7 @@ typedef struct { (key == KC_BRIGHTNESS_DOWN ? BRIGHTNESSDOWN : \ (key == KC_LAUNCHPAD ? LAUNCHPAD : \ (key == KC_MISSION_CONTROL ? MISSION_CONTROL : \ - (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))))) + (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))))))) uint8_t has_anykey(report_keyboard_t* keyboard_report); uint8_t get_first_key(report_keyboard_t* keyboard_report); From 1989e58a21f100f2a79086e4a4fdf9a9b8bf4b5e Mon Sep 17 00:00:00 2001 From: lbibass Date: Thu, 3 Jan 2019 10:32:42 -0500 Subject: [PATCH 5/5] removed fn0? Doesn't seem to break anything. --- quantum/keymap_common.c | 2 +- tmk_core/common/keycode.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 75ad7b1d8cf4..9d0c36a5a162 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -54,7 +54,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) uint8_t action_layer, when, mod; switch (keycode) { - case KC_FN0 ... KC_FN31: + case KC_FN1 ... KC_FN31: action.code = keymap_function_id_to_action(FN_INDEX(keycode)); break; case KC_A ... KC_EXSEL: diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index 872c8588b43d..8d42e9a473ab 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -47,7 +47,7 @@ along with this program. If not, see . #define MOD_INDEX(code) ((code) & 0x07) #define FN_BIT(code) (1 << FN_INDEX(code)) -#define FN_INDEX(code) ((code) - KC_FN0) +#define FN_INDEX(code) ((code) - KC_FN1) #define FN_MIN KC_FN0 #define FN_MAX KC_FN31 @@ -469,7 +469,6 @@ enum internal_special_keycodes KC_LAUNCHPAD, /* Fn keys */ - KC_FN0 = 0xC0, KC_FN1, KC_FN2, KC_FN3,