diff options
| author | 2019-06-03 16:04:56 -0400 | |
|---|---|---|
| committer | 2019-06-03 16:56:46 -0400 | |
| commit | 7ea07c60633e2f775dc06e8d58b25ffa0e4dd312 (patch) | |
| tree | a1f70027372e07005badb85df52612bc3b0764cf /src/input_common/sdl/sdl_impl.cpp | |
| parent | input_common/sdl: Remove unused header includes and forward declarations (diff) | |
| download | yuzu-7ea07c60633e2f775dc06e8d58b25ffa0e4dd312.tar.gz yuzu-7ea07c60633e2f775dc06e8d58b25ffa0e4dd312.tar.xz yuzu-7ea07c60633e2f775dc06e8d58b25ffa0e4dd312.zip | |
input_common/sdl/sdl_impl: Resolve two sign conversion warnings
Silences the final two warnings in SDL code.
Diffstat (limited to 'src/input_common/sdl/sdl_impl.cpp')
| -rw-r--r-- | src/input_common/sdl/sdl_impl.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 24252279d..be1a77b30 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp | |||
| @@ -161,30 +161,35 @@ std::shared_ptr<SDLJoystick> SDLState::GetSDLJoystickBySDLID(SDL_JoystickID sdl_ | |||
| 161 | std::lock_guard lock{joystick_map_mutex}; | 161 | std::lock_guard lock{joystick_map_mutex}; |
| 162 | auto map_it = joystick_map.find(guid); | 162 | auto map_it = joystick_map.find(guid); |
| 163 | if (map_it != joystick_map.end()) { | 163 | if (map_it != joystick_map.end()) { |
| 164 | auto vec_it = std::find_if(map_it->second.begin(), map_it->second.end(), | 164 | const auto vec_it = |
| 165 | [&sdl_joystick](const std::shared_ptr<SDLJoystick>& joystick) { | 165 | std::find_if(map_it->second.begin(), map_it->second.end(), |
| 166 | return sdl_joystick == joystick->GetSDLJoystick(); | 166 | [&sdl_joystick](const std::shared_ptr<SDLJoystick>& joystick) { |
| 167 | }); | 167 | return sdl_joystick == joystick->GetSDLJoystick(); |
| 168 | }); | ||
| 168 | if (vec_it != map_it->second.end()) { | 169 | if (vec_it != map_it->second.end()) { |
| 169 | // This is the common case: There is already an existing SDL_Joystick maped to a | 170 | // This is the common case: There is already an existing SDL_Joystick maped to a |
| 170 | // SDLJoystick. return the SDLJoystick | 171 | // SDLJoystick. return the SDLJoystick |
| 171 | return *vec_it; | 172 | return *vec_it; |
| 172 | } | 173 | } |
| 174 | |||
| 173 | // Search for a SDLJoystick without a mapped SDL_Joystick... | 175 | // Search for a SDLJoystick without a mapped SDL_Joystick... |
| 174 | auto nullptr_it = std::find_if(map_it->second.begin(), map_it->second.end(), | 176 | const auto nullptr_it = std::find_if(map_it->second.begin(), map_it->second.end(), |
| 175 | [](const std::shared_ptr<SDLJoystick>& joystick) { | 177 | [](const std::shared_ptr<SDLJoystick>& joystick) { |
| 176 | return !joystick->GetSDLJoystick(); | 178 | return !joystick->GetSDLJoystick(); |
| 177 | }); | 179 | }); |
| 178 | if (nullptr_it != map_it->second.end()) { | 180 | if (nullptr_it != map_it->second.end()) { |
| 179 | // ... and map it | 181 | // ... and map it |
| 180 | (*nullptr_it)->SetSDLJoystick(sdl_joystick); | 182 | (*nullptr_it)->SetSDLJoystick(sdl_joystick); |
| 181 | return *nullptr_it; | 183 | return *nullptr_it; |
| 182 | } | 184 | } |
| 185 | |||
| 183 | // There is no SDLJoystick without a mapped SDL_Joystick | 186 | // There is no SDLJoystick without a mapped SDL_Joystick |
| 184 | // Create a new SDLJoystick | 187 | // Create a new SDLJoystick |
| 185 | auto joystick = std::make_shared<SDLJoystick>(guid, map_it->second.size(), sdl_joystick); | 188 | const int port = static_cast<int>(map_it->second.size()); |
| 189 | auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick); | ||
| 186 | return map_it->second.emplace_back(std::move(joystick)); | 190 | return map_it->second.emplace_back(std::move(joystick)); |
| 187 | } | 191 | } |
| 192 | |||
| 188 | auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick); | 193 | auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick); |
| 189 | return joystick_map[guid].emplace_back(std::move(joystick)); | 194 | return joystick_map[guid].emplace_back(std::move(joystick)); |
| 190 | } | 195 | } |
| @@ -211,7 +216,8 @@ void SDLState::InitJoystick(int joystick_index) { | |||
| 211 | (*it)->SetSDLJoystick(sdl_joystick); | 216 | (*it)->SetSDLJoystick(sdl_joystick); |
| 212 | return; | 217 | return; |
| 213 | } | 218 | } |
| 214 | auto joystick = std::make_shared<SDLJoystick>(guid, joystick_guid_list.size(), sdl_joystick); | 219 | const int port = static_cast<int>(joystick_guid_list.size()); |
| 220 | auto joystick = std::make_shared<SDLJoystick>(guid, port, sdl_joystick); | ||
| 215 | joystick_guid_list.emplace_back(std::move(joystick)); | 221 | joystick_guid_list.emplace_back(std::move(joystick)); |
| 216 | } | 222 | } |
| 217 | 223 | ||