瀏覽代碼

Rename joystick directions

Ensure joystick direction enum names are consistent.
feature/data-structs
TheoryOfNekomata 2 年之前
父節點
當前提交
e53b96adb3
共有 3 個文件被更改,包括 12 次插入12 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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") {


Loading…
取消
儲存