Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bit_t is_media_keycode(keycode_t keycode) {
return is_media(keycode);
}
void handle_media_keycode(keycode_t keycode, key_event_t event) REENT {
uint8_t consumer_code = 0;
if (event == EVENT_PRESSED) {
switch (keycode) {
case KC_MEDIA_NEXT_TRACK : consumer_code = HID_CONSUMER_SCAN_NEXT_TRACK ; break ;
case KC_MEDIA_PREV_TRACK : consumer_code = HID_CONSUMER_SCAN_PREVIOUS_TRACK ; break ;
case KC_MEDIA_FAST_FORWARD : consumer_code = HID_CONSUMER_FAST_FORWARD ; break ;
case KC_MEDIA_REWIND : consumer_code = HID_CONSUMER_REWIND ; break ;
case KC_MEDIA_STOP : consumer_code = HID_CONSUMER_STOP ; break ;
case KC_MEDIA_EJECT : consumer_code = HID_CONSUMER_EJECT ; break ;
case KC_MEDIA_PLAY_PAUSE : consumer_code = HID_CONSUMER_PLAY_PAUSE ; break ;
case KC_AUDIO_MUTE : consumer_code = HID_CONSUMER_MUTE ; break ;
case KC_AUDIO_VOL_UP : consumer_code = HID_CONSUMER_VOLUME_INCREMENT ; break ;
case KC_AUDIO_VOL_DOWN : consumer_code = HID_CONSUMER_VOLUME_DECREMENT ; break ;
}
g_media_report.id = REPORT_ID_CONSUMER;
g_media_report.code = consumer_code;
g_report_pending_media = true;
} else if (event == EVENT_RELEASED) {
g_media_report.id = REPORT_ID_CONSUMER;
g_media_report.code = 0;
g_report_pending_media = true;
}
}
const XRAM keycode_callbacks_t media_keycodes = {
.checker = is_media_keycode,
.handler = handle_media_keycode,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment