From 3400dfdf4ea478894b2a96ac0bd27868c052fbeb Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 24 Jul 2018 00:45:07 +0700 Subject: nrf52840 boot mouse does not work, need more work --- examples/device/nrf52840/src/main.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'examples/device') 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); + } } } -- cgit v1.3.1