Input: Refactor JOY_* constants.

**Breaking change**

Removed the `JOY_SNES_*` and `JOY_SEGA_*` constants. Imho there's no reason for a modern game engine to provide button aliases for decades-old hardware.
Also renamed `JOY_ANALOG_{0,1}_{X,Y}` to `JOY_ANALOG_{L,R}{X,Y}` and removed `JOY_ANALOG_2_*`.
This commit is contained in:
Andreas Haas 2017-03-24 17:33:52 +01:00
parent efaeebab4d
commit 0d8f5660f6
No known key found for this signature in database
GPG Key ID: B5FFAE1B65FBD2E1
3 changed files with 23 additions and 51 deletions

View File

@ -349,21 +349,11 @@ static _GlobalConstant _global_constants[] = {
BIND_GLOBAL_CONSTANT(JOY_BUTTON_15), BIND_GLOBAL_CONSTANT(JOY_BUTTON_15),
BIND_GLOBAL_CONSTANT(JOY_BUTTON_MAX), BIND_GLOBAL_CONSTANT(JOY_BUTTON_MAX),
BIND_GLOBAL_CONSTANT(JOY_SNES_A),
BIND_GLOBAL_CONSTANT(JOY_SNES_B),
BIND_GLOBAL_CONSTANT(JOY_SNES_X),
BIND_GLOBAL_CONSTANT(JOY_SNES_Y),
BIND_GLOBAL_CONSTANT(JOY_SONY_CIRCLE), BIND_GLOBAL_CONSTANT(JOY_SONY_CIRCLE),
BIND_GLOBAL_CONSTANT(JOY_SONY_X), BIND_GLOBAL_CONSTANT(JOY_SONY_X),
BIND_GLOBAL_CONSTANT(JOY_SONY_SQUARE), BIND_GLOBAL_CONSTANT(JOY_SONY_SQUARE),
BIND_GLOBAL_CONSTANT(JOY_SONY_TRIANGLE), BIND_GLOBAL_CONSTANT(JOY_SONY_TRIANGLE),
BIND_GLOBAL_CONSTANT(JOY_SEGA_B),
BIND_GLOBAL_CONSTANT(JOY_SEGA_A),
BIND_GLOBAL_CONSTANT(JOY_SEGA_X),
BIND_GLOBAL_CONSTANT(JOY_SEGA_Y),
BIND_GLOBAL_CONSTANT(JOY_XBOX_B), BIND_GLOBAL_CONSTANT(JOY_XBOX_B),
BIND_GLOBAL_CONSTANT(JOY_XBOX_A), BIND_GLOBAL_CONSTANT(JOY_XBOX_A),
BIND_GLOBAL_CONSTANT(JOY_XBOX_X), BIND_GLOBAL_CONSTANT(JOY_XBOX_X),
@ -397,14 +387,11 @@ static _GlobalConstant _global_constants[] = {
BIND_GLOBAL_CONSTANT(JOY_AXIS_7), BIND_GLOBAL_CONSTANT(JOY_AXIS_7),
BIND_GLOBAL_CONSTANT(JOY_AXIS_MAX), BIND_GLOBAL_CONSTANT(JOY_AXIS_MAX),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_0_X), BIND_GLOBAL_CONSTANT(JOY_ANALOG_LX),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_0_Y), BIND_GLOBAL_CONSTANT(JOY_ANALOG_LY),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_1_X), BIND_GLOBAL_CONSTANT(JOY_ANALOG_RX),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_1_Y), BIND_GLOBAL_CONSTANT(JOY_ANALOG_RY),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_2_X),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_2_Y),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_L2), BIND_GLOBAL_CONSTANT(JOY_ANALOG_L2),
BIND_GLOBAL_CONSTANT(JOY_ANALOG_R2), BIND_GLOBAL_CONSTANT(JOY_ANALOG_R2),

View File

