PAD: Cleanup variable scope.

Codacy.
This commit is contained in:
lightningterror 2022-06-24 17:54:07 +02:00
parent 732d30c919
commit 59e9d80b18
4 changed files with 44 additions and 39 deletions

View File

@ -378,7 +378,7 @@ void SelChanged(int port, int slot)
if (!hWnd) if (!hWnd)
return; return;
HWND hWndTemp, hWndList = GetDlgItem(hWnd, IDC_BINDINGS_LIST); HWND hWndTemp, hWndList = GetDlgItem(hWnd, IDC_BINDINGS_LIST);
int j, i = ListView_GetSelectedCount(hWndList); int i = ListView_GetSelectedCount(hWndList);
wchar_t* devName = L"N/A"; wchar_t* devName = L"N/A";
wchar_t* key = L"N/A"; wchar_t* key = L"N/A";
wchar_t* command = L"N/A"; wchar_t* command = L"N/A";
@ -387,20 +387,20 @@ void SelChanged(int port, int slot)
int sensitivity = 0; int sensitivity = 0;
int deadZone = 0; int deadZone = 0;
int skipDeadZone = 0; int skipDeadZone = 0;
int nonButtons = 0;
// Set if sensitivity != 0, but need to disable flip anyways. // Set if sensitivity != 0, but need to disable flip anyways.
// Only used to relative axes. // Only used to relative axes.
int disableFlip = 0; int disableFlip = 0;
wchar_t temp[4][1000]; wchar_t temp[4][1000];
Device* dev; Device* dev;
int bFound = 0; int bFound = 0;
int ffbFound = 0;
ForceFeedbackBinding* ffb = 0; ForceFeedbackBinding* ffb = 0;
Binding* b = 0; Binding* b = 0;
if (i >= 1) if (i >= 1)
{ {
int index = -1; int index = -1;
int flipped = 0; int flipped = 0;
int nonButtons = 0;
int ffbFound = 0;
while (1) while (1)
{ {
if (!(config.bind && (!config.configureOnBind || quickSetup))) if (!(config.bind && (!config.configureOnBind || quickSetup)))
@ -411,7 +411,8 @@ void SelChanged(int port, int slot)
item.iItem = index; item.iItem = index;
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
item.pszText = temp[3]; item.pszText = temp[3];
for (j = 0; j < 3; j++) int j = 0;
for (; j < 3; j++)
{ {
item.iSubItem = j; item.iSubItem = j;
item.cchTextMax = sizeof(temp[0]) / sizeof(temp[3][0]); item.cchTextMax = sizeof(temp[0]) / sizeof(temp[3][0]);

View File

@ -280,13 +280,13 @@ void EnumRawInputDevices()
wchar_t* productID = displayName + 10000; wchar_t* productID = displayName + 10000;
RAWINPUTDEVICELIST* list = (RAWINPUTDEVICELIST*)malloc(sizeof(RAWINPUTDEVICELIST) * count); RAWINPUTDEVICELIST* list = (RAWINPUTDEVICELIST*)malloc(sizeof(RAWINPUTDEVICELIST) * count);
int keyboardCount = 1;
int mouseCount = 1;
count = GetRawInputDeviceList(list, (unsigned int*)&count, sizeof(RAWINPUTDEVICELIST)); count = GetRawInputDeviceList(list, (unsigned int*)&count, sizeof(RAWINPUTDEVICELIST));
// Not necessary, but reminder that count is -1 on failure. // Not necessary, but reminder that count is -1 on failure.
if (count > 0) if (count > 0)
{ {
int keyboardCount = 1;
int mouseCount = 1;
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
if (list[i].dwType != RIM_TYPEKEYBOARD && list[i].dwType != RIM_TYPEMOUSE) if (list[i].dwType != RIM_TYPEKEYBOARD && list[i].dwType != RIM_TYPEMOUSE)

View File

@ -38,6 +38,8 @@ WindowsMouse::WindowsMouse(DeviceAPI api, int hWheel, wchar_t* displayName, wcha
} }
wchar_t* WindowsMouse::GetPhysicalControlName(PhysicalControl* control) wchar_t* WindowsMouse::GetPhysicalControlName(PhysicalControl* control)
{
if (control->id < 9)
{ {
wchar_t* names[9] = { wchar_t* names[9] = {
L"L Button", L"L Button",
@ -49,8 +51,9 @@ wchar_t* WindowsMouse::GetPhysicalControlName(PhysicalControl* control)
L"Y Axis", L"Y Axis",
L"Y Wheel", L"Y Wheel",
L"X Wheel"}; L"X Wheel"};
if (control->id < 9)
return names[control->id]; return names[control->id];
}
return Device::GetPhysicalControlName(control); return Device::GetPhysicalControlName(control);
} }

View File

@ -115,6 +115,9 @@ public:
} }
wchar_t* GetPhysicalControlName(PhysicalControl* c) wchar_t* GetPhysicalControlName(PhysicalControl* c)
{
unsigned int i = (unsigned int)(c - physicalControls);
if (i < 21)
{ {
const static wchar_t* names[] = { const static wchar_t* names[] = {
L"D-pad Up", L"D-pad Up",
@ -139,9 +142,7 @@ public:
L"Right Thumb X", L"Right Thumb X",
L"Right Thumb Y", L"Right Thumb Y",
}; };
unsigned int i = (unsigned int)(c - physicalControls);
if (i < 21)
{
return (wchar_t*)names[i]; return (wchar_t*)names[i];
} }
return Device::GetPhysicalControlName(c); return Device::GetPhysicalControlName(c);