| 208 | } |
| 209 | |
| 210 | static void AddGameControllerDB() { |
| 211 | // Load mappings from crowd-sourced controller database |
| 212 | // Update at: |
| 213 | // https://github.com/gabomdq/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt |
| 214 | DiskFileDescriptor file; |
| 215 | std::vector<char> file_buf; |
| 216 | if (!file.Open("Data/gamecontrollerdb.txt", "r")) { |
| 217 | return; |
| 218 | } |
| 219 | int file_size = file.GetSize(); |
| 220 | file_buf.resize(file_size); |
| 221 | |
| 222 | int bytes_read = file.ReadBytesPartial(&file_buf[0], file_size); |
| 223 | file_buf.resize(bytes_read + 1); |
| 224 | file_buf.back() = '\0'; |
| 225 | file.Close(); |
| 226 | |
| 227 | SDL_RWops* SDL_file = SDL_RWFromConstMem(&file_buf[0], file_buf.size()); |
| 228 | if (SDL_file) { |
| 229 | int mappings = SDL_GameControllerAddMappingsFromRW(SDL_file, 1); |
| 230 | LOGI << "Added " << mappings << " controller mappings." << std::endl; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | void Input::Initialize() { |
| 235 | InitKeyTranslator(); |
no test coverage detected