I have modified the included HID mouse example to allow for left/right/middle mouse clicks. However, it is not clear to me how to set an event handler for both when a button goes HIGH as well as LOW using the button handler module.
static void buttons_init(void)
{
static app_button_cfg_t buttons[] =
{
{LEFT_CLICK_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler},
{RIGHT_CLICK_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}
};
APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true);
button_event_handler will only be called when the left click pin goes LOW. No handler is called when the pin goes HIGH.
I do not see a way to use the app_button.c library to set both a HIGH and LOW handler for the same pin, only one or the other.
I have attempted:
static void buttons_init(void)
{
static app_button_cfg_t buttons[] =
{
{LEFT_CLICK_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler},
{LEFT_CLICK_PIN_NO, true, NRF_GPIO_PIN_NOPULL, button_event_handler2},
{RIGHT_CLICK_PIN_NO, false, NRF_GPIO_PIN_NOPULL, button_event_handler}
};
But seem to get repeated mouse click sends using this method.
Am I missing something here?