Zeropad: Fix a glitch in the new esc code, and the hat code should not save in the same spots as the axis code.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1248 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-05-23 22:20:16 +00:00
parent 342da0e2a8
commit f1be4728ba
2 changed files with 37 additions and 30 deletions

View File

@ -232,8 +232,26 @@ void CALLBACK PADupdate(int pad)
}
}
}
#ifdef EXPERIMENTAL_POV_CODE
else if (IS_POV(key))
{
int joyid = PAD_GETJOYID(key);
if (joyid >= 0 && (joyid < (int)s_vjoysticks.size()))
{
pjoy = s_vjoysticks[joyid];
int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
int pad = (pjoy)->GetPAD();
if (PAD_GETPOVSIGN(key) && (value < -2048))
clear_bit(status[pad], i);
else if (!PAD_GETPOVSIGN(key) && (value > 2048))
clear_bit(status[pad], i);
else
set_bit(status[pad], i);
}
}
#ifdef EXPERIMENTAL_POV_CODE
else if (IS_HAT(key))
{
int joyid = PAD_GETJOYID(key);
if ((joyid >= 0) && (joyid < (int)s_vjoysticks.size()))
@ -247,7 +265,7 @@ void CALLBACK PADupdate(int pad)
//PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVDIR(key), key);
if (value != SDL_HAT_CENTERED)
{
if (PAD_GETPOVDIR(key) == value)
if (PAD_GETHATDIR(key) == value)
set_bit(status[pad], i);
else
clear_bit(status[pad], i);
@ -271,29 +289,10 @@ void CALLBACK PADupdate(int pad)
break;
}
}
else
/*else
{
clear_bit(status[pad], i);
}
}
}
#else
else if (IS_POV(key))
{
int joyid = PAD_GETJOYID(key);
if (joyid >= 0 && (joyid < (int)s_vjoysticks.size()))
{
pjoy = s_vjoysticks[joyid];
int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
int pad = (pjoy)->GetPAD();
if (PAD_GETPOVSIGN(key) && (value < -2048))
clear_bit(status[pad], i);
else if (!PAD_GETPOVSIGN(key) && (value > 2048))
clear_bit(status[pad], i);
else
set_bit(status[pad], i);
}*/
}
}
#endif
@ -347,7 +346,7 @@ void UpdateConf(int pad)
#ifdef EXPERIMENTAL_POV_CODE
{
tmp.resize(28);
switch(PAD_GETPOVDIR(conf.keys[pad][i]))
switch(PAD_GETHATDIR(conf.keys[pad][i]))
{
case SDL_HAT_UP:
sprintf(&tmp[0], "JPOVU-%d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]));
@ -449,12 +448,18 @@ bool PollKeyboard(char* &temp, u32* &pkey)
{
if (ev->type == GDK_KEY_PRESS)
{
*pkey = ev->key.keyval;
if (ev->key.keyval == GDK_Escape)
{
temp = "Unknown";
*pkey = NULL;
}
else
{
temp = XKeysymToString(ev->key.keyval);
*pkey = ev->key.keyval;
}
return true;
}
@ -545,7 +550,7 @@ bool PollPOV(vector<JoystickInfo*>::iterator itjoy, int &jbutton, int &dir, u32*
case SDL_HAT_RIGHT:
case SDL_HAT_DOWN:
case SDL_HAT_LEFT:
*pkey = PAD_POV((*itjoy)->GetId(), value, i);
*pkey = PAD_HAT((*itjoy)->GetId(), value, i);
jbutton = i;
dir = value;
PAD_LOG("Hat Pressed!");

View File

@ -49,13 +49,13 @@ extern "C"
extern char libraryName[256];
#define FORIT(it, v) for(it = (v).begin(); it != (v).end(); (it)++)
#define IS_KEYBOARD(key) (key < 0x10000)
#define IS_JOYBUTTONS(key) (key >= 0x10000 && key < 0x20000) // buttons
#define IS_JOYSTICK(key) (key >= 0x20000 && key < 0x30000) // analog
#define IS_POV(key) (key >= 0x30000 && key < 0x40000) // uses analog as buttons (cares about sign)
#define IS_MOUSE(key) (key >= 0x40000 && key < 0x50000) // mouse
#define IS_HAT(key) (key >= 0x40000 && key < 0x50000) // uses hat as buttons (cares about sign)
//#define IS_MOUSE(key) (key >= 0x40000 && key < 0x50000) // mouse
#define PAD_GETKEY(key) ((key) & 0xffff)
#define PAD_GETJOYID(key) (((key) & 0xf000) >> 12)
@ -64,8 +64,10 @@ extern char libraryName[256];
#define PAD_JOYBUTTON(joyid, buttonid) (0x10000 | ((joyid) << 12) | (buttonid))
#define PAD_JOYSTICK(joyid, axisid) (0x20000 | ((joyid) << 12) | (axisid))
#define PAD_POV(joyid, sign, axisid) (0x30000 | ((joyid) << 12) | ((sign) << 8) | (axisid))
#define PAD_HAT(joyid, dir, axisid) (0x40000 | ((joyid) << 12) | ((dir) << 8) | (axisid))
#define PAD_GETPOVSIGN(key) (((key) & 0x100) >> 8)
#define PAD_GETPOVDIR(key) (((key) & ~ 0x30000) >> 8)
#define PAD_GETHATDIR(key) (((key) & ~ 0x40000) >> 8)
#ifdef __LINUX__
#define PADKEYS 28