Files
itgmania212121/stepmania/src/RageInput.h
T

117 lines
2.7 KiB
C++
Raw Normal View History

#ifndef RAGEINPUT_H
#define RAGEINPUT_H
/*
-----------------------------------------------------------------------------
File: RageInput.h
Desc: Wrapper for SDL's input routines. Generates InputEvents.
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
2001-11-03 10:52:42 +00:00
struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick;
2001-11-21 03:21:00 +00:00
#include "SDL_keysym.h"
2001-12-28 10:15:59 +00:00
const int NUM_KEYBOARD_BUTTONS = SDLK_LAST;
2001-11-25 04:31:44 +00:00
const int NUM_JOYSTICKS = 4;
const int NUM_JOYSTICK_AXES = 4; // X, Y, Z, rudder
const int NUM_JOYSTICK_HATS = 1;
const int NUM_PUMPS = 2;
const int NUM_PUMP_PAD_BUTTONS = 11;
2001-11-03 10:52:42 +00:00
const int NUM_DEVICE_BUTTONS = NUM_KEYBOARD_BUTTONS;
2001-11-25 10:49:31 +00:00
enum InputDevice {
DEVICE_KEYBOARD = 0,
2002-04-16 17:31:00 +00:00
DEVICE_JOY1,
DEVICE_JOY2,
DEVICE_JOY3,
DEVICE_JOY4,
DEVICE_PUMP1,
DEVICE_PUMP2,
2001-11-25 10:49:31 +00:00
NUM_INPUT_DEVICES, // leave this at the end
DEVICE_NONE // means this is NULL
};
2001-11-03 10:52:42 +00:00
// button byte codes for directional pad
2001-11-25 10:49:31 +00:00
enum JoystickButton {
2003-01-09 07:46:45 +00:00
JOY_LEFT = 0, JOY_RIGHT,
JOY_UP, JOY_DOWN,
JOY_Z_UP, JOY_Z_DOWN,
2002-09-08 06:13:47 +00:00
JOY_Z_ROT_UP, JOY_Z_ROT_DOWN,
JOY_HAT_LEFT, JOY_HAT_RIGHT, JOY_HAT_UP, JOY_HAT_DOWN,
JOY_1, JOY_2, JOY_3, JOY_4, JOY_5, JOY_6, JOY_7, JOY_8, JOY_9, JOY_10,
JOY_11, JOY_12, JOY_13, JOY_14, JOY_15, JOY_16, JOY_17, JOY_18, JOY_19, JOY_20,
JOY_21, JOY_22, JOY_23, JOY_24,
2001-11-25 10:49:31 +00:00
NUM_JOYSTICK_BUTTONS // leave this at the end
};
2001-11-03 10:52:42 +00:00
2001-11-25 10:49:31 +00:00
struct DeviceInput
2001-11-03 10:52:42 +00:00
{
public:
2001-11-25 10:49:31 +00:00
InputDevice device;
int button;
2001-11-25 04:31:44 +00:00
2001-11-25 10:49:31 +00:00
DeviceInput() { device=DEVICE_NONE; };
DeviceInput( InputDevice d, int b ) { device=d; button=b; };
2001-11-03 10:52:42 +00:00
2001-12-19 01:50:57 +00:00
bool operator==( const DeviceInput &other )
{
return device == other.device && button == other.button;
};
2001-11-25 10:49:31 +00:00
CString GetDescription();
CString toString();
bool fromString( const CString &s );
2001-11-03 10:52:42 +00:00
bool IsValid() const { return device != DEVICE_NONE; };
void MakeInvalid() { device = DEVICE_NONE; };
char ToChar() const;
static int NumButtons(InputDevice device);
2001-11-03 10:52:42 +00:00
};
class RageInput
{
SDL_Joystick* m_pJoystick[NUM_JOYSTICKS];
2001-11-03 10:52:42 +00:00
2003-02-15 06:44:53 +00:00
enum State { CURRENT = 0, LAST, NUM_STATES };
2001-11-03 10:52:42 +00:00
struct state_t {
struct device_t {
bool button[NUM_DEVICE_BUTTONS];
} m_Devices[NUM_INPUT_DEVICES];
2003-02-15 06:44:53 +00:00
} state[NUM_STATES];
/* Structure for reading Pump pads: */
2003-02-15 06:00:33 +00:00
struct pump_t;
pump_t *m_Pumps;
2001-11-03 10:52:42 +00:00
public:
RageInput();
2001-11-03 10:52:42 +00:00
~RageInput();
void Update( float fDeltaTime );
bool BeingPressed( DeviceInput di, bool bPrevState );
bool IsBeingPressed( DeviceInput di ) { return BeingPressed(di, false); }
bool WasBeingPressed( DeviceInput di ) { return BeingPressed(di, true); }
2001-11-03 10:52:42 +00:00
};
namespace USB {
char *GetUSBDevicePath (int num);
HANDLE OpenUSB (int VID, int PID, int num);
};
2001-11-03 10:52:42 +00:00
2002-05-19 01:59:48 +00:00
extern RageInput* INPUTMAN; // global and accessable from anywhere in our program
#endif