From 72005edb4500ac1de52879c169b4637bc77a14bc Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Wed, 23 Feb 2011 18:40:55 -0600 Subject: [PATCH] mac mouse stuff in progress; this won't compile but luckily it's not in anyone's config yet --- src/archutils/Darwin/MouseDevice.cpp | 38 +++++++++++++++++++++++++--- src/archutils/Darwin/MouseDevice.h | 11 ++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/archutils/Darwin/MouseDevice.cpp b/src/archutils/Darwin/MouseDevice.cpp index c765fc0f30..718440a0c0 100644 --- a/src/archutils/Darwin/MouseDevice.cpp +++ b/src/archutils/Darwin/MouseDevice.cpp @@ -1,10 +1,16 @@ #include "global.h" #include "MouseDevice.h" +using __gnu_cxx::hash_map; + +Mouse::Mouse() : id( InputDevice_Invalid ), +{ +} + bool MouseDevice::AddLogicalDevice( int usagePage, int usage ) { // Mice can either be kHIDUsage_GD_Mouse or kHIDUsage_GD_Pointer... - // Let's just go with kHIDUsage_GD_Mouse for now. + // Let's just go with kHIDUsage_GD_Mouse for now. -aj return usagePage == kHIDPage_GenericDesktop && usage == kHIDUsage_GD_Mouse; } @@ -13,12 +19,38 @@ void MouseDevice::AddElement( int usagePage, int usage, IOHIDElementCookie cooki if( usagePage != kHIDPage_GenericDesktop ) return; - DeviceButton button; + if( usagePage == kHIDPage_Button ) + { + const DeviceButton buttonID = enum_add2( MOUSE_LEFT, usage - kHIDUsage_Button_1 ); + + bool mouseWheel = (buttonID == MOUSE_WHEELUP || buttonID == MOUSE_WHEELDOWN); + if( buttonID <= MOUSE_MIDDLE || mouseWheel ) + mapping[cookie] = buttonID; + else + LOG->Warn( "Button id too large: %d.", int(buttonID) ); + break; + } + + /* if( UsbKeyToDeviceButton(usage,button) ) m_Mapping[cookie] = button; + */ } void MouseDevice::Open() { - // I hate coding blind... + for( hash_map::const_iterator i = m_Mapping.begin(); i != m_Mapping.end(); ++i ) + { + AddElementToQueue( i->first ); + } +} + +void MouseDevice::GetButtonPresses( vector& vPresses, IOHIDElementCookie cookie, int value, const RageTimer& now ) const +{ + // hmm... +} + +void MouseDeviceDevice::GetDevicesAndDescriptions( vector& vDevices ) const +{ + vDevices.push_back( InputDeviceInfo(DEVICE_MOUSE, "Mouse") ); } \ No newline at end of file diff --git a/src/archutils/Darwin/MouseDevice.h b/src/archutils/Darwin/MouseDevice.h index 0dc1ee565f..14ee9b40cc 100644 --- a/src/archutils/Darwin/MouseDevice.h +++ b/src/archutils/Darwin/MouseDevice.h @@ -3,6 +3,15 @@ #include "HIDDevice.h" +struct Mouse +{ + InputDevice id; + // map cookie to button + __gnu_cxx::hash_map mapping; + + Mouse(); +}; + class MouseDevice : public HIDDevice { private: @@ -14,6 +23,8 @@ protected: void Open() public: + void GetButtonPresses( vector& vPresses, IOHIDElementCookie cookie, int value, const RageTimer& now ) const; + void GetDevicesAndDescriptions( vector& vDevices ) const; // even more stuff };