From d00b8081ac71b2b3ab05f2cf9230193b6af9eaa2 Mon Sep 17 00:00:00 2001 From: Shanoah Alkire Date: Sat, 27 Apr 2019 19:30:29 -0700 Subject: [PATCH] onepad: bring the sensibility changes over to onepad as well as onepad_legacy. --- plugins/onepad/SDL/joystick.cpp | 3 +++ plugins/onepad/controller.h | 15 +++++++++----- .../onepad/wx_dialog/GamepadConfiguration.cpp | 20 ++++++++++--------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/plugins/onepad/SDL/joystick.cpp b/plugins/onepad/SDL/joystick.cpp index a2b5dfe311..2ecbb18cb6 100644 --- a/plugins/onepad/SDL/joystick.cpp +++ b/plugins/onepad/SDL/joystick.cpp @@ -263,9 +263,12 @@ bool JoystickInfo::TestForce(float strength = 0.60) int JoystickInfo::GetInput(gamePadValues input) { + float k = g_conf.get_sensibility() / 100.0; // convert sensibility to float + // Handle analog inputs which range from -32k to +32k. Range conversion is handled later in the controller if (IsAnalogKey(input)) { int value = SDL_GameControllerGetAxis(m_controller, (SDL_GameControllerAxis)m_pad_to_sdl[input]); + value *= k; return (abs(value) > m_deadzone) ? value : 0; } diff --git a/plugins/onepad/controller.h b/plugins/onepad/controller.h index 12ea124e64..c0710c9ca9 100644 --- a/plugins/onepad/controller.h +++ b/plugins/onepad/controller.h @@ -63,7 +63,7 @@ public: ftw = 1; packed_options = 0; ff_intensity = 0x7FFF; // set it at max value by default - sensibility = 500; + sensibility = 100; for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) { keysym_map[pad].clear(); } @@ -105,15 +105,20 @@ public: } /** - * Set sensibility value, sensibility is not yet implemented(and will probably be after evdev) - * However, there will be an upper range too, less than 0 is an obvious wrong - * Anyway, we are doing object oriented code, members are definitely not supposed to be public + * Set sensibility value. + * There will be an upper range, and less than 0 is obviously wrong. + * We are doing object oriented code, so members are definitely not supposed to be public. **/ void set_sensibility(u32 new_sensibility) { - if (sensibility > 0) { + if (new_sensibility > 0) + { sensibility = new_sensibility; } + else + { + sensibility = 1; + } } u32 get_sensibility() diff --git a/plugins/onepad/wx_dialog/GamepadConfiguration.cpp b/plugins/onepad/wx_dialog/GamepadConfiguration.cpp index 01c5419ef5..ae8c2591e3 100644 --- a/plugins/onepad/wx_dialog/GamepadConfiguration.cpp +++ b/plugins/onepad/wx_dialog/GamepadConfiguration.cpp @@ -26,7 +26,7 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) wxID_ANY, // ID _T("Gamepad configuration"), // Title wxDefaultPosition, // Position - wxSize(400, 230), // Width + Lenght + wxSize(400, 270), // Width + Length // Style wxSYSTEM_MENU | wxCAPTION | @@ -38,8 +38,8 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) m_pan_gamepad_config = new wxPanel( this, // Parent wxID_ANY, // ID - wxDefaultPosition, // Prosition - wxSize(300, 200) // Size + wxDefaultPosition, // Position + wxSize(300, 230) // Size ); m_cb_rumble = new wxCheckBox( m_pan_gamepad_config, // Parent @@ -75,7 +75,8 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) 0, // min value 0x0000 0x7FFF, // max value 0x7FFF wxPoint(150, 83), // Position - wxSize(200, 30) // Size + wxSize(200, 50), // Size + wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM ); wxString txt_joystick = wxT("Joystick sensibility"); @@ -83,7 +84,7 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) m_pan_gamepad_config, // Parent wxID_ANY, // ID txt_joystick, // Text which must be displayed - wxPoint(20, 120), // Position + wxPoint(20, 150), // Position wxDefaultSize // Size ); @@ -92,16 +93,17 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) wxID_ANY, // ID 0, // value 0, // min value - 100, // max value - wxPoint(150, 113), // Position - wxSize(200, 30) // Size + 200, // max value + wxPoint(150, 143), // Position + wxSize(200, 50), // Size + wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM ); m_bt_ok = new wxButton( m_pan_gamepad_config, // Parent wxID_ANY, // ID _T("&OK"), // Label - wxPoint(320, 160), // Position + wxPoint(320, 210), // Position wxSize(60, 25) // Size );