Zeropad: Archiving some hat work. Still disabled and buggy, but I want to be able to revert back here if neccessary.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1184 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-05-15 00:42:05 +00:00
parent bddfd67bae
commit 5b4935dd86
5 changed files with 83 additions and 48 deletions

View File

@ -136,6 +136,7 @@ void on_joydevicescombo_changed(GtkComboBox *combobox, gpointer user_data)
void on_checkbutton_reverselx_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTLX << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
conf.options |= mask;
else
@ -145,6 +146,7 @@ void on_checkbutton_reverselx_toggled(GtkToggleButton *togglebutton, gpointer us
void on_checkbutton_reversely_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTLY << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
conf.options |= mask;
else
@ -163,6 +165,7 @@ void on_checkbutton_reverserx_toggled(GtkToggleButton *togglebutton, gpointer us
void on_checkbutton_reversery_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTRY << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
conf.options |= mask;
else
@ -172,11 +175,13 @@ void on_checkbutton_reversery_toggled(GtkToggleButton *togglebutton, gpointer us
void on_forcefeedback_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTLX << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
{
conf.options |= mask;
int joyid = gtk_combo_box_get_active(GTK_COMBO_BOX(s_devicecombo));
if (joyid >= 0 && joyid < (int)s_vjoysticks.size()) s_vjoysticks[joyid]->TestForce();
}
else

View File

@ -126,28 +126,16 @@ void CALLBACK PADupdate(int pad)
switch (i)
{
case PAD_R_LEFT:
Analog::ConfigurePad(PAD_RX, pad, DEF_VALUE);
break;
case PAD_R_UP:
Analog::ConfigurePad(PAD_RY, pad, DEF_VALUE);
break;
case PAD_L_LEFT:
Analog::ConfigurePad(PAD_LX, pad, DEF_VALUE);
break;
case PAD_L_UP:
Analog::ConfigurePad(PAD_LY, pad, DEF_VALUE);
break;
case PAD_R_DOWN:
Analog::ConfigurePad(PAD_RY, pad, -DEF_VALUE);
Analog::ConfigurePad(Analog::AnalogToPad(i), pad, DEF_VALUE);
break;
case PAD_R_RIGHT:
Analog::ConfigurePad(PAD_RX, pad, -DEF_VALUE);
break;
case PAD_L_DOWN:
Analog::ConfigurePad(PAD_LY, pad, -DEF_VALUE);
break;
case PAD_R_DOWN:
case PAD_L_RIGHT:
Analog::ConfigurePad(PAD_LX, pad, -DEF_VALUE);
case PAD_L_DOWN:
Analog::ConfigurePad(Analog::AnalogToPad(i), pad, -DEF_VALUE);
break;
}
i += 0xff00;
@ -172,34 +160,8 @@ void CALLBACK PADupdate(int pad)
if ((i > PAD_RY) && (i <= PAD_R_LEFT))
{
switch (i)
{
case PAD_R_LEFT:
Analog::ResetPad(PAD_RX, pad);
break;
case PAD_R_UP:
Analog::ResetPad(PAD_RY, pad);
break;
case PAD_L_LEFT:
Analog::ResetPad(PAD_LX, pad);
break;
case PAD_L_UP:
Analog::ResetPad(PAD_LY, pad);
break;
case PAD_R_DOWN:
Analog::ResetPad(PAD_RY, pad);
break;
case PAD_R_RIGHT:
Analog::ResetPad(PAD_RX, pad);
break;
case PAD_L_DOWN:
Analog::ResetPad(PAD_LY, pad);
break;
case PAD_L_RIGHT:
Analog::ResetPad(PAD_LX, pad);
break;
}
i += 0xff00;
Analog::ResetPad(Analog::AnalogToPad(i), pad);
i += 0xff00;
}
#endif
if (i != -1)
@ -255,6 +217,7 @@ void CALLBACK PADupdate(int pad)
pjoy = s_vjoysticks[joyid];
int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
int pad = (pjoy)->GetPAD();
switch (i)
{
case PAD_LX:
@ -279,12 +242,46 @@ void CALLBACK PADupdate(int pad)
int value = SDL_JoystickGetHat((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
int pad = (pjoy)->GetPAD();
int temp;
//PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVSIGN(key), key);
if PAD_GETPOVSIGN(key)
//PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVDIR(key), key);
if (value != 0)
{
if (PAD_GETPOVDIR(key) == value)
set_bit(status[pad], i);
/*else
clear_bit(status[pad], i);*/
switch (value)
{
case SDL_HAT_UP:
PAD_LOG("Up!\n");
break;
case SDL_HAT_RIGHT:
PAD_LOG("Right!\n");
break;
case SDL_HAT_DOWN:
PAD_LOG("Down!\n");
break;
case SDL_HAT_LEFT:
PAD_LOG("Left!\n");
break;
case SDL_HAT_CENTER:
clear_bit(status[pad], i);
break;
}
}
else
{
//clear_bit(status[pad], i);
}
/*if PAD_GETPOVSIGN(key)
set_bit(status[pad], i);
else
clear_bit(status[pad], i);
clear_bit(status[pad], i);*/
}
}
#else
@ -357,7 +354,7 @@ void UpdateConf(int pad)
#ifdef EXPERAMENTAL_POV_CODE
{
tmp.resize(28);
switch(PAD_GETPOVSIGN(conf.keys[pad][i]))
switch(PAD_GETPOVDIR(conf.keys[pad][i]))
{
case SDL_HAT_UP:
sprintf(&tmp[0], "JPOVU-%d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]));

View File

@ -128,4 +128,35 @@ namespace Analog
PAD_LOG("Setting pad[%d]@%d to %d from %d\n", padvalue, i, value, temp);
}
int AnalogToPad(int padvalue)
{
switch (padvalue)
{
case PAD_R_LEFT:
return PAD_RX;
break;
case PAD_R_UP:
return PAD_RY;
break;
case PAD_L_LEFT:
return PAD_LX;
break;
case PAD_L_UP:
return PAD_LY;
break;
case PAD_R_DOWN:
return PAD_RY;
break;
case PAD_R_RIGHT:
return PAD_RX;
break;
case PAD_L_DOWN:
return PAD_LY;
break;
case PAD_L_RIGHT:
return PAD_LX;
break;
}
return 0;
}
}

View File

@ -29,4 +29,5 @@
extern void ResetPad(int padvalue, u8 i);
extern void ConfigurePad(int padvalue, u8 i, int value);
extern int KeypadToPad(u8 keypress);
extern int AnalogToPad(int padvalue);
}

View File

@ -65,6 +65,7 @@ extern char libraryName[256];
#define PAD_JOYSTICK(joyid, axisid) (0x20000 | ((joyid) << 12) | (axisid))
#define PAD_POV(joyid, sign, axisid) (0x30000 | ((joyid) << 12) | ((sign) << 8) | (axisid))
#define PAD_GETPOVSIGN(key) (((key) & 0x100) >> 8)
#define PAD_GETPOVDIR(key) (((key) & ~ 0x30000) >> 8)
#ifdef __LINUX__
#define PADKEYS 28