1 /* 2 * Copyright 2008-2011 Michael Lotz <mmlr@mlotz.ch> 3 * Distributed under the terms of the MIT license. 4 */ 5 #ifndef USB_MOUSE_PROTOCOL_HANDLER_H 6 #define USB_MOUSE_PROTOCOL_HANDLER_H 7 8 9 #include <InterfaceDefs.h> 10 11 #include "ProtocolHandler.h" 12 13 14 class HIDCollection; 15 class HIDReportItem; 16 17 18 #ifndef B_MAX_MOUSE_BUTTONS 19 # define B_MAX_MOUSE_BUTTONS 8 20 #endif 21 22 23 class MouseProtocolHandler : public ProtocolHandler { 24 public: 25 MouseProtocolHandler(HIDReport &report, 26 HIDReportItem &xAxis, 27 HIDReportItem &yAxis); 28 29 static void AddHandlers(HIDDevice &device, 30 HIDCollection &collection, 31 ProtocolHandler *&handlerList); 32 33 virtual status_t Control(uint32 *cookie, uint32 op, void *buffer, 34 size_t length); 35 36 private: 37 status_t _ReadReport(void *buffer, uint32 *cookie); 38 39 HIDReport & fReport; 40 41 HIDReportItem & fXAxis; 42 HIDReportItem & fYAxis; 43 HIDReportItem * fWheel; 44 HIDReportItem * fHorizontalPan; 45 HIDReportItem * fButtons[B_MAX_MOUSE_BUTTONS]; 46 47 uint32 fLastButtons; 48 uint32 fClickCount; 49 bigtime_t fLastClickTime; 50 bigtime_t fClickSpeed; 51 }; 52 53 #endif // USB_MOUSE_PROTOCOL_HANDLER_H 54