Okay, the SDL input driver changing display preferences finally got to
me, so I'm cleaning it up. Add "level" parameter to DeviceInput, indicating the degree the axis or button is depressed. If it's < 0, it's not an analog input; otherwise, IET_LEVEL_CHANGED events will come in when the level changes. Add secondary stick axis inputs, so there's a correct place to put them. Handle these inputs in ScreenCenterImage. Inputs mapped to gameplay inputs are always a primary input; otherwise, the first stick is translate and the secondary is scale. Input is analog when possible; holding shift reverses the map, so keyboard input works roughly the same as before. Do away with the special Xbox-specific centering code; use the standard centering matrix. If this doesn't work, any special cases to fix it should be hidden away in RageDisplay_D3D. The input maps are likely to work on the Xbox as is, since the SDL driver maps axes in order, but I can't test it. This won't work with PS2 converters, since #1: those things map the secondary axis to seemingly random places (on mine, JOY_Z_UP, JOY_Z_DOWN, JOY_ROT_Z_UP, JOY_ROT_Z_DOWN), and #2: they don't identify themselves uniquely. Unless there's a pattern in how they're mapping that I can't see (since I don't have many converters), this just can't be done reliably. (No big deal; PCs have keyboards.)
This commit is contained in:
@@ -58,6 +58,10 @@ CString DeviceInput::GetDescription()
|
||||
case JOY_RIGHT: sReturn += "Right"; break;
|
||||
case JOY_UP: sReturn += "Up"; break;
|
||||
case JOY_DOWN: sReturn += "Down"; break;
|
||||
case JOY_LEFT_2: sReturn += "Left2"; break;
|
||||
case JOY_RIGHT_2: sReturn += "Right2"; break;
|
||||
case JOY_UP_2: sReturn += "Up2"; break;
|
||||
case JOY_DOWN_2: sReturn += "Down2"; break;
|
||||
case JOY_Z_UP: sReturn += "Z-Up"; break;
|
||||
case JOY_Z_DOWN: sReturn += "Z-Down"; break;
|
||||
case JOY_ROT_UP: sReturn += "R-Up"; break;
|
||||
@@ -260,9 +264,6 @@ char DeviceInput::ToChar() const
|
||||
case DEVICE_KEYBOARD:
|
||||
if( button < 128 )
|
||||
return (char) button;
|
||||
/* XXX: SDLK_WORLD_* are for international keyboards; we can handle those,
|
||||
* now, by mapping it to Unicode. However, I can't find any documentation
|
||||
* on those keysyms. */
|
||||
return '\0';
|
||||
default:
|
||||
return '\0';
|
||||
|
||||
@@ -205,14 +205,26 @@ enum InputDevice {
|
||||
DEVICE_NONE // means this is NULL
|
||||
};
|
||||
|
||||
// button byte codes for directional pad
|
||||
enum JoystickButton {
|
||||
/* Joystick inputs. We try to have enough input names so any input on a reasonable
|
||||
* joystick has an obvious mapping, but keep it generic and don't try to handle odd
|
||||
* special cases. For example, many controllers have two sticks, so the JOY_LEFT_2, etc.
|
||||
* pairs are useful for many types of sticks. */
|
||||
enum JoystickButton
|
||||
{
|
||||
/* Standard axis: */
|
||||
JOY_LEFT = 0, JOY_RIGHT,
|
||||
JOY_UP, JOY_DOWN,
|
||||
|
||||
/* Secondary sticks: */
|
||||
JOY_LEFT_2, JOY_RIGHT_2,
|
||||
JOY_UP_2, JOY_DOWN_2,
|
||||
|
||||
JOY_Z_UP, JOY_Z_DOWN,
|
||||
JOY_ROT_UP, JOY_ROT_DOWN, JOY_ROT_LEFT, JOY_ROT_RIGHT, JOY_ROT_Z_UP, JOY_ROT_Z_DOWN,
|
||||
JOY_HAT_LEFT, JOY_HAT_RIGHT, JOY_HAT_UP, JOY_HAT_DOWN,
|
||||
JOY_AUX_1, JOY_AUX_2, JOY_AUX_3, JOY_AUX_4,
|
||||
|
||||
/* Buttons: */
|
||||
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, JOY_25, JOY_26, JOY_27, JOY_28, JOY_29, JOY_30,
|
||||
@@ -273,17 +285,22 @@ struct DeviceInput
|
||||
public:
|
||||
InputDevice device;
|
||||
int button;
|
||||
|
||||
/* This is usually 0 or 1. Analog joystick inputs can set this to a percentage (0..1).
|
||||
* This should be 0 for analog axes within the dead zone. */
|
||||
float level;
|
||||
|
||||
RageTimer ts;
|
||||
|
||||
DeviceInput(): device(DEVICE_NONE), button(-1), ts(RageZeroTimer) { }
|
||||
DeviceInput( InputDevice d, int b ): device(d), button(b), ts(RageZeroTimer) { }
|
||||
DeviceInput( InputDevice d, int b, const RageTimer &t ):
|
||||
device(d), button(b), ts(t) { }
|
||||
DeviceInput(): device(DEVICE_NONE), button(-1), ts(RageZeroTimer), level(0) { }
|
||||
DeviceInput( InputDevice d, int b, float l=0 ): device(d), button(b), level(l), ts(RageZeroTimer) { }
|
||||
DeviceInput( InputDevice d, int b, float l, const RageTimer &t ):
|
||||
device(d), button(b), level(l), ts(t) { }
|
||||
|
||||
bool operator==( const DeviceInput &other )
|
||||
bool operator==( const DeviceInput &other ) const
|
||||
{
|
||||
/* Return true if we represent the same button on the same device. Don't
|
||||
* compare ts. */
|
||||
* compare level or ts. */
|
||||
return device == other.device && button == other.button;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user