window(const std::string& title, int width, int height, uint32_t flag = 0): ptr(SDL_CreateWindow(title.c_str(), npos, npos, width, height, flag)) { if(ptr == nullptr) { GUM_ERROR_HANDLER(); } render.reset(SDL_CreateRenderer(ptr.get(), -1, renderer::accelerated)); if(render == nullptr) { GUM_ERROR_HANDLER(); } }
int16_t axis(int i) const { int16_t result = SDL_JoystickGetAxis(ptr.get(), i); if(result == 0) { GUM_ERROR_HANDLER(result); } return result; }
inline int number_of_joysticks() { int x = SDL_NumJoysticks(); if(x < 0) { GUM_ERROR_HANDLER(x); } return x; }
joystick_id id() const { joystick_id result = SDL_JoystickInstanceID(ptr.get()); if(result == 0) { GUM_ERROR_HANDLER(result); } return result; }
int hats() const { int result = SDL_JoystickNumHats(ptr.get()); if(result < 0) { GUM_ERROR_HANDLER(result); } return result; }
inline int add_controller_mapping_from_file(const std::string& filename) { int result = SDL_GameControllerAddMappingsFromFile(filename.c_str()); if(result == -1) { GUM_ERROR_HANDLER(result); } return result; }
inline bool add_controller_mapping(const std::string& mapping) { int result = SDL_GameControllerAddMapping(mapping.c_str()); if(result == -1) { GUM_ERROR_HANDLER(false); } return result == 1; }
void create(int index) { ptr.reset(SDL_GameControllerOpen(index)); if(ptr == nullptr) { GUM_ERROR_HANDLER(); } }
controller(int index): ptr(SDL_GameControllerOpen(index)) { if(ptr == nullptr) { GUM_ERROR_HANDLER(); } }
void to_fullscreen(bool b = true) { if(SDL_SetWindowFullscreen(ptr.get(), b ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)) { GUM_ERROR_HANDLER(); } }
void brightness(float bright) { if(SDL_SetWindowBrightness(ptr.get(), bright)) { GUM_ERROR_HANDLER(); } }