Other Parts Discussed in Thread: CC2541
Hi!
I'm trying to use LAUNCHXL-CC2640R2 with hid_emu_kbd_cc2640r2lp_app as an HID mouse. I used the original code and it worked fine, when the buttons are pressed on the board the device writes "a" or "b" on the pc/smartphone. So I enable the compiler variable USE_HID_MOUSE and then changed the place where hid keyboard reports are called then I putted hid mouse reports there, just like the code below:
/********************************************************************* * @fn HidEmuKbd_handleKeys * * @brief Handles all key events for this device. * * @param keys - bit field for key events. Valid entries: * KEY_UP * KEY_RIGHT * * @return none */ static void HidEmuKbd_handleKeys(uint8_t keys) { if (keys & KEY_LEFT) { // Key Press. //HidEmuKbd_sendReport(KEY_LEFT_HID_BINDING); HidEmuKbd_sendMouseReport(-2);// Cursor moves to the left // Key Release. // NB: releasing a key press will not propagate a signal to this function, // so a "key release" is reported immediately afterwards here. //HidEmuKbd_sendReport(KEY_NONE); } if (keys & KEY_RIGHT) { // Key Press. HidEmuKbd_sendMouseReport(2);//Cursor moves to the right //HidEmuKbd_sendReport(KEY_RIGHT_HID_BINDING); // Key Release // NB: releasing a key press will not propagate a signal to this function, // so a "key release" is reported immediately afterwards here. //HidEmuKbd_sendReport(KEY_NONE); } } #ifdef USE_HID_MOUSE /********************************************************************* * @fn HidEmuKbd_sendMouseReport * * @brief Build and send a HID mouse report. * * @param buttons - Mouse button code * * @return none */ static void HidEmuKbd_sendMouseReport(uint8_t buttons) { uint8_t buf[HID_MOUSE_IN_RPT_LEN]; buf[0] = 0; // Buttons buf[1] = buttons; // X buf[2] = 0; // Y buf[3] = 0; // Wheel buf[4] = 0; // AC Pan HidDev_Report(HID_RPT_ID_MOUSE_IN, HID_REPORT_TYPE_INPUT, HID_MOUSE_IN_RPT_LEN, buf); } #endif // USE_HID_MOUSE
So I was expecting that when my board was paired it would create a mouse cursor on the central device and when the buttons were pressed the cursor would move to the corresponding directions, but nothing happens.
Regards,
Bruno.