This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How does 52832 sdk16 change the button state

Hello Nordic team,


I'm getting started with BLE, using the 52832 SDK16 HID mouse example. In the example, clicking the button only moves 5 pixels. How can I move the cursor continuously. I tried to modify the example descriptor as a gamepad and found that clicking the button will only send data once. The button has been pressed all the time, and the data cannot be updated in real time. How to solve it.


thank you for your support.

Parents
  • Hi,

    The example generates only one event per time a button is pressed. Which means that you would have to check if the button is still pressed if you want the cursor to keep moving. One way is by calling bsp_button_is_pressed() after a button pressed event is generated. You could then call mouse_movement_send() as long as bsp_button_is_pressed() returns true for that button. Just make sure that you don't do it in interrupt context as it might interfere with Softdevice operations. I suggest that you rather set a flag in interrupt context after the button has been pressed and then check the flag in a loop in main context. Probably not the most elegant solution, but it should work Slight smile

    regards
    Jared
Reply
  • Hi,

    The example generates only one event per time a button is pressed. Which means that you would have to check if the button is still pressed if you want the cursor to keep moving. One way is by calling bsp_button_is_pressed() after a button pressed event is generated. You could then call mouse_movement_send() as long as bsp_button_is_pressed() returns true for that button. Just make sure that you don't do it in interrupt context as it might interfere with Softdevice operations. I suggest that you rather set a flag in interrupt context after the button has been pressed and then check the flag in a loop in main context. Probably not the most elegant solution, but it should work Slight smile

    regards
    Jared
Children
Related