win32 rawinput & wgi joystick: avoid -Werror=declaration-after-statement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 5765686..12dd1e7 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -452,12 +452,12 @@ RAWINPUT_UpdateWindowsGamingInput()
wgi_state.dirty = SDL_FALSE;
if (wgi_state.need_device_list_update) {
+ HRESULT hr;
+ __FIVectorView_1_Windows__CGaming__CInput__CGamepad *gamepads;
wgi_state.need_device_list_update = SDL_FALSE;
for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) {
wgi_state.per_gamepad[ii]->connected = SDL_FALSE;
}
- HRESULT hr;
- __FIVectorView_1_Windows__CGaming__CInput__CGamepad *gamepads;
hr = __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics_get_Gamepads(wgi_state.gamepad_statics, &gamepads);
if (SUCCEEDED(hr)) {
@@ -482,13 +482,15 @@ RAWINPUT_UpdateWindowsGamingInput()
}
if (!found) {
/* New device, add it */
+ WindowsGamingInputGamepadState *gamepad_state;
+
wgi_state.per_gamepad_count++;
wgi_state.per_gamepad = SDL_realloc(wgi_state.per_gamepad, sizeof(wgi_state.per_gamepad[0]) * wgi_state.per_gamepad_count);
if (!wgi_state.per_gamepad) {
SDL_OutOfMemory();
return;
}
- WindowsGamingInputGamepadState *gamepad_state = SDL_calloc(1, sizeof(*gamepad_state));
+ gamepad_state = SDL_calloc(1, sizeof(*gamepad_state));
if (!gamepad_state) {
SDL_OutOfMemory();
return;
@@ -534,6 +536,10 @@ RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx)
wgi_state.need_device_list_update = SDL_TRUE;
wgi_state.ref_count++;
if (!wgi_state.initialized) {
+ static const IID SDL_IID_IGamepadStatics = { 0x8BBCE529, 0xD49C, 0x39E9, { 0x95, 0x60, 0xE4, 0x7D, 0xDE, 0x96, 0xB7, 0xC8 } };
+ HRESULT hr;
+ HMODULE hModule;
+
/* I think this takes care of RoInitialize() in a way that is compatible with the rest of SDL */
if (FAILED(WIN_CoInitialize())) {
return;
@@ -541,9 +547,7 @@ RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx)
wgi_state.initialized = SDL_TRUE;
wgi_state.dirty = SDL_TRUE;
- static const IID SDL_IID_IGamepadStatics = { 0x8BBCE529, 0xD49C, 0x39E9, { 0x95, 0x60, 0xE4, 0x7D, 0xDE, 0x96, 0xB7, 0xC8 } };
- HRESULT hr;
- HMODULE hModule = LoadLibraryA("combase.dll");
+ hModule = LoadLibraryA("combase.dll");
if (hModule != NULL) {
typedef HRESULT (WINAPI *WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER *hstringHeader, HSTRING* string);
typedef HRESULT (WINAPI *RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void** factory);
diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c
index 33b4eb5..950fe7c 100644
--- a/src/joystick/windows/SDL_windows_gaming_input.c
+++ b/src/joystick/windows/SDL_windows_gaming_input.c
@@ -103,7 +103,7 @@ SDL_IsXInputDevice(Uint16 vendor, Uint16 product)
#ifdef SDL_JOYSTICK_RAWINPUT
&& !RAWINPUT_IsEnabled()
#endif
- ) {
+ ) {
return SDL_FALSE;
}
@@ -424,12 +424,14 @@ static __FIEventHandler_1_Windows__CGaming__CInput__CRawGameController controlle
static int
WGI_JoystickInit(void)
{
+ HMODULE hModule;
+ HRESULT hr;
+
if (FAILED(WIN_CoInitialize())) {
return SDL_SetError("CoInitialize() failed");
}
- HRESULT hr;
- HMODULE hModule = LoadLibraryA("combase.dll");
+ hModule = LoadLibraryA("combase.dll");
if (hModule != NULL) {
typedef HRESULT (WINAPI *WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER *hstringHeader, HSTRING* string);
typedef HRESULT (WINAPI *WindowsDeleteString_t)(HSTRING string);