From 9bfd0833b4cc7aa1be6d539ac6e1dc50560abeed Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 26 Dec 2006 22:54:18 +0000 Subject: [PATCH] set level, not down param --- .../src/arch/InputHandler/InputHandler_Carbon.cpp | 2 +- .../InputHandler/InputHandler_Linux_Joystick.cpp | 7 ++++--- .../src/arch/InputHandler/InputHandler_Linux_tty.cpp | 2 +- .../arch/InputHandler/InputHandler_Win32_MIDI.cpp | 7 ++----- .../src/arch/InputHandler/InputHandler_Win32_MIDI.h | 2 +- .../arch/InputHandler/InputHandler_Win32_Pump.cpp | 6 +++--- stepmania/src/arch/InputHandler/InputHandler_X11.cpp | 6 +++--- .../src/arch/InputHandler/InputHandler_Xbox.cpp | 12 ++++++------ 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp b/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp index 2de867ea05..76953d61cc 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Carbon.cpp @@ -31,7 +31,7 @@ void InputHandler_Carbon::QueueCallBack( void *target, int result, void *refcon, while( (result = CALL(queue, getNextEvent, &event, zeroTime, 0)) == kIOReturnSuccess ) dev->GetButtonPresses( vPresses, int(event.elementCookie), int(event.value), now ); FOREACH_CONST( DeviceInput, vPresses, i ) - This->ButtonPressed( *i, i->level > 0.5f ); + This->ButtonPressed( *i ); } static void RunLoopStarted( CFRunLoopObserverRef o, CFRunLoopActivity a, void *sem ) diff --git a/stepmania/src/arch/InputHandler/InputHandler_Linux_Joystick.cpp b/stepmania/src/arch/InputHandler/InputHandler_Linux_Joystick.cpp index 52c8a369c3..f2fbe04040 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Linux_Joystick.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Linux_Joystick.cpp @@ -155,15 +155,16 @@ void InputHandler_Linux_Joystick::InputThread() // In 2.6.11 using an EMS USB2, the event number for P1 Tri (the first button) // is being reported as 32 instead of 0. Correct for this. wrap( iNum, 32 ); // max number of joystick buttons. Make this a constant? - ButtonPressed( DeviceInput(id, enum_add2(JOY_BUTTON_1, iNum), 0, now), event.value ); + ButtonPressed( DeviceInput(id, enum_add2(JOY_BUTTON_1, iNum), event.value, now) ); break; } case JS_EVENT_AXIS: { DeviceButton neg = enum_add2(JOY_LEFT, 2*event.number); DeviceButton pos = enum_add2(JOY_RIGHT, 2*event.number); - ButtonPressed(DeviceInput(id, neg, 0, now), event.value < -16000); - ButtonPressed(DeviceInput(id, pos, 0, now), event.value > +16000); + float l = SCALE( int(event.value), 0.0f, 32767, 0.0f, 1.0f ); + ButtonPressed(DeviceInput(id, neg, max(-l,0), now), event.value < -16000); + ButtonPressed(DeviceInput(id, pos, max(+l,0), now), event.value > +16000); break; } diff --git a/stepmania/src/arch/InputHandler/InputHandler_Linux_tty.cpp b/stepmania/src/arch/InputHandler/InputHandler_Linux_tty.cpp index 5e19782477..88015caa08 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Linux_tty.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Linux_tty.cpp @@ -183,7 +183,7 @@ void InputHandler_Linux_tty::Update() const int butno = keys[key]; const bool pressed = !(keybuf[i] & 0x80); - ButtonPressed(DeviceInput(DEVICE_KEYBOARD, butno), pressed); + ButtonPressed( DeviceInput(DEVICE_KEYBOARD, butno, pressed) ); } } diff --git a/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp b/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp index b4896e5836..1cb056a812 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp @@ -89,12 +89,9 @@ static void CALLBACK midiCallback( HMIDIIN device, UINT status, DWORD instancePt if( iType == 144 ) { - DeviceInput di = DeviceInput( DEVICE_MIDI, enum_add2(MIDI_FIRST, iChannel) ); + DeviceInput di = DeviceInput( DEVICE_MIDI, enum_add2(MIDI_FIRST, iChannel), iValue > 0 ); di.ts.Touch(); - if( iValue > 0 ) - ((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di, true ); - else - ((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di, false ); + ((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di ); } } } diff --git a/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.h b/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.h index 1132fbc13c..8f6abef9ae 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.h +++ b/stepmania/src/arch/InputHandler/InputHandler_Win32_MIDI.h @@ -12,7 +12,7 @@ public: void GetDevicesAndDescriptions( vector& vDevicesOut ); - void SetDev( DeviceInput key, bool pressed ) { ButtonPressed( key, pressed ); } + void SetDev( DeviceInput key ) { ButtonPressed( key ); } private: bool m_bFoundDevice; diff --git a/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp b/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp index 12e5933f02..e7d5ea4f96 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp @@ -20,7 +20,7 @@ InputHandler_Win32_Pump::InputHandler_Win32_Pump() bool bFoundOnePad = false; for( int i = 0; i < NUM_PUMPS; ++i ) { - if( m_pDevice[i].Open(pump_usb_vid, pump_usb_pid, sizeof(long), i, NULL) ) + if( m_pDevice[i].Open(pump_usb_vid, pump_usb_pid, sizeof(long), i) ) { bFoundOnePad = true; LOG->Info( "Found Pump pad %i", i ); @@ -60,13 +60,13 @@ void InputHandler_Win32_Pump::HandleInput( int iDevice, int iEvent ) for( int iButton = 0; iButton < ARRAYLEN(bits); ++iButton ) { - DeviceInput di( id, enum_add2(JOY_BUTTON_1, iButton) ); + DeviceInput di( id, enum_add2(JOY_BUTTON_1, iButton), !(iEvent & bits[iButton]) ); /* If we're in a thread, our timestamp is accurate. */ if( InputThread.IsCreated() ) di.ts.Touch(); - ButtonPressed( di, !(iEvent & bits[iButton]) ); + ButtonPressed( di ); } } diff --git a/stepmania/src/arch/InputHandler/InputHandler_X11.cpp b/stepmania/src/arch/InputHandler/InputHandler_X11.cpp index e90e6587ae..7c987cfbff 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_X11.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_X11.cpp @@ -171,7 +171,7 @@ void InputHandler_X11::Update() continue; } // This is a new event so the last release was not a repeat. - ButtonPressed( DeviceInput(DEVICE_KEYBOARD, lastDB), false ); + ButtonPressed( DeviceInput(DEVICE_KEYBOARD, lastDB, 0) ); lastEvent.type = 0; } // Why only the zero index? @@ -179,13 +179,13 @@ void InputHandler_X11::Update() if( lastDB == DeviceButton_Invalid ) continue; if( bPress ) - ButtonPressed( DeviceInput(DEVICE_KEYBOARD, lastDB), true ); + ButtonPressed( DeviceInput(DEVICE_KEYBOARD, lastDB, 1) ); else lastEvent = event; } // Handle any last releases. if( lastEvent.type != 0 ) - ButtonPressed( DeviceInput(DEVICE_KEYBOARD, lastDB), false ); + ButtonPressed( DeviceInput(DEVICE_KEYBOARD, lastDB, 0) ); InputHandler::UpdateTimer(); } diff --git a/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp b/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp index f7ff93177c..e62d66a222 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp @@ -109,8 +109,8 @@ void InputHandler_Xbox::Update() LOG->Warn("Ignored joystick event (button too high)"); continue; } - DeviceInput di(inputDevice, Button); - ButtonPressed(di, nowPressed != 0); + DeviceInput di(inputDevice, Button, nowPressed != 0); + ButtonPressed(di); continue; } } @@ -129,8 +129,8 @@ void InputHandler_Xbox::Update() LOG->Warn("Ignored joystick event (button too high)"); continue; } - DeviceInput di(inputDevice, Button); - ButtonPressed(di, nowPressed); + DeviceInput di(inputDevice, Button, nowPressed); + ButtonPressed(di); continue; } } @@ -149,8 +149,8 @@ void InputHandler_Xbox::Update() DeviceButton neg = (DeviceButton)(JOY_LEFT + (2 * j)); DeviceButton pos = (DeviceButton)(JOY_RIGHT + (2 * j)); float l = SCALE( axes[j], 0.0f, 32768.0f, 0.0f, 1.0f ); - ButtonPressed(DeviceInput(inputDevice, neg,max(-l,0),RageZeroTimer), axes[j] > -16000); - ButtonPressed(DeviceInput(inputDevice, pos,max(+l,0),RageZeroTimer), axes[j] < +16000); + ButtonPressed(DeviceInput(inputDevice, neg,max(-l,0),RageZeroTimer)); + ButtonPressed(DeviceInput(inputDevice, pos,max(+l,0),RageZeroTimer)); continue; } }