SDL and menu joystick fixes by NY00123 (thanks!).

git-svn-id: https://svn.eduke32.com/eduke32@1716 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2010-10-21 02:20:40 +00:00
parent e0588e4a70
commit a925d39273
2 changed files with 27 additions and 7 deletions

View file

@ -86,6 +86,9 @@ static SDL_Surface * loadappicon(void);
static mutex_t m_initprintf; static mutex_t m_initprintf;
// Joystick dead and saturation zones
uint16_t *joydead, *joysatur;
int32_t wm_msgbox(char *name, char *fmt, ...) int32_t wm_msgbox(char *name, char *fmt, ...)
{ {
char buf[2048]; char buf[2048];
@ -487,6 +490,12 @@ int32_t initinput(void)
joyaxis = (int32_t *)Bcalloc(joynumaxes, sizeof(int32_t)); joyaxis = (int32_t *)Bcalloc(joynumaxes, sizeof(int32_t));
joyhat = (int32_t *)Bcalloc(joynumhats, sizeof(int32_t)); joyhat = (int32_t *)Bcalloc(joynumhats, sizeof(int32_t));
for (i = 0; i < joynumhats; i++)
joyhat[i] = -1; // centre
joydead = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t));
joysatur = (uint16_t *)Bcalloc(joynumaxes, sizeof(uint16_t));
} }
} }
@ -611,9 +620,8 @@ void readmousebstatus(int32_t *b)
// //
void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur) void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur)
{ {
UNREFERENCED_PARAMETER(axis); joydead[axis] = dead;
UNREFERENCED_PARAMETER(dead); joysatur[axis] = satur;
UNREFERENCED_PARAMETER(satur);
} }
@ -622,8 +630,8 @@ void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur)
// //
void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur) void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur)
{ {
UNREFERENCED_PARAMETER(axis); *dead = joydead[axis];
*dead = *satur = 0; *satur = joysatur[axis];
} }
@ -1736,7 +1744,19 @@ int32_t handleevents(void)
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
if (appactive && ev.jaxis.axis < joynumaxes) if (appactive && ev.jaxis.axis < joynumaxes)
{
joyaxis[ev.jaxis.axis] = ev.jaxis.value * 10000 / 32767; joyaxis[ev.jaxis.axis] = ev.jaxis.value * 10000 / 32767;
if ((joyaxis[ev.jaxis.axis] < joydead[ev.jaxis.axis])
&& (joyaxis[ev.jaxis.axis] > -joydead[ev.jaxis.axis]))
joyaxis[ev.jaxis.axis] = 0;
else if (joyaxis[ev.jaxis.axis] >= joysatur[ev.jaxis.axis])
joyaxis[ev.jaxis.axis] = 10000;
else if (joyaxis[ev.jaxis.axis] <= -joysatur[ev.jaxis.axis])
joyaxis[ev.jaxis.axis] = -10000;
else
joyaxis[ev.jaxis.axis] = joyaxis[ev.jaxis.axis] *
10000 / joysatur[ev.jaxis.axis];
}
break; break;
case SDL_JOYHATMOTION: case SDL_JOYHATMOTION:

View file

@ -4335,7 +4335,7 @@ cheat_for_port_credits:
break; break;
} }
for (m=first; m<last-1; m++) for (m = first; m < last; m++)
{ {
int32_t odx,dx,ody,dy; int32_t odx,dx,ody,dy;
Bstrcpy(tempbuf,(char *)getjoyname(0,m)); Bstrcpy(tempbuf,(char *)getjoyname(0,m));