diff options
Diffstat (limited to 'keyboard.c')
| -rw-r--r-- | keyboard.c | 74 |
1 files changed, 59 insertions, 15 deletions
diff --git a/keyboard.c b/keyboard.c index fd6e23042..af1706735 100644 --- a/keyboard.c +++ b/keyboard.c | |||
| @@ -31,6 +31,9 @@ void keyboard_init(void) | |||
| 31 | void keyboard_proc(void) | 31 | void keyboard_proc(void) |
| 32 | { | 32 | { |
| 33 | uint8_t fn_bits = 0; | 33 | uint8_t fn_bits = 0; |
| 34 | #ifdef USB_EXTRA_ENABLE | ||
| 35 | uint16_t consumer_code = 0; | ||
| 36 | #endif | ||
| 34 | 37 | ||
| 35 | matrix_scan(); | 38 | matrix_scan(); |
| 36 | 39 | ||
| @@ -64,20 +67,8 @@ void keyboard_proc(void) | |||
| 64 | fn_bits |= FN_BIT(code); | 67 | fn_bits |= FN_BIT(code); |
| 65 | } | 68 | } |
| 66 | #ifdef USB_EXTRA_ENABLE | 69 | #ifdef USB_EXTRA_ENABLE |
| 67 | // audio control & system control | 70 | // System Control |
| 68 | else if (code == KB_MUTE) { | 71 | else if (code == KB_SYSTEM_POWER) { |
| 69 | host_audio_send(AUDIO_MUTE); | ||
| 70 | _delay_ms(500); | ||
| 71 | host_audio_send(0); | ||
| 72 | } else if (code == KB_VOLU) { | ||
| 73 | host_audio_send(AUDIO_VOL_UP); | ||
| 74 | _delay_ms(200); | ||
| 75 | host_audio_send(0); | ||
| 76 | } else if (code == KB_VOLD) { | ||
| 77 | host_audio_send(AUDIO_VOL_DOWN); | ||
| 78 | _delay_ms(200); | ||
| 79 | host_audio_send(0); | ||
| 80 | } else if (code == KB_PWR) { | ||
| 81 | #ifdef HOST_PJRC | 72 | #ifdef HOST_PJRC |
| 82 | if (suspend && remote_wakeup) { | 73 | if (suspend && remote_wakeup) { |
| 83 | usb_remote_wakeup(); | 74 | usb_remote_wakeup(); |
| @@ -87,7 +78,57 @@ void keyboard_proc(void) | |||
| 87 | #else | 78 | #else |
| 88 | host_system_send(SYSTEM_POWER_DOWN); | 79 | host_system_send(SYSTEM_POWER_DOWN); |
| 89 | #endif | 80 | #endif |
| 90 | _delay_ms(1000); | 81 | host_system_send(0); |
| 82 | _delay_ms(500); | ||
| 83 | } else if (code == KB_SYSTEM_SLEEP) { | ||
| 84 | host_system_send(SYSTEM_SLEEP); | ||
| 85 | host_system_send(0); | ||
| 86 | _delay_ms(500); | ||
| 87 | } else if (code == KB_SYSTEM_WAKE) { | ||
| 88 | host_system_send(SYSTEM_WAKE_UP); | ||
| 89 | host_system_send(0); | ||
| 90 | _delay_ms(500); | ||
| 91 | } | ||
| 92 | // Consumer Page | ||
| 93 | else if (code == KB_AUDIO_MUTE) { | ||
| 94 | consumer_code = AUDIO_MUTE; | ||
| 95 | } else if (code == KB_AUDIO_VOL_UP) { | ||
| 96 | consumer_code = AUDIO_VOL_UP; | ||
| 97 | } else if (code == KB_AUDIO_VOL_DOWN) { | ||
| 98 | consumer_code = AUDIO_VOL_DOWN; | ||
| 99 | } | ||
| 100 | else if (code == KB_MEDIA_NEXT_TRACK) { | ||
| 101 | consumer_code = TRANSPORT_NEXT_TRACK; | ||
| 102 | } else if (code == KB_MEDIA_PREV_TRACK) { | ||
| 103 | consumer_code = TRANSPORT_PREV_TRACK; | ||
| 104 | } else if (code == KB_MEDIA_STOP) { | ||
| 105 | consumer_code = TRANSPORT_STOP; | ||
| 106 | } else if (code == KB_MEDIA_PLAY_PAUSE) { | ||
| 107 | consumer_code = TRANSPORT_PLAY_PAUSE; | ||
| 108 | } else if (code == KB_MEDIA_SELECT) { | ||
| 109 | consumer_code = AL_CC_CONFIG; | ||
| 110 | } | ||
| 111 | else if (code == KB_MAIL) { | ||
| 112 | consumer_code = AL_EMAIL; | ||
| 113 | } else if (code == KB_CALCULATOR) { | ||
| 114 | consumer_code = AL_CALCULATOR; | ||
| 115 | } else if (code == KB_MY_COMPUTER) { | ||
| 116 | consumer_code = AL_LOCAL_BROWSER; | ||
| 117 | } | ||
| 118 | else if (code == KB_WWW_SEARCH) { | ||
| 119 | consumer_code = AC_SEARCH; | ||
| 120 | } else if (code == KB_WWW_HOME) { | ||
| 121 | consumer_code = AC_HOME; | ||
| 122 | } else if (code == KB_WWW_BACK) { | ||
| 123 | consumer_code = AC_BACK; | ||
| 124 | } else if (code == KB_WWW_FORWARD) { | ||
| 125 | consumer_code = AC_FORWARD; | ||
| 126 | } else if (code == KB_WWW_STOP) { | ||
| 127 | consumer_code = AC_STOP; | ||
| 128 | } else if (code == KB_WWW_REFRESH) { | ||
| 129 | consumer_code = AC_REFRESH; | ||
| 130 | } else if (code == KB_WWW_FAVORITES) { | ||
| 131 | consumer_code = AC_BOOKMARKS; | ||
| 91 | } | 132 | } |
| 92 | #endif | 133 | #endif |
| 93 | else if (IS_KEY(code)) { | 134 | else if (IS_KEY(code)) { |
| @@ -113,6 +154,9 @@ void keyboard_proc(void) | |||
| 113 | // TODO: should send only when changed from last report | 154 | // TODO: should send only when changed from last report |
| 114 | if (matrix_is_modified()) { | 155 | if (matrix_is_modified()) { |
| 115 | host_send_keyboard_report(); | 156 | host_send_keyboard_report(); |
| 157 | #ifdef USB_EXTRA_ENABLE | ||
| 158 | host_consumer_send(consumer_code); | ||
| 159 | #endif | ||
| 116 | #ifdef DEBUG_LED | 160 | #ifdef DEBUG_LED |
| 117 | // LED flash for debug | 161 | // LED flash for debug |
| 118 | DEBUG_LED_CONFIG; | 162 | DEBUG_LED_CONFIG; |
