From c8c4e838e08ff93312492d5022a8423f8e43e587 Mon Sep 17 00:00:00 2001 From: Mark Cannon Date: Wed, 13 Feb 2008 17:16:10 +0000 Subject: [PATCH] git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@19 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- src/Makefile.am | 3 +- src/RageInputDevice.cpp | 2 + src/RageInputDevice.h | 2 + src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp | 85 ++++++---------------- src/arch/InputHandler/InputHandler_Linux_PIUIO.h | 6 +- src/arch/Lights/LightsDriver_External.cpp | 2 - src/arch/Lights/LightsDriver_External.h | 3 +- src/arch/arch.cpp | 2 +- src/io/USBDriver.h | 3 +- 9 files changed, 37 insertions(+), 71 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 0a8c2819..1585297c 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -207,7 +207,8 @@ endif if LINUX MemoryCard += arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp arch/MemoryCard/MemoryCardDriverThreaded_Linux.h -InputHandler += arch/InputHandler/InputHandler_Linux_Joystick.h arch/InputHandler/InputHandler_Linux_Joystick.cpp +InputHandler += arch/InputHandler/InputHandler_Linux_Joystick.h arch/InputHandler/InputHandler_Linux_Joystick.cpp \ + arch/InputHandler/InputHandler_Linux_PIUIO.h arch/InputHandler/InputHandler_Linux_PIUIO.cpp endif Arch = $(LoadingWindow) $(Sound) $(ArchHooks) $(InputHandler) $(MovieTexture) \ diff --git a/src/RageInputDevice.cpp b/src/RageInputDevice.cpp index af9513af..db624d3c 100755 --- a/src/RageInputDevice.cpp +++ b/src/RageInputDevice.cpp @@ -134,6 +134,8 @@ static const CString InputDeviceNames[] = { "Pump2", "Midi", "Para1", + "ITGIO", + "PIUIO", }; XToString( InputDevice, NUM_INPUT_DEVICES ); StringToX( InputDevice ); diff --git a/src/RageInputDevice.h b/src/RageInputDevice.h index 670f9a4f..74062e77 100755 --- a/src/RageInputDevice.h +++ b/src/RageInputDevice.h @@ -31,6 +31,8 @@ enum InputDevice { DEVICE_PUMP2, DEVICE_MIDI, DEVICE_PARA1, + DEVICE_PIUIO, + DEVICE_ITGIO, NUM_INPUT_DEVICES, // leave this at the end DEVICE_NONE // means this is NULL }; diff --git a/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp b/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp index 5256550a..64870a9f 100644 --- a/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp +++ b/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp @@ -2,9 +2,12 @@ #include "RageLog.h" #include "LightsManager.h" +#include "arch/Lights/LightsDriver_External.h" // needed for g_LightsState #include "PrefsManager.h" #include "InputHandler_Linux_PIUIO.h" +LightsState g_LightsState; + InputHandler_Linux_PIUIO::InputHandler_Linux_PIUIO() { m_bShutdown = false; @@ -12,7 +15,7 @@ InputHandler_Linux_PIUIO::InputHandler_Linux_PIUIO() // device found and set if( IOBoard.Open() ) { - m_iLightData = 0; // initialise + m_bFoundDevice = true; InputThread.SetName( "PIUIO thread" ); InputThread.Create( InputThread_Start, this ); @@ -20,8 +23,7 @@ InputHandler_Linux_PIUIO::InputHandler_Linux_PIUIO() else { LOG->Warn( "InputHandler_Linux_PIUIO: could not open I/O board." ); - - + } } InputHandler_Linux_PIUIO::~InputHandler_Linux_PIUIO() @@ -37,63 +39,13 @@ InputHandler_Linux_PIUIO::~InputHandler_Linux_PIUIO() // remember to delete device handler when finished } -bool InputHandler_Linux_PIUIO::DeviceMatches( int idVendor, int idProduct ) -{ - if( idVendor == 1351 && idProduct == 4098 ) - return true; - - return false; -} - -bool InputHandler_Linux_PIUIO::Read( u_int32_t *pData ) -{ - int iResult; - - while( 1 ) - { - iResult = usb_control_msg(device, 192, 174, 0, 0, *pData, 8, 10000); - if( iResult == 8 ) // all data read - break; - - // all data not read - LOG->Trace( "Device error: %s", usb_strerror() ); - Close(); - - while( !Open() ) - usleep( 100000 ); - } - - return true; -} - -bool InputHandler_Linux_PIUIO::Write( u_int32_t iData ) -{ - int iResult; - - while( 1 ) - { - // XXX: this can't be right...but we'll worry later. - iResult = usb_control_msg(device, 64, 174, 0, 0, iData, 8, 10000 ); - - if( iResult == 8 ) - break; - - LOG->Trace( "Device error: %s", usb_strerror() ); - Close(); - - while( !Open() ) - usleep( 100000 ); - } - - return true; -} - void InputHandler_Linux_PIUIO::GetDevicesAndDescriptions( vector& vDevicesOut, vector& vDescriptionsOut ) { if( m_bFoundDevice ) { -// vDevicesOut.push_back( In - vDescriptionsOut.push_back( "Input/lights controller" ); + // currently a dummy number + vDevicesOut.push_back( InputDevice(DEVICE_PIUIO) ); + vDescriptionsOut.push_back( "PIUIO" ); } } @@ -105,20 +57,27 @@ int InputHandler_Linux_PIUIO::InputThread_Start( void *p ) void InputHandler_Linux_PIUIO::InputThreadMain() { + /* For now, we just want to test lights updates. */ UpdateLights(); - Write(); + IOBoard.Write( m_iLightData ); } void InputHandler_Linux_PIUIO::UpdateLights() { // XXX: need to check LightsDriver somehow - ASSERT( g_LightsState ); - // lighting needs cleaned up - vector/array map? - // currently, I just want to get all this outlined. - // it might even be completely wrong, but at least - // we'll know what we're doing. + static const int iCabinetData[NUM_CABINET_LIGHTS-1] = + { (1 << 22), (1 << 25), (1 << 24), (1 << 23), 0, 0, (1 << 10) }; + + // reset + m_iLightData = 0; + // Just do cabinet lights for now and we'll figure the rest later. + FOREACH_ENUM( CabinetLight, NUM_CABINET_LIGHTS-1, cl ) + if( g_LightsState.m_bCabinetLights[cl] ) + m_iLightData += iCabinetData[cl]; +// for reference +#if 0 // probably marquee lights if( g_LightsState[0] ) m_iLightData += (1 << 22); if( g_LightsState[1] ) m_iLightData += (1 << 25); @@ -140,4 +99,6 @@ void InputHandler_Linux_PIUIO::UpdateLights() if( g_LightsState[29] ) m_iLightData += (1 << 5); if( g_LightsState[30] ) m_iLightData += (1 << 2); if( g_LightsState[31] ) m_iLightData += (1 << 3); +#endif } + diff --git a/src/arch/InputHandler/InputHandler_Linux_PIUIO.h b/src/arch/InputHandler/InputHandler_Linux_PIUIO.h index 8bbe5a59..52fae3a1 100644 --- a/src/arch/InputHandler/InputHandler_Linux_PIUIO.h +++ b/src/arch/InputHandler/InputHandler_Linux_PIUIO.h @@ -7,7 +7,6 @@ #include "InputHandler.h" #include "RageThreads.h" -#include "InputHandler_USBDriver.h" #include "io/PIUIO.h" class InputHandler_Linux_PIUIO: public InputHandler @@ -16,11 +15,14 @@ public: InputHandler_Linux_PIUIO(); ~InputHandler_Linux_PIUIO(); - void Update( float fDeltaTime ); +// for non-threaded input...should we even bother? +// void Update( float fDeltaTime ); + void GetDevicesAndDescriptions( vector& vDevicesOut, vector& vDescriptionsOut ); private: PIUIO IOBoard; RageThread InputThread; + bool m_bFoundDevice; bool m_bShutdown; uint32_t m_iLightData; diff --git a/src/arch/Lights/LightsDriver_External.cpp b/src/arch/Lights/LightsDriver_External.cpp index b7ac0a9c..2400520e 100755 --- a/src/arch/Lights/LightsDriver_External.cpp +++ b/src/arch/Lights/LightsDriver_External.cpp @@ -8,8 +8,6 @@ #include "RageUtil.h" #include "LightsDriver_External.h" -extern LightsState g_LightsState; - LightsDriver_External::LightsDriver_External() { ZERO( g_LightsState ); diff --git a/src/arch/Lights/LightsDriver_External.h b/src/arch/Lights/LightsDriver_External.h index 03609b7f..33bbe84f 100755 --- a/src/arch/Lights/LightsDriver_External.h +++ b/src/arch/Lights/LightsDriver_External.h @@ -13,9 +13,10 @@ public: void Set( const LightsState *ls ); - LightsState g_LightsState; }; +extern LightsState g_LightsState; + #define USE_LIGHTS_DRIVER_EXTERNAL #endif diff --git a/src/arch/arch.cpp b/src/arch/arch.cpp index c393f694..c38335d5 100755 --- a/src/arch/arch.cpp +++ b/src/arch/arch.cpp @@ -51,7 +51,7 @@ void MakeInputHandlers(CString drivers, vector &Add) #ifdef USE_INPUT_HANDLER_XBOX if(!s->CompareNoCase("Xbox") ) ret = new InputHandler_Xbox; #endif -#ifdef USE_INPUT_HANDLER_LINUX_PIUIO_NOTIMPL +#ifdef USE_INPUT_HANDLER_LINUX_PIUIO if(!s->CompareNoCase("PIUIO") ) ret = new InputHandler_Linux_PIUIO; #endif #ifdef USE_INPUT_HANDLER_LINUX_IOW_NOTIMPL diff --git a/src/io/USBDriver.h b/src/io/USBDriver.h index 251e94ac..c4b73192 100644 --- a/src/io/USBDriver.h +++ b/src/io/USBDriver.h @@ -12,7 +12,6 @@ public: bool Open(); void Close(); - protected: struct usb_device *FindDevice(); @@ -22,7 +21,7 @@ protected: int m_iInterfaceNumber; }; -#endif +#endif /* IO_USBDRIVER_H */ /* * (c) 2008 BoXoRRoXoRs -- 2.11.0