Permalink
Browse files

Fix joypad/joystick movement

remove joy_state variable (its use was identical to the newer gamepad_states variable
  • Loading branch information...
segrax committed Apr 9, 2016
1 parent 671c8b5 commit 46258dba22e9f65f5cee96e840ebfb94a873d7d5
Showing with 24 additions and 12 deletions.
  1. +0 −1 data.h
  2. +2 −2 seg000.c
  3. +22 −9 seg009.c
View
1 data.h
@@ -525,7 +525,6 @@ extern SDL_Window* window_;
extern SDL_Texture* sdl_texture_;
extern SDL_Joystick* sdl_controller_ INIT( = 0 );
extern int joy_state INIT( = { 0 } ); // hor
extern int gamepad_states[3] INIT( = { 0, 0, 0 } ); // hor, ver, shift
extern int screen_updates_suspended;
View
@@ -1069,10 +1069,10 @@ void __pascal far check_fall_flo() {
// seg000:1051
void __pascal far read_joyst_control() {
// stub
if ((gamepad_states[0] == -1) || (joy_state == -1))
if (gamepad_states[0] == -1)
control_x = -1;
if ((gamepad_states[0] == 1) || (joy_state == 1))
if (gamepad_states[0] == 1)
control_x = 1;
if (gamepad_states[1] == -1)
View
@@ -2490,32 +2490,45 @@ void idle() {
if (event.jaxis.axis == 0) {
if (event.jaxis.value < -8000)
joy_state = -1; // left
gamepad_states[0] = -1; // left
else if (event.jaxis.value > 8000)
joy_state = 1; // right
gamepad_states[0] = 1; // right
else
joy_state = 0;
gamepad_states[0] = 0;
}
if (event.jaxis.axis == 1) {
if (event.jaxis.value < -30000)
gamepad_states[1] = -1; // up
else if (event.jaxis.value > 30000)
gamepad_states[1] = 1; // down
else
gamepad_states[1] = 0;
}
break;
case SDL_JOYHATMOTION:
switch (event.jhat.value)
{
case 1: gamepad_states[1] = -1; break; // up
case 2: gamepad_states[0] = 1; break; // right
case 3: gamepad_states[0] = 1; break; // right (and up)
case 6: gamepad_states[0] = 1; break; // right (and down)
case 3: gamepad_states[0] = 1; gamepad_states[1] = -1; break; // right (and up)
case 4: gamepad_states[1] = 1; break; // down
case 6: gamepad_states[0] = 1; gamepad_states[1] = 1; break; // right (and down)
case 8: gamepad_states[0] = -1; break; // left
case 9: gamepad_states[0] = -1; break; // left (and up)
case 12: gamepad_states[0] = -1; break; // left (and down)
default: gamepad_states[0] = 0; break;
case 9: gamepad_states[0] = -1; gamepad_states[1] = -1; break; // left (and up)
case 12: gamepad_states[0] = -1; gamepad_states[1] = 1; break; // left (and down)
default: gamepad_states[0] = 0; gamepad_states[1] = 0; break;
}
break;
case SDL_JOYBUTTONDOWN:
switch (event.jbutton.button)
{
case 0: gamepad_states[1] = 1; break; /*** A (down) ***/
case 1: quit (0); break; /*** B (quit) ***/
case 1: quit( 0 ); break; /*** B (quit) ***/
case 2: gamepad_states[2] = 1; break; /*** X (shift) ***/
case 3: gamepad_states[1] = -1; break; /*** Y (up) ***/
case 4: break; /*** left shoulder ***/

0 comments on commit 46258db

Please sign in to comment.