Permalink
Browse files

onepad_legacy: reformat code.

  • Loading branch information...
arcum42 committed Oct 7, 2018
1 parent f800ed9 commit 896c9cccec94a193126f586ec1ff3a2e5f418257
@@ -37,10 +37,10 @@ void GamePad::UpdateReleaseState()
void GamePad::DoRumble(int type, int pad)
{
u32 id = conf->get_joyid(pad);
if (GamePadIdWithinBounds(id)) {
if (GamePadIdWithinBounds(id))
{
GamePad *gamePad = s_vgamePad[id];
if (gamePad)
gamePad->Rumble(type, pad);
if (gamePad) gamePad->Rumble(type, pad);
}
}
@@ -23,13 +23,15 @@
void KeyStatus::Init()
{
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
{
m_button[pad] = 0xFFFF;
m_internal_button_kbd[pad] = 0xFFFF;
m_internal_button_joy[pad] = 0xFFFF;
m_state_acces[pad] = false;
for (int index = 0; index < MAX_KEYS; index++) {
for (int index = 0; index < MAX_KEYS; index++)
{
m_button_pressure[pad][index] = 0xFF;
m_internal_button_pressure[pad][index] = 0xFF;
}
@@ -51,13 +53,16 @@ void KeyStatus::Init()
void KeyStatus::press(u32 pad, u32 index, s32 value)
{
if (!IsAnalogKey(index)) {
if (!IsAnalogKey(index))
{
m_internal_button_pressure[pad][index] = value;
if (m_state_acces[pad])
clear_bit(m_internal_button_kbd[pad], index);
else
clear_bit(m_internal_button_joy[pad], index);
} else {
}
else
{
// clamp value
if (value > MAX_ANALOG_VALUE)
value = MAX_ANALOG_VALUE;
@@ -79,12 +84,15 @@ void KeyStatus::press(u32 pad, u32 index, s32 value)
void KeyStatus::release(u32 pad, u32 index)
{
if (!IsAnalogKey(index)) {
if (!IsAnalogKey(index))
{
if (m_state_acces[pad])
set_bit(m_internal_button_kbd[pad], index);
else
set_bit(m_internal_button_joy[pad], index);
} else {
}
else
{
analog_set(pad, index, m_analog_released_val);
}
}
@@ -102,7 +110,8 @@ void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
else
m_internal_analog_ref = &m_internal_analog_joy[pad];
switch (index) {
switch (index)
{
case PAD_R_LEFT:
case PAD_R_RIGHT:
m_internal_analog_ref->rx = value;
@@ -130,7 +139,8 @@ void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
bool KeyStatus::analog_is_reversed(u32 pad, u32 index)
{
switch (index) {
switch (index)
{
case PAD_L_RIGHT:
case PAD_L_LEFT:
return (conf->pad_options[pad].reverse_lx);
@@ -154,7 +164,8 @@ bool KeyStatus::analog_is_reversed(u32 pad, u32 index)
u8 KeyStatus::get(u32 pad, u32 index)
{
switch (index) {
switch (index)
{
case PAD_R_LEFT:
case PAD_R_RIGHT:
return m_analog[pad].rx;
@@ -19,14 +19,14 @@
#include "GamepadConfiguration.h"
// Construtor of GamepadConfiguration
// Constructor of GamepadConfiguration
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
: wxDialog(
parent, // Parent
wxID_ANY, // ID
_T("Gamepad configuration"), // Title
wxDefaultPosition, // Position
wxSize(400, 230), // Width + Lenght
wxSize(400, 230), // Width + Length
// Style
wxSYSTEM_MENU |
wxCAPTION |
@@ -40,27 +40,27 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
wxID_ANY, // ID
wxDefaultPosition, // Prosition
wxSize(300, 200) // Size
);
);
m_cb_rumble = new wxCheckBox(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Enable rumble"), // Label
wxPoint(20, 20) // Position
);
);
m_cb_hack_sixaxis_usb = new wxCheckBox(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Hack: Sixaxis/DS3 plugged in USB"), // Label
wxPoint(20, 40) // Position
);
);
m_cb_hack_sixaxis_pressure = new wxCheckBox(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Hack: Sixaxis/DS3 pressure"), // Label
wxPoint(20, 60) // Position
);
);
wxString txt_rumble = wxT("Rumble intensity");
m_lbl_rumble_intensity = new wxStaticText(
@@ -69,7 +69,7 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
txt_rumble, // Text which must be displayed
wxPoint(20, 90), // Position
wxDefaultSize // Size
);
);
m_sl_rumble_intensity = new wxSlider(
m_pan_gamepad_config, // Parent
@@ -79,7 +79,7 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
0x7FFF, // max value 0x7FFF
wxPoint(150, 83), // Position
wxSize(200, 30) // Size
);
);
wxString txt_joystick = wxT("Joystick sensibility");
m_lbl_rumble_intensity = new wxStaticText(
@@ -88,7 +88,7 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
txt_joystick, // Text which must be displayed
wxPoint(20, 120), // Position
wxDefaultSize // Size
);
);
m_sl_joystick_sensibility = new wxSlider(
m_pan_gamepad_config, // Parent
@@ -98,23 +98,23 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
100, // max value
wxPoint(150, 113), // Position
wxSize(200, 30) // Size
);
);
m_bt_ok = new wxButton(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&OK"), // Label
wxPoint(250, 160), // Position
wxSize(60, 25) // Size
);
);
m_bt_cancel = new wxButton(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Cancel"), // Label
wxPoint(320, 160), // Position
wxSize(60, 25) // Size
);
);
Bind(wxEVT_BUTTON, &GamepadConfiguration::OnButtonClicked, this);
Bind(wxEVT_SCROLL_THUMBRELEASE, &GamepadConfiguration::OnSliderReleased, this);
@@ -137,7 +137,8 @@ void GamepadConfiguration::InitGamepadConfiguration()
* if the pad id is 1, you need at least 2 gamepad connected,
* Prevent to use a none initialized value on s_vgamePad (core dump)
*/
if (s_vgamePad.size() >= m_pad_id + 1) {
if (s_vgamePad.size() >= m_pad_id + 1)
{
/*
* Determine if the device can use rumble
* Use TestForce with a very low strength (can't be felt)
@@ -150,7 +151,9 @@ void GamepadConfiguration::InitGamepadConfiguration()
// m_cb_rumble->Disable(); // disable the rumble checkbox
// m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
// }
} else {
}
else
{
wxMessageBox(L"No gamepad detected.");
m_sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider
m_cb_rumble->Disable(); // disable the rumble checkbox
@@ -170,9 +173,12 @@ void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event)
// Affichage d'un message à chaque clic sur le bouton
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
int bt_id = bt_tmp->GetId(); // get the real ID
if (bt_id == m_bt_ok->GetId()) { // If the button ID is equals to the Ok button ID
if (bt_id == m_bt_ok->GetId()) // If the button ID is equals to the Ok button ID
{
Close(); // Close the window
} else if (bt_id == m_bt_cancel->GetId()) { // If the button ID is equals to the cancel button ID
}
else if (bt_id == m_bt_cancel->GetId()) // If the button ID is equals to the cancel button ID
{
reset(); // reinitialize the value of each parameters
Close(); // Close the window
}
@@ -187,7 +193,8 @@ void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
{
wxSlider *sl_tmp = (wxSlider *)event.GetEventObject(); // get the slider object
int sl_id = sl_tmp->GetId(); // slider id
if (sl_id == m_sl_rumble_intensity->GetId()) { // if this is the rumble intensity slider
if (sl_id == m_sl_rumble_intensity->GetId()) // if this is the rumble intensity slider
{
u32 intensity = m_sl_rumble_intensity->GetValue(); // get the new value
conf->set_ff_intensity(intensity); // and set the force feedback intensity value with it
// get the rumble intensity
@@ -204,7 +211,9 @@ void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
* 1 : maximum value of the intensity for the sdl rumble test
*/
s_vgamePad[m_pad_id]->TestForce(strength / 0x7FFF);
} else if (sl_id == m_sl_joystick_sensibility->GetId()) {
}
else if (sl_id == m_sl_joystick_sensibility->GetId())
{
u32 sensibility = m_sl_joystick_sensibility->GetValue(); // get the new value
conf->set_sensibility(sensibility); // and set the joystick sensibility
}
@@ -217,17 +226,25 @@ void GamepadConfiguration::OnCheckboxChange(wxCommandEvent &event)
{
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
int cb_id = cb_tmp->GetId();
if (cb_id == m_cb_rumble->GetId()) {
if (cb_id == m_cb_rumble->GetId())
{
conf->pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue()) ? (u32)1 : (u32)0;
if (m_cb_rumble->GetValue()) {
if (m_cb_rumble->GetValue())
{
s_vgamePad[m_pad_id]->TestForce();
m_sl_rumble_intensity->Enable();
} else {
}
else
{
m_sl_rumble_intensity->Disable();
}
} else if (cb_id == m_cb_hack_sixaxis_usb->GetId()) {
}
else if (cb_id == m_cb_hack_sixaxis_usb->GetId())
{
conf->pad_options[m_pad_id].sixaxis_usb = (m_cb_hack_sixaxis_usb->GetValue()) ? (u32)1 : (u32)0;
} else if (cb_id == m_cb_hack_sixaxis_pressure->GetId()) {
}
else if (cb_id == m_cb_hack_sixaxis_pressure->GetId())
{
conf->pad_options[m_pad_id].sixaxis_pressure = (m_cb_hack_sixaxis_pressure->GetValue()) ? (u32)1 : (u32)0;
}
}
Oops, something went wrong.

2 comments on commit 896c9cc

@arcum42

This comment has been minimized.

Show comment
Hide comment
@arcum42

arcum42 Oct 7, 2018

Contributor

Alright, looking at the failure here, it's rather bizarre. This commit is only reformatting and only only on onepad_legacy. One function had the name changed by one letter, and one constant had two letters swapped, both due to spelling mistakes. The only other place using either of those was in onepad.

However, travis is only failing on gcc 4.9, not any of the other checks, and it's failing on GSdx, bizarrely enough. Here's the error in the log:

[ 54%] �[32mBuilding CXX object plugins/GSdx/CMakeFiles/GSdx.dir/GSWndOGL.cpp.o�[0m
[ 54%] �[32mBuilding CXX object plugins/GSdx/CMakeFiles/GSdx.dir/GSWndEGL.cpp.o�[0m
[ 55%] �[32m�[1mLinking CXX shared module libGSdx.so�[0m
[ 55%] �[32mBuilding CXX object plugins/spu2-x/src/CMakeFiles/spu2x-2.0.0.dir/SndOut_Portaudio.cpp.o�[0m
CMakeFiles/GSdx.dir/GSDrawScanlineCodeGenerator.x86.avx2.cpp.o: In function `GSDrawScanlineCodeGenerator::Generate()':
GSDrawScanlineCodeGenerator.x86.avx2.cpp:(.text+0x10e70): multiple definition of `GSDrawScanlineCodeGenerator::Generate()'
CMakeFiles/GSdx.dir/GSDrawScanlineCodeGenerator.cpp.o:GSDrawScanlineCodeGenerator.cpp:(.text+0x130): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [plugins/GSdx/libGSdx.so] Error 1
make[1]: *** [plugins/GSdx/CMakeFiles/GSdx.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

This really doesn't seem like it has anything to do with this commit, and is rather strange. Maybe to compiler options changed or something?

Contributor

arcum42 replied Oct 7, 2018

Alright, looking at the failure here, it's rather bizarre. This commit is only reformatting and only only on onepad_legacy. One function had the name changed by one letter, and one constant had two letters swapped, both due to spelling mistakes. The only other place using either of those was in onepad.

However, travis is only failing on gcc 4.9, not any of the other checks, and it's failing on GSdx, bizarrely enough. Here's the error in the log:

[ 54%] �[32mBuilding CXX object plugins/GSdx/CMakeFiles/GSdx.dir/GSWndOGL.cpp.o�[0m
[ 54%] �[32mBuilding CXX object plugins/GSdx/CMakeFiles/GSdx.dir/GSWndEGL.cpp.o�[0m
[ 55%] �[32m�[1mLinking CXX shared module libGSdx.so�[0m
[ 55%] �[32mBuilding CXX object plugins/spu2-x/src/CMakeFiles/spu2x-2.0.0.dir/SndOut_Portaudio.cpp.o�[0m
CMakeFiles/GSdx.dir/GSDrawScanlineCodeGenerator.x86.avx2.cpp.o: In function `GSDrawScanlineCodeGenerator::Generate()':
GSDrawScanlineCodeGenerator.x86.avx2.cpp:(.text+0x10e70): multiple definition of `GSDrawScanlineCodeGenerator::Generate()'
CMakeFiles/GSdx.dir/GSDrawScanlineCodeGenerator.cpp.o:GSDrawScanlineCodeGenerator.cpp:(.text+0x130): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [plugins/GSdx/libGSdx.so] Error 1
make[1]: *** [plugins/GSdx/CMakeFiles/GSdx.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

This really doesn't seem like it has anything to do with this commit, and is rather strange. Maybe to compiler options changed or something?

@lightningterror

This comment has been minimized.

Show comment
Hide comment
@lightningterror

lightningterror Oct 7, 2018

Member

I restarted the same build on my master branch and it builds but it doesn't include these latest three commits.
Will update when the build finishes with those commits included.

Edit: Looks like it didn't fail on my repo with the latest commits.

Member

lightningterror replied Oct 7, 2018

I restarted the same build on my master branch and it builds but it doesn't include these latest three commits.
Will update when the build finishes with those commits included.

Edit: Looks like it didn't fail on my repo with the latest commits.

Please sign in to comment.