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