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

@ -39,18 +39,21 @@ WindowsMouse::WindowsMouse(DeviceAPI api, int hWheel, wchar_t* displayName, wcha
wchar_t* WindowsMouse::GetPhysicalControlName(PhysicalControl* control) wchar_t* WindowsMouse::GetPhysicalControlName(PhysicalControl* control)
{ {
wchar_t* names[9] = {
L"L Button",
L"R Button",
L"M Button",
L"Mouse 4",
L"Mouse 5",
L"X Axis",
L"Y Axis",
L"Y Wheel",
L"X Wheel"};
if (control->id < 9) if (control->id < 9)
{
wchar_t* names[9] = {
L"L Button",
L"R Button",
L"M Button",
L"Mouse 4",
L"Mouse 5",
L"X Axis",
L"Y Axis",
L"Y Wheel",
L"X Wheel"};
return names[control->id]; return names[control->id];
}
return Device::GetPhysicalControlName(control); return Device::GetPhysicalControlName(control);
} }

View File

@ -116,32 +116,33 @@ public:
wchar_t* GetPhysicalControlName(PhysicalControl* c) wchar_t* GetPhysicalControlName(PhysicalControl* c)
{ {
const static wchar_t* names[] = {
L"D-pad Up",
L"D-pad Down",
L"D-pad Left",
L"D-pad Right",
L"Start",
L"Back",
L"Left Thumb",
L"Right Thumb",
L"Left Shoulder",
L"Right Shoulder",
L"Guide",
L"A",
L"B",
L"X",
L"Y",
L"Left Trigger",
L"Right Trigger",
L"Left Thumb X",
L"Left Thumb Y",
L"Right Thumb X",
L"Right Thumb Y",
};
unsigned int i = (unsigned int)(c - physicalControls); unsigned int i = (unsigned int)(c - physicalControls);
if (i < 21) if (i < 21)
{ {
const static wchar_t* names[] = {
L"D-pad Up",
L"D-pad Down",
L"D-pad Left",
L"D-pad Right",
L"Start",
L"Back",
L"Left Thumb",
L"Right Thumb",
L"Left Shoulder",
L"Right Shoulder",
L"Guide",
L"A",
L"B",
L"X",
L"Y",
L"Left Trigger",
L"Right Trigger",
L"Left Thumb X",
L"Left Thumb Y",
L"Right Thumb X",
L"Right Thumb Y",
};
return (wchar_t*)names[i]; return (wchar_t*)names[i];
} }
return Device::GetPhysicalControlName(c); return Device::GetPhysicalControlName(c);