mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 19:39:24 +01:00
Fix joystick handling for multiple joysticks (well, partly at least)
This commit is contained in:
parent
fa3e08bee8
commit
ec924bafeb
@ -164,7 +164,7 @@ private:
|
|||||||
uint8 poll_joystick(int port);
|
uint8 poll_joystick(int port);
|
||||||
uint8 poll_joystick_axes(int port, bool *has_event);
|
uint8 poll_joystick_axes(int port, bool *has_event);
|
||||||
uint8 poll_joystick_hats(int port, bool *has_event);
|
uint8 poll_joystick_hats(int port, bool *has_event);
|
||||||
uint8 poll_joystick_buttons(int port, bool *has_event);
|
uint8 poll_joystick_buttons(int port, uint8 *table, bool *has_event);
|
||||||
void thread_func(void);
|
void thread_func(void);
|
||||||
|
|
||||||
bool thread_running; // Emulation thread is running
|
bool thread_running; // Emulation thread is running
|
||||||
|
@ -247,6 +247,7 @@ void C64::VBlank(bool draw_frame)
|
|||||||
if (ThePrefs.JoystickSwap)
|
if (ThePrefs.JoystickSwap)
|
||||||
joy_port_1 = 1;
|
joy_port_1 = 1;
|
||||||
|
|
||||||
|
SDL_JoystickUpdate();
|
||||||
// Poll joysticks
|
// Poll joysticks
|
||||||
j1 = poll_joystick(!joy_port_1);
|
j1 = poll_joystick(!joy_port_1);
|
||||||
j2 = poll_joystick(joy_port_1);
|
j2 = poll_joystick(joy_port_1);
|
||||||
|
@ -884,7 +884,7 @@ uint8 C64::poll_joystick_hats(int port, bool *has_event)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 C64::poll_joystick_buttons(int port, bool *has_event)
|
uint8 C64::poll_joystick_buttons(int port, uint8 *table, bool *has_event)
|
||||||
{
|
{
|
||||||
SDL_Joystick *js = joy[port];
|
SDL_Joystick *js = joy[port];
|
||||||
uint8 out = 0xff;
|
uint8 out = 0xff;
|
||||||
@ -901,12 +901,10 @@ uint8 C64::poll_joystick_buttons(int port, bool *has_event)
|
|||||||
Gui::gui->pushJoystickEvent(ev);
|
Gui::gui->pushJoystickEvent(ev);
|
||||||
*has_event = true;
|
*has_event = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kc == JOY_NONE)
|
if (kc == JOY_NONE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TheDisplay->UpdateKeyMatrix(kc, !cur,
|
table[kc] = cur ? 2 : 1;
|
||||||
TheCIA1->KeyMatrix, TheCIA1->RevMatrix, &out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@ -919,20 +917,35 @@ uint8 C64::poll_joystick(int port)
|
|||||||
{
|
{
|
||||||
bool has_event = false;
|
bool has_event = false;
|
||||||
uint8 out = 0xff;
|
uint8 out = 0xff;
|
||||||
|
static uint8 last_table_ports[2][0xff];
|
||||||
if (port == 0 && (joy[0] || joy[1]))
|
static uint8 table_ports[2][0xff];
|
||||||
SDL_JoystickUpdate();
|
uint8 *last_table = last_table_ports[port];
|
||||||
|
uint8 *table = table_ports[port];
|
||||||
|
|
||||||
if (!joy[port])
|
if (!joy[port])
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
|
memset(table, 0, 0xff);
|
||||||
|
|
||||||
out &= this->poll_joystick_axes(port, &has_event);
|
out &= this->poll_joystick_axes(port, &has_event);
|
||||||
out &= this->poll_joystick_hats(port, &has_event);
|
out &= this->poll_joystick_hats(port, &has_event);
|
||||||
out &= this->poll_joystick_buttons(port, &has_event);
|
out &= this->poll_joystick_buttons(port, table, &has_event);
|
||||||
|
|
||||||
if (!has_event)
|
if (!has_event)
|
||||||
Gui::gui->pushJoystickEvent(EVENT_NONE);
|
Gui::gui->pushJoystickEvent(EVENT_NONE);
|
||||||
|
|
||||||
|
/* Handle keyboard codes */
|
||||||
|
for (int i = 0; i < 0x51; i++)
|
||||||
|
{
|
||||||
|
if (table[i] == 0 || table[i] == last_table[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TheDisplay->UpdateKeyMatrix(i, table[i] == 1,
|
||||||
|
TheCIA1->KeyMatrix, TheCIA1->RevMatrix, &out);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(last_table, table, sizeof(table));
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +158,7 @@ void Prefs::SetupJoystickDefaults()
|
|||||||
this->JoystickButtons[7] = 0x50;
|
this->JoystickButtons[7] = 0x50;
|
||||||
this->JoystickButtons[9] = 0x50;
|
this->JoystickButtons[9] = 0x50;
|
||||||
this->JoystickButtons[10] = 0x50;
|
this->JoystickButtons[10] = 0x50;
|
||||||
|
|
||||||
this->MenuJoystickButtons[3] = KEY_SELECT;
|
this->MenuJoystickButtons[3] = KEY_SELECT;
|
||||||
this->MenuJoystickButtons[7] = KEY_SELECT;
|
this->MenuJoystickButtons[7] = KEY_SELECT;
|
||||||
this->MenuJoystickButtons[9] = KEY_SELECT;
|
this->MenuJoystickButtons[9] = KEY_SELECT;
|
||||||
@ -204,7 +205,6 @@ void Prefs::SetupJoystickDefaults()
|
|||||||
/* Saitek P380 */
|
/* Saitek P380 */
|
||||||
else if (strcmp(name, "Jess Tech Dual Analog Pad") == 0)
|
else if (strcmp(name, "Jess Tech Dual Analog Pad") == 0)
|
||||||
{
|
{
|
||||||
printf("Found joystikk\n");
|
|
||||||
/* Pad */
|
/* Pad */
|
||||||
this->JoystickHats[0] = HAT_PLAIN;
|
this->JoystickHats[0] = HAT_PLAIN;
|
||||||
this->MenuJoystickHats[0] = HAT_PLAIN;
|
this->MenuJoystickHats[0] = HAT_PLAIN;
|
||||||
|
Loading…
Reference in New Issue
Block a user