applied kode54's sdl/gtk joypad patch
This commit is contained in:
parent
9de4eedf3b
commit
60f7dad351
|
@ -144,9 +144,17 @@ void JoypadConfigDialog::vUpdateEntries()
|
||||||
else if (what < 0x30)
|
else if (what < 0x30)
|
||||||
{
|
{
|
||||||
// joystick hat
|
// joystick hat
|
||||||
|
int dir = (what & 3);
|
||||||
what = (what & 15);
|
what = (what & 15);
|
||||||
what >>= 2;
|
what >>= 2;
|
||||||
os << " Hat " << what;
|
os << " Hat " << what << " ";
|
||||||
|
switch (dir)
|
||||||
|
{
|
||||||
|
case 0: os << "Up"; break;
|
||||||
|
case 1: os << "Down"; break;
|
||||||
|
case 2: os << "Right"; break;
|
||||||
|
case 3: os << "Left"; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
csName = os.str().c_str();
|
csName = os.str().c_str();
|
||||||
|
@ -209,6 +217,7 @@ void JoypadConfigDialog::vOnInputEvent(const SDL_Event &event)
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = inputGetEventCode(event);
|
int code = inputGetEventCode(event);
|
||||||
|
if (!code) return;
|
||||||
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
|
inputSetKeymap(m_ePad, m_astKeys[m_iCurrentEntry].m_eKeyFlag, code);
|
||||||
vUpdateEntries();
|
vUpdateEntries();
|
||||||
|
|
||||||
|
@ -241,11 +250,17 @@ bool JoypadConfigDialog::bOnConfigIdle()
|
||||||
}
|
}
|
||||||
vEmptyEventQueue();
|
vEmptyEventQueue();
|
||||||
break;
|
break;
|
||||||
case SDL_JOYHATMOTION:
|
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_JOYBUTTONUP:
|
||||||
vOnInputEvent(event);
|
vOnInputEvent(event);
|
||||||
vEmptyEventQueue();
|
vEmptyEventQueue();
|
||||||
break;
|
break;
|
||||||
|
case SDL_JOYHATMOTION:
|
||||||
|
if (event.jhat.value)
|
||||||
|
{
|
||||||
|
vOnInputEvent(event);
|
||||||
|
vEmptyEventQueue();
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,11 @@ static int sensorY = 2047;
|
||||||
|
|
||||||
static uint32_t sdlGetHatCode(const SDL_Event &event)
|
static uint32_t sdlGetHatCode(const SDL_Event &event)
|
||||||
{
|
{
|
||||||
|
if (!event.jhat.value) return 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
((event.jhat.which + 1) << 16) |
|
((event.jhat.which + 1) << 16) |
|
||||||
|
32 |
|
||||||
(event.jhat.hat << 2) |
|
(event.jhat.hat << 2) |
|
||||||
(
|
(
|
||||||
event.jhat.value & SDL_HAT_UP ? 0 :
|
event.jhat.value & SDL_HAT_UP ? 0 :
|
||||||
|
@ -106,6 +109,8 @@ static uint32_t sdlGetButtonCode(const SDL_Event &event)
|
||||||
|
|
||||||
static uint32_t sdlGetAxisCode(const SDL_Event &event)
|
static uint32_t sdlGetAxisCode(const SDL_Event &event)
|
||||||
{
|
{
|
||||||
|
if (event.jaxis.value >= -16384 && event.jaxis.value <= 16384) return 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
((event.jaxis.which + 1) << 16) |
|
((event.jaxis.which + 1) << 16) |
|
||||||
(event.jaxis.axis << 1) |
|
(event.jaxis.axis << 1) |
|
||||||
|
|
Loading…
Reference in New Issue