diff options
| author | hathach <[email protected]> | 2018-07-25 00:16:09 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-07-25 00:16:09 +0700 |
| commit | 71934228d2902079da0c0dc65d97cc78f1b1eaab (patch) | |
| tree | c580b64fe37dc70798a303dc20f915a3471604f4 /examples | |
| parent | 67e52af936fe85c11300355293b34b5523439d55 (diff) | |
tested boot mouse working
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/device/nrf52840/src/main.c | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/examples/device/nrf52840/src/main.c b/examples/device/nrf52840/src/main.c index 000adb9dc..84876e7a5 100644 --- a/examples/device/nrf52840/src/main.c +++ b/examples/device/nrf52840/src/main.c @@ -103,7 +103,36 @@ void virtual_com_task(void) void usb_hid_task(void) { /*------------- Keyboard -------------*/ - if ( tud_hid_keyboard_ready() ) +// if ( tud_hid_keyboard_ready() ) +// { +// // Poll every 10ms +// static tu_timeout_t tm = { .start = 0, .interval = 10 }; +// +// if ( !tu_timeout_expired(&tm) ) return; // not enough time +// tu_timeout_reset(&tm); +// +// uint32_t const btn = board_buttons(); +// +// if ( btn ) +// { +// uint8_t keycode[6] = { 0 }; +// +// for(uint8_t i=0; i < 6; i++) +// { +// if ( btn & (1 << i) ) keycode[i] = HID_KEY_A + i; +// } +// +// tud_hid_keyboard_keycode(0, keycode); +// }else +// { +// // Null means all zeroes keycodes +// tud_hid_keyboard_keycode(0, NULL); +// } +// } + + + /*------------- Mouse -------------*/ + if ( tud_hid_mouse_ready() ) { // Poll every 10ms static tu_timeout_t tm = { .start = 0, .interval = 10 }; @@ -115,40 +144,9 @@ void usb_hid_task(void) if ( btn ) { - uint8_t keycode[6] = { 0 }; - - for(uint8_t i=0; i < 6; i++) - { - if ( btn & (1 << i) ) keycode[i] = HID_KEY_A + i; - } - - tud_hid_keyboard_keycode(0, keycode); - }else - { - // Null means all zeroes keycodes - tud_hid_keyboard_keycode(0, NULL); + tud_hid_mouse_data(0, 10, 0, 0, 0); } } - - - /*------------- Mouse -------------*/ - // if ( tud_hid_mouse_ready() ) - // { - // // Poll every 10ms - // static tu_timeout_t tm = { .start = 0, .interval = 10 }; - // - // if ( !tu_timeout_expired(&tm) ) return; // not enough time - // tu_timeout_reset(&tm); - // - // uint32_t const btn = board_buttons(); - // - // if ( btn ) - // { - // hid_mouse_report_t report = { .buttons = 0, .x = 10, .y = 0, .wheel = 0 }; - // tud_hid_mouse_report(&report); - // } - // } - } |
