void EngineInput::UpdateAllStates() { MSG msg; if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } UpdateKeyboardState(); UpdateMouseState(); }
//***************************************************************************** // //! This function handles event callbacks from the USB HID driver layer. //! //! \param pvMouse is the pointer that was passed in to the USBHHIDOpen() //! call. //! \param ui32Event is the event that has been passed up from the HID driver. //! \param ui32MsgParam has meaning related to the \e ui32Event that occurred. //! \param pvMsgData has meaning related to the \e ui32Event that occurred. //! //! This function will receive all event updates from the HID driver layer. //! The mouse driver itself will mostly be concerned with report callbacks //! from the HID driver layer and parsing them into keystrokes for the //! application that has registered for callbacks with the USBHMouseOpen() //! call. //! //! \return Non-zero values should be assumed to indicate an error condition. // //***************************************************************************** uint32_t USBHMouseCallback(void *pvMouse, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData) { tUSBHMouse *psMsInstance; // // Recover the pointer to the instance data. // psMsInstance = (tUSBHMouse *)pvMouse; switch(ui32Event) { // // New mouse has been connected so notify the application. // case USB_EVENT_CONNECTED: { // // Remember that a mouse is present. // psMsInstance->ui32HIDFlags |= USBHMS_DEVICE_PRESENT; // // Notify the application that a new mouse was connected. // psMsInstance->pfnCallback(0, ui32Event, ui32MsgParam, pvMsgData); break; } case USB_EVENT_DISCONNECTED: { // // No mouse is present. // psMsInstance->ui32HIDFlags &= ~USBHMS_DEVICE_PRESENT; // // Notify the application that the mouse was disconnected. // psMsInstance->pfnCallback(0, ui32Event, ui32MsgParam, pvMsgData); break; } case USB_EVENT_RX_AVAILABLE: { // // New mouse report structure was received. // USBHHIDGetReport(psMsInstance->psHIDInstance, 0, psMsInstance->pui8Buffer, USBHMS_REPORT_SIZE); // // Update the current state of the mouse and notify the application // of any changes. // UpdateMouseState(psMsInstance); break; } } return(0); }