From 20f0e52a1a9af448eb8adf78662daf74156cfa07 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 23 May 2009 23:07:53 +0000 Subject: [PATCH] Zeropad: All around my hat... git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1249 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zeropad/Linux/callbacks.c | 68 ++++++++++++++--------------- plugins/zeropad/Linux/callbacks.h | 36 +++++++-------- plugins/zeropad/Linux/interface.c | 22 +++++----- plugins/zeropad/Linux/linux.cpp | 54 +++++++++++++++-------- plugins/zeropad/Linux/zeropad.glade | 30 ++++++------- plugins/zeropad/zeropad.cpp | 6 +-- plugins/zeropad/zeropad.h | 5 +-- 7 files changed, 119 insertions(+), 102 deletions(-) diff --git a/plugins/zeropad/Linux/callbacks.c b/plugins/zeropad/Linux/callbacks.c index cb65ceeb21..81945c91cb 100644 --- a/plugins/zeropad/Linux/callbacks.c +++ b/plugins/zeropad/Linux/callbacks.c @@ -9,6 +9,15 @@ #include "support.h" +void +OnAbout_Ok (GtkDialog *dialog, + gint response_id, + gpointer user_data) +{ + +} + + void OnConf_Pad1 (GtkButton *button, 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 on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, gpointer user_data) @@ -74,23 +107,7 @@ on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton, void -on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - -} - - -void -on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - -} - - -void -on_forcefeedback_toggled (GtkToggleButton *togglebutton, +OnConf_Ok (GtkButton *button, 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) -{ - -} - diff --git a/plugins/zeropad/Linux/callbacks.h b/plugins/zeropad/Linux/callbacks.h index 3e57b0e5d4..ff61cd234e 100644 --- a/plugins/zeropad/Linux/callbacks.h +++ b/plugins/zeropad/Linux/callbacks.h @@ -1,6 +1,11 @@ #include +void +OnAbout_Ok (GtkDialog *dialog, + gint response_id, + gpointer user_data); + void OnConf_Pad1 (GtkButton *button, gpointer user_data); @@ -25,6 +30,18 @@ void OnConf_Key (GtkButton *button, 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 on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, gpointer user_data); @@ -34,26 +51,9 @@ on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton, gpointer user_data); void -on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_forcefeedback_toggled (GtkToggleButton *togglebutton, +OnConf_Ok (GtkButton *button, gpointer user_data); void OnConf_Cancel (GtkButton *button, gpointer user_data); - -void -OnConf_Ok (GtkButton *button, - gpointer user_data); - -void -OnAbout_Ok (GtkDialog *dialog, - gint response_id, - gpointer user_data); diff --git a/plugins/zeropad/Linux/interface.c b/plugins/zeropad/Linux/interface.c index d8e669e802..dd5158b82c 100644 --- a/plugins/zeropad/Linux/interface.c +++ b/plugins/zeropad/Linux/interface.c @@ -145,8 +145,8 @@ create_Conf (void) GtkWidget *Analog; GtkWidget *label6; GtkWidget *dialog_action_area1; - GtkWidget *cancelbutton1; GtkWidget *okbutton1; + GtkWidget *cancelbutton1; Conf = gtk_dialog_new (); gtk_widget_set_name (Conf, "Conf"); @@ -672,18 +672,18 @@ create_Conf (void) gtk_widget_show (dialog_action_area1); 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"); gtk_widget_set_name (okbutton1, "okbutton1"); gtk_widget_show (okbutton1); gtk_dialog_add_action_widget (GTK_DIALOG (Conf), okbutton1, GTK_RESPONSE_OK); 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_CALLBACK (OnConf_Pad1), NULL); @@ -801,12 +801,12 @@ create_Conf (void) g_signal_connect ((gpointer) Analog, "clicked", G_CALLBACK (OnConf_Key), NULL); - g_signal_connect ((gpointer) cancelbutton1, "clicked", - G_CALLBACK (OnConf_Cancel), - NULL); g_signal_connect ((gpointer) okbutton1, "clicked", G_CALLBACK (OnConf_Ok), NULL); + g_signal_connect ((gpointer) cancelbutton1, "clicked", + G_CALLBACK (OnConf_Cancel), + NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ 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, label6, "label6"); 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, cancelbutton1, "cancelbutton1"); return Conf; } diff --git a/plugins/zeropad/Linux/linux.cpp b/plugins/zeropad/Linux/linux.cpp index 32d3583137..8378fe5295 100644 --- a/plugins/zeropad/Linux/linux.cpp +++ b/plugins/zeropad/Linux/linux.cpp @@ -120,7 +120,8 @@ void CALLBACK PADupdate(int pad) key = XLookupKeysym((XKeyEvent *) & E, 0); i = FindKey(key, pad); -#ifdef ANALOG_CONTROLS_HACK + + // Analog controls. if ((i > PAD_RY) && (i <= PAD_R_LEFT)) { switch (i) @@ -140,7 +141,7 @@ void CALLBACK PADupdate(int pad) } i += 0xff00; } -#endif + if (i != -1) { clear_bit(keyRelease, i); @@ -156,14 +157,14 @@ void CALLBACK PADupdate(int pad) key = XLookupKeysym((XKeyEvent *) & E, 0); i = FindKey(key, pad); -#ifdef ANALOG_CONTROLS_HACK + // Analog Controls. if ((i > PAD_RY) && (i <= PAD_R_LEFT)) { Analog::ResetPad(Analog::AnalogToPad(i), pad); i += 0xff00; } -#endif + if (i != -1) { clear_bit(keyPress, i); @@ -260,39 +261,57 @@ 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_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); + } else + { 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) { case SDL_HAT_UP: - PAD_LOG("Up!\n"); + PAD_LOG("D-pad Up!\n"); break; case SDL_HAT_RIGHT: - PAD_LOG("Right!\n"); + PAD_LOG("D-pad Right!\n"); break; case SDL_HAT_DOWN: - PAD_LOG("Down!\n"); + PAD_LOG("D-pad Down!\n"); break; case SDL_HAT_LEFT: - PAD_LOG("Left!\n"); + PAD_LOG("D-pad Left!\n"); break; } } - /*else + else { clear_bit(status[pad], i); - }*/ + } } } #endif @@ -342,8 +361,8 @@ void UpdateConf(int pad) tmp.resize(28); sprintf(&tmp[0], "JAxis %d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i])); } - else if (IS_POV(conf.keys[pad][i])) #ifdef EXPERIMENTAL_POV_CODE + else if (IS_HAT(conf.keys[pad][i])) { tmp.resize(28); switch(PAD_GETHATDIR(conf.keys[pad][i])) @@ -366,6 +385,7 @@ void UpdateConf(int pad) } } #else + else if (IS_POV(conf.keys[pad][i])) { tmp.resize(28); 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::iterator itjoy, bool pov, int &jbutton, boo if (pov) { - *pkey = PAD_POV((*itjoy)->GetId(), value < 0, i); negative = (value < 0); + *pkey = PAD_POV((*itjoy)->GetId(), negative, i); } else // axis { @@ -535,7 +555,7 @@ SDL_HAT_DOWN, SDL_HAT_LEFT, SDL_HAT_RIGHTUP, SDL_HAT_RIGHTDOWN, SDL_HAT_LEFTUP, SDL_HAT_LEFTDOWN*/ -bool PollPOV(vector::iterator itjoy, int &jbutton, int &dir, u32* &pkey) +bool PollHAT(vector::iterator itjoy, int &jbutton, int &dir, u32* &pkey) { #ifdef EXPERIMENTAL_POV_CODE for (int i = 0; i < (*itjoy)->GetNumPOV(); ++i) @@ -628,7 +648,7 @@ void OnConf_Key(GtkButton *button, gpointer user_data) } #ifdef EXPERIMENTAL_POV_CODE - if (PollPOV(itjoy, jbutton, direction, pkey)) + if (PollHAT(itjoy, jbutton, direction, pkey)) { char str[32]; diff --git a/plugins/zeropad/Linux/zeropad.glade b/plugins/zeropad/Linux/zeropad.glade index ef754e23a4..7c33fea000 100644 --- a/plugins/zeropad/Linux/zeropad.glade +++ b/plugins/zeropad/Linux/zeropad.glade @@ -46,20 +46,6 @@ and SSSPSXPad, TwinPad authors True GTK_BUTTONBOX_END - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - True @@ -70,7 +56,21 @@ and SSSPSXPad, TwinPad authors GTK_RELIEF_NORMAL True -5 - + + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + diff --git a/plugins/zeropad/zeropad.cpp b/plugins/zeropad/zeropad.cpp index b67549fc54..13582dfe27 100644 --- a/plugins/zeropad/zeropad.cpp +++ b/plugins/zeropad/zeropad.cpp @@ -309,7 +309,7 @@ void PADsetMode(int pad, int mode) u8 CALLBACK PADstartPoll(int pad) { - PAD_LOG("PADstartPoll: %d\n", pad); + //PAD_LOG("PADstartPoll: %d\n", pad); curPad = pad - 1; curByte = 0; @@ -325,7 +325,7 @@ u8 _PADpoll(u8 value) { curByte++; - PAD_LOG("PADpoll: cmd: %x\n", value); + //PAD_LOG("PADpoll: cmd: %x\n", value); curCmd = value; switch (value) @@ -541,7 +541,7 @@ u8 CALLBACK PADpoll(u8 value) u8 ret; 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; } diff --git a/plugins/zeropad/zeropad.h b/plugins/zeropad/zeropad.h index d6c5d2ba98..8e3127b1f0 100644 --- a/plugins/zeropad/zeropad.h +++ b/plugins/zeropad/zeropad.h @@ -156,14 +156,11 @@ enum gamePadValues PAD_L2 = 0 }; -// Activate bolche's analog contols hack -#define ANALOG_CONTROLS_HACK +// Activate bolche's analog controls hack // DEF_VALUE is the strength you press the control. // Code taken from http://forums.pcsx2.net/thread-4699.html -#ifdef ANALOG_CONTROLS_HACK #define DEF_VALUE 32766 -#endif /* end of pad.h */