diff options
| author | hathach <[email protected]> | 2018-07-24 00:45:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-07-24 00:45:07 +0700 |
| commit | 3400dfdf4ea478894b2a96ac0bd27868c052fbeb (patch) | |
| tree | dd125486da17644a8929da89fec079a47f3757af /examples | |
| parent | 546f2a1165555819bf3ef09fe1afcfbcbb084dd9 (diff) | |
nrf52840 boot mouse does not work, need more work
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/device/nrf52840/src/main.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/examples/device/nrf52840/src/main.c b/examples/device/nrf52840/src/main.c index cc18cce24..1f7f5b22e 100644 --- a/examples/device/nrf52840/src/main.c +++ b/examples/device/nrf52840/src/main.c @@ -98,29 +98,25 @@ void virtual_com_task(void) } //--------------------------------------------------------------------+ -// USB CDC +// USB HID //--------------------------------------------------------------------+ void usb_hid_task(void) { if ( tud_mounted() ) { - if ( !tud_hid_keyboard_busy() ) - { - // 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 bt = board_buttons(); - if ( bt ) + /*------------- Keyboard -------------*/ +/* + if ( !tud_hid_keyboard_busy() ) + { + if ( btn ) { uint8_t keycode[6] = { 0 }; for(uint8_t i=0; i < 6; i++) { - if ( bt & (1 << i) ) keycode[i] = HID_KEY_A + i; + if ( btn & (1 << i) ) keycode[i] = HID_KEY_A + i; } tud_hid_keyboard_send_keycode(0, keycode); @@ -130,10 +126,24 @@ void usb_hid_task(void) tud_hid_keyboard_send_report(NULL); } } +*/ + /*------------- Mouse -------------*/ if ( !tud_hid_mouse_busy() ) { + // 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_send_report(&report); + } } } |