@ -89,32 +89,20 @@ enum {
JOY_DPAD_LEFT = JOY_BUTTON_14, JOY_DPAD_LEFT = JOY_BUTTON_14,
JOY_DPAD_RIGHT = JOY_BUTTON_15, JOY_DPAD_RIGHT = JOY_BUTTON_15,
// a little history about game controllers (who copied who) JOY_SONY_CIRCLE = JOY_BUTTON_1,
JOY_SONY_X = JOY_BUTTON_0,
JOY_SONY_SQUARE = JOY_BUTTON_2,
JOY_SONY_TRIANGLE = JOY_BUTTON_3,
JOY_SNES_B = JOY_BUTTON_0, JOY_XBOX_A = JOY_BUTTON_0,
JOY_SNES_A = JOY_BUTTON_1, JOY_XBOX_B = JOY_BUTTON_1,
JOY_SNES_Y = JOY_BUTTON_2, JOY_XBOX_X = JOY_BUTTON_2,
JOY_SNES_X = JOY_BUTTON_3, JOY_XBOX_Y = JOY_BUTTON_3,
JOY_SONY_CIRCLE = JOY_SNES_A, JOY_DS_A = JOY_BUTTON_1,
JOY_SONY_X = JOY_SNES_B, JOY_DS_B = JOY_BUTTON_0,
JOY_SONY_SQUARE = JOY_SNES_Y, JOY_DS_X = JOY_BUTTON_3,
JOY_SONY_TRIANGLE = JOY_SNES_X, JOY_DS_Y = JOY_BUTTON_2,
JOY_SEGA_B = JOY_SNES_A,
JOY_SEGA_A = JOY_SNES_B,
JOY_SEGA_X = JOY_SNES_Y,
JOY_SEGA_Y = JOY_SNES_X,
JOY_XBOX_B = JOY_SEGA_B,
JOY_XBOX_A = JOY_SEGA_A,
JOY_XBOX_X = JOY_SEGA_X,
JOY_XBOX_Y = JOY_SEGA_Y,
JOY_DS_A = JOY_SNES_A,
JOY_DS_B = JOY_SNES_B,
JOY_DS_X = JOY_SNES_X,
JOY_DS_Y = JOY_SNES_Y,
JOY_WII_C = JOY_BUTTON_5, JOY_WII_C = JOY_BUTTON_5,
JOY_WII_Z = JOY_BUTTON_6, JOY_WII_Z = JOY_BUTTON_6,
@ -134,14 +122,11 @@ enum {
JOY_AXIS_7 = 7, JOY_AXIS_7 = 7,
JOY_AXIS_MAX = 8, JOY_AXIS_MAX = 8,
JOY_ANALOG_0_X = JOY_AXIS_0, JOY_ANALOG_LX = JOY_AXIS_0,
JOY_ANALOG_0_Y = JOY_AXIS_1, JOY_ANALOG_LY = JOY_AXIS_1,
JOY_ANALOG_1_X = JOY_AXIS_2, JOY_ANALOG_RX = JOY_AXIS_2,
JOY_ANALOG_1_Y = JOY_AXIS_3, JOY_ANALOG_RY = JOY_AXIS_3,
JOY_ANALOG_2_X = JOY_AXIS_4,
JOY_ANALOG_2_Y = JOY_AXIS_5,
JOY_ANALOG_L2 = JOY_AXIS_6, JOY_ANALOG_L2 = JOY_AXIS_6,
JOY_ANALOG_R2 = JOY_AXIS_7, JOY_ANALOG_R2 = JOY_AXIS_7,

View File

@ -325,7 +325,7 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
InputEvent ev; InputEvent ev;
ev.type = InputEvent::JOYPAD_MOTION; ev.type = InputEvent::JOYPAD_MOTION;
ev.device = 0; ev.device = 0;
ev.joy_motion.axis = JOY_ANALOG_0_X; ev.joy_motion.axis = JOY_ANALOG_0;
ev.joy_motion.axis_value = (p_x / (float)ACCEL_RANGE); ev.joy_motion.axis_value = (p_x / (float)ACCEL_RANGE);
ev.ID = ++last_event_id; ev.ID = ++last_event_id;
last_accel.x = p_x; last_accel.x = p_x;
@ -336,7 +336,7 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
InputEvent ev; InputEvent ev;
ev.type = InputEvent::JOYPAD_MOTION; ev.type = InputEvent::JOYPAD_MOTION;
ev.device = 0; ev.device = 0;
ev.joy_motion.axis = JOY_ANALOG_0_Y; ev.joy_motion.axis = JOY_ANALOG_1;
ev.joy_motion.axis_value = (p_y / (float)ACCEL_RANGE); ev.joy_motion.axis_value = (p_y / (float)ACCEL_RANGE);
ev.ID = ++last_event_id; ev.ID = ++last_event_id;
last_accel.y = p_y; last_accel.y = p_y;
@ -347,7 +347,7 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
InputEvent ev; InputEvent ev;
ev.type = InputEvent::JOYPAD_MOTION; ev.type = InputEvent::JOYPAD_MOTION;
ev.device = 0; ev.device = 0;
ev.joy_motion.axis = JOY_ANALOG_1_X; ev.joy_motion.axis = JOY_ANALOG_2;
ev.joy_motion.axis_value = ( (1.0 - p_z) / (float)ACCEL_RANGE); ev.joy_motion.axis_value = ( (1.0 - p_z) / (float)ACCEL_RANGE);
ev.ID = ++last_event_id; ev.ID = ++last_event_id;
last_accel.z = p_z; last_accel.z = p_z;