Permalink
Browse files

Allow defining the four directions of the axis through the config file

  • Loading branch information...
1 parent d6c64e9 commit accdf4bb05af2a62ed78572ad4f0e2ffca20a855 @mariospr committed with Jun 14, 2014
Showing with 19 additions and 4 deletions.
  1. +5 −0 unix/keyconstants.h
  2. +5 −0 unix/keys.h
  3. +9 −4 unix/unix.cpp
View
@@ -27,6 +27,11 @@
#define RU_2 26
#define RD_2 27
+#define JB_UP 16
+#define JB_DOWN 17
+#define JB_LEFT 18
+#define JB_RIGHT 19
+
#define ACCEL 50
#define QUIT 51
#define HELP 52
View
@@ -27,3 +27,8 @@
#define RPI_JOY_ACCEL 7
#define RPI_JOY_QLOAD 10
#define RPI_JOY_QSAVE 11
+
+#define RPI_JOY_UP 16
+#define RPI_JOY_DOWN 17
+#define RPI_JOY_LEFT 18
+#define RPI_JOY_RIGHT 19
View
@@ -472,6 +472,11 @@ void S9xInitInputDevices ()
sfc_key[RD_2] = SDLK_3; */
//Configure joysticks from config file or defaults
+ sfc_joy[JB_UP] = get_integer_conf("Joystick", "JB_UP", RPI_JOY_UP);
+ sfc_joy[JB_DOWN] = get_integer_conf("Joystick", "JB_DOWN", RPI_JOY_DOWN);
+ sfc_joy[JB_LEFT] = get_integer_conf("Joystick", "JB_LEFT", RPI_JOY_LEFT);
+ sfc_joy[JB_RIGHT] = get_integer_conf("Joystick", "JB_RIGHT", RPI_JOY_RIGHT);
+
sfc_joy[A_1] = get_integer_conf("Joystick", "A_1", RPI_JOY_A);
sfc_joy[B_1] = get_integer_conf("Joystick", "B_1", RPI_JOY_B);
sfc_joy[X_1] = get_integer_conf("Joystick", "X_1", RPI_JOY_X);
@@ -1114,10 +1119,10 @@ uint32 S9xReadJoypad (int which1)
if (keyssnes[sfc_key[A_1]] == SDL_PRESSED || joy_buttons[which1][sfc_joy[A_1]]) val |= SNES_A_MASK;
if (keyssnes[sfc_key[START_1]] == SDL_PRESSED || joy_buttons[which1][sfc_joy[START_1]]) val |= SNES_START_MASK;
if (keyssnes[sfc_key[SELECT_1]] == SDL_PRESSED || joy_buttons[which1][sfc_joy[SELECT_1]]) val |= SNES_SELECT_MASK;
- if (keyssnes[sfc_key[UP_1]] == SDL_PRESSED || joy_axes[which1][joyaxis_UD] == UP) val |= SNES_UP_MASK;
- if (keyssnes[sfc_key[DOWN_1]] == SDL_PRESSED || joy_axes[which1][joyaxis_UD] == DOWN) val |= SNES_DOWN_MASK;
- if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED || joy_axes[which1][joyaxis_LR] == LEFT) val |= SNES_LEFT_MASK;
- if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED || joy_axes[which1][joyaxis_LR] == RIGHT) val |= SNES_RIGHT_MASK;
+ if (keyssnes[sfc_key[UP_1]] == SDL_PRESSED || joy_axes[which1][JA_UD] == UP || joy_buttons[which1][sfc_joy[JB_UP]]) val |= SNES_UP_MASK;
+ if (keyssnes[sfc_key[DOWN_1]] == SDL_PRESSED || joy_axes[which1][JA_UD] == DOWN || joy_buttons[which1][sfc_joy[JB_DOWN]]) val |= SNES_DOWN_MASK;
+ if (keyssnes[sfc_key[LEFT_1]] == SDL_PRESSED || joy_axes[which1][JA_LR] == LEFT || joy_buttons[which1][sfc_joy[JB_LEFT]]) val |= SNES_LEFT_MASK;
+ if (keyssnes[sfc_key[RIGHT_1]] == SDL_PRESSED || joy_axes[which1][JA_LR] == RIGHT || joy_buttons[which1][sfc_joy[JB_RIGHT]]) val |= SNES_RIGHT_MASK;
} else {
if (joy_buttons[which1][sfc_joy[L_1]]) val |= SNES_TL_MASK;
if (joy_buttons[which1][sfc_joy[R_1]]) val |= SNES_TR_MASK;

0 comments on commit accdf4b

Please sign in to comment.