src/joystick/hidapi/SDL_hidapi_xbox360.c
changeset 13840 df7f6873371a
parent 13758 dcf07006dda6
equal deleted inserted replaced
13839:52dbeb97b294 13840:df7f6873371a
   268 static SDL_bool
   268 static SDL_bool
   269 HIDAPI_DriverXbox360_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, Uint8 *slot_idx)
   269 HIDAPI_DriverXbox360_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, Uint8 *slot_idx)
   270 {
   270 {
   271     int user_index;
   271     int user_index;
   272     int match_count;
   272     int match_count;
       
   273 
       
   274     *slot_idx = 0;
   273 
   275 
   274     match_count = 0;
   276     match_count = 0;
   275     for (user_index = 0; user_index < XUSER_MAX_COUNT; ++user_index) {
   277     for (user_index = 0; user_index < XUSER_MAX_COUNT; ++user_index) {
   276         if (!xinput_state[user_index].used && HIDAPI_DriverXbox360_XInputSlotMatches(state, user_index)) {
   278         if (!xinput_state[user_index].used && HIDAPI_DriverXbox360_XInputSlotMatches(state, user_index)) {
   277             ++match_count;
   279             ++match_count;
  1153             }
  1155             }
  1154         }
  1156         }
  1155         if (!ctx->xinput_correlated) {
  1157         if (!ctx->xinput_correlated) {
  1156             SDL_bool new_correlation_count = 0;
  1158             SDL_bool new_correlation_count = 0;
  1157             if (HIDAPI_DriverXbox360_MissingXInputSlot()) {
  1159             if (HIDAPI_DriverXbox360_MissingXInputSlot()) {
  1158                 Uint8 correlation_id;
  1160                 Uint8 correlation_id = 0;
  1159                 Uint8 slot_idx;
  1161                 Uint8 slot_idx = 0;
  1160                 if (HIDAPI_DriverXbox360_GuessXInputSlot(&match_state_xinput, &correlation_id, &slot_idx)) {
  1162                 if (HIDAPI_DriverXbox360_GuessXInputSlot(&match_state_xinput, &correlation_id, &slot_idx)) {
  1161                     /* we match exactly one XInput device */
  1163                     /* we match exactly one XInput device */
  1162                     /* Probably can do without xinput_correlation_count, just check and clear xinput_slot to ANY, unless
  1164                     /* Probably can do without xinput_correlation_count, just check and clear xinput_slot to ANY, unless
  1163                        we need even more frames to be sure */
  1165                        we need even more frames to be sure */
  1164                     if (ctx->xinput_correlation_count && ctx->xinput_slot == slot_idx) {
  1166                     if (ctx->xinput_correlation_count && ctx->xinput_slot == slot_idx) {