Zeropad: All around my hat...

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1249 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-05-23 23:07:53 +00:00
parent f1be4728ba
commit 20f0e52a1a
7 changed files with 119 additions and 102 deletions

View File

@ -9,6 +9,15 @@
#include "support.h" #include "support.h"
void
OnAbout_Ok (GtkDialog *dialog,
gint response_id,
gpointer user_data)
{
}
void void
OnConf_Pad1 (GtkButton *button, OnConf_Pad1 (GtkButton *button,
gpointer user_data) gpointer user_data)
@ -57,6 +66,30 @@ OnConf_Key (GtkButton *button,
} }
void
on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_forcefeedback_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void void
on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton,
gpointer user_data) gpointer user_data)
@ -74,23 +107,7 @@ on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton,
void void
on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, OnConf_Ok (GtkButton *button,
gpointer user_data)
{
}
void
on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_forcefeedback_toggled (GtkToggleButton *togglebutton,
gpointer user_data) gpointer user_data)
{ {
@ -104,20 +121,3 @@ OnConf_Cancel (GtkButton *button,
} }
void
OnConf_Ok (GtkButton *button,
gpointer user_data)
{
}
void
OnAbout_Ok (GtkDialog *dialog,
gint response_id,
gpointer user_data)
{
}

View File

@ -1,6 +1,11 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
void
OnAbout_Ok (GtkDialog *dialog,
gint response_id,
gpointer user_data);
void void
OnConf_Pad1 (GtkButton *button, OnConf_Pad1 (GtkButton *button,
gpointer user_data); gpointer user_data);
@ -25,6 +30,18 @@ void
OnConf_Key (GtkButton *button, OnConf_Key (GtkButton *button,
gpointer user_data); gpointer user_data);
void
on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_forcefeedback_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void void
on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton,
gpointer user_data); gpointer user_data);
@ -34,26 +51,9 @@ on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton,
gpointer user_data); gpointer user_data);
void void
on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, OnConf_Ok (GtkButton *button,
gpointer user_data);
void
on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_forcefeedback_toggled (GtkToggleButton *togglebutton,
gpointer user_data); gpointer user_data);
void void
OnConf_Cancel (GtkButton *button, OnConf_Cancel (GtkButton *button,
gpointer user_data); gpointer user_data);
void
OnConf_Ok (GtkButton *button,
gpointer user_data);
void
OnAbout_Ok (GtkDialog *dialog,
gint response_id,
gpointer user_data);

View File

