add InputHandler abstraction
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "SDL_utils.h"
|
||||
#include "RageLog.h"
|
||||
#include "InputFilter.h"
|
||||
#include "arch/InputHandler/InputHandler.h"
|
||||
|
||||
RageInput* INPUTMAN = NULL; // globally accessable input device
|
||||
|
||||
@@ -54,28 +55,24 @@ RageInput::RageInput()
|
||||
}
|
||||
SDL_JoystickEventState( SDL_ENABLE );
|
||||
|
||||
//
|
||||
// Init pump
|
||||
//
|
||||
m_Pump = new PumpPadDevice;
|
||||
/* Init optional devices. */
|
||||
MakeInputHandlers(Devices);
|
||||
}
|
||||
|
||||
RageInput::~RageInput()
|
||||
{
|
||||
//
|
||||
// De-init pump
|
||||
//
|
||||
delete m_Pump;
|
||||
/* Delete optional devices. */
|
||||
for(unsigned i = 0; i < Devices.size(); ++i)
|
||||
delete Devices[i];
|
||||
|
||||
SDL_QuitSubSystem( SDL_INIT_JOYSTICK );
|
||||
}
|
||||
|
||||
void RageInput::Update( float fDeltaTime )
|
||||
{
|
||||
//
|
||||
// Update Pump
|
||||
//
|
||||
m_Pump->Update();
|
||||
/* Update optional devices. */
|
||||
for(unsigned i = 0; i < Devices.size(); ++i)
|
||||
Devices[i]->Update(fDeltaTime);
|
||||
}
|
||||
|
||||
bool RageInput::FeedSDLEvent(const SDL_Event &event)
|
||||
|
||||
@@ -10,13 +10,11 @@
|
||||
|
||||
#include "RageInputDevice.h"
|
||||
#include "SDL_utils.h"
|
||||
|
||||
#include "arch/InputHandler/InputHandler_Win32_Pump.h"
|
||||
#include "arch/arch.h"
|
||||
|
||||
class RageInput
|
||||
{
|
||||
/* Structure for reading Pump pads: */
|
||||
PumpPadDevice *m_Pump;
|
||||
vector<InputHandler *> Devices;
|
||||
|
||||
public:
|
||||
RageInput();
|
||||
@@ -28,7 +26,6 @@ public:
|
||||
|
||||
extern RageInput* INPUTMAN; // global and accessable from anywhere in our program
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
* be used by RageInputFeeders.
|
||||
*/
|
||||
|
||||
class RageInputFeeder
|
||||
class InputHandler
|
||||
{
|
||||
public:
|
||||
virtual void Update(float fDeltaTime) { }
|
||||
virtual ~RageInputFeeder() { }
|
||||
virtual ~InputHandler() { }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#pragma comment(lib, "ddk/setupapi.lib")
|
||||
#pragma comment(lib, "ddk/hid.lib")
|
||||
|
||||
struct PumpPadDevice::dev_t {
|
||||
struct InputHandler_Win32_Pump::dev_t {
|
||||
dev_t();
|
||||
~dev_t();
|
||||
HANDLE h;
|
||||
@@ -112,20 +112,20 @@ HANDLE USB::OpenUSB (int VID, int PID, int num)
|
||||
}
|
||||
|
||||
|
||||
PumpPadDevice::dev_t::dev_t()
|
||||
InputHandler_Win32_Pump::dev_t::dev_t()
|
||||
{
|
||||
ZeroMemory( &ov, sizeof(ov) );
|
||||
pending=false;
|
||||
h = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
PumpPadDevice::dev_t::~dev_t()
|
||||
InputHandler_Win32_Pump::dev_t::~dev_t()
|
||||
{
|
||||
if(h != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(h);
|
||||
}
|
||||
|
||||
PumpPadDevice::PumpPadDevice()
|
||||
InputHandler_Win32_Pump::InputHandler_Win32_Pump()
|
||||
{
|
||||
const int pump_usb_vid = 0x0d2f, pump_usb_pid = 0x0001;
|
||||
|
||||
@@ -139,12 +139,12 @@ PumpPadDevice::PumpPadDevice()
|
||||
}
|
||||
}
|
||||
|
||||
PumpPadDevice::~PumpPadDevice()
|
||||
InputHandler_Win32_Pump::~InputHandler_Win32_Pump()
|
||||
{
|
||||
delete[] dev;
|
||||
}
|
||||
|
||||
int PumpPadDevice::dev_t::GetPadEvent()
|
||||
int InputHandler_Win32_Pump::dev_t::GetPadEvent()
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -179,7 +179,7 @@ int PumpPadDevice::dev_t::GetPadEvent()
|
||||
return buf;
|
||||
}
|
||||
|
||||
void PumpPadDevice::Update()
|
||||
void InputHandler_Win32_Pump::Update(float fDeltaTime)
|
||||
{
|
||||
static const int bits[] = {
|
||||
/* P1 */ (1<<9), (1<<12), (1<<13), (1<<11), (1<<10),
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
#include "InputHandler.h"
|
||||
|
||||
class PumpPadDevice: RageInputFeeder
|
||||
class InputHandler_Win32_Pump: public InputHandler
|
||||
{
|
||||
struct dev_t; /* MYOB */
|
||||
|
||||
dev_t *dev;
|
||||
|
||||
public:
|
||||
void Update();
|
||||
PumpPadDevice();
|
||||
~PumpPadDevice();
|
||||
void Update(float fDeltaTime);
|
||||
InputHandler_Win32_Pump();
|
||||
~InputHandler_Win32_Pump();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,13 @@ LoadingWindow *MakeLoadingWindow() { return new ARCH_LOADING_WINDOW; }
|
||||
ErrorDialog *MakeErrorDialog() { return new ARCH_ERROR_DIALOG; }
|
||||
ArchHooks *MakeArchHooks() { return new ARCH_HOOKS; }
|
||||
|
||||
void MakeInputHandlers(vector<InputHandler *> &Add)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
Add.push_back(new InputHandler_Win32_Pump);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Err, this is ugly--breaks arch encapsulation. Hmm. */
|
||||
RageSoundDriver *MakeRageSoundDriver(CString drivers)
|
||||
{
|
||||
|
||||
@@ -6,12 +6,15 @@ class ErrorDialog;
|
||||
class LoadingWindow;
|
||||
class RageSoundDriver;
|
||||
class ArchHooks;
|
||||
class InputHandler;
|
||||
|
||||
ErrorDialog *MakeErrorDialog();
|
||||
LoadingWindow *MakeLoadingWindow();
|
||||
RageSoundDriver *MakeRageSoundDriver(CString drivers);
|
||||
ArchHooks *MakeArchHooks();
|
||||
|
||||
void MakeInputHandlers(vector<InputHandler *> &Add);
|
||||
RageSoundDriver *MakeRageSoundDriver(CString drivers);
|
||||
|
||||
/* Define the default list of sound drivers for each arch. */
|
||||
#if defined(WIN32)
|
||||
#define DEFAULT_SOUND_DRIVER_LIST "DirectSound,DirectSound-sw,WaveOut"
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "ErrorDialog/ErrorDialog_Win32.h"
|
||||
#include "ArchHooks/ArchHooks_Win32.h"
|
||||
|
||||
#include "InputHandler/InputHandler_Win32_Pump.h"
|
||||
|
||||
#include "Sound/RageSoundDriver_DSound.h"
|
||||
#include "Sound/RageSoundDriver_DSound_Software.h"
|
||||
#include "Sound/RageSoundDriver_WaveOut.h"
|
||||
|
||||
Reference in New Issue
Block a user