fix bug when mapping a joystick axis control but no button

This commit is contained in:
Arisotura 2019-06-20 16:31:28 +02:00
parent f59094e033
commit e2dc98d144
2 changed files with 43 additions and 29 deletions

View File

@ -125,6 +125,10 @@ void JoyMappingName(int id, char* str)
return;
}
bool hasbtn = ((id & 0xFFFF) != 0xFFFF);
if (hasbtn)
{
if (id & 0x100)
{
int hatnum = ((id >> 4) & 0xF) + 1;
@ -141,6 +145,11 @@ void JoyMappingName(int id, char* str)
{
sprintf(str, "Button %d", (id & 0xFFFF) + 1);
}
}
else
{
strcpy(str, "");
}
if (id & 0x10000)
{
@ -151,9 +160,9 @@ void JoyMappingName(int id, char* str)
switch ((id >> 20) & 0xF)
{
case 0: sprintf(str, "%s / Axis %d +", tmp, axisnum); break;
case 1: sprintf(str, "%s / Axis %d -", tmp, axisnum); break;
case 2: sprintf(str, "%s / Trigger %d", tmp, axisnum); break;
case 0: sprintf(str, "%s%sAxis %d +", tmp, hasbtn?" / ":"", axisnum); break;
case 1: sprintf(str, "%s%sAxis %d -", tmp, hasbtn?" / ":"", axisnum); break;
case 2: sprintf(str, "%s%sTrigger %d", tmp, hasbtn?" / ":"", axisnum); break;
}
}
}
@ -287,7 +296,7 @@ Uint32 JoyPoll(Uint32 interval, void* param)
}
int oldmap;
if (dlg->joymap[id] == -1) oldmap = 0;
if (dlg->joymap[id] == -1) oldmap = 0xFFFF;
else oldmap = dlg->joymap[id];
int nbuttons = SDL_JoystickNumButtons(joy);

View File

@ -710,6 +710,10 @@ bool JoystickButtonDown(int val)
{
if (val == -1) return false;
bool hasbtn = ((val & 0xFFFF) != 0xFFFF);
if (hasbtn)
{
if (val & 0x100)
{
int hatnum = (val >> 4) & 0xF;
@ -731,6 +735,7 @@ bool JoystickButtonDown(int val)
if (btnval) return true;
}
}
if (val & 0x10000)
{