Skip to content
Permalink
Browse files

Re-integrated right analog support.

  • Loading branch information...
Rinnegatamante committed Apr 24, 2018
1 parent f500cc8 commit 57fc95240f15999842f433589f77fa53fa977e45
Showing with 51 additions and 5 deletions.
  1. +40 −0 source/id_in.cpp
  2. +1 −0 source/id_in.h
  3. +10 −5 source/wl_play.cpp
@@ -182,6 +182,46 @@ void IN_GetJoyDelta(int *dx,int *dy)
*dy = y;
}

void IN_GetJoyDelta2(int *dx,int *dy)
{
if(!Joystick)
{
*dx = *dy = 0;
return;
}

SDL_JoystickUpdate();
#ifdef _arch_dreamcast
int x = 0;
int y = 0;
#else
int x = SDL_JoystickGetAxis(Joystick, 2) >> 8;
int y = SDL_JoystickGetAxis(Joystick, 3) >> 8;
#endif

if(param_joystickhat != -1)
{
uint8_t hatState = SDL_JoystickGetHat(Joystick, param_joystickhat);
if(hatState & SDL_HAT_RIGHT)
x += 127;
else if(hatState & SDL_HAT_LEFT)
x -= 127;
if(hatState & SDL_HAT_DOWN)
y += 127;
else if(hatState & SDL_HAT_UP)
y -= 127;

if(x < -128) x = -128;
else if(x > 127) x = 127;

if(y < -128) y = -128;
else if(y > 127) y = 127;
}

*dx = x;
*dy = y;
}

///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyFineDelta() - Returns the relative movement of the specified
@@ -174,6 +174,7 @@ boolean IN_JoyPresent();
void IN_SetJoyCurrent(int joyIndex);
int IN_JoyButtons (void);
void IN_GetJoyDelta(int *dx,int *dy);
void IN_GetJoyDelta2(int *dx,int *dy);
void IN_GetJoyFineDelta(int *dx, int *dy);

void IN_StartAck(void);
@@ -362,20 +362,25 @@ void PollMouseMove (void)

void PollJoystickMove (void)
{
int joyx, joyy;
int joyx, joyy, joyx2, joyy2;

IN_GetJoyDelta (&joyx, &joyy);
IN_GetJoyDelta2 (&joyx2, &joyy2);

int delta = buttonstate[bt_run] ? RUNMOVE * tics : BASEMOVE * tics;

if (joyx > 64 || buttonstate[bt_turnright])
controlx += delta;
else if (joyx < -64 || buttonstate[bt_turnleft])
controlx -= delta;
if (joyx > 64 || buttonstate[bt_straferight])
buttonstate[bt_straferight] = 1;
else if (joyx < -64 || buttonstate[bt_strafeleft])
buttonstate[bt_strafeleft] = 1;
if (joyy > 64 || buttonstate[bt_movebackward])
controly += delta;
else if (joyy < -64 || buttonstate[bt_moveforward])
controly -= delta;
if (joyx2 > 64 || buttonstate[bt_turnright])
controlx += delta;
else if (joyx2 < -64 || buttonstate[bt_turnleft])
controlx -= delta;
}

/*

0 comments on commit 57fc952

Please sign in to comment.
You can’t perform that action at this time.