Bladeren bron

Rename joystick directions

Ensure joystick direction enum names are consistent.
feature/data-structs
TheoryOfNekomata 2 jaren geleden
bovenliggende
commit
e53b96adb3
3 gewijzigde bestanden met toevoegingen van 12 en 12 verwijderingen
  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 Bestand weergeven

@@ -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) {
if (e.type == SDL_JOYAXISMOTION) {
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_LEFT);
@@ -36,8 +36,8 @@ void IZ_HandleJoystickAxisEvents(SDL_Event e, IZ_JoystickState* state, IZ_Action
return;
}
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_DOWN);


+ 4
- 4
src/packages/game/input/IZ_joystick.h Bestand weergeven

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

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;

typedef struct {


+ 4
- 4
src/packages/game/input/input.test.c Bestand weergeven

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

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

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

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

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

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

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

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

it("handles positive motion") {


Laden…
Annuleren
Opslaan