add monkey scripting input driver for longevity testing

This commit is contained in:
Chris Danford
2004-10-16 15:04:10 +00:00
parent b3f472ae8c
commit 722941a646
14 changed files with 216 additions and 27 deletions
+2 -1
View File
@@ -106,7 +106,8 @@ endif
ArchHooks = arch/ArchHooks/ArchHooks.cpp arch/ArchHooks/ArchHooks.h ArchHooks = arch/ArchHooks/ArchHooks.cpp arch/ArchHooks/ArchHooks.h
InputHandler = arch/InputHandler/InputHandler.cpp arch/InputHandler/InputHandler.h InputHandler = arch/InputHandler/InputHandler.cpp arch/InputHandler/InputHandler.h \
arch/InputHandler/InputHandler_MonkeyKeyboard.cpp arch/InputHandler/InputHandler_MonkeyKeyboard.h
MovieTexture = arch/MovieTexture/MovieTexture.cpp arch/MovieTexture/MovieTexture.h \ MovieTexture = arch/MovieTexture/MovieTexture.cpp arch/MovieTexture/MovieTexture.h \
arch/MovieTexture/MovieTexture_Null.cpp arch/MovieTexture/MovieTexture_Null.h arch/MovieTexture/MovieTexture_Null.cpp arch/MovieTexture/MovieTexture_Null.h
+7 -2
View File
@@ -271,6 +271,8 @@ void PrefsManager::Init()
m_fSoundVolume = DEFAULT_SOUND_VOLUME; m_fSoundVolume = DEFAULT_SOUND_VOLUME;
m_iSoundResampleQuality = RageSoundReader_Resample::RESAMP_NORMAL; m_iSoundResampleQuality = RageSoundReader_Resample::RESAMP_NORMAL;
m_sInputDrivers = DEFAULT_INPUT_DRIVER_LIST;
m_sMovieDrivers = DEFAULT_MOVIE_DRIVER_LIST; m_sMovieDrivers = DEFAULT_MOVIE_DRIVER_LIST;
// StepMania.cpp sets these on first run: // StepMania.cpp sets these on first run:
@@ -467,6 +469,7 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers ); ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers );
ini.GetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead ); ini.GetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead );
ini.GetValue( "Options", "SoundDevice", m_iSoundDevice ); ini.GetValue( "Options", "SoundDevice", m_iSoundDevice );
ini.GetValue( "Options", "InputDrivers", m_sInputDrivers );
ini.GetValue( "Options", "MovieDrivers", m_sMovieDrivers ); ini.GetValue( "Options", "MovieDrivers", m_sMovieDrivers );
ini.GetValue( "Options", "EasterEggs", m_bEasterEggs ); ini.GetValue( "Options", "EasterEggs", m_bEasterEggs );
ini.GetValue( "Options", "MarvelousTiming", (int&)m_iMarvelousTiming ); ini.GetValue( "Options", "MarvelousTiming", (int&)m_iMarvelousTiming );
@@ -809,10 +812,12 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue ( "Options", "SoundDrivers", m_sSoundDrivers ); ini.SetValue ( "Options", "SoundDrivers", m_sSoundDrivers );
if(m_fSoundVolume != DEFAULT_SOUND_VOLUME) if(m_fSoundVolume != DEFAULT_SOUND_VOLUME)
ini.SetValue( "Options", "SoundVolume", m_fSoundVolume ); ini.SetValue( "Options", "SoundVolume", m_fSoundVolume );
if(m_sLightsDriver != DEFAULT_LIGHTS_DRIVER) if(m_sInputDrivers != DEFAULT_INPUT_DRIVER_LIST)
ini.SetValue( "Options", "LightsDriver", m_sLightsDriver ); ini.SetValue ( "Options", "InputDrivers", m_sInputDrivers );
if(m_sMovieDrivers != DEFAULT_MOVIE_DRIVER_LIST) if(m_sMovieDrivers != DEFAULT_MOVIE_DRIVER_LIST)
ini.SetValue ( "Options", "MovieDrivers", m_sMovieDrivers ); ini.SetValue ( "Options", "MovieDrivers", m_sMovieDrivers );
if(m_sLightsDriver != DEFAULT_LIGHTS_DRIVER)
ini.SetValue( "Options", "LightsDriver", m_sLightsDriver );
ini.SetValue( "Options", "AdditionalSongFolders", m_sAdditionalSongFolders); ini.SetValue( "Options", "AdditionalSongFolders", m_sAdditionalSongFolders);
ini.SetValue( "Options", "AdditionalFolders", m_sAdditionalFolders); ini.SetValue( "Options", "AdditionalFolders", m_sAdditionalFolders);
+1
View File
@@ -251,6 +251,7 @@ public:
CString m_iSoundDevice; CString m_iSoundDevice;
float m_fSoundVolume; float m_fSoundVolume;
int m_iSoundResampleQuality; int m_iSoundResampleQuality;
CString m_sInputDrivers;
CString m_sMovieDrivers; CString m_sMovieDrivers;
CString m_sLightsDriver; CString m_sLightsDriver;
CString m_sLightsStepsDifficulty; CString m_sLightsStepsDifficulty;
+2 -2
View File
@@ -7,12 +7,12 @@
RageInput* INPUTMAN = NULL; // globally accessable input device RageInput* INPUTMAN = NULL; // globally accessable input device
RageInput::RageInput() RageInput::RageInput( CString drivers )
{ {
LOG->Trace( "RageInput::RageInput()" ); LOG->Trace( "RageInput::RageInput()" );
/* Init optional devices. */ /* Init optional devices. */
MakeInputHandlers(Devices); MakeInputHandlers(drivers,Devices);
/* If no input devices are loaded, the user won't be able to input anything. /* If no input devices are loaded, the user won't be able to input anything.
* That should never happen. */ * That should never happen. */
+1 -1
View File
@@ -11,7 +11,7 @@ class RageInput
vector<InputHandler *> Devices; vector<InputHandler *> Devices;
public: public:
RageInput(); RageInput( CString drivers );
~RageInput(); ~RageInput();
void Update( float fDeltaTime ); void Update( float fDeltaTime );
+1 -1
View File
@@ -99,7 +99,7 @@ void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventTy
if( MenuI.button != MENU_BUTTON_COIN ) if( MenuI.button != MENU_BUTTON_COIN )
SCREENMAN->PlayCoinSound(); SCREENMAN->PlayCoinSound();
SCREENMAN->SendMessageToTopScreen( SM_StopMusic ); SCREENMAN->SendMessageToTopScreen( SM_StopMusic );
usleep( (int)(JOIN_PAUSE_SECONDS*1000000) ); // do a little pause, like the arcade does usleep( (int)(JOIN_PAUSE_SECONDS*1000*1000) ); // do a little pause, like the arcade does
LOG->Trace("ScreenAttract::AttractInput: go to ScreenTitleMenu" ); LOG->Trace("ScreenAttract::AttractInput: go to ScreenTitleMenu" );
SCREENMAN->SetNewScreen( "ScreenTitleMenu" ); SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
break; break;
+1 -1
View File
@@ -1093,7 +1093,7 @@ int main(int argc, char* argv[])
/* This initializes objects that change the SDL event mask, and has other /* This initializes objects that change the SDL event mask, and has other
* dependencies on the SDL video subsystem, so it must be initialized after DISPLAY. */ * dependencies on the SDL video subsystem, so it must be initialized after DISPLAY. */
INPUTMAN = new RageInput; INPUTMAN = new RageInput( PREFSMAN->m_sInputDrivers );
// These things depend on the TextureManager, so do them after! // These things depend on the TextureManager, so do them after!
FONT = new FontManager; FONT = new FontManager;
+8
View File
@@ -1218,6 +1218,14 @@ SOURCE=.\arch\InputHandler\InputHandler_DirectInputHelper.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\arch\InputHandler\InputHandler_MonkeyKeyboard.cpp
# End Source File
# Begin Source File
SOURCE=.\arch\InputHandler\InputHandler_MonkeyKeyboard.h
# End Source File
# Begin Source File
SOURCE=.\arch\InputHandler\InputHandler_Win32_Para.cpp SOURCE=.\arch\InputHandler\InputHandler_Win32_Para.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
+6
View File
@@ -1069,6 +1069,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File <File
RelativePath="arch\InputHandler\InputHandler_DirectInputHelper.h"> RelativePath="arch\InputHandler\InputHandler_DirectInputHelper.h">
</File> </File>
<File
RelativePath="arch\InputHandler\InputHandler_MonkeyKeyboard.cpp">
</File>
<File
RelativePath="arch\InputHandler\InputHandler_MonkeyKeyboard.h">
</File>
<File <File
RelativePath="arch\InputHandler\InputHandler_Win32_Para.cpp"> RelativePath="arch\InputHandler\InputHandler_Win32_Para.cpp">
</File> </File>
@@ -0,0 +1,100 @@
#include "global.h"
#include "InputHandler_MonkeyKeyboard.h"
#include "RageUtil.h"
InputHandler_MonkeyKeyboard::InputHandler_MonkeyKeyboard() :
m_diLast(DEVICE_KEYBOARD,KEY_SPACE)
{
}
InputHandler_MonkeyKeyboard::~InputHandler_MonkeyKeyboard()
{
}
void InputHandler_MonkeyKeyboard::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut)
{
vDevicesOut.push_back( InputDevice(DEVICE_KEYBOARD) );
vDescriptionsOut.push_back( "MonkeyKeyboard" );
}
static const int g_keys[] =
{
// Some of the default keys for the dance game type
KEY_LEFT, // DANCE_BUTTON_LEFT,
KEY_RIGHT, // DANCE_BUTTON_RIGHT,
KEY_UP, // DANCE_BUTTON_UP,
KEY_DOWN, // DANCE_BUTTON_DOWN,
KEY_ENTER, // DANCE_BUTTON_START,
KEY_ENTER, // DANCE_BUTTON_START,
KEY_ENTER, // DANCE_BUTTON_START,
KEY_DEL, // DANCE_BUTTON_MENULEFT
KEY_PGDN, // DANCE_BUTTON_MENURIGHT
KEY_HOME, // DANCE_BUTTON_MENUUP
KEY_END, // DANCE_BUTTON_MENUDOWN
KEY_F1, // DANCE_BUTTON_COIN
KEY_F1, // DANCE_BUTTON_COIN
KEY_KP_C4, // DANCE_BUTTON_LEFT,
KEY_KP_C6, // DANCE_BUTTON_RIGHT,
KEY_KP_C8, // DANCE_BUTTON_UP,
KEY_KP_C2, // DANCE_BUTTON_DOWN,
KEY_KP_C7, // DANCE_BUTTON_UPLEFT,
KEY_KP_C9, // DANCE_BUTTON_UPRIGHT,
KEY_KP_ENTER, // DANCE_BUTTON_START,
KEY_KP_ENTER, // DANCE_BUTTON_START,
KEY_KP_ENTER, // DANCE_BUTTON_START,
KEY_KP_SLASH, // DANCE_BUTTON_MENULEFT
KEY_KP_ASTERISK, // DANCE_BUTTON_MENURIGHT
KEY_KP_HYPHEN, // DANCE_BUTTON_MENUUP
KEY_KP_PLUS, // DANCE_BUTTON_MENUDOWN
};
int GetRandomKeyboadKey()
{
int index = rand()%ARRAYSIZE(g_keys);
return g_keys[index];
}
void InputHandler_MonkeyKeyboard::Update(float fDeltaTime)
{
float fSecsAgo = m_timerPressButton.Ago();
if( fSecsAgo > 0.5 )
{
// End the previous key
ButtonPressed(m_diLast, false);
// Choose a new key and send it.
m_diLast = DeviceInput(DEVICE_KEYBOARD,GetRandomKeyboadKey());
ButtonPressed(m_diLast, true);
m_timerPressButton.Touch();
}
}
/*
* (c) 2002-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
@@ -0,0 +1,46 @@
#ifndef INPUT_HANDLER_MONKEY_SCRIPT
#define INPUT_HANDLER_MONKEY_SCRIPT 1
#include "InputHandler.h"
#include "RageTimer.h"
#include "RageInputDevice.h"
class InputHandler_MonkeyKeyboard: public InputHandler
{
RageTimer m_timerPressButton;
DeviceInput m_diLast; // Last input that we sent
public:
void Update(float fDeltaTime);
InputHandler_MonkeyKeyboard();
~InputHandler_MonkeyKeyboard();
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut);
};
#endif
/*
* (c) 2002-2004 Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+19 -6
View File
@@ -65,19 +65,32 @@ LoadingWindow *MakeLoadingWindow()
LowLevelWindow *MakeLowLevelWindow() { return new ARCH_LOW_LEVEL_WINDOW; } LowLevelWindow *MakeLowLevelWindow() { return new ARCH_LOW_LEVEL_WINDOW; }
#endif #endif
void MakeInputHandlers(vector<InputHandler *> &Add) void MakeInputHandlers(CString drivers, vector<InputHandler *> &Add)
{
CStringArray DriversToTry;
split(drivers, ",", DriversToTry, true);
ASSERT( DriversToTry.size() != 0 );
CString Driver;
RageSoundDriver *ret = NULL;
for(unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i)
{ {
#if defined(_WINDOWS) #if defined(_WINDOWS)
Add.push_back(new InputHandler_DInput); if(!DriversToTry[i].CompareNoCase("DirectInput")) Add.push_back(new InputHandler_DInput);
Add.push_back(new InputHandler_Win32_Pump); if(!DriversToTry[i].CompareNoCase("Pump")) Add.push_back(new InputHandler_Win32_Pump);
// Add.push_back(new InputHandler_Win32_Para); // if(!DriversToTry[i].CompareNoCase("Para")) Add.push_back(new InputHandler_Win32_Para);
#elif defined(_XBOX) #elif defined(_XBOX)
Add.push_back(new InputHandler_Xbox); if(!DriversToTry[i].CompareNoCase("Xbox")) Add.push_back(new InputHandler_Xbox);
#endif #endif
#if defined(SUPPORT_SDL_INPUT) #if defined(SUPPORT_SDL_INPUT)
Add.push_back(new InputHandler_SDL); if(!DriversToTry[i].CompareNoCase("SDL")) Add.push_back(new InputHandler_SDL);
#endif #endif
if(!DriversToTry[i].CompareNoCase("MonkeyKeyboard"))Add.push_back(new InputHandler_MonkeyKeyboard);
}
} }
RageSoundDriver *MakeRageSoundDriver(CString drivers) RageSoundDriver *MakeRageSoundDriver(CString drivers)
+9 -1
View File
@@ -13,7 +13,7 @@ class MemoryCardDriver;
LoadingWindow *MakeLoadingWindow(); LoadingWindow *MakeLoadingWindow();
LowLevelWindow *MakeLowLevelWindow(); LowLevelWindow *MakeLowLevelWindow();
void MakeInputHandlers(vector<InputHandler *> &Add); void MakeInputHandlers(CString drivers,vector<InputHandler *> &Add);
RageSoundDriver *MakeRageSoundDriver(CString drivers); RageSoundDriver *MakeRageSoundDriver(CString drivers);
/* These definitions are in here, instead of in arch_*.h, because they /* These definitions are in here, instead of in arch_*.h, because they
@@ -34,6 +34,14 @@ RageSoundDriver *MakeRageSoundDriver(CString drivers);
#define DEFAULT_SOUND_DRIVER_LIST "Null" #define DEFAULT_SOUND_DRIVER_LIST "Null"
#endif #endif
#if defined(_WINDOWS)
#define DEFAULT_INPUT_DRIVER_LIST "DirectInput,Pump"
#elif defined(_XBOX)
#define DEFAULT_INPUT_DRIVER_LIST "Xbox"
#else
#define DEFAULT_INPUT_DRIVER_LIST "SDL"
#endif
#define DEFAULT_MOVIE_DRIVER_LIST "FFMpeg,Null" #define DEFAULT_MOVIE_DRIVER_LIST "FFMpeg,Null"
/* Choose your renderers. */ /* Choose your renderers. */
+1
View File
@@ -26,6 +26,7 @@
* header. */ * header. */
#define SUPPORT_SDL_INPUT #define SUPPORT_SDL_INPUT
#include "InputHandler/InputHandler_SDL.h" #include "InputHandler/InputHandler_SDL.h"
#include "InputHandler/InputHandler_MonkeyKeyboard.h"
/* Load default fallback drivers; some of these may be overridden by arch-specific /* Load default fallback drivers; some of these may be overridden by arch-specific
* drivers. These are all singleton drivers--we never use more than one. */ * drivers. These are all singleton drivers--we never use more than one. */