/** * @brief USR_MOUSE_ProcessData * Process Mouse data * @param data : Mouse data to be displayed * @retval None */ void USR_MOUSE_ProcessData(HID_MOUSE_Data_TypeDef *data) { uint8_t idx = 1; static uint8_t b_state[3] = { 0, 0 , 0}; if ((data->x != 0) && (data->y != 0)) { HID_MOUSE_UpdatePosition(data->x , data->y); } for ( idx = 0 ; idx < 3 ; idx ++) { if(data->button & 1 << idx) { if(b_state[idx] == 0) { HID_MOUSE_ButtonPressed (idx); b_state[idx] = 1; } } else { if(b_state[idx] == 1) { HID_MOUSE_ButtonReleased (idx); b_state[idx] = 0; } } } }
/** * @brief Main routine for Mouse application * @param phost: Host handle * @retval None */ static void USBH_MouseDemo(USBH_HandleTypeDef *phost) { HID_MOUSE_Info_TypeDef *m_pinfo; if(hid_demo.mouse_state != HID_MOUSE_START) { m_pinfo = USBH_HID_GetMouseInfo(phost); if(m_pinfo != NULL) { /* Handle Mouse data position */ USR_MOUSE_ProcessData(&mouse_info); if(m_pinfo->buttons[0]) { HID_MOUSE_ButtonPressed(0); } else { HID_MOUSE_ButtonReleased(0); } if(m_pinfo->buttons[1]) { HID_MOUSE_ButtonPressed(2); } else { HID_MOUSE_ButtonReleased(2); } if(m_pinfo->buttons[2]) { HID_MOUSE_ButtonPressed(1); } else { HID_MOUSE_ButtonReleased(1); } } } }
/** * @brief USR_MOUSE_ProcessData * Process Mouse data * @param data : Mouse data to be displayed * @retval None */ void USR_MOUSE_ProcessData(HID_MOUSE_Data_TypeDef *data) { uint8_t idx = 1; static uint8_t b_state[3] = { 0, 0 , 0}; char temp[20]; if(DEMO_HID_ShowData == 0) { if ((data->x != 0) && (data->y != 0)) { HID_MOUSE_UpdatePosition(data->x , data->y); } for ( idx = 0 ; idx < 3 ; idx ++) { if(data->button & 1 << idx) { if(b_state[idx] == 0) { HID_MOUSE_ButtonPressed (idx); b_state[idx] = 1; } } else { if(b_state[idx] == 1) { HID_MOUSE_ButtonReleased (idx); b_state[idx] = 0; } } } } else { sprintf(temp ,"> %02xh %02xh %02xh %02xh\n" , HID_Machine.buff[0], HID_Machine.buff[1], HID_Machine.buff[2], HID_Machine.buff[3]); LCD_DbgLog(temp); } }
/** * @brief USR_MOUSE_ProcessData * Process Mouse data * @param data : Mouse data to be displayed * @retval None */ void USR_MOUSE_ProcessData(HID_MOUSE_Data_TypeDef *data) { uint8_t idx = 1; static uint8_t b_state[3] = { 0, 0 , 0}; data_X = data->x; data_Y = data->y; data_Button = data->button; if ((data->x != 0) && (data->y != 0)) { HID_MOUSE_UpdatePosition(data->x , data->y); STM_EVAL_LEDToggle(LED_Blue); // added by "STM32" } for ( idx = 0 ; idx < 3 ; idx ++) { if(data->button & 1 << idx) { if(b_state[idx] == 0) { HID_MOUSE_ButtonPressed (idx); b_state[idx] = 1; } } else { if(b_state[idx] == 1) { HID_MOUSE_ButtonReleased (idx); b_state[idx] = 0; } } } }