From 7fc8f686fc91aaf61577b444df2c134013dfe646 Mon Sep 17 00:00:00 2001 From: Mark Cannon Date: Mon, 24 Mar 2008 23:58:40 +0000 Subject: [PATCH] Converted ITGIO to uint16_t, which it should be according to documentation git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@170 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- src/PrefsManager.cpp | 1 + src/PrefsManager.h | 1 + src/arch/InputHandler/InputHandler_Linux_Iow.cpp | 18 ++++++++---------- src/arch/InputHandler/InputHandler_Linux_Iow.h | 8 ++++---- src/io/ITGIO.cpp | 12 ++++++------ src/io/ITGIO.h | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/PrefsManager.cpp b/src/PrefsManager.cpp index fa6d5140..c3126e7b 100755 --- a/src/PrefsManager.cpp +++ b/src/PrefsManager.cpp @@ -303,6 +303,7 @@ PrefsManager::PrefsManager() : m_bThreadedMovieDecode ( "ThreadedMovieDecode", true ), m_bScreenTestMode ( "ScreenTestMode", false ), m_bDebugUSBInput ( "DebugUSBInput", false ), + m_bITGIOBitFlip ( "ITGIOBitFlip", false ), m_bDebugLights ( "DebugLights", false ), m_bMonkeyInput ( "MonkeyInput", false ), m_sMachineName ( "MachineName", "" ), diff --git a/src/PrefsManager.h b/src/PrefsManager.h index a5051999..138147c8 100755 --- a/src/PrefsManager.h +++ b/src/PrefsManager.h @@ -316,6 +316,7 @@ public: Preference m_bThreadedMovieDecode; Preference m_bScreenTestMode; Preference m_bDebugUSBInput; + Preference m_bITGIOBitFlip; Preference m_bDebugLights; Preference m_bMonkeyInput; Preference m_sMachineName; diff --git a/src/arch/InputHandler/InputHandler_Linux_Iow.cpp b/src/arch/InputHandler/InputHandler_Linux_Iow.cpp index 3f02125b..5d3816a4 100644 --- a/src/arch/InputHandler/InputHandler_Linux_Iow.cpp +++ b/src/arch/InputHandler/InputHandler_Linux_Iow.cpp @@ -68,6 +68,10 @@ void InputHandler_Linux_Iow::InputThreadMain() IOBoard.Write( m_iWriteData ); IOBoard.Read( &m_iInputData ); + + if( PREFSMAN->m_bITGIOBitFlip ) + m_iInputData = ~m_iInputData; + HandleInput(); // give up 0.01 sec for other events - @@ -79,15 +83,16 @@ void InputHandler_Linux_Iow::InputThreadMain() /* Thanks, ITG-IO documentation! <3 */ void InputHandler_Linux_Iow::HandleInput() { - uint32_t i = 1; // convenience hack + uint16_t i = 1; // convenience hack if( PREFSMAN->m_bDebugUSBInput && (m_iInputData != 0) && (m_iInputData != m_iLastInput) ) { - LOG->Info( "Input: %i", m_iInputData ); + if( LOG ) + LOG->Info( "Input: %i", m_iInputData ); CString sInputs; - for( unsigned x = 0; x < 32; x++ ) + for( unsigned x = 0; x < 16; x++ ) { /* the bit we expect isn't in the data */ if( !(m_iInputData & (i << x)) ) @@ -165,11 +170,4 @@ void InputHandler_Linux_Iow::UpdateLights() FOREACH_ENUM( GameButton, 4, gb ) if( g_LightsState.m_bGameButtonLights[gc][gb] ) m_iWriteData |= iPadBits[gc][gb]; - - CString sBits; - - for( int x = 0; x < 16; x++ ) - sBits += (m_iWriteData & (1 << (16-x))) ? "1" : "0"; - - LOG->Trace( "%s", sBits.c_str() ); } diff --git a/src/arch/InputHandler/InputHandler_Linux_Iow.h b/src/arch/InputHandler/InputHandler_Linux_Iow.h index 590f5d3d..a6a21e77 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; - uint32_t m_iInputData; - uint32_t m_iLastInput; + uint16_t m_iInputData; + uint16_t m_iLastInput; - uint32_t m_iWriteData; - uint32_t m_iLastWrite; + uint16_t m_iWriteData; + uint16_t m_iLastWrite; static int InputThread_Start( void *p ); diff --git a/src/io/ITGIO.cpp b/src/io/ITGIO.cpp index 55c35f7d..468b4699 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( uint32_t *pData ) +bool ITGIO::Read( uint16_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, 4, 1000); - if( iResult == 4 ) // all data read + iResult = usb_control_msg(m_pHandle, 161, 1, 256, 0, (char *)pData, 2, 1000); + if( iResult == 2 ) // all data read break; // all data not read @@ -36,15 +36,15 @@ bool ITGIO::Read( uint32_t *pData ) return true; } -bool ITGIO::Write( uint32_t iData ) +bool ITGIO::Write( uint16_t iData ) { int iResult; while( 1 ) { - iResult = usb_control_msg(m_pHandle, 33, 9, 512, 0, (char *)&iData, 4, 1000 ); + iResult = usb_control_msg(m_pHandle, 33, 9, 512, 0, (char *)&iData, 2, 1000 ); - if( iResult == 4 ) // all data read + if( iResult == 2 ) // all data read break; Reconnect(); diff --git a/src/io/ITGIO.h b/src/io/ITGIO.h index 30ff1d57..bda2da47 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( uint32_t *pData ); - bool Write( uint32_t iData ); + bool Read( uint16_t *pData ); + bool Write( uint16_t iData ); /* Globally accessible. */ static int m_iInputErrorCount; -- 2.11.0