diff --git a/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp b/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp index 18784bf7ca..48b9f371f9 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp @@ -24,12 +24,12 @@ void InputHandler_Carbon::QueueCallBack( void *target, int result, void *refcon, IOHIDEventStruct event; AbsoluteTime zeroTime = { 0, 0 }; HIDDevice *dev = This->m_vDevices[int( refcon )]; - vector > vPresses; + vector vPresses; while( (result = CALL(queue, getNextEvent, &event, zeroTime, 0)) == kIOReturnSuccess ) dev->GetButtonPresses( vPresses, int(event.elementCookie), int(event.value), now ); - for( vector >::const_iterator i = vPresses.begin(); i != vPresses.end(); ++i ) - This->ButtonPressed( i->first, i->second ); + FOREACH_CONST( DeviceInput, vPresses, i ) + This->ButtonPressed( *i, i->level > 0.5f ); } static void RunLoopStarted( CFRunLoopObserverRef o, CFRunLoopActivity a, void *sem ) diff --git a/stepmania/src/archutils/Darwin/HIDDevice.h b/stepmania/src/archutils/Darwin/HIDDevice.h index 1a8b219390..5bd6fe10af 100644 --- a/stepmania/src/archutils/Darwin/HIDDevice.h +++ b/stepmania/src/archutils/Darwin/HIDDevice.h @@ -103,8 +103,7 @@ public: * The value of the element is passed to determine if this is a push or a release. The time * is provided as an optimization. */ - virtual void GetButtonPresses( vector >& vPresses, int cookie, - int value, const RageTimer& now ) const = 0; + virtual void GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const = 0; /* * Returns the number of IDs assigned starting from startID. This is not meaningful for devices like diff --git a/stepmania/src/archutils/Darwin/JoystickDevice.cpp b/stepmania/src/archutils/Darwin/JoystickDevice.cpp index 285db0cbe8..8e517239a8 100644 --- a/stepmania/src/archutils/Darwin/JoystickDevice.cpp +++ b/stepmania/src/archutils/Darwin/JoystickDevice.cpp @@ -132,8 +132,7 @@ bool JoystickDevice::SupportsVidPid( int vid, int pid ) return true; } -void JoystickDevice::GetButtonPresses( vector >& vPresses, int cookie, - int value, const RageTimer& now ) const +void JoystickDevice::GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const { FOREACH_CONST( Joystick, m_vSticks, i ) { @@ -143,48 +142,48 @@ void JoystickDevice::GetButtonPresses( vector >& vPresse { float level = SCALE( value, js.x_min, js.x_max, -1.0f, 1.0f ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_LEFT, max(-level, 0.0f), now), level < -0.5f) ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_RIGHT, max(level, 0.0f), now), level > 0.5f) ); + vPresses.push_back( DeviceInput(js.id, JOY_LEFT, max(-level, 0.0f), now) ); + vPresses.push_back( DeviceInput(js.id, JOY_RIGHT, max(level, 0.0f), now) ); break; } else if( js.y_axis == cookie ) { float level = SCALE( value, js.y_min, js.y_max, -1.0f, 1.0f ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_UP, max(-level, 0.0f), now), level < -0.5f) ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_DOWN, max(level, 0.0f), now), level > 0.5f) ); + vPresses.push_back( DeviceInput(js.id, JOY_UP, max(-level, 0.0f), now) ); + vPresses.push_back( DeviceInput(js.id, JOY_DOWN, max(level, 0.0f), now) ); break; } else if( js.z_axis == cookie ) { float level = SCALE( value, js.z_min, js.z_max, -1.0f, 1.0f ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_Z_UP, max(-level, 0.0f), now), level < -0.5f) ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_Z_DOWN, max(level, 0.0f), now), level > 0.5f) ); + vPresses.push_back( DeviceInput(js.id, JOY_Z_UP, max(-level, 0.0f), now) ); + vPresses.push_back( DeviceInput(js.id, JOY_Z_DOWN, max(level, 0.0f), now) ); break; } else if( js.x_rot == cookie ) { float level = SCALE( value, js.rx_min, js.rx_max, -1.0f, 1.0f ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_ROT_LEFT, max(-level, 0.0f), now), level < -0.5f) ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_ROT_RIGHT, max(level, 0.0f), now), level > 0.5f) ); + vPresses.push_back( DeviceInput(js.id, JOY_ROT_LEFT, max(-level, 0.0f), now) ); + vPresses.push_back( DeviceInput(js.id, JOY_ROT_RIGHT, max(level, 0.0f), now) ); break; } else if( js.y_rot == cookie ) { float level = SCALE( value, js.ry_min, js.ry_max, -1.0f, 1.0f ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_ROT_UP, max(-level, 0.0f), now), level < -0.5f) ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_ROT_DOWN, max(level, 0.0f), now), level > 0.5f) ); + vPresses.push_back( DeviceInput(js.id, JOY_ROT_UP, max(-level, 0.0f), now) ); + vPresses.push_back( DeviceInput(js.id, JOY_ROT_DOWN, max(level, 0.0f), now) ); break; } else if( js.z_rot == cookie ) { float level = SCALE( value, js.rz_min, js.rz_max, -1.0f, 1.0f ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_ROT_Z_UP, max(-level, 0.0f), now), level < -0.5f) ); - vPresses.push_back( make_pair(DeviceInput(js.id, JOY_ROT_Z_DOWN, max(level, 0.0f), now), level > 0.5f) ); + vPresses.push_back( DeviceInput(js.id, JOY_ROT_Z_UP, max(-level, 0.0f), now) ); + vPresses.push_back( DeviceInput(js.id, JOY_ROT_Z_DOWN, max(level, 0.0f), now) ); break; } else @@ -195,7 +194,7 @@ void JoystickDevice::GetButtonPresses( vector >& vPresse iter = js.mapping.find( cookie ); if( iter != js.mapping.end() ) { - vPresses.push_back( make_pair(DeviceInput(js.id, iter->second, value, now), value) ); + vPresses.push_back( DeviceInput(js.id, iter->second, value, now) ); break; } } diff --git a/stepmania/src/archutils/Darwin/JoystickDevice.h b/stepmania/src/archutils/Darwin/JoystickDevice.h index 4386f36a16..6a7b75a4d4 100644 --- a/stepmania/src/archutils/Darwin/JoystickDevice.h +++ b/stepmania/src/archutils/Darwin/JoystickDevice.h @@ -31,8 +31,7 @@ protected: bool SupportsVidPid( int vid, int pid ); public: - void GetButtonPresses( vector >& vPresses, int cookie, - int value, const RageTimer& now ) const; + void GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const; int AssignIDs( InputDevice startID ); void GetDevicesAndDescriptions( vector& vDevices ) const; }; diff --git a/stepmania/src/archutils/Darwin/KeyboardDevice.cpp b/stepmania/src/archutils/Darwin/KeyboardDevice.cpp index e5bd99cecb..1c08cd89b1 100644 --- a/stepmania/src/archutils/Darwin/KeyboardDevice.cpp +++ b/stepmania/src/archutils/Darwin/KeyboardDevice.cpp @@ -166,13 +166,12 @@ void KeyboardDevice::Open() AddElementToQueue( i->first ); } -void KeyboardDevice::GetButtonPresses( vector >& vPresses, int cookie, - int value, const RageTimer& now ) const +void KeyboardDevice::GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const { hash_map::const_iterator iter = m_Mapping.find( cookie ); if( iter != m_Mapping.end() ) - vPresses.push_back( pair(DeviceInput(DEVICE_KEYBOARD, iter->second, value, now), value) ); + vPresses.push_back( DeviceInput(DEVICE_KEYBOARD, iter->second, value, now) ); } diff --git a/stepmania/src/archutils/Darwin/KeyboardDevice.h b/stepmania/src/archutils/Darwin/KeyboardDevice.h index 9338aed1a2..fee61e0480 100644 --- a/stepmania/src/archutils/Darwin/KeyboardDevice.h +++ b/stepmania/src/archutils/Darwin/KeyboardDevice.h @@ -15,8 +15,7 @@ protected: void Open(); public: - void GetButtonPresses( vector >& vPresses, int cookie, - int value, const RageTimer& now ) const; + void GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const; void GetDevicesAndDescriptions( vector& vDevices ) const; static bool DeviceButtonToMacVirtualKey( DeviceButton button, UInt8 &iMacVKOut ); diff --git a/stepmania/src/archutils/Darwin/PumpDevice.cpp b/stepmania/src/archutils/Darwin/PumpDevice.cpp index e7dfc42eba..2f691b18fc 100644 --- a/stepmania/src/archutils/Darwin/PumpDevice.cpp +++ b/stepmania/src/archutils/Darwin/PumpDevice.cpp @@ -11,8 +11,7 @@ void PumpDevice::Open() AddElementToQueue( 8 ); } -void PumpDevice::GetButtonPresses( vector >& vPresses, int cookie, - int value, const RageTimer& now ) const +void PumpDevice::GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const { DeviceButton db1 = DeviceButton_Invalid; DeviceButton db2 = DeviceButton_Invalid; @@ -46,15 +45,9 @@ void PumpDevice::GetButtonPresses( vector >& vPresses, i break; } if( db1 != DeviceButton_Invalid ) - { - DeviceInput di( m_Id, db1, pressed1 ? 1.0f : 0.0f , now ); - vPresses.push_back( pair(di, pressed1) ); - } + vPresses.push_back( DeviceInput(m_Id, db1, pressed1 ? 1.0f : 0.0f , now) ); if( db2 != DeviceButton_Invalid ) - { - DeviceInput di( m_Id, db2, pressed2 ? 1.0f : 0.0f , now ); - vPresses.push_back( pair(di, pressed2) ); - } + vPresses.push_back( DeviceInput(m_Id, db2, pressed2 ? 1.0f : 0.0f , now) ); } int PumpDevice::AssignIDs( InputDevice startID ) diff --git a/stepmania/src/archutils/Darwin/PumpDevice.h b/stepmania/src/archutils/Darwin/PumpDevice.h index 418887a524..b493d711a2 100644 --- a/stepmania/src/archutils/Darwin/PumpDevice.h +++ b/stepmania/src/archutils/Darwin/PumpDevice.h @@ -16,8 +16,7 @@ protected: bool SupportsVidPid( int vid, int pid ) { return vid == 0x0d2f && pid == 0x0001; } public: - void GetButtonPresses( vector >& vPresses, int cookie, - int value, const RageTimer& now ) const; + void GetButtonPresses( vector& vPresses, int cookie, int value, const RageTimer& now ) const; int AssignIDs( InputDevice startID ); void GetDevicesAndDescriptions( vector& vDevices ) const; };