|
@@ -22,237 +22,239 @@ spec("input") { |
|
|
|
|
|
|
|
|
u8 p; |
|
|
u8 p; |
|
|
for (p = 0; p < PLAYERS; p += 1) { |
|
|
for (p = 0; p < PLAYERS; p += 1) { |
|
|
describe("on axis motion events") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.type = SDL_JOYAXISMOTION; |
|
|
|
|
|
state[p].config.axis_threshold = 8000u; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
describe("on primary horizontal direction") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_HORIZONTAL1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_RIGHT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_LEFT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
describe("on secondary horizontal direction") { |
|
|
|
|
|
|
|
|
describe("on player %u", p) { |
|
|
|
|
|
describe("on axis motion events") { |
|
|
before_each() { |
|
|
before_each() { |
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_HORIZONTAL2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_RIGHT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
e.type = SDL_JOYAXISMOTION; |
|
|
|
|
|
state[p].config.axis_threshold = 8000u; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_LEFT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
describe("on primary horizontal direction") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_HORIZONTAL1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_RIGHT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_LEFT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold);; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
describe("on primary vertical direction") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_VERTICAL1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_DOWN), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
describe("on secondary horizontal direction") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_HORIZONTAL2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_RIGHT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_LEFT), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold);; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_UP), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
describe("on primary vertical direction") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_VERTICAL1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_DOWN), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_UP), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold);; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold);; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
describe("on secondary vertical direction") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_VERTICAL2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_DOWN), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_UP), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold);; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
describe("on secondary vertical direction") { |
|
|
|
|
|
|
|
|
describe("on hat motion events") { |
|
|
before_each() { |
|
|
before_each() { |
|
|
e.jaxis.axis = IZ_JOY_AXIS_DIRECTION_VERTICAL2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles positive motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_DOWN), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles negative motion") { |
|
|
|
|
|
e.jaxis.value = -GenerateAxisValueOutsideThreshold(state[p].config.axis_threshold); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << IZ_ACTION_INDEX_UP), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles neutral motion") { |
|
|
|
|
|
e.jaxis.value = GenerateAxisValueWithinThreshold(state[p].config.axis_threshold);; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
printf("(axis value: %d) ", e.jaxis.value); |
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == 0, |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
e.type = SDL_JOYHATMOTION; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
describe("on hat motion events") { |
|
|
|
|
|
before_each() { |
|
|
|
|
|
e.type = SDL_JOYHATMOTION; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (u8 i = 0; i < 4; i += 1) { |
|
|
|
|
|
it("handles motion for %s action", ACTION_NAMES[i]) { |
|
|
|
|
|
e.jhat.value = (0x1u << i); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1u << i), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles motion for %s deactivation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.jhat.value = 0; |
|
|
|
|
|
action[p] = ~0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
!(action[p] & (0x1 << i)), |
|
|
|
|
|
"Action not unset." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
for (u8 i = 0; i < 4; i += 1) { |
|
|
|
|
|
it("handles motion for %s action", ACTION_NAMES[i]) { |
|
|
|
|
|
e.jhat.value = (0x1u << i); |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1u << i), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles motion for %s deactivation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.jhat.value = 0; |
|
|
|
|
|
action[p] = ~0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
!(action[p] & (0x1 << i)), |
|
|
|
|
|
"Action not unset." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
describe("on button events") { |
|
|
|
|
|
for (u8 i = 4; i < CONTROLS; i += 1) { |
|
|
|
|
|
it("handles %s action activation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_JOYBUTTONDOWN; |
|
|
|
|
|
e.jbutton.button = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1u << i), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles %s action deactivation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_JOYBUTTONUP; |
|
|
|
|
|
e.jbutton.button = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = ~0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
!(action[p] & (0x1 << i)), |
|
|
|
|
|
"Action not unset." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
describe("on button events") { |
|
|
|
|
|
for (u8 i = 4; i < CONTROLS; i += 1) { |
|
|
|
|
|
it("handles %s action activation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_JOYBUTTONDOWN; |
|
|
|
|
|
e.jbutton.button = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1u << i), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
it("handles %s action deactivation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_JOYBUTTONUP; |
|
|
|
|
|
e.jbutton.button = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_JOYSTICK_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = ~0; |
|
|
|
|
|
|
|
|
|
|
|
IZ_JoystickHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
!(action[p] & (0x1 << i)), |
|
|
|
|
|
"Action not unset." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -296,31 +298,33 @@ spec("input") { |
|
|
static IZ_Action action[PLAYERS] = {}; |
|
|
static IZ_Action action[PLAYERS] = {}; |
|
|
|
|
|
|
|
|
for (u8 p = 0; p < PLAYERS; p += 1) { |
|
|
for (u8 p = 0; p < PLAYERS; p += 1) { |
|
|
for (u8 i = 0; i < CONTROLS; i += 1) { |
|
|
|
|
|
it("handles %s action activation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_KEYDOWN; |
|
|
|
|
|
e.key.keysym.sym = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
describe("on player %u", p) { |
|
|
|
|
|
for (u8 i = 0; i < CONTROLS; i += 1) { |
|
|
|
|
|
it("handles %s action activation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_KEYDOWN; |
|
|
|
|
|
e.key.keysym.sym = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = 0; |
|
|
|
|
|
|
|
|
IZ_KeyboardHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << i), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
IZ_KeyboardHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
action[p] == (0x1 << i), |
|
|
|
|
|
"Action not set." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
it("handles %s action deactivation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_KEYUP; |
|
|
|
|
|
e.key.keysym.sym = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = ~0; |
|
|
|
|
|
|
|
|
it("handles %s action deactivation", ACTION_NAMES[i]) { |
|
|
|
|
|
e.type = SDL_KEYUP; |
|
|
|
|
|
e.key.keysym.sym = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
state[p].config.control_mapping[i] = IZ_DEFAULT_KEYBOARD_STATE[p].config.control_mapping[i]; |
|
|
|
|
|
action[p] = ~0; |
|
|
|
|
|
|
|
|
IZ_KeyboardHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
!(action[p] & (0x1 << i)), |
|
|
|
|
|
"Action not unset." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
IZ_KeyboardHandleEvents(e, &state, &action); |
|
|
|
|
|
check( |
|
|
|
|
|
!(action[p] & (0x1 << i)), |
|
|
|
|
|
"Action not unset." |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|