Skip to content
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

Use function for KEYCODE2 routines instead of macro. #8101

Merged
merged 3 commits into from
Feb 7, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions tmk_core/common/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,44 @@ typedef struct {
} __attribute__((packed)) report_mouse_t;

/* keycode to system usage */
#define KEYCODE2SYSTEM(key) (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0)))
static inline uint16_t KEYCODE2SYSTEM(uint8_t key) {
switch (key) {
case KC_SYSTEM_POWER: return SYSTEM_POWER_DOWN;
case KC_SYSTEM_SLEEP: return SYSTEM_SLEEP;
case KC_SYSTEM_WAKE: return SYSTEM_WAKE_UP;
default: return 0;
}
}

/* keycode to consumer usage */
#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 : (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : (key == KC_MEDIA_STOP ? TRANSPORT_STOP : (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : (key == KC_MAIL ? AL_EMAIL : (key == KC_CALCULATOR ? AL_CALCULATOR : (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : (key == KC_WWW_SEARCH ? AC_SEARCH : (key == KC_WWW_HOME ? AC_HOME : (key == KC_WWW_BACK ? AC_BACK : (key == KC_WWW_FORWARD ? AC_FORWARD : (key == KC_WWW_STOP ? AC_STOP : (key == KC_WWW_REFRESH ? AC_REFRESH : (key == KC_BRIGHTNESS_UP ? BRIGHTNESS_UP : (key == KC_BRIGHTNESS_DOWN ? BRIGHTNESS_DOWN : (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0)))))))))))))))))))))))
static inline uint16_t KEYCODE2CONSUMER(uint8_t key) {
switch (key) {
case KC_AUDIO_MUTE: return AUDIO_MUTE;
case KC_AUDIO_VOL_UP: return AUDIO_VOL_UP;
case KC_AUDIO_VOL_DOWN: return AUDIO_VOL_DOWN;
case KC_MEDIA_NEXT_TRACK: return TRANSPORT_NEXT_TRACK;
case KC_MEDIA_PREV_TRACK: return TRANSPORT_PREV_TRACK;
case KC_MEDIA_FAST_FORWARD: return TRANSPORT_FAST_FORWARD;
case KC_MEDIA_REWIND: return TRANSPORT_REWIND;
case KC_MEDIA_STOP: return TRANSPORT_STOP;
case KC_MEDIA_EJECT: return TRANSPORT_STOP_EJECT;
case KC_MEDIA_PLAY_PAUSE: return TRANSPORT_PLAY_PAUSE;
case KC_MEDIA_SELECT: return AL_CC_CONFIG;
case KC_MAIL: return AL_EMAIL;
case KC_CALCULATOR: return AL_CALCULATOR;
case KC_MY_COMPUTER: return AL_LOCAL_BROWSER;
case KC_WWW_SEARCH: return AC_SEARCH;
case KC_WWW_HOME: return AC_HOME;
case KC_WWW_BACK: return AC_BACK;
case KC_WWW_FORWARD: return AC_FORWARD;
case KC_WWW_STOP: return AC_STOP;
case KC_WWW_REFRESH: return AC_REFRESH;
case KC_BRIGHTNESS_UP: return BRIGHTNESS_UP;
case KC_BRIGHTNESS_DOWN: return BRIGHTNESS_DOWN;
case KC_WWW_FAVORITES: return AC_BOOKMARKS;
default: return 0;
}
}

uint8_t has_anykey(report_keyboard_t* keyboard_report);
uint8_t get_first_key(report_keyboard_t* keyboard_report);
Expand Down