Browse Source

Update joystick config binding

Fix off-by-one error.
master
TheoryOfNekomata 1 year ago
parent
commit
a1d3052ab5
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      src/packages/game/input/IZ_joystick.c

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

@@ -1,6 +1,6 @@
#include "IZ_joystick.h" #include "IZ_joystick.h"


static INI_ConfigItem joystick_config_items[IZ_PLAYERS * (IZ_CONTROLS - 4 + 2) + 1];
static INI_ConfigItem joystick_config_items[IZ_PLAYERS * (IZ_CONTROLS - 4 + 3) + 1];


bool IZ_JoystickIsValidAxisThreshold(u16 value) { bool IZ_JoystickIsValidAxisThreshold(u16 value) {
return (4000 <= value && value <= 12000); return (4000 <= value && value <= 12000);
@@ -202,7 +202,8 @@ void IZ_JoystickInitializeConfigItems(INI_ConfigItem config_items[]) {
for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) { for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
main_section_name = IZ_calloc(64, sizeof(char)); main_section_name = IZ_calloc(64, sizeof(char));
sprintf(main_section_name, "Joystick.%d", player_index); sprintf(main_section_name, "Joystick.%d", player_index);
u8 base_index = (player_index * (IZ_CONTROLS - 4 + 2));
// The `+ 3` corresponds to the first three config items. Add as appropriate.
u8 base_index = (player_index * (IZ_CONTROLS - 4 + 3));
config_items[base_index] = (INI_ConfigItem) { config_items[base_index] = (INI_ConfigItem) {
INI_CONFIG_TYPE_I32, INI_CONFIG_TYPE_I32,
main_section_name, main_section_name,
@@ -254,7 +255,7 @@ void IZ_JoystickInitializeConfigItems(INI_ConfigItem config_items[]) {
} }
} }


config_items[IZ_PLAYERS * (IZ_CONTROLS - 4 + 2) + 1] = INI_CONFIG_ITEM_NULL;
config_items[IZ_PLAYERS * (IZ_CONTROLS - 4 + 3)] = INI_CONFIG_ITEM_NULL;
} }


IZ_ProcedureResult IZ_JoystickInitializeConfig(IZ_JoystickState(* state)[IZ_PLAYERS], const char* config_path, u8 argc, const char* argv[]) { IZ_ProcedureResult IZ_JoystickInitializeConfig(IZ_JoystickState(* state)[IZ_PLAYERS], const char* config_path, u8 argc, const char* argv[]) {


Loading…
Cancel
Save