]>
git.gir.st - tmk_keyboard.git/blob - keyboard.c
4 #include "matrix_skel.h"
6 #include "usb_keycodes.h"
11 #ifdef MOUSEKEY_ENABLE
16 static uint8_t last_leds
= 0;
19 void keyboard_init(void)
23 #ifdef PS2_MOUSE_ENABLE
28 void keyboard_proc(void)
34 if (matrix_is_modified()) {
35 if (debug_matrix
) matrix_print();
37 // LED flash for debug
43 if (matrix_has_ghost()) {
45 debug("matrix has ghost!!\n");
49 host_swap_keyboard_report();
50 host_clear_keyboard_report();
51 for (int row
= 0; row
< matrix_rows(); row
++) {
52 for (int col
= 0; col
< matrix_cols(); col
++) {
53 if (!matrix_is_on(row
, col
)) continue;
55 uint8_t code
= layer_get_keycode(row
, col
);
58 } else if (IS_MOD(code
)) {
59 host_add_mod_bit(MOD_BIT(code
));
60 } else if (IS_FN(code
)) {
61 fn_bits
|= FN_BIT(code
);
63 #ifdef USB_EXTRA_ENABLE
65 // audio control & system control
66 else if (code == KB_MUTE) {
67 usb_extra_audio_send(AUDIO_MUTE);
68 usb_extra_audio_send(0);
70 } else if (code == KB_VOLU) {
71 usb_extra_audio_send(AUDIO_VOL_UP);
72 usb_extra_audio_send(0);
74 } else if (code == KB_VOLD) {
75 usb_extra_audio_send(AUDIO_VOL_DOWN);
76 usb_extra_audio_send(0);
78 } else if (code == KB_PWR) {
79 if (suspend && remote_wakeup) {
82 usb_extra_system_send(SYSTEM_POWER_DOWN);
88 else if (IS_KEY(code
)) {
91 #ifdef MOUSEKEY_ENABLE
92 else if (IS_MOUSEKEY(code
)) {
93 mousekey_decode(code
);
97 debug("ignore keycode: "); debug_hex(code
); debug("\n");
102 layer_switching(fn_bits
);
104 if (command_proc()) {
109 // TODO: should send only when changed from last report
110 if (matrix_is_modified()) {
111 host_send_keyboard_report();
113 // LED flash for debug
119 #ifdef MOUSEKEY_ENABLE
123 #ifdef PS2_MOUSE_ENABLE
124 // TODO: should comform new API
125 if (ps2_mouse_read() == 0)
126 ps2_mouse_usb_send();
129 if (last_leds
!= host_keyboard_leds()) {
130 keyboard_set_leds(host_keyboard_leds());
131 last_leds
= host_keyboard_leds();
135 void keyboard_set_leds(uint8_t leds
)