Skip to content

Commit

Permalink
[Core] Add Apple Globe key support
Browse files Browse the repository at this point in the history
Attempt X at this.  ZMK added it recently, and looking into it, this should be a simple
consumer page code (0x29D), and doesn't require any special handling, an Apple supported
VID:PID combo, or anything like that.  Just Extrakey enabled, and the appropriate consumer
code.  Tested locally.
  • Loading branch information
drashna committed Oct 10, 2023
1 parent 17c7d1f commit fb94bc4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
Empty file.
12 changes: 12 additions & 0 deletions data/constants/keycodes/keycodes_0.0.4_basic.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"keycodes": {
"0x00C3": {
"group": "media",
"key": "KC_GLOBE",
"label": "Apple Globe/FN Key",
"aliases": [
"KC_GLB"
]
}
}
}
4 changes: 3 additions & 1 deletion quantum/keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ enum qk_keycode_defines {
KC_ASSISTANT = 0x00C0,
KC_MISSION_CONTROL = 0x00C1,
KC_LAUNCHPAD = 0x00C2,
KC_GLOBE = 0x00C3,
KC_MS_UP = 0x00CD,
KC_MS_DOWN = 0x00CE,
KC_MS_LEFT = 0x00CF,
Expand Down Expand Up @@ -904,6 +905,7 @@ enum qk_keycode_defines {
KC_ASST = KC_ASSISTANT,
KC_MCTL = KC_MISSION_CONTROL,
KC_LPAD = KC_LAUNCHPAD,
KC_GLB = KC_GLOBE,
KC_MS_U = KC_MS_UP,
KC_MS_D = KC_MS_DOWN,
KC_MS_L = KC_MS_LEFT,
Expand Down Expand Up @@ -1403,7 +1405,7 @@ enum qk_keycode_defines {
#define IS_INTERNAL_KEYCODE(code) ((code) >= KC_NO && (code) <= KC_TRANSPARENT)
#define IS_BASIC_KEYCODE(code) ((code) >= KC_A && (code) <= KC_EXSEL)
#define IS_SYSTEM_KEYCODE(code) ((code) >= KC_SYSTEM_POWER && (code) <= KC_SYSTEM_WAKE)
#define IS_CONSUMER_KEYCODE(code) ((code) >= KC_AUDIO_MUTE && (code) <= KC_LAUNCHPAD)
#define IS_CONSUMER_KEYCODE(code) ((code) >= KC_AUDIO_MUTE && (code) <= KC_GLOBE)
#define IS_MOUSE_KEYCODE(code) ((code) >= KC_MS_UP && (code) <= KC_MS_ACCEL2)
#define IS_MODIFIER_KEYCODE(code) ((code) >= KC_LEFT_CTRL && (code) <= KC_RIGHT_GUI)
#define IS_SWAP_HANDS_KEYCODE(code) ((code) >= QK_SWAP_HANDS_TOGGLE && (code) <= QK_SWAP_HANDS_ONE_SHOT)
Expand Down
2 changes: 1 addition & 1 deletion quantum/keymap_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ action_t action_for_keycode(uint16_t keycode) {
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
break;
case KC_AUDIO_MUTE ... KC_LAUNCHPAD:
case KC_AUDIO_MUTE ... KC_GLOBE:
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
break;
#endif
Expand Down
1 change: 1 addition & 0 deletions tests/test_common/keycode_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {
{KC_ASSISTANT, "KC_ASSISTANT"},
{KC_MISSION_CONTROL, "KC_MISSION_CONTROL"},
{KC_LAUNCHPAD, "KC_LAUNCHPAD"},
{KC_GLOBE, "KC_GLOBE"},
{KC_MS_UP, "KC_MS_UP"},
{KC_MS_DOWN, "KC_MS_DOWN"},
{KC_MS_LEFT, "KC_MS_LEFT"},
Expand Down
3 changes: 3 additions & 0 deletions tmk_core/protocol/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ enum consumer_usages {
AC_STOP = 0x226,
AC_REFRESH = 0x227,
AC_BOOKMARKS = 0x22A,
AC_GLOBE = 0x29D,
AC_MISSION_CONTROL = 0x29F,
AC_LAUNCHPAD = 0x2A0
};
Expand Down Expand Up @@ -324,6 +325,8 @@ static inline uint16_t KEYCODE2CONSUMER(uint8_t key) {
return AC_MISSION_CONTROL;
case KC_LAUNCHPAD:
return AC_LAUNCHPAD;
case KC_GLOBE:
return AC_GLOBE;
default:
return 0;
}
Expand Down

5 comments on commit fb94bc4

@HVR88
Copy link

@HVR88 HVR88 commented on fb94bc4 Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about including Globe as a modifier so that it can also be used programmatically and with VIA as an advanced code, plus take advantage of all the QMK modifier benefits/functions?

Getting you everything you can do with other modifiers like CTRL: https://github.com/qmk/qmk_firmware/blob/master/docs/feature_advanced_keycodes.md

It would then be super easy to recreate any regular globe shortcuts from VIA such as GLB(KC_N) for Notification Center, etc.

@drashna
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the way that everything is set up, there isn't a way to do that, in a large part because there is no room in the keycode mapping to support that.

@HVR88
Copy link

@HVR88 HVR88 commented on fb94bc4 Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a shame. Easy enough to use alternatives when compiling QMK, just not as nice for people using only the VIA web or app.

@veryredpp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry if this is a newbie comment, but would i need to reflash my keyboard to be able to map the globe key through qmk?

@drashna
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry if this is a newbie comment, but would i need to reflash my keyboard to be able to map the globe key through qmk?

This code isn't in the main QMK repo, so using that wouldn't help you. And yes, you'd have to reflash the firmware

Please sign in to comment.