# SDL: Removed 100 ms hitch when querying third party Nintendo Switch controllers that don't respond to request for info (8acf7)

**URL:** <https://discourse.libsdl.org/t/sdl-removed-100-ms-hitch-when-querying-third-party-nintendo-switch-controllers-that-dont-respond-to-request-for-info-8acf7/44358>\
**Category:** SDL Commits\
**Created:** [June 21, 2023, 9:12pm UTC](https://discourse.libsdl.org/t/sdl-removed-100-ms-hitch-when-querying-third-party-nintendo-switch-controllers-that-dont-respond-to-request-for-info-8acf7/44358 "2023-06-21T21:12:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [June 21, 2023, 9:12pm UTC](https://discourse.libsdl.org/t/sdl-removed-100-ms-hitch-when-querying-third-party-nintendo-switch-controllers-that-dont-respond-to-request-for-info-8acf7/44358/1 "2023-06-21T21:12:02Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/8acf72965031a5101f478eccd69d092001134184>

```diff
From 8acf72965031a5101f478eccd69d092001134184 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 21 Jun 2023 14:11:41 -0700
Subject: [PATCH] Removed 100 ms hitch when querying third party Nintendo
 Switch controllers that don't respond to request for info

---
 src/joystick/hidapi/SDL_hidapi_switch.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index f53857ccc60a..9544806e2985 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -998,7 +998,9 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic
         ctx->m_bSyncWrite = SDL_TRUE;
         ctx->m_nMaxWriteAttempts = GetMaxWriteAttempts(device);
 
- for (attempts = 0; attempts < MAX_ATTEMPTS; ++attempts) {
+ for ( ; ; ) {
+ ++attempts;
+ device->is_bluetooth = SDL_FALSE;
             if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) {
                 SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0];
 
@@ -1011,13 +1013,12 @@ static ESwitchDeviceInfoControllerType ReadJoyConControllerType(SDL_HIDAPI_Devic
                     eControllerType = CalculateControllerType(ctx, (ESwitchDeviceInfoControllerType)reply->deviceInfo.ucDeviceType);
                 }
             }
- if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown) {
+ if (eControllerType == k_eSwitchDeviceInfoControllerType_Unknown && attempts < MAX_ATTEMPTS) {
                 /* Wait a bit and try again */
                 SDL_Delay(100);
                 continue;
- } else {
- break;
             }
+ break;
         }
         SDL_free(ctx);
     }

```
