Skip to content

Commit

Permalink
[input] implement new KINC_GAMEPAD_MAX_COUNT macro
Browse files Browse the repository at this point in the history
  • Loading branch information
samhocevar committed Mar 20, 2024
1 parent bd85118 commit 8b8764e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,17 @@ namespace {
}
}

const int gamepadCount = 12;
HIDGamepad gamepads[gamepadCount];
HIDGamepad gamepads[KINC_GAMEPAD_MAX_COUNT];
}

void Kore::initHIDGamepads() {
for (int i = 0; i < gamepadCount; ++i) {
for (int i = 0; i < KINC_GAMEPAD_MAX_COUNT; ++i) {
gamepads[i].init(i);
}
}

void Kore::updateHIDGamepads() {
for (int i = 0; i < gamepadCount; ++i) {
for (int i = 0; i < KINC_GAMEPAD_MAX_COUNT; ++i) {
gamepads[i].update();
}
}
Expand Down
7 changes: 3 additions & 4 deletions Backends/System/Linux/Sources/kinc/backend/gamepad.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ struct HIDGamepadUdevHelper {

static struct HIDGamepadUdevHelper udev_helper;

#define gamepadCount 12
static struct HIDGamepad gamepads[gamepadCount];
static struct HIDGamepad gamepads[KINC_GAMEPAD_MAX_COUNT];

static void HIDGamepadUdevHelper_openOrCloseGamepad(struct HIDGamepadUdevHelper *helper, struct udev_device *dev) {
const char *action = udev_device_get_action(dev);
Expand Down Expand Up @@ -167,15 +166,15 @@ static void HIDGamepadUdevHelper_close(struct HIDGamepadUdevHelper *helper) {
}

void kinc_linux_initHIDGamepads() {
for (int i = 0; i < gamepadCount; ++i) {
for (int i = 0; i < KINC_GAMEPAD_MAX_COUNT; ++i) {
HIDGamepad_init(&gamepads[i], i);
}
HIDGamepadUdevHelper_init(&udev_helper);
}

void kinc_linux_updateHIDGamepads() {
HIDGamepadUdevHelper_update(&udev_helper);
for (int i = 0; i < gamepadCount; ++i) {
for (int i = 0; i < KINC_GAMEPAD_MAX_COUNT; ++i) {
HIDGamepad_update(&gamepads[i]);
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/kinc/input/gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
extern "C" {
#endif

#define KINC_GAMEPAD_MAX_COUNT 12

/// <summary>
/// Sets the gamepad-connect-callback which is called when a gamepad is connected.
/// </summary>
Expand Down

0 comments on commit 8b8764e

Please sign in to comment.