From 698d2a3abe44a5084797353a506b9c9b0d439846 Mon Sep 17 00:00:00 2001 From: Laurence Muller Date: Mon, 21 Jul 2008 22:08:56 +0000 Subject: [PATCH] nJoy: This should fix the non-working R shoulder button and the analog troubles. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@48 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_nJoy_SDL/config.cpp | 7 +++-- .../Plugin_nJoy_SDL/Plugin_nJoy_SDL/nJoy.cpp | 28 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/config.cpp b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/config.cpp index c857c7bec2..24e2a9c121 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/config.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/config.cpp @@ -421,7 +421,9 @@ void SetControllerAll(HWND hDlg, int controller) SetButton(hDlg, IDTEXT_Y, joysticks[controller].buttons[CTL_Y_BUTTON]); SetButton(hDlg, IDTEXT_Z, joysticks[controller].buttons[CTL_Z_TRIGGER]); SetButton(hDlg, IDTEXT_START, joysticks[controller].buttons[CTL_START]); + SetButton(hDlg, IDTEXT_DPAD, joysticks[controller].dpad); + SetButton(hDlg, IDTEXT_MX, joysticks[controller].axis[CTL_MAIN_X]); SetButton(hDlg, IDTEXT_MY, joysticks[controller].axis[CTL_MAIN_Y]); SetButton(hDlg, IDTEXT_SX, joysticks[controller].axis[CTL_SUB_X]); @@ -439,15 +441,14 @@ void GetControllerAll(HWND hDlg, int controller) joysticks[controller].ID = (int)SendMessage(GetDlgItem(hDlg, IDC_JOYNAME), CB_GETCURSEL, 0, 0); joysticks[controller].buttons[CTL_L_SHOULDER] = GetButton(hDlg, IDTEXT_SHOULDERL); - joysticks[controller].buttons[CTL_L_SHOULDER] = GetButton(hDlg, IDTEXT_SHOULDERL); - + joysticks[controller].buttons[CTL_R_SHOULDER] = GetButton(hDlg, IDTEXT_SHOULDERR); joysticks[controller].buttons[CTL_A_BUTTON] = GetButton(hDlg, IDTEXT_A); joysticks[controller].buttons[CTL_B_BUTTON] = GetButton(hDlg, IDTEXT_B); joysticks[controller].buttons[CTL_X_BUTTON] = GetButton(hDlg, IDTEXT_X); joysticks[controller].buttons[CTL_Y_BUTTON] = GetButton(hDlg, IDTEXT_Y); joysticks[controller].buttons[CTL_Z_TRIGGER] = GetButton(hDlg, IDTEXT_Z); - joysticks[controller].buttons[CTL_START] = GetButton(hDlg, IDTEXT_START); + joysticks[controller].dpad = GetButton(hDlg, IDTEXT_DPAD); joysticks[controller].axis[CTL_MAIN_X] = GetButton(hDlg, IDTEXT_MX); diff --git a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/nJoy.cpp index 423b44a0c6..88bfcfeeef 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL/nJoy.cpp @@ -174,21 +174,21 @@ void PAD_GetStatus(BYTE _numPAD, SPADStatus* _pPADStatus) // Adjust range // The value returned by SDL_JoystickGetAxis is a signed integer (-32768 to 32768) - // -128 and 128 - int main_stick_x = joystate[_numPAD].axis[CTL_MAIN_X] / 256; - int main_stick_y = joystate[_numPAD].axis[CTL_MAIN_Y] / 256; - int sub_stick_x = joystate[_numPAD].axis[CTL_SUB_X] / 256; - int sub_stick_y = joystate[_numPAD].axis[CTL_SUB_Y] / 256; + // The value used for the gamecube controller is an unsigned char (0 to 255) + int main_stick_x = (joystate[_numPAD].axis[CTL_MAIN_X]>>8)+127; + int main_stick_y = (joystate[_numPAD].axis[CTL_MAIN_Y]>>8)+127; + int sub_stick_x = (joystate[_numPAD].axis[CTL_SUB_X]>>8)+127; + int sub_stick_y = (joystate[_numPAD].axis[CTL_SUB_Y]>>8)+127; - // TODO: fix, 128 would cause 0x00 - if(main_stick_x > 127) - main_stick_x = 127; - if(main_stick_y > 127) - main_stick_y = 127; - if(sub_stick_x > 127) - sub_stick_x = 127; - if(sub_stick_y > 127) - sub_stick_y = 127; + // Quick fix + if(main_stick_x > 255) + main_stick_x = 255; + if(main_stick_y > 255) + main_stick_y = 255; + if(sub_stick_x > 255) + sub_stick_x = 255; + if(sub_stick_y > 255) + sub_stick_y = 255; // Send values to Dolpin if ((main_stick_x < deadzone2) || (main_stick_x > deadzone)) _pPADStatus->stickX += main_stick_x;