Browse Source

Rename joystick directions

Ensure joystick direction enum names are consistent.
feature/data-structs
TheoryOfNekomata 2 years ago
parent
commit
e53b96adb3
3 changed files with 12 additions and 12 deletions
  1. +4
    -4
      src/packages/game/input/IZ_joystick.c
  2. +4
    -4
      src/packages/game/input/IZ_joystick.h
  3. +4
    -4
      src/packages/game/input/input.test.c

+ 4
- 4
src/packages/game/input/IZ_joystick.c View File

@@ -21,8 +21,8 @@ void IZ_HandleJoystickDeviceEvents(SDL_Event e, IZ_JoystickState* state) {
void IZ_HandleJoystickAxisEvents(SDL_Event e, IZ_JoystickState* state, IZ_Action* action) { void IZ_HandleJoystickAxisEvents(SDL_Event e, IZ_JoystickState* state, IZ_Action* action) {
if (e.type == SDL_JOYAXISMOTION) { if (e.type == SDL_JOYAXISMOTION) {
if ( if (
e.jaxis.axis == IZ_JOYAXIS_DIRECTION_HORIZONTAL1
|| e.jaxis.axis == IZ_JOYAXIS_DIRECTION_HORIZONTAL2
e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_HORIZONTAL1
|| e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_HORIZONTAL2
) { ) {
*action &= ~(0x1 << IZ_ACTION_INDEX_RIGHT); *action &= ~(0x1 << IZ_ACTION_INDEX_RIGHT);
*action &= ~(0x1 << IZ_ACTION_INDEX_LEFT); *action &= ~(0x1 << IZ_ACTION_INDEX_LEFT);
@@ -36,8 +36,8 @@ void IZ_HandleJoystickAxisEvents(SDL_Event e, IZ_JoystickState* state, IZ_Action
return; return;
} }
if ( if (
e.jaxis.axis == IZ_JOYAXIS_DIRECTION_VERTICAL1
|| e.jaxis.axis == IZ_JOYAXIS_DIRECTION_VERTICAL2
e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_VERTICAL1
|| e.jaxis.axis == IZ_JOY_AXIS_DIRECTION_VERTICAL2
) { ) {
*action &= ~(0x1 << IZ_ACTION_INDEX_UP); *action &= ~(0x1 << IZ_ACTION_INDEX_UP);
*action &= ~(0x1 << IZ_ACTION_INDEX_DOWN); *action &= ~(0x1 << IZ_ACTION_INDEX_DOWN);


+ 4
- 4
src/packages/game/input/IZ_joystick.h View File

@@ -9,10 +9,10 @@
typedef uint8_t IZ_PadButton; typedef uint8_t IZ_PadButton;


typedef enum { typedef enum {
IZ_JOYAXIS_DIRECTION_HORIZONTAL1 = 0,
IZ_JOYAXIS_DIRECTION_VERTICAL1 = 1,
IZ_JOYAXIS_DIRECTION_HORIZONTAL2 = 3,
IZ_JOYAXIS_DIRECTION_VERTICAL2 = 4,
IZ_JOY_AXIS_DIRECTION_HORIZONTAL1 = 0,
IZ_JOY_AXIS_DIRECTION_VERTICAL1 = 1,
IZ_JOY_AXIS_DIRECTION_HORIZONTAL2 = 3,
IZ_JOY_AXIS_DIRECTION_VERTICAL2 = 4,
} IZ_JoyAxisDirection; } IZ_JoyAxisDirection;


typedef struct { typedef struct {


+ 4
- 4
src/packages/game/input/input.test.c View File

@@ -27,7 +27,7 @@ spec("input") {


describe("on primary horizontal direction") { describe("on primary horizontal direction") {
before_each() { before_each() {
e.jaxis.axis = IZ_JOYAXIS_DIRECTION_HORIZONTAL1;
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_HORIZONTAL1;
} }


it("handles positive motion") { it("handles positive motion") {
@@ -69,7 +69,7 @@ spec("input") {


describe("on secondary horizontal direction") { describe("on secondary horizontal direction") {
before_each() { before_each() {
e.jaxis.axis = IZ_JOYAXIS_DIRECTION_HORIZONTAL2;
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_HORIZONTAL2;
} }


it("handles positive motion") { it("handles positive motion") {
@@ -111,7 +111,7 @@ spec("input") {


describe("on primary vertical direction") { describe("on primary vertical direction") {
before_each() { before_each() {
e.jaxis.axis = IZ_JOYAXIS_DIRECTION_VERTICAL1;
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_VERTICAL1;
} }


it("handles positive motion") { it("handles positive motion") {
@@ -153,7 +153,7 @@ spec("input") {


describe("on secondary vertical direction") { describe("on secondary vertical direction") {
before_each() { before_each() {
e.jaxis.axis = IZ_JOYAXIS_DIRECTION_VERTICAL2;
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_VERTICAL2;
} }


it("handles positive motion") { it("handles positive motion") {


Loading…
Cancel
Save