From 87779a5528db1a518ec59223a3978bc971df1534 Mon Sep 17 00:00:00 2001 From: Patrick McIlroy Date: Tue, 8 Apr 2008 03:19:46 +0000 Subject: [PATCH] git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@197 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- src/InputMapper.cpp | 1 + src/MiscITG.cpp | 4 ++ src/RageInputDevice.cpp | 2 +- src/RageInputDevice.h | 1 + src/arch/InputHandler/InputHandler_PIUIO.cpp | 80 ++++++++++++++++++---------- 5 files changed, 60 insertions(+), 28 deletions(-) diff --git a/src/InputMapper.cpp b/src/InputMapper.cpp index 8833dbb3..3e5da2a9 100755 --- a/src/InputMapper.cpp +++ b/src/InputMapper.cpp @@ -96,6 +96,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = /* Other controls */ { 0, IO_OPERATOR_MENU, DANCE_BUTTON_OPERATOR, false }, + { 0, IO_OPERATOR_MENU2, DANCE_BUTTON_OPERATOR, false }, { 0, IO_INSERT_COIN, DANCE_BUTTON_COIN, false }, END_MARKER } diff --git a/src/MiscITG.cpp b/src/MiscITG.cpp index b37d9bdf..70464a67 100644 --- a/src/MiscITG.cpp +++ b/src/MiscITG.cpp @@ -155,7 +155,11 @@ CString GetSerialNumber() CString sNewSerial; uchar spBuf[32]; +#ifdef WIN32 + if ( (copr.portnum = owAcquireEx("COM1")) == -1 ) +#else if ( (copr.portnum = owAcquireEx("/dev/ttyS0")) == -1 ) +#endif { LOG->Warn("Failed to get machine serial, unable to acquire port"); return "????????"; diff --git a/src/RageInputDevice.cpp b/src/RageInputDevice.cpp index 1da864c1..a44182e6 100755 --- a/src/RageInputDevice.cpp +++ b/src/RageInputDevice.cpp @@ -254,7 +254,7 @@ static const CString IOBoardButtonNames[] = { "P2-MenuLeft", "P2-MenuRight", - "Service", + "Service", "Service", "Coin", }; XToString( IOBoardButton, NUM_IO_BUTTONS ); diff --git a/src/RageInputDevice.h b/src/RageInputDevice.h index 762986a4..b542cea3 100755 --- a/src/RageInputDevice.h +++ b/src/RageInputDevice.h @@ -319,6 +319,7 @@ enum IOBoardButton { IO_P2_MENU_RIGHT, IO_OPERATOR_MENU, + IO_OPERATOR_MENU2, IO_INSERT_COIN, NUM_IO_BUTTONS, diff --git a/src/arch/InputHandler/InputHandler_PIUIO.cpp b/src/arch/InputHandler/InputHandler_PIUIO.cpp index bfb40bf9..48522d05 100644 --- a/src/arch/InputHandler/InputHandler_PIUIO.cpp +++ b/src/arch/InputHandler/InputHandler_PIUIO.cpp @@ -77,18 +77,19 @@ void InputHandler_PIUIO::InputThreadMain() // give up 0.01 sec per read for other events - // this may need adjusting for sync/lag fixing - usleep( 10000 ); + usleep( 0 ); } } static CString ShortArrayToBin( uint64_t arr[4] ) { CString result; + uint64_t one = 1; for (int i = 0; i < 4; i++) { for (int j = 63; j >= 0; j--) { - if (arr[i] & (1 << j)) + if (arr[i] & (one << j)) { result += "1"; } @@ -102,32 +103,67 @@ static CString ShortArrayToBin( uint64_t arr[4] ) return result; } +// P1: right left bottom top, P2: right left bottom top +int sensor_bits[19]; + + +/* not yet implemented */ +static CString SensorDescriptions[] = { "right", "left", "bottom", "top" }; + +/* not yet implemented */ +static CString GetSensorDescription( int iBits ) +{ + if ( iBits == 0 ) + return ""; + + CStringArray retSensors; + for( int i = 0; i < 4; i++ ) + if ( iBits & (1 << i) ) + retSensors.push_back(SensorDescriptions[i]); + + return join(", ", retSensors); +} + void InputHandler_PIUIO::HandleInput() { uint64_t i = 1; // convenience hack - bool bInputIsZero = false, bInputChanged = false; + bool bInputIsNonZero = false, bInputChanged = false; uint32_t iNewLightData = 0; + for (unsigned j = 0; j < 19; j++) sensor_bits[j] = 0; + for (uint64_t j = 0; j < 4; j++) { iNewLightData = m_iLightData & 0xfffcfffc; - iNewLightData |= (j | (j << 32)); + iNewLightData |= (j | (j << 16)); IOBoard.Write( iNewLightData ); /* Get the data and send it to RageInput */ IOBoard.Read( &(m_iInputData[j]) ); /* PIUIO opens high - for more logical processing, invert it */ m_iInputData[j] = ~m_iInputData[j]; + + // P1 left right up down + if (m_iInputData[j] & (i << 2)) sensor_bits[0] |= (i << j); + if (m_iInputData[j] & (i << 3)) sensor_bits[1] |= (i << j); + if (m_iInputData[j] & (i << 0)) sensor_bits[2] |= (i << j); + if (m_iInputData[j] & (i << 1)) sensor_bits[3] |= (i << j); + + // P2 left right up down + if (m_iInputData[j] & (i << 18)) sensor_bits[8] |= (i << j); + if (m_iInputData[j] & (i << 19)) sensor_bits[9] |= (i << j); + if (m_iInputData[j] & (i << 16)) sensor_bits[10] |= (i << j); + if (m_iInputData[j] & (i << 17)) sensor_bits[11] |= (i << j); } for (int j = 0; j < 4; j++) { - if (m_iInputData[j] != 0) bInputIsZero = true;; + if (m_iInputData[j] != 0) bInputIsNonZero = true; if (m_iInputData[j] != m_iLastInputData[j]) bInputChanged = true; } /* If they asked for it... */ - if( /*PREFSMAN->m_bDebugUSBInput &&*/ !bInputIsZero && bInputChanged) + if( PREFSMAN->m_bDebugUSBInput) { - LOG->Trace( "Input: %s", ShortArrayToBin(m_iInputData).c_str() ); + if (bInputIsNonZero && bInputChanged) LOG->Trace( "Input: %s", ShortArrayToBin(m_iInputData).c_str() ); if (SCREENMAN) SCREENMAN->SystemMessageNoAnimate(ShortArrayToBin(m_iInputData)); @@ -156,7 +192,10 @@ void InputHandler_PIUIO::HandleInput() iInputBitField |= m_iInputData[j]; } + InputDevice id = DEVICE_PIUIO; + // FIXME: these are for the right sensors only! + // XXX fixed 4/7/08. Game. Set. Match. --infamouspat static const uint64_t iInputBits[NUM_IO_BUTTONS] = { /* Player 1 */ //Left arrow @@ -184,11 +223,9 @@ void InputHandler_PIUIO::HandleInput() /* General input */ // Service button, Coin event - (i << 9), (i << 5) + (i << 9), (i << 14), (i << 10) }; - InputDevice id = DEVICE_PIUIO; - for( int iButton = 0; iButton < NUM_IO_BUTTONS; iButton++ ) { DeviceInput di(id, iButton); @@ -197,6 +234,11 @@ void InputHandler_PIUIO::HandleInput() if( InputThread.IsCreated() ) di.ts.Touch(); + if (iButton < 4 || (iButton > 7 && iButton < 12)) + { + INPUTFILTER->SetButtonComment(di, GetSensorDescription(sensor_bits[iButton])); + } + /* Is the button we're looking for flagged in the input data? */ ButtonPressed( di, iInputBitField & iInputBits[iButton] ); } @@ -206,22 +248,6 @@ void InputHandler_PIUIO::HandleInput() m_iLastInputData[j] = m_iInputData[j]; } -/* not yet implemented */ -CString SensorDescriptions[] = { "right", "left", "bottom", "top" }; - -/* not yet implemented */ -CString GetSensorDescription( int iBits ) -{ - if ( iBits == 0 ) - return ""; - - CStringArray retSensors; - for( int i = 0; i < 3; i++ ) - if ( iBits & (1 << i) ) - retSensors.push_back(SensorDescriptions[i]); - - return join(", ", retSensors); -} /* Requires "LightsDriver=ext" */ void InputHandler_PIUIO::UpdateLights() @@ -261,7 +287,7 @@ void InputHandler_PIUIO::UpdateLights() } /* - * (c) 2008 BoXoRRoXoRs + * (c) 2005 Chris Danford, Glenn Maynard. Re-implemented by vyhd, infamouspat * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a -- 2.11.0