@ -145,8 +145,8 @@ create_Conf (void)
GtkWidget *Analog; GtkWidget *Analog;
GtkWidget *label6; GtkWidget *label6;
GtkWidget *dialog_action_area1; GtkWidget *dialog_action_area1;
GtkWidget *cancelbutton1;
GtkWidget *okbutton1; GtkWidget *okbutton1;
GtkWidget *cancelbutton1;
Conf = gtk_dialog_new (); Conf = gtk_dialog_new ();
gtk_widget_set_name (Conf, "Conf"); gtk_widget_set_name (Conf, "Conf");
@ -672,18 +672,18 @@ create_Conf (void)
gtk_widget_show (dialog_action_area1); gtk_widget_show (dialog_action_area1);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
gtk_widget_set_name (cancelbutton1, "cancelbutton1");
gtk_widget_show (cancelbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (Conf), cancelbutton1, GTK_RESPONSE_CANCEL);
GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
okbutton1 = gtk_button_new_from_stock ("gtk-ok"); okbutton1 = gtk_button_new_from_stock ("gtk-ok");
gtk_widget_set_name (okbutton1, "okbutton1"); gtk_widget_set_name (okbutton1, "okbutton1");
gtk_widget_show (okbutton1); gtk_widget_show (okbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (Conf), okbutton1, GTK_RESPONSE_OK); gtk_dialog_add_action_widget (GTK_DIALOG (Conf), okbutton1, GTK_RESPONSE_OK);
GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
gtk_widget_set_name (cancelbutton1, "cancelbutton1");
gtk_widget_show (cancelbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (Conf), cancelbutton1, GTK_RESPONSE_CANCEL);
GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
g_signal_connect ((gpointer) PAD1, "clicked", g_signal_connect ((gpointer) PAD1, "clicked",
G_CALLBACK (OnConf_Pad1), G_CALLBACK (OnConf_Pad1),
NULL); NULL);
@ -801,12 +801,12 @@ create_Conf (void)
g_signal_connect ((gpointer) Analog, "clicked", g_signal_connect ((gpointer) Analog, "clicked",
G_CALLBACK (OnConf_Key), G_CALLBACK (OnConf_Key),
NULL); NULL);
g_signal_connect ((gpointer) cancelbutton1, "clicked",
G_CALLBACK (OnConf_Cancel),
NULL);
g_signal_connect ((gpointer) okbutton1, "clicked", g_signal_connect ((gpointer) okbutton1, "clicked",
G_CALLBACK (OnConf_Ok), G_CALLBACK (OnConf_Ok),
NULL); NULL);
g_signal_connect ((gpointer) cancelbutton1, "clicked",
G_CALLBACK (OnConf_Cancel),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */ /* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (Conf, Conf, "Conf"); GLADE_HOOKUP_OBJECT_NO_REF (Conf, Conf, "Conf");
@ -890,8 +890,8 @@ create_Conf (void)
GLADE_HOOKUP_OBJECT (Conf, Analog, "Analog"); GLADE_HOOKUP_OBJECT (Conf, Analog, "Analog");
GLADE_HOOKUP_OBJECT (Conf, label6, "label6"); GLADE_HOOKUP_OBJECT (Conf, label6, "label6");
GLADE_HOOKUP_OBJECT_NO_REF (Conf, dialog_action_area1, "dialog_action_area1"); GLADE_HOOKUP_OBJECT_NO_REF (Conf, dialog_action_area1, "dialog_action_area1");
GLADE_HOOKUP_OBJECT (Conf, cancelbutton1, "cancelbutton1");
GLADE_HOOKUP_OBJECT (Conf, okbutton1, "okbutton1"); GLADE_HOOKUP_OBJECT (Conf, okbutton1, "okbutton1");
GLADE_HOOKUP_OBJECT (Conf, cancelbutton1, "cancelbutton1");
return Conf; return Conf;
} }

View File

@ -120,7 +120,8 @@ void CALLBACK PADupdate(int pad)
key = XLookupKeysym((XKeyEvent *) & E, 0); key = XLookupKeysym((XKeyEvent *) & E, 0);
i = FindKey(key, pad); i = FindKey(key, pad);
#ifdef ANALOG_CONTROLS_HACK
// Analog controls.
if ((i > PAD_RY) && (i <= PAD_R_LEFT)) if ((i > PAD_RY) && (i <= PAD_R_LEFT))
{ {
switch (i) switch (i)
@ -140,7 +141,7 @@ void CALLBACK PADupdate(int pad)
} }
i += 0xff00; i += 0xff00;
} }
#endif
if (i != -1) if (i != -1)
{ {
clear_bit(keyRelease, i); clear_bit(keyRelease, i);
@ -156,14 +157,14 @@ void CALLBACK PADupdate(int pad)
key = XLookupKeysym((XKeyEvent *) & E, 0); key = XLookupKeysym((XKeyEvent *) & E, 0);
i = FindKey(key, pad); i = FindKey(key, pad);
#ifdef ANALOG_CONTROLS_HACK
// Analog Controls.
if ((i > PAD_RY) && (i <= PAD_R_LEFT)) if ((i > PAD_RY) && (i <= PAD_R_LEFT))
{ {
Analog::ResetPad(Analog::AnalogToPad(i), pad); Analog::ResetPad(Analog::AnalogToPad(i), pad);
i += 0xff00; i += 0xff00;
} }
#endif
if (i != -1) if (i != -1)
{ {
clear_bit(keyPress, i); clear_bit(keyPress, i);
@ -260,39 +261,57 @@ void CALLBACK PADupdate(int pad)
int value = SDL_JoystickGetHat((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key)); int value = SDL_JoystickGetHat((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
int pad = (pjoy)->GetPAD(); int pad = (pjoy)->GetPAD();
int temp;
//PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVDIR(key), key); //PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVDIR(key), key);
if (value != SDL_HAT_CENTERED) if ((value != SDL_HAT_CENTERED) && (PAD_GETHATDIR(key) == value))
{ {
if (PAD_GETHATDIR(key) == value) if ((value == SDL_HAT_UP) || (value == SDL_HAT_RIGHT) || (value == SDL_HAT_DOWN) ||(value == SDL_HAT_LEFT))
{
set_bit(status[pad], i); set_bit(status[pad], i);
}
else else
{
clear_bit(status[pad], i); clear_bit(status[pad], i);
}
switch (i)
{
case PAD_LEFT:
PAD_LOG("Hat Left!\n");
break;
case PAD_DOWN:
PAD_LOG("Hat Down!\n");
break;
case PAD_RIGHT:
PAD_LOG("Hat Right!\n");
break;
case PAD_UP:
PAD_LOG("Hat Up!\n");
break;
}
switch (value) switch (value)
{ {
case SDL_HAT_UP: case SDL_HAT_UP:
PAD_LOG("Up!\n"); PAD_LOG("D-pad Up!\n");
break; break;
case SDL_HAT_RIGHT: case SDL_HAT_RIGHT:
PAD_LOG("Right!\n"); PAD_LOG("D-pad Right!\n");
break; break;
case SDL_HAT_DOWN: case SDL_HAT_DOWN:
PAD_LOG("Down!\n"); PAD_LOG("D-pad Down!\n");
break; break;
case SDL_HAT_LEFT: case SDL_HAT_LEFT:
PAD_LOG("Left!\n"); PAD_LOG("D-pad Left!\n");
break; break;
} }
} }
/*else else
{ {
clear_bit(status[pad], i); clear_bit(status[pad], i);
}*/ }
} }
} }
#endif #endif
@ -342,8 +361,8 @@ void UpdateConf(int pad)
tmp.resize(28); tmp.resize(28);
sprintf(&tmp[0], "JAxis %d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i])); sprintf(&tmp[0], "JAxis %d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]));
} }
else if (IS_POV(conf.keys[pad][i]))
#ifdef EXPERIMENTAL_POV_CODE #ifdef EXPERIMENTAL_POV_CODE
else if (IS_HAT(conf.keys[pad][i]))
{ {
tmp.resize(28); tmp.resize(28);
switch(PAD_GETHATDIR(conf.keys[pad][i])) switch(PAD_GETHATDIR(conf.keys[pad][i]))
@ -366,6 +385,7 @@ void UpdateConf(int pad)
} }
} }
#else #else
else if (IS_POV(conf.keys[pad][i]))
{ {
tmp.resize(28); tmp.resize(28);
sprintf(&tmp[0], "JPOV %d%s", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]), PAD_GETPOVSIGN(conf.keys[pad][i]) ? "-" : "+"); sprintf(&tmp[0], "JPOV %d%s", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]), PAD_GETPOVSIGN(conf.keys[pad][i]) ? "-" : "+");
@ -515,8 +535,8 @@ bool PollAxes(vector<JoystickInfo*>::iterator itjoy, bool pov, int &jbutton, boo
if (pov) if (pov)
{ {
*pkey = PAD_POV((*itjoy)->GetId(), value < 0, i);
negative = (value < 0); negative = (value < 0);
*pkey = PAD_POV((*itjoy)->GetId(), negative, i);
} }
else // axis else // axis
{ {
@ -535,7 +555,7 @@ SDL_HAT_DOWN, SDL_HAT_LEFT,
SDL_HAT_RIGHTUP, SDL_HAT_RIGHTDOWN, SDL_HAT_RIGHTUP, SDL_HAT_RIGHTDOWN,
SDL_HAT_LEFTUP, SDL_HAT_LEFTDOWN*/ SDL_HAT_LEFTUP, SDL_HAT_LEFTDOWN*/
bool PollPOV(vector<JoystickInfo*>::iterator itjoy, int &jbutton, int &dir, u32* &pkey) bool PollHAT(vector<JoystickInfo*>::iterator itjoy, int &jbutton, int &dir, u32* &pkey)
{ {
#ifdef EXPERIMENTAL_POV_CODE #ifdef EXPERIMENTAL_POV_CODE
for (int i = 0; i < (*itjoy)->GetNumPOV(); ++i) for (int i = 0; i < (*itjoy)->GetNumPOV(); ++i)
@ -628,7 +648,7 @@ void OnConf_Key(GtkButton *button, gpointer user_data)
} }
#ifdef EXPERIMENTAL_POV_CODE #ifdef EXPERIMENTAL_POV_CODE
if (PollPOV(itjoy, jbutton, direction, pkey)) if (PollHAT(itjoy, jbutton, direction, pkey))
{ {
char str[32]; char str[32];

View File

@ -46,20 +46,6 @@ and SSSPSXPad, TwinPad authors</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="OnConf_Cancel" last_modification_time="Sat, 31 Mar 2007 21:49:12 GMT"/>
</widget>
</child>
<child> <child>
<widget class="GtkButton" id="okbutton1"> <widget class="GtkButton" id="okbutton1">
<property name="visible">True</property> <property name="visible">True</property>
@ -70,7 +56,21 @@ and SSSPSXPad, TwinPad authors</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<property name="response_id">-5</property> <property name="response_id">-5</property>
<signal name="clicked" handler="OnConf_Ok" last_modification_time="Sat, 31 Mar 2007 21:49:21 GMT"/> <signal name="clicked" handler="OnConf_Ok" last_modification_time="Sat, 23 May 2009 23:05:00 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="OnConf_Cancel" last_modification_time="Sat, 23 May 2009 23:04:50 GMT"/>
</widget> </widget>
</child> </child>
</widget> </widget>

View File

@ -309,7 +309,7 @@ void PADsetMode(int pad, int mode)
u8 CALLBACK PADstartPoll(int pad) u8 CALLBACK PADstartPoll(int pad)
{ {
PAD_LOG("PADstartPoll: %d\n", pad); //PAD_LOG("PADstartPoll: %d\n", pad);
curPad = pad - 1; curPad = pad - 1;
curByte = 0; curByte = 0;
@ -325,7 +325,7 @@ u8 _PADpoll(u8 value)
{ {
curByte++; curByte++;
PAD_LOG("PADpoll: cmd: %x\n", value); //PAD_LOG("PADpoll: cmd: %x\n", value);
curCmd = value; curCmd = value;
switch (value) switch (value)
@ -541,7 +541,7 @@ u8 CALLBACK PADpoll(u8 value)
u8 ret; u8 ret;
ret = _PADpoll(value); ret = _PADpoll(value);
PAD_LOG("PADpoll: %x (%d: %x)\n", value, curByte, ret); //PAD_LOG("PADpoll: %x (%d: %x)\n", value, curByte, ret);
return ret; return ret;
} }

View File

@ -156,14 +156,11 @@ enum gamePadValues
PAD_L2 = 0 PAD_L2 = 0
}; };
// Activate bolche's analog contols hack // Activate bolche's analog controls hack
#define ANALOG_CONTROLS_HACK
// DEF_VALUE is the strength you press the control. // DEF_VALUE is the strength you press the control.
// Code taken from http://forums.pcsx2.net/thread-4699.html // Code taken from http://forums.pcsx2.net/thread-4699.html
#ifdef ANALOG_CONTROLS_HACK
#define DEF_VALUE 32766 #define DEF_VALUE 32766
#endif
/* end of pad.h */ /* end of pad.h */