git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@19 83fadc84-e282...
authorMark Cannon <vyhdycokio@gmail.com>
Wed, 13 Feb 2008 17:16:10 +0000 (17:16 +0000)
committerMark Cannon <vyhdycokio@gmail.com>
Wed, 13 Feb 2008 17:16:10 +0000 (17:16 +0000)
src/Makefile.am
src/RageInputDevice.cpp
src/RageInputDevice.h
src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp
src/arch/InputHandler/InputHandler_Linux_PIUIO.h
src/arch/Lights/LightsDriver_External.cpp
src/arch/Lights/LightsDriver_External.h
src/arch/arch.cpp
src/io/USBDriver.h

index 0a8c281..1585297 100755 (executable)
@@ -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) \
index af9513a..db624d3 100755 (executable)
@@ -134,6 +134,8 @@ static const CString InputDeviceNames[] = {
        "Pump2",
        "Midi",
        "Para1",
+       "ITGIO",
+       "PIUIO",
 };
 XToString( InputDevice, NUM_INPUT_DEVICES );
 StringToX( InputDevice );
index 670f9a4..74062e7 100755 (executable)
@@ -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
 };
index 5256550..64870a9 100644 (file)
@@ -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<InputDevice>& vDevicesOut, vector<CString>& 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
 }
+
index 8bbe5a5..52fae3a 100644 (file)
@@ -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<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut );
 private:
        PIUIO IOBoard;
        RageThread InputThread;
 
+       bool m_bFoundDevice;
        bool m_bShutdown;
        uint32_t m_iLightData;
 
index b7ac0a9..2400520 100755 (executable)
@@ -8,8 +8,6 @@
 #include "RageUtil.h"
 #include "LightsDriver_External.h"
 
-extern LightsState g_LightsState;
-
 LightsDriver_External::LightsDriver_External()
 {
        ZERO( g_LightsState );
index 03609b7..33bbe84 100755 (executable)
@@ -13,9 +13,10 @@ public:
        
        void Set( const LightsState *ls );
 
-       LightsState g_LightsState;
 };
 
+extern LightsState g_LightsState;
+
 #define USE_LIGHTS_DRIVER_EXTERNAL
 
 #endif
index c393f69..c38335d 100755 (executable)
@@ -51,7 +51,7 @@ void MakeInputHandlers(CString drivers, vector<InputHandler *> &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
index 251e94a..c4b7319 100644 (file)
@@ -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