Skip to content
Permalink
Browse files

Onepad (legacy) sensibility implementation for linux (#2932)

* Implementation of onepad sensibility for linux

* cast floats to int

* Fix the sensibility sanity checking, and clean up the dialog box a bit.
  • Loading branch information...
y-salnikov authored and arcum42 committed Apr 28, 2019
1 parent ead3d21 commit ff9749f6dce6f4043a603d240e0bdcdf26c41ef6
@@ -131,11 +131,11 @@ void PollForJoystickInput(int cpad)
int value = gamePad->GetAxisFromKey(cpad, i);
bool sign = key_to_axis_sign(cpad, i);
bool full_axis = key_to_axis_type(cpad, i);

float k=conf->get_sensibility()/100.0; // convert sensibility to float
if (IsAnalogKey(i))
{
if (abs(value) > gamePad->GetDeadzone())
key_status->press(cpad, i, value);
key_status->press(cpad, i, (int)(value*k));
else
key_status->release(cpad, i);
}
@@ -152,9 +152,9 @@ void PollForJoystickInput(int cpad)
else
{
if (sign && (-value > gamePad->GetDeadzone()))
key_status->press(cpad, i, std::min(-value / 128, 0xFF));
key_status->press(cpad, i, std::min((int)(-value*k) / 128, 0xFF));
else if (!sign && (value > gamePad->GetDeadzone()))
key_status->press(cpad, i, std::min(value / 128, 0xFF));
key_status->press(cpad, i, std::min((int)(value*k) / 128, 0xFF));
else
key_status->release(cpad, i);
}
@@ -85,7 +85,7 @@ class PADconf
memset(&keys, 0, sizeof(keys));
log = packed_options = joyid_map = 0;
ff_intensity = 0x7FFF; // set it at max value by default
sensibility = 500;
sensibility = 100; // set it at 100%
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
{
keysym_map[pad].clear();
@@ -127,16 +127,21 @@ class PADconf
}

/**
* 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()
@@ -26,7 +26,7 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
wxID_ANY, // ID
_T("Gamepad configuration"), // Title
wxDefaultPosition, // Position
wxSize(400, 230), // Width + Length
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
@@ -78,15 +78,16 @@ 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");
m_lbl_rumble_intensity = new wxStaticText(
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
);

@@ -95,24 +96,25 @@ 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_bt_cancel = new wxButton(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&OK"), // Label
wxPoint(250, 160), // Position
_T("&Cancel"), // Label
wxPoint(250, 210), // Position
wxSize(60, 25) // Size
);

m_bt_cancel = new wxButton(
m_bt_ok = new wxButton(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Cancel"), // Label
wxPoint(320, 160), // Position
_T("&OK"), // Label
wxPoint(320, 210), // Position
wxSize(60, 25) // Size
);

0 comments on commit ff9749f

Please sign in to comment.
You can’t perform that action at this time.