From: Mark Cannon Date: Sun, 30 Mar 2008 08:40:06 +0000 (+0000) Subject: Added accurate Iow input mappings, re-fixed ITGIO data to uint32_t, other minor stuff X-Git-Url: http://cameron1729.xyz/?a=commitdiff_plain;h=f8667d7356a82940df8634b0ebdda2d88d386a81;p=openitg.git Added accurate Iow input mappings, re-fixed ITGIO data to uint32_t, other minor stuff git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@174 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- diff --git a/ToDo.txt b/ToDo.txt index 77862d0d..ae3e72b8 100644 --- a/ToDo.txt +++ b/ToDo.txt @@ -1,6 +1,8 @@ /* More-or-less in order of priority. */ /* Bug fixing */ +Make ITGIO map the 2P buttons to player 2 instead of player 1 +Make "g_sInputType" and "GetInputType()" work properly /* Minor feature additions */ -Implement "InputDebounceTime" diff --git a/src/RageInputDevice.cpp b/src/RageInputDevice.cpp index a366a06b..1da864c1 100755 --- a/src/RageInputDevice.cpp +++ b/src/RageInputDevice.cpp @@ -135,8 +135,8 @@ static const CString InputDeviceNames[] = { "Midi", "Para1", "Debug", - "ITGIO", "PIUIO", + "ITGIO", }; XToString( InputDevice, NUM_INPUT_DEVICES ); StringToX( InputDevice ); diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index 8b462e94..13dd68f9 100755 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -1305,7 +1305,7 @@ bool ScreenSelectMusic::ValidateCustomSong( Song* pSong ) // EXPERIMENT: fix input-killing bug INPUTFILTER->Reset(); - INPUTFILTER->Update( 0 ); + INPUTFILTER->Update( 1 ); SCREENMAN->HideOverlayMessage(); diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 8d4aa26e..a08f8fed 100755 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -296,7 +296,6 @@ void ResetGame() } SaveGamePrefsToDisk(); - // // update last seen joysticks // diff --git a/src/arch/InputHandler/InputHandler_Linux_Iow.cpp b/src/arch/InputHandler/InputHandler_Linux_Iow.cpp index 2abf947d..ea0c22b3 100644 --- a/src/arch/InputHandler/InputHandler_Linux_Iow.cpp +++ b/src/arch/InputHandler/InputHandler_Linux_Iow.cpp @@ -10,6 +10,8 @@ extern LightsState g_LightsState; extern CString g_sInputType; +// Iow lights thread is disabled for now: causes major, major input problems + InputHandler_Linux_Iow::InputHandler_Linux_Iow() { m_bShutdown = false; @@ -24,8 +26,9 @@ InputHandler_Linux_Iow::InputHandler_Linux_Iow() m_bFoundDevice = true; InputThread.SetName( "Iow thread" ); - LightsThread.SetName( "Iow lights thread" ); +// LightsThread.SetName( "Iow lights thread" ); InputThread.Create( InputThread_Start, this ); +// LightsThread.Create( LightsThread_Start, this ); g_sInputType = "ITGIO"; } @@ -79,45 +82,63 @@ void InputHandler_Linux_Iow::InputThreadMain() { IOBoard.Read( &m_iInputData ); - if( PREFSMAN->m_bITGIOBitFlip ) - m_iInputData = ~m_iInputData; + m_iInputData = ~m_iInputData; HandleInput(); - // give up 0.005 sec for other events - +// UpdateLights(); +// IOBoard.Write( m_iWriteData ); + + // give up 0.008 sec for other events - // this may need adjusting for lag/offsets - usleep( 5000 ); + usleep( 8000 ); } } void InputHandler_Linux_Iow::LightsThreadMain() { +/* while( !m_bShutdown ) { - UpdateLights(); - IOBoard.Write( m_iWriteData ); - // give up 0.01 sec for other events - // this may need adjusting for lag/offsets usleep( 10000 ); } +*/ } -/* Thanks, ITG-IO documentation! <3 */ +/* Thanks, ITG-IO documentation. ):< */ void InputHandler_Linux_Iow::HandleInput() { - uint16_t i = 1; // convenience hack + uint32_t i = 1; // convenience hack + static const uint32_t iInputBits[NUM_IO_BUTTONS] = { + /* Player 1 - left, right, up, down */ + (i << 18), (i << 19), (i << 16), (i << 17), + + /* Player 1 - Select (unused), Start, MenuLeft, MenuRight */ + 0, (i << 20), (i << 21), (i << 22), + + /* Player 2 - left, right, up, down */ + (i << 25), (i << 26), (i << 23), (i << 24), + + /* Player 2 - Select (unused), Start, MenuLeft, MenuRight */ + 0, (i << 27), (i << 28), (i << 29), + + /* Service, coin insert */ + // FIXME: Service is obviously wrong + (i << 1), (i << 31) }; - if( PREFSMAN->m_bDebugUSBInput && (m_iInputData != 0) && (m_iInputData != m_iLastInput) ) + if( (m_iInputData != 0) ) { if( LOG ) LOG->Info( "Input: %i", m_iInputData ); CString sInputs; - for( unsigned x = 0; x < 16; x++ ) + for( unsigned x = 0; x < 32; x++ ) { /* the bit we expect isn't in the data */ +// if( (m_iInputData & (i << x)) ) if( !(m_iInputData & (i << x)) ) continue; @@ -131,22 +152,6 @@ void InputHandler_Linux_Iow::HandleInput() LOG->Info( sInputs ); } - static const uint16_t iInputBits[NUM_IO_BUTTONS] = { - /* Player 1 - left, right, up, down */ - (1 << 13), (1 << 12), (1 << 15), (1 << 14), - - /* Player 1 - Select (unused), Start, MenuLeft, MenuRight */ - 0, (1 << 11), (1 << 10), (1 << 9), - - /* Player 2 - left, right, up, down */ - (1 << 6), (1 << 5), (1 << 8), (1 << 7), - - /* Player 2 - Select (unused), Start, MenuLeft, MenuRight */ - 0, (1 << 4), (1 << 3), (1 << 2), - - /* Service, coin insert */ - (1 << 1), (1 << 0) }; - InputDevice id = DEVICE_ITGIO; for( int iButton = 0; iButton < NUM_IO_BUTTONS; iButton++ ) @@ -163,18 +168,19 @@ void InputHandler_Linux_Iow::HandleInput() /* Requires "LightsDriver=ext" */ void InputHandler_Linux_Iow::UpdateLights() { - static const uint16_t iCabinetBits[NUM_CABINET_LIGHTS] = { + /* FIXME: none of these are tested, and it's likely none are right. */ + static const uint32_t iCabinetBits[NUM_CABINET_LIGHTS] = { /* Upper-left, upper-right, lower-left, lower-right marquee */ - (1 << 8), (1 << 10), (1 << 9), (1 << 11), + (1 << 24), (1 << 26), (1 << 25), (1 << 27), /* P1 select, P2 select, both bass */ - (1 << 13), (1 << 12), (1 << 15), (1 << 15) }; + (1 << 29), (1 << 28), (1 << 31), (1 << 31) }; - static const uint16_t iPadBits[2][4] = + static const uint32_t iPadBits[2][4] = { /* Left, right, up, down */ - { (1 << 1), (1 << 0), (1 << 3), (1 << 2) }, /* Player 1 */ - { (1 << 5), (1 << 4), (1 << 7), (1 << 6) } /* Player 2 */ + { (1 << 17), (1 << 16), (1 << 19), (1 << 18) }, /* Player 1 */ + { (1 << 21), (1 << 20), (1 << 23), (1 << 22) } /* Player 2 */ }; m_iLastWrite = m_iWriteData; diff --git a/src/arch/InputHandler/InputHandler_Linux_Iow.h b/src/arch/InputHandler/InputHandler_Linux_Iow.h index 6b1d5fb3..12bfac4b 100644 --- a/src/arch/InputHandler/InputHandler_Linux_Iow.h +++ b/src/arch/InputHandler/InputHandler_Linux_Iow.h @@ -28,11 +28,11 @@ private: bool m_bFoundDevice; bool m_bShutdown; - uint16_t m_iInputData; - uint16_t m_iLastInput; + uint32_t m_iInputData; + uint32_t m_iLastInput; - uint16_t m_iWriteData; - uint16_t m_iLastWrite; + uint32_t m_iWriteData; + uint32_t m_iLastWrite; static int InputThread_Start( void *p ); static int LightsThread_Start( void *p ); diff --git a/src/io/ITGIO.cpp b/src/io/ITGIO.cpp index 468b4699..0217885c 100644 --- a/src/io/ITGIO.cpp +++ b/src/io/ITGIO.cpp @@ -17,15 +17,15 @@ bool ITGIO::Matches( int idVendor, int idProduct ) const return false; } -bool ITGIO::Read( uint16_t *pData ) +bool ITGIO::Read( uint32_t *pData ) { int iResult; while( 1 ) { /* XXX: I hate magic values. What do these mean? -- Vyhd */ - iResult = usb_control_msg(m_pHandle, 161, 1, 256, 0, (char *)pData, 2, 1000); - if( iResult == 2 ) // all data read + iResult = usb_control_msg(m_pHandle, 161, 1, 256, 0, (char *)pData, 4, 1000); + if( iResult == 4 ) // all data read break; // all data not read @@ -36,15 +36,15 @@ bool ITGIO::Read( uint16_t *pData ) return true; } -bool ITGIO::Write( uint16_t iData ) +bool ITGIO::Write( uint32_t iData ) { int iResult; while( 1 ) { - iResult = usb_control_msg(m_pHandle, 33, 9, 512, 0, (char *)&iData, 2, 1000 ); - - if( iResult == 2 ) // all data read + iResult = usb_control_msg(m_pHandle, 33, 9, 512, 0, (char *)&iData, 4, 1000 ); + + if( iResult == 4 ) // all data read break; Reconnect(); @@ -55,6 +55,7 @@ bool ITGIO::Write( uint16_t iData ) void ITGIO::Reconnect() { + LOG->Warn( "Attempting to reconnect ITGIO" ); //if( ??? ) // m_sInputError = "I/O timeout"; diff --git a/src/io/ITGIO.h b/src/io/ITGIO.h index bda2da47..30ff1d57 100644 --- a/src/io/ITGIO.h +++ b/src/io/ITGIO.h @@ -11,8 +11,8 @@ public: // all in one place. It's not important right now, though. - Vyhd // static bool DeviceMatches( int idVendor, int idProduct ); - bool Read( uint16_t *pData ); - bool Write( uint16_t iData ); + bool Read( uint32_t *pData ); + bool Write( uint32_t iData ); /* Globally accessible. */ static int m_iInputErrorCount;