From cae05180f5c45f7582740866f5e38b2a3887cf78 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 10 Jul 2009 00:05:05 +0000 Subject: [PATCH] Onepad: Added a clear all button, and did some work on the backend. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1481 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/onepad/Linux/callbacks.c | 44 ++++---- plugins/onepad/Linux/callbacks.h | 24 +++-- plugins/onepad/Linux/gui.cpp | 6 ++ plugins/onepad/Linux/interface.c | 59 +++++----- plugins/onepad/Linux/linux.cpp | 48 ++++----- .../Linux/{openpad.glade => onepad.glade} | 102 ++++++++++-------- .../Linux/{openpad.gladep => onepad.gladep} | 0 plugins/onepad/controller.cpp | 30 +++--- plugins/onepad/controller.h | 17 ++- plugins/onepad/joystick.cpp | 10 +- plugins/onepad/onepad.cpp | 11 ++ plugins/onepad/onepad.h | 1 + 12 files changed, 206 insertions(+), 146 deletions(-) rename plugins/onepad/Linux/{openpad.glade => onepad.glade} (98%) rename plugins/onepad/Linux/{openpad.gladep => onepad.gladep} (100%) diff --git a/plugins/onepad/Linux/callbacks.c b/plugins/onepad/Linux/callbacks.c index 6e4d979f59..c6a117566c 100644 --- a/plugins/onepad/Linux/callbacks.c +++ b/plugins/onepad/Linux/callbacks.c @@ -67,15 +67,7 @@ OnConf_Key (GtkButton *button, void -on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - -} - - -void -on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, +on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, gpointer user_data) { @@ -91,7 +83,15 @@ on_forcefeedback_toggled (GtkToggleButton *togglebutton, void -on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, +on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + +} + + +void +on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton, gpointer user_data) { @@ -106,6 +106,22 @@ on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton, } +void +on_Remove (GtkButton *button, + gpointer user_data) +{ + +} + + +void +on_Clear (GtkButton *button, + gpointer user_data) +{ + +} + + void OnConf_Ok (GtkButton *button, gpointer user_data) @@ -121,11 +137,3 @@ OnConf_Cancel (GtkButton *button, } - -void -on_Remove (GtkButton *button, - gpointer user_data) -{ - -} - diff --git a/plugins/onepad/Linux/callbacks.h b/plugins/onepad/Linux/callbacks.h index 1194f3ba9b..8aa6f6261f 100644 --- a/plugins/onepad/Linux/callbacks.h +++ b/plugins/onepad/Linux/callbacks.h @@ -31,11 +31,7 @@ OnConf_Key (GtkButton *button, gpointer user_data); void -on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, +on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, gpointer user_data); void @@ -43,13 +39,25 @@ on_forcefeedback_toggled (GtkToggleButton *togglebutton, gpointer user_data); void -on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton, +on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + +void +on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton, gpointer user_data); void on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton, gpointer user_data); +void +on_Remove (GtkButton *button, + gpointer user_data); + +void +on_Clear (GtkButton *button, + gpointer user_data); + void OnConf_Ok (GtkButton *button, gpointer user_data); @@ -57,7 +65,3 @@ OnConf_Ok (GtkButton *button, void OnConf_Cancel (GtkButton *button, gpointer user_data); - -void -on_Remove (GtkButton *button, - gpointer user_data); diff --git a/plugins/onepad/Linux/gui.cpp b/plugins/onepad/Linux/gui.cpp index 769f493f79..ceb2dc5572 100644 --- a/plugins/onepad/Linux/gui.cpp +++ b/plugins/onepad/Linux/gui.cpp @@ -360,6 +360,12 @@ void SysMessage(char *fmt, ...) gtk_main(); } +void on_Clear(GtkButton *button, gpointer user_data) +{ + clearPAD(); + init_tree_view(); +} + void on_Remove(GtkButton *button, gpointer user_data) { GtkTreeSelection *selection; diff --git a/plugins/onepad/Linux/interface.c b/plugins/onepad/Linux/interface.c index 520bb9c60a..d568a76ba0 100644 --- a/plugins/onepad/Linux/interface.c +++ b/plugins/onepad/Linux/interface.c @@ -104,14 +104,12 @@ create_Conf (void) GtkWidget *R1; GtkWidget *label3; GtkWidget *label6; - GtkWidget *L_Up; GtkWidget *L_Left; GtkWidget *Lx; GtkWidget *Ly; GtkWidget *L_Down; GtkWidget *L_Right; GtkWidget *checkbutton_reverselx; - GtkWidget *checkbutton_reversely; GtkWidget *R_Up; GtkWidget *R_Left; GtkWidget *Rx; @@ -126,6 +124,9 @@ create_Conf (void) GtkWidget *scrolledwindow2; GtkWidget *padtreeview; GtkWidget *label7; + GtkWidget *checkbutton_reversely; + GtkWidget *L_Up; + GtkWidget *clear_button; GtkWidget *remove_button; GtkWidget *dialog_action_area1; GtkWidget *okbutton1; @@ -355,12 +356,6 @@ create_Conf (void) gtk_label_set_justify (GTK_LABEL (label6), GTK_JUSTIFY_CENTER); gtk_label_set_line_wrap (GTK_LABEL (label6), TRUE); - L_Up = gtk_button_new_with_mnemonic (_("Up")); - gtk_widget_set_name (L_Up, "L_Up"); - gtk_widget_show (L_Up); - gtk_fixed_put (GTK_FIXED (fixed1), L_Up, 384, 240); - gtk_widget_set_size_request (L_Up, 64, 24); - L_Left = gtk_button_new_with_mnemonic (_("Left")); gtk_widget_set_name (L_Left, "L_Left"); gtk_widget_show (L_Left); @@ -397,12 +392,6 @@ create_Conf (void) gtk_fixed_put (GTK_FIXED (fixed1), checkbutton_reverselx, 360, 344); gtk_widget_set_size_request (checkbutton_reverselx, 111, 22); - checkbutton_reversely = gtk_check_button_new_with_mnemonic (_("Reverse LY")); - gtk_widget_set_name (checkbutton_reversely, "checkbutton_reversely"); - gtk_widget_show (checkbutton_reversely); - gtk_fixed_put (GTK_FIXED (fixed1), checkbutton_reversely, 360, 368); - gtk_widget_set_size_request (checkbutton_reversely, 111, 22); - R_Up = gtk_button_new_with_mnemonic (_("Up")); gtk_widget_set_name (R_Up, "R_Up"); gtk_widget_show (R_Up); @@ -489,11 +478,29 @@ create_Conf (void) gtk_widget_show (label7); gtk_frame_set_label_widget (GTK_FRAME (frame2), label7); + checkbutton_reversely = gtk_check_button_new_with_mnemonic (_("Reverse LY")); + gtk_widget_set_name (checkbutton_reversely, "checkbutton_reversely"); + gtk_widget_show (checkbutton_reversely); + gtk_fixed_put (GTK_FIXED (fixed1), checkbutton_reversely, 360, 368); + gtk_widget_set_size_request (checkbutton_reversely, 111, 22); + + L_Up = gtk_button_new_with_mnemonic (_("Up")); + gtk_widget_set_name (L_Up, "L_Up"); + gtk_widget_show (L_Up); + gtk_fixed_put (GTK_FIXED (fixed1), L_Up, 384, 240); + gtk_widget_set_size_request (L_Up, 64, 24); + + clear_button = gtk_button_new_with_mnemonic (_("Clear All")); + gtk_widget_set_name (clear_button, "clear_button"); + gtk_widget_show (clear_button); + gtk_fixed_put (GTK_FIXED (fixed1), clear_button, 168, 352); + gtk_widget_set_size_request (clear_button, 70, 24); + remove_button = gtk_button_new_with_mnemonic (_("Remove")); gtk_widget_set_name (remove_button, "remove_button"); gtk_widget_show (remove_button); - gtk_fixed_put (GTK_FIXED (fixed1), remove_button, 248, 352); - gtk_widget_set_size_request (remove_button, 0, 0); + gtk_fixed_put (GTK_FIXED (fixed1), remove_button, 240, 352); + gtk_widget_set_size_request (remove_button, 70, 24); dialog_action_area1 = GTK_DIALOG (Conf)->action_area; gtk_widget_set_name (dialog_action_area1, "dialog_action_area1"); @@ -578,9 +585,6 @@ create_Conf (void) g_signal_connect ((gpointer) R1, "clicked", G_CALLBACK (OnConf_Key), NULL); - g_signal_connect ((gpointer) L_Up, "clicked", - G_CALLBACK (OnConf_Key), - NULL); g_signal_connect ((gpointer) L_Left, "clicked", G_CALLBACK (OnConf_Key), NULL); @@ -599,9 +603,6 @@ create_Conf (void) g_signal_connect ((gpointer) checkbutton_reverselx, "toggled", G_CALLBACK (on_checkbutton_reverselx_toggled), NULL); - g_signal_connect ((gpointer) checkbutton_reversely, "toggled", - G_CALLBACK (on_checkbutton_reversely_toggled), - NULL); g_signal_connect ((gpointer) R_Up, "clicked", G_CALLBACK (OnConf_Key), NULL); @@ -629,6 +630,15 @@ create_Conf (void) g_signal_connect ((gpointer) checkbutton_reversery, "toggled", G_CALLBACK (on_checkbutton_reversery_toggled), NULL); + g_signal_connect ((gpointer) checkbutton_reversely, "toggled", + G_CALLBACK (on_checkbutton_reversely_toggled), + NULL); + g_signal_connect ((gpointer) L_Up, "clicked", + G_CALLBACK (OnConf_Key), + NULL); + g_signal_connect ((gpointer) clear_button, "clicked", + G_CALLBACK (on_Clear), + NULL); g_signal_connect ((gpointer) remove_button, "clicked", G_CALLBACK (on_Remove), NULL); @@ -678,14 +688,12 @@ create_Conf (void) GLADE_HOOKUP_OBJECT (Conf, R1, "R1"); GLADE_HOOKUP_OBJECT (Conf, label3, "label3"); GLADE_HOOKUP_OBJECT (Conf, label6, "label6"); - GLADE_HOOKUP_OBJECT (Conf, L_Up, "L_Up"); GLADE_HOOKUP_OBJECT (Conf, L_Left, "L_Left"); GLADE_HOOKUP_OBJECT (Conf, Lx, "Lx"); GLADE_HOOKUP_OBJECT (Conf, Ly, "Ly"); GLADE_HOOKUP_OBJECT (Conf, L_Down, "L_Down"); GLADE_HOOKUP_OBJECT (Conf, L_Right, "L_Right"); GLADE_HOOKUP_OBJECT (Conf, checkbutton_reverselx, "checkbutton_reverselx"); - GLADE_HOOKUP_OBJECT (Conf, checkbutton_reversely, "checkbutton_reversely"); GLADE_HOOKUP_OBJECT (Conf, R_Up, "R_Up"); GLADE_HOOKUP_OBJECT (Conf, R_Left, "R_Left"); GLADE_HOOKUP_OBJECT (Conf, Rx, "Rx"); @@ -700,6 +708,9 @@ create_Conf (void) GLADE_HOOKUP_OBJECT (Conf, scrolledwindow2, "scrolledwindow2"); GLADE_HOOKUP_OBJECT (Conf, padtreeview, "padtreeview"); GLADE_HOOKUP_OBJECT (Conf, label7, "label7"); + GLADE_HOOKUP_OBJECT (Conf, checkbutton_reversely, "checkbutton_reversely"); + GLADE_HOOKUP_OBJECT (Conf, L_Up, "L_Up"); + GLADE_HOOKUP_OBJECT (Conf, clear_button, "clear_button"); GLADE_HOOKUP_OBJECT (Conf, remove_button, "remove_button"); GLADE_HOOKUP_OBJECT_NO_REF (Conf, dialog_action_area1, "dialog_action_area1"); GLADE_HOOKUP_OBJECT (Conf, okbutton1, "okbutton1"); diff --git a/plugins/onepad/Linux/linux.cpp b/plugins/onepad/Linux/linux.cpp index d7928bd4f5..365045498e 100644 --- a/plugins/onepad/Linux/linux.cpp +++ b/plugins/onepad/Linux/linux.cpp @@ -67,12 +67,11 @@ int _GetJoystickIdFromPAD(int pad) { for (int i = 0; i < PADKEYS; ++i) { - u32 temp = get_key(PadEnum[pad][p],i); - KeyType k = type_of_key(temp); + KeyType k = type_of_key(PadEnum[pad][p],i); if (k == PAD_JOYSTICK || k == PAD_JOYBUTTONS) { - joyid = key_to_joystick_id(temp); + joyid = key_to_joystick_id(PadEnum[pad][p],i); return joyid; } } @@ -100,19 +99,18 @@ EXPORT_C_(void) PADupdate(int pad) for (int i = 0; i < PADKEYS; i++) { - int key = get_key(PadEnum[pad][0], i); + int cpad = PadEnum[pad][0]; - if (JoystickIdWithinBounds(key_to_joystick_id(key))) + if (JoystickIdWithinBounds(key_to_joystick_id(cpad, i))) { - JoystickInfo* pjoy = s_vjoysticks[key_to_joystick_id(key)]; + JoystickInfo* pjoy = s_vjoysticks[key_to_joystick_id(cpad, i)]; int pad = (pjoy)->GetPAD(); - KeyType k = type_of_key(key); - switch (k) + switch (type_of_key(cpad, i)) { case PAD_JOYBUTTONS: { - int value = SDL_JoystickGetButton((pjoy)->GetJoy(), key_to_button(key)); + int value = SDL_JoystickGetButton((pjoy)->GetJoy(), key_to_button(cpad, i)); if (value) clear_bit(status[pad], i); // released @@ -122,7 +120,7 @@ EXPORT_C_(void) PADupdate(int pad) } case PAD_JOYSTICK: { - int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), key_to_axis(key)); + int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), key_to_axis(cpad, i)); switch (i) { @@ -141,12 +139,14 @@ EXPORT_C_(void) PADupdate(int pad) #ifdef EXPERIMENTAL_POV_CODE case PAD_HAT: { - int value = SDL_JoystickGetHat((pjoy)->GetJoy(), key_to_axis(key)); + int value = SDL_JoystickGetHat((pjoy)->GetJoy(), key_to_axis(cpad, i)); - //PAD_LOG("Hat = %d for key %d\n", key_to_hat_dir(key), key); - if ((value != SDL_HAT_CENTERED) && (key_to_hat_dir(key) == value)) + if ((value != SDL_HAT_CENTERED) && (key_to_hat_dir(cpad, i) == value)) { - if ((value == SDL_HAT_UP) || (value == SDL_HAT_RIGHT) || (value == SDL_HAT_DOWN) ||(value == SDL_HAT_LEFT)) + if ((value == SDL_HAT_UP) || + (value == SDL_HAT_RIGHT) || + (value == SDL_HAT_DOWN) || + (value == SDL_HAT_LEFT)) { set_bit(status[pad], i); PAD_LOG("Registered %s. Set (%d)\n", HatName(value), i); @@ -165,11 +165,11 @@ EXPORT_C_(void) PADupdate(int pad) #endif case PAD_POV: { - int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), key_to_axis(key)); + int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), key_to_axis(cpad, i)); - if (key_to_pov_sign(key) && (value < -2048)) + if (key_to_pov_sign(cpad, i) && (value < -2048)) clear_bit(status[pad], i); - else if (!key_to_pov_sign(key) && (value > 2048)) + else if (!key_to_pov_sign(cpad, i) && (value > 2048)) clear_bit(status[pad], i); else set_bit(status[pad], i); @@ -184,19 +184,19 @@ EXPORT_C_(void) PADupdate(int pad) string KeyName(int pad, int key) { string tmp; - KeyType k = type_of_key(get_key(pad, key)); + KeyType k = type_of_key(pad, key); switch (k) { case PAD_KEYBOARD: { - char* pstr = KeysymToChar(pad_to_key(get_key(pad, key))); + char* pstr = KeysymToChar(pad_to_key(pad, key)); if (pstr != NULL) tmp = pstr; break; } case PAD_JOYBUTTONS: { - int button = key_to_button(get_key(pad, key)); + int button = key_to_button(pad, key); tmp.resize(28); sprintf(&tmp[0], "JBut %d", button); @@ -204,7 +204,7 @@ string KeyName(int pad, int key) } case PAD_JOYSTICK: { - int axis = key_to_axis(get_key(pad, key)); + int axis = key_to_axis(pad, key); tmp.resize(28); sprintf(&tmp[0], "JAxis %d", axis); @@ -213,10 +213,10 @@ string KeyName(int pad, int key) #ifdef EXPERIMENTAL_POV_CODE case PAD_HAT: { - int axis = key_to_axis(get_key(pad, key)); + int axis = key_to_axis(pad, key); tmp.resize(28); - switch(key_to_hat_dir(get_key(pad, key))) + switch(key_to_hat_dir(pad, key)) { case SDL_HAT_UP: sprintf(&tmp[0], "JPOVU-%d", axis); @@ -240,7 +240,7 @@ string KeyName(int pad, int key) case PAD_POV: { tmp.resize(28); - sprintf(&tmp[0], "JPOV %d%s", key_to_axis(get_key(pad, key)), key_to_pov_sign(get_key(pad, key)) ? "-" : "+"); + sprintf(&tmp[0], "JPOV %d%s", key_to_axis(pad, key), key_to_pov_sign(pad, key) ? "-" : "+"); break; } default: break; diff --git a/plugins/onepad/Linux/openpad.glade b/plugins/onepad/Linux/onepad.glade similarity index 98% rename from plugins/onepad/Linux/openpad.glade rename to plugins/onepad/Linux/onepad.glade index d0e9014f78..2f3e526522 100644 --- a/plugins/onepad/Linux/openpad.glade +++ b/plugins/onepad/Linux/onepad.glade @@ -698,24 +698,6 @@ and SSSPSXPad, TwinPad authors - - - 64 - 24 - True - True - Up - True - GTK_RELIEF_NORMAL - True - - - - 384 - 240 - - - 64 @@ -827,27 +809,6 @@ and SSSPSXPad, TwinPad authors - - - 111 - 22 - True - True - Reverse LY - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 360 - 368 - - - 64 @@ -1098,10 +1059,67 @@ Feedback + + + 111 + 22 + True + True + Reverse LY + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 360 + 368 + + + + + + 64 + 24 + True + True + Up + True + GTK_RELIEF_NORMAL + True + + + + 384 + 240 + + + + + + 70 + 24 + True + True + Clear All + True + GTK_RELIEF_NORMAL + True + + + + 168 + 352 + + + - 0 - 0 + 70 + 24 True True Remove @@ -1111,7 +1129,7 @@ Feedback - 248 + 240 352 diff --git a/plugins/onepad/Linux/openpad.gladep b/plugins/onepad/Linux/onepad.gladep similarity index 100% rename from plugins/onepad/Linux/openpad.gladep rename to plugins/onepad/Linux/onepad.gladep diff --git a/plugins/onepad/controller.cpp b/plugins/onepad/controller.cpp index d4d22deb05..1e1292aa88 100644 --- a/plugins/onepad/controller.cpp +++ b/plugins/onepad/controller.cpp @@ -32,8 +32,10 @@ __forceinline int get_key(int pad, int index) return conf.keys[pad][index]; } -__forceinline KeyType type_of_key(int key) +__forceinline KeyType type_of_key(int pad, int index) { + int key = conf.keys[pad][index]; + if (key < 0x10000) return PAD_KEYBOARD; else if (key >= 0x10000 && key < 0x20000) return PAD_JOYBUTTONS; else if (key >= 0x20000 && key < 0x30000) return PAD_JOYSTICK; @@ -42,24 +44,24 @@ __forceinline KeyType type_of_key(int key) else return PAD_NULL; } - __forceinline int pad_to_key(int key) + __forceinline int pad_to_key(int pad, int index) { - return ((key) & 0xffff); + return ((conf.keys[pad][index]) & 0xffff); } -__forceinline int key_to_joystick_id(int key) +__forceinline int key_to_joystick_id(int pad, int index) { - return (((key) & 0xf000) >> 12); + return (((conf.keys[pad][index]) & 0xf000) >> 12); } -__forceinline int key_to_button(int key) +__forceinline int key_to_button(int pad, int index) { - return ((key) & 0xff); + return ((conf.keys[pad][index]) & 0xff); } -__forceinline int key_to_axis(int key) +__forceinline int key_to_axis(int pad, int index) { - return ((key) & 0xff); + return ((conf.keys[pad][index]) & 0xff); } __forceinline int button_to_key(int joy_id, int button_id) @@ -82,12 +84,12 @@ __forceinline int hat_to_key(int joy_id, int dir, int axis_id) return (0x40000 | ((joy_id) << 12) | ((dir) << 8) | (axis_id)); } -__forceinline int key_to_pov_sign(int key) +__forceinline int key_to_pov_sign(int pad, int index) { - return (((key) & 0x100) >> 8); + return (((conf.keys[pad][index]) & 0x100) >> 8); } -__forceinline int key_to_hat_dir(int key) +__forceinline int key_to_hat_dir(int pad, int index) { - return (((key) & ~ 0x40000) >> 8); -} \ No newline at end of file + return (((conf.keys[pad][index]) & ~ 0x40000) >> 8); +} diff --git a/plugins/onepad/controller.h b/plugins/onepad/controller.h index 84b90e3183..592a10c63d 100644 --- a/plugins/onepad/controller.h +++ b/plugins/onepad/controller.h @@ -44,21 +44,21 @@ enum KeyType PAD_NULL = -1 }; - extern int set_key(int pad, int index, int value); extern int get_key(int pad, int index); -extern KeyType type_of_key(int key); -extern int pad_to_key(int key); -extern int key_to_joystick_id(int key); -extern int key_to_button(int key); -extern int key_to_axis(int key); +extern KeyType type_of_key(int pad, int index); +extern int pad_to_key(int pad, int index); +extern int key_to_joystick_id(int pad, int index); +extern int key_to_button(int pad, int index); +extern int key_to_axis(int pad, int index); +extern int key_to_pov_sign(int pad, int index); +extern int key_to_hat_dir(int pad, int index); + extern int button_to_key(int joy_id, int button_id); extern int joystick_to_key(int joy_id, int axis_id); extern int pov_to_key(int joy_id, int sign, int axis_id); extern int hat_to_key(int joy_id, int dir, int axis_id); -extern int key_to_pov_sign(int key); -extern int key_to_hat_dir(int key); //#define EXPERIMENTAL_POV_CODE extern int PadEnum[2][2]; @@ -70,7 +70,6 @@ typedef struct u32 options; // upper 16 bits are for pad2 } PADconf; - typedef struct { u8 x, y; diff --git a/plugins/onepad/joystick.cpp b/plugins/onepad/joystick.cpp index 2cbbc312a2..cf66bfb5cc 100644 --- a/plugins/onepad/joystick.cpp +++ b/plugins/onepad/joystick.cpp @@ -102,10 +102,10 @@ void JoystickInfo::EnumerateJoysticks(vector& vjoysticks) for (int i = 0; i < PADKEYS; ++i) { - KeyType k = type_of_key(get_key(pad,i)); + KeyType k = type_of_key(pad,i); if (k == PAD_JOYSTICK || k == PAD_JOYBUTTONS) { - joyid = key_to_joystick_id(get_key(pad,i)); + joyid = key_to_joystick_id(pad,i); break; } } @@ -169,15 +169,15 @@ void JoystickInfo::Assign(int newpad) { for (int i = 0; i < PADKEYS; ++i) { - KeyType k = type_of_key(get_key(pad,i)); + KeyType k = type_of_key(pad,i); if (k == PAD_JOYBUTTONS) { - set_key(pad, i, button_to_key(_id, key_to_button(get_key(pad,i)))); + set_key(pad, i, button_to_key(_id, key_to_button(pad,i))); } else if (k == PAD_JOYSTICK) { - set_key(pad, i, joystick_to_key(_id, key_to_button(get_key(pad,i)))); + set_key(pad, i, joystick_to_key(_id, key_to_button(pad,i))); } } } diff --git a/plugins/onepad/onepad.cpp b/plugins/onepad/onepad.cpp index 1a8ed56f72..38709d6418 100644 --- a/plugins/onepad/onepad.cpp +++ b/plugins/onepad/onepad.cpp @@ -227,6 +227,17 @@ void initLogging() #endif } +void clearPAD() +{ + for (int pad = 0; pad < PADSUBKEYS; pad++) + { + for (int key= 0; key < PADKEYS; ++key) + { + set_key(pad, key, 0); + } + } +} + EXPORT_C_(s32) PADinit(u32 flags) { initLogging(); diff --git a/plugins/onepad/onepad.h b/plugins/onepad/onepad.h index 8056ac2619..da9b60fd8e 100644 --- a/plugins/onepad/onepad.h +++ b/plugins/onepad/onepad.h @@ -129,6 +129,7 @@ extern keyEvent event; extern u16 status[2]; extern u32 pads; +void clearPAD(); int POV(u32 direction, u32 angle); s32 _PADopen(void *pDsp); void _PADclose();