From a894ac3c2ff1e3a25a1fe8b2d308cf176f1ad5e8 Mon Sep 17 00:00:00 2001 From: Mark Cannon Date: Fri, 7 Mar 2008 20:13:58 +0000 Subject: [PATCH] Preliminary ScreenArcadeStart, reinstated HOOKS->SystemReboot on Linux git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@111 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- src/ScreenArcadeStart.cpp | 162 +++++++++++++++++++++++ src/ScreenArcadeStart.h | 34 +++++ src/arch/ArchHooks/ArchHooks_Unix.cpp | 11 +- src/arch/InputHandler/InputHandler_Linux_PIUIO.h | 1 + 4 files changed, 198 insertions(+), 10 deletions(-) create mode 100644 src/ScreenArcadeStart.cpp create mode 100644 src/ScreenArcadeStart.h diff --git a/src/ScreenArcadeStart.cpp b/src/ScreenArcadeStart.cpp new file mode 100644 index 00000000..60923961 --- /dev/null +++ b/src/ScreenArcadeStart.cpp @@ -0,0 +1,162 @@ +/* Basic screen functions */ +#include "global.h" +#include "RageLog.h" +#include "RageUtil.h" +#include "ScreenArcadeStart.h" +#include "ScreenManager.h" +#include "ActorFrame.h" + +/* I'd like to include these as needed only */ +//#include "GameState.h" +//#include "GameSoundManager.h" +//#include "ThemeManager.h" +//#include "Game.h" +//#include "ScreenDimensions.h" +//#include "GameManager.h" +//#include "PrefsManager.h" +//#include "ActorUtil.h" + +/* Serial number functions */ +#include "MiscITG.h" + +/* USBDevice tests */ +#include "io/USBDevice.h" + +/* Input board loading/testing */ +#include "io/USBDriver.h" +#include "io/PIUIO.h" +#include "io/ITGIO.h" + +/* InputHandler loading */ +#include "RageInput.h" +#include "InputMapper.h" +#include "arch/InputHandler/InputHandler_Linux_ITGIO.h" +#include "arch/InputHandler/InputHandler_Linux_PIUIO.h" + +#define NEXT_SCREEN THEME->GetMetric( m_sName, "NextScreen" ); + +REGISTER_SCREEN_CLASS( ScreenArcadeStart ); + +ScreenArcadeStart::ScreenArcadeStart( CString sClassName ) : ScreenWithMenuElements( sClassName ) +{ + LOG->Trace( "ScreenArcadeStart::ScreenArcadeStart()" ); +} + +void ScreenArcadeStart::Init() +{ + CString sGameSerial = GetSerialNumber(); + + ScreenWithMenuElements::Init(); + + m_Error.LoadFromFont( THEME->GetPathF( "ScreenArcadeStart", "error" ) ); + m_Error.SetName( "Error" ); + SET_XY_AND_ON_COMMAND( m_Error ); + this->AddChild( &m_Error ); + + this->SortByDrawOrder(); + + CString sError = ""; + + if( !LoadHandler(sError) ) + { + m_Error.SetText( sError ); + return; + } + + if( !Refresh(sError) ) + { + m_Error.SetText( sError ); + return; + } + + if( sError.empty() ) + LOG->Trace( "All OK" ); +} + +ScreenArcadeStart::~ScreenArcadeStart() +{ + LOG->Trace( "ScreenArcadeStart::~ScreenArcadeStart()" ); + + if( m_bFatalError ) + HOOKS->SystemReboot(); +} + +void ScreenArcadeStart::Update( float fDeltaTime ) +{ + Screen::Update( fDeltaTime ); +} + +void ScreenArcadeStart::DrawPrimitives() +{ + Screen::DrawPrimitives(); +} + +void ScreenArcadeStart::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) +{ + if( type != IET_FIRST_PRESS && type != IET_SLOW_REPEAT ) + return; // ignore + + Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default handler +} + +void ScreenArcadeStart::HandleScreenMessage( const ScreenMessage SM ) +{ + switch( SM ) + { + case SM_GoToNextScreen: + case SM_GoToPrevScreen: + SCREENMAN->SetNewScreen( "ScreenOptionsMenu" ); + break; + } +} + +void ScreenArcadeStart::MenuStart( PlayerNumber pn ) +{ + MenuBack(pn); +} + +bool ScreenArcadeStart::Refresh( CString &sMessage ) +{ + vector vDevices; + GetUSBDeviceList( vDevices ); + + +} + +bool ScreenArcadeStart::LoadHandler( CString &sMessage ) +{ + USBDriver *pDriver; + + bIsKit = false; + /* Default to PIUIO if this isn't a kit, at least for now */ + if( IsAFile( "/rootfs/itgdata/K" ) + bIsKit = true; + + if( bIsKit ) + pDriver = new ITGIO; + else + pDriver = new PIUIO; + + /* Attempt a connection */ + if( !pDriver->Open() ) + { + sMessage = "The input/lights controller could not be initialized.\n\nPlease consult the service manual."; + delete pDriver; + return false; + } + + pDriver->Close(); + delete pDriver; + + if( bIsKit ) + INPUTMAN->AddHandler( new InputHandler_Linux_Iow ); + else + INPUTMAN->AddHandler( new InputHandler_Linux_PIUIO ); + + LOG->Trace( "Remapping joysticks after loading driver." ); + + INPUTMAPPER->AutoMapJoysticksForCurrentGame(); + INPUTMAPPER->SaveMappingsToDisk(); + + return true; +} diff --git a/src/ScreenArcadeStart.h b/src/ScreenArcadeStart.h new file mode 100644 index 00000000..2fa1bce2 --- /dev/null +++ b/src/ScreenArcadeStart.h @@ -0,0 +1,34 @@ +/* ScreenArcadeStart - performs several start-up checks before loading + * on an arcade platform. */ + +#ifndef SCREEN_ARCADE_START_H +#define SCREEN_ARCADE_START_H + +#include "ScreenWithMenuElements.h" +#include "BitmapText.h" + +class ScreenArcadeStart : public ScreenWithMenuElements +{ +public: + ScreenArcadeStart( CString sName ); + virtual void Init(); + virtual ~ScreenArcadeStart(); + + virtual void DrawPrimitives(); + virtual void Update( float fDelta ); + virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); + virtual void HandleScreenMessage( const ScreenMessage SM ); + + virtual void MenuStart( PlayerNumber pn ); + virtual void MenuBack( PlayerNumber pn ); +private: + void Refresh(); + void LoadHandler(); + + BitmapText m_Error; + + bool m_bFatalError; +}; + +#endif + diff --git a/src/arch/ArchHooks/ArchHooks_Unix.cpp b/src/arch/ArchHooks/ArchHooks_Unix.cpp index 11ff49ed..050fc9aa 100755 --- a/src/arch/ArchHooks/ArchHooks_Unix.cpp +++ b/src/arch/ArchHooks/ArchHooks_Unix.cpp @@ -36,17 +36,9 @@ static bool IsFatalSignal( int signal ) } } -/* The fuck...? This gets called at runtime. I've - * got no clue what's going on here... -- Vyhd */ void ArchHooks_Unix::SystemReboot() { - LOG->Warn( "SystemReboot() called." ); -} - -/* -void ArchHooks_Unix::SystemReboot() -{ - if( !(IsAFile("/rootfs/tmp/no-crash-reboot") || IsAFile( "Data/no-reboot")) ) + if( !(IsAFile("/rootfs/tmp/no-reboot") || IsAFile( "Data/no-reboot")) ) { LOG->Warn( "no-reboot not found. Rebooting." ); @@ -58,7 +50,6 @@ void ArchHooks_Unix::SystemReboot() ExitGame(); } -*/ static void DoCleanShutdown( int signal, siginfo_t *si, const ucontext_t *uc ) { diff --git a/src/arch/InputHandler/InputHandler_Linux_PIUIO.h b/src/arch/InputHandler/InputHandler_Linux_PIUIO.h index 20fef0cf..0ba7e4eb 100644 --- a/src/arch/InputHandler/InputHandler_Linux_PIUIO.h +++ b/src/arch/InputHandler/InputHandler_Linux_PIUIO.h @@ -13,6 +13,7 @@ class InputHandler_Linux_PIUIO: public InputHandler { public: InputHandler_Linux_PIUIO(); +// InputHandler_Linux_PIUIO( USBDriver *pDriver ); ~InputHandler_Linux_PIUIO(); // for non-threaded input...should we even bother? -- 2.11.0