Linux joystick fix
authorMark Cannon <vyhdycokio@gmail.com>
Sat, 23 Aug 2008 20:00:41 +0000 (20:00 +0000)
committerMark Cannon <vyhdycokio@gmail.com>
Sat, 23 Aug 2008 20:00:41 +0000 (20:00 +0000)
git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@490 83fadc84-e282-4d84-a09a-c4228d6ae7e5

ToDo.txt
src/TournamentManager.cpp
src/arch/InputHandler/InputHandler.cpp
src/arch/InputHandler/InputHandler_Linux_Joystick.cpp

index a515892..dd37769 100644 (file)
--- a/ToDo.txt
+++ b/ToDo.txt
@@ -8,6 +8,7 @@
 -InputHandler_PIUIO's coin code is broken\r
 -"Random" selections for non-existant BGVids always return the same video\r
 -OptionsList: linear tweening is borked despite every other command working\r
+-Recalculate precentages correctly with removal mods and negative BPMs\r
 -Full Screen -> Full Screen switch does not actually reset resolution, rather just the window size\r
 \r
 /* Minor feature additions */\r
index 90bb535..bdaece4 100644 (file)
@@ -182,8 +182,8 @@ bool TournamentManager::DeleteCompetitor( Competitor *cptr )
                return false;\r
 \r
        SAFE_DELETE( *iter );\r
-\r
        m_pCompetitors.erase( iter );\r
+\r
        return true;\r
 }\r
 \r
@@ -192,8 +192,8 @@ bool TournamentManager::DeleteCompetitorByIndex( unsigned i )
        ASSERT( i <= m_pCompetitors.size() );\r
 \r
        SAFE_DELETE( m_pCompetitors[i] );\r
-\r
        m_pCompetitors.erase( m_pCompetitors.begin() + i );\r
+\r
        return true;\r
 }\r
 \r
index 7bffef9..93908f1 100755 (executable)
@@ -7,7 +7,7 @@
 #include <map>
 
 /* This code is taken from CNLohr's 3.9 AC build. */
-map< int, RageTimer > m_LastHit;
+map<int, RageTimer> m_LastHit;
 
 void InputHandler::UpdateTimer()
 {
@@ -17,18 +17,19 @@ void InputHandler::UpdateTimer()
 
 void InputHandler::ButtonPressed( DeviceInput di, bool Down )
 {
-       // this gets spammed a lot.
-       /*
-       if( di.button != KEY_SPACE )
-               LOG->Debug( "%s %s", di.toString().c_str(), Down ? "pressed" : "released" );
-       */
-
        if( di.ts.IsZero() )
        {
                di.ts = m_LastUpdate.Half();
                ++m_iInputsSinceUpdate;
        }
 
+       // uncomment if you need to check timestamps on input...
+       // threaded input should never pass 0.000010 or so.
+       /*
+       if( di.button != KEY_SPACE )
+               LOG->Debug( "%s %s - timestamp, %f", di.toString().c_str(), Down ? "pressed" : "released", di.ts.Ago() );
+       */
+
        if( !Down )
        {
                INPUTFILTER->ButtonPressed( di, Down );
index 7923c74..cb14ac6 100755 (executable)
@@ -147,6 +147,7 @@ void InputHandler_Linux_Joystick::InputThread()
                        }
 
                        InputDevice id = InputDevice(DEVICE_JOY1 + i);
+                       DeviceInput di = DeviceInput( id, JOY_1 );
 
                        event.type &= ~JS_EVENT_INIT;
                        switch (event.type) {
@@ -155,15 +156,21 @@ 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, JOY_1 + iNum), event.value );
+
+                               // set the DeviceInput timestamp and button
+                               di.button = JOY_1 + iNum;
+                               di.ts.Touch();
+                               ButtonPressed( di, event.value );
                                break;
                        }
                                
                        case JS_EVENT_AXIS: {
                                DeviceButton neg = (JoystickButton)(JOY_LEFT+2*event.number);
                                DeviceButton pos = (JoystickButton)(JOY_RIGHT+2*event.number);
-                               ButtonPressed( DeviceInput(id, neg), event.value < -16000 );
-                               ButtonPressed( DeviceInput(id, pos), event.value > +16000 );
+
+                               di.ts.Touch();
+                               di.button = neg; ButtonPressed( di, event.value < -16000 );
+                               di.button = pos; ButtonPressed( di, event.value > +16000 );
                                break;
                        }