Mouse moving down, left, while stoping on button-right-up
This commit is contained in:
committed by
odri@aconno.de
parent
0516ba3929
commit
a09eb86dcf
+53
-10
@@ -7,7 +7,11 @@ extern AconnoGPIO ld1;
|
||||
|
||||
static int8_t hid_acc_for_report_get(int16_t acc);
|
||||
|
||||
static void mouse_move_timer_handler(void * p_context);
|
||||
static void mouse_move_down_timer_handler(void * p_context);
|
||||
|
||||
static void mouse_move_up_timer_handler(void * p_context);
|
||||
|
||||
static void mouse_move_left_timer_handler(void * p_context);
|
||||
|
||||
static void usbd_user_ev_handler(app_usbd_event_type_t event);
|
||||
|
||||
@@ -19,17 +23,37 @@ static void usbd_user_ev_handler(app_usbd_event_type_t event);
|
||||
* If report sending was successful it clears accumulated positions
|
||||
* and mark last button state that was transfered.
|
||||
*/
|
||||
void hid_generic_mouse_process_state()
|
||||
void hid_generic_mouse_process_state(USB_DIR direction)
|
||||
{
|
||||
ret_code_t ret;
|
||||
ret = app_usbd_hid_mouse_x_move(&m_app_hid_mouse, CONFIG_MOUSE_MOVE_STEP);
|
||||
APP_ERROR_CHECK(ret);
|
||||
UNUSED_RETURN_VALUE(app_timer_start(m_mouse_move_timer, APP_TIMER_TICKS(CONFIG_MOUSE_MOVE_TIME_MS), NULL));
|
||||
switch(direction)
|
||||
{
|
||||
case USB_DIR::DOWN:
|
||||
{
|
||||
ret = app_usbd_hid_mouse_y_move(&m_app_hid_mouse, CONFIG_MOUSE_MOVE_STEP);
|
||||
APP_ERROR_CHECK(ret);
|
||||
UNUSED_RETURN_VALUE(app_timer_start(m_mouse_move_down_timer, APP_TIMER_TICKS(CONFIG_MOUSE_MOVE_TIME_MS), NULL));
|
||||
break;
|
||||
}
|
||||
case USB_DIR::LEFT:
|
||||
{
|
||||
ret = app_usbd_hid_mouse_x_move(&m_app_hid_mouse, -CONFIG_MOUSE_MOVE_STEP);
|
||||
APP_ERROR_CHECK(ret);
|
||||
UNUSED_RETURN_VALUE(app_timer_start(m_mouse_move_left_timer, APP_TIMER_TICKS(CONFIG_MOUSE_MOVE_TIME_MS), NULL));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hid_generic_mouse_stop_state(void)
|
||||
{
|
||||
UNUSED_RETURN_VALUE(app_timer_stop(m_mouse_move_timer));
|
||||
UNUSED_RETURN_VALUE(app_timer_stop(m_mouse_move_down_timer));
|
||||
//UNUSED_RETURN_VALUE(app_timer_stop(m_mouse_move_up_timer));
|
||||
UNUSED_RETURN_VALUE(app_timer_stop(m_mouse_move_left_timer));
|
||||
}
|
||||
|
||||
void usbSetup()
|
||||
@@ -41,8 +65,15 @@ void usbSetup()
|
||||
usbd_user_ev_handler
|
||||
};
|
||||
|
||||
app_timer_create(&m_mouse_move_timer, APP_TIMER_MODE_REPEATED,
|
||||
mouse_move_timer_handler);
|
||||
app_timer_create(&m_mouse_move_down_timer, APP_TIMER_MODE_REPEATED,
|
||||
mouse_move_down_timer_handler);
|
||||
|
||||
app_timer_create(&m_mouse_move_up_timer, APP_TIMER_MODE_REPEATED,
|
||||
mouse_move_up_timer_handler);
|
||||
|
||||
app_timer_create(&m_mouse_move_left_timer, APP_TIMER_MODE_REPEATED,
|
||||
mouse_move_left_timer_handler);
|
||||
|
||||
APP_ERROR_CHECK(ret);
|
||||
|
||||
//NRF_LOG_INFO("BEFORE USB INIT");
|
||||
@@ -76,14 +107,26 @@ void usbSetup()
|
||||
}
|
||||
}
|
||||
|
||||
static void mouse_move_timer_handler(void * p_context)
|
||||
static void mouse_move_down_timer_handler(void * p_context)
|
||||
{
|
||||
UNUSED_PARAMETER(p_context);
|
||||
UNUSED_RETURN_VALUE(app_usbd_hid_mouse_x_move(&m_app_hid_mouse, CONFIG_MOUSE_MOVE_STEP));
|
||||
UNUSED_RETURN_VALUE(app_usbd_hid_mouse_y_move(&m_app_hid_mouse, CONFIG_MOUSE_MOVE_STEP));
|
||||
|
||||
}
|
||||
|
||||
static void mouse_move_up_timer_handler(void * p_context)
|
||||
{
|
||||
UNUSED_PARAMETER(p_context);
|
||||
UNUSED_RETURN_VALUE(app_usbd_hid_mouse_y_move(&m_app_hid_mouse, -CONFIG_MOUSE_MOVE_STEP));
|
||||
|
||||
}
|
||||
|
||||
static void mouse_move_left_timer_handler(void * p_context)
|
||||
{
|
||||
UNUSED_PARAMETER(p_context);
|
||||
UNUSED_RETURN_VALUE(app_usbd_hid_mouse_x_move(&m_app_hid_mouse, -CONFIG_MOUSE_MOVE_STEP));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Class specific event handler.
|
||||
|
||||
Reference in New Issue
Block a user