Exemplo n.º 1
0
    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();
        }
    }
Exemplo n.º 2
0
 int16_t axis(int i) const {
     int16_t result = SDL_JoystickGetAxis(ptr.get(), i);
     if(result == 0) {
         GUM_ERROR_HANDLER(result);
     }
     return result;
 }
Exemplo n.º 3
0
inline int number_of_joysticks() {
    int x = SDL_NumJoysticks();
    if(x < 0) {
        GUM_ERROR_HANDLER(x);
    }
    return x;
}
Exemplo n.º 4
0
 joystick_id id() const {
     joystick_id result = SDL_JoystickInstanceID(ptr.get());
     if(result == 0) {
         GUM_ERROR_HANDLER(result);
     }
     return result;
 }
Exemplo n.º 5
0
 int hats() const {
     int result = SDL_JoystickNumHats(ptr.get());
     if(result < 0) {
         GUM_ERROR_HANDLER(result);
     }
     return result;
 }
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
 void create(int index) {
     ptr.reset(SDL_GameControllerOpen(index));
     if(ptr == nullptr) {
         GUM_ERROR_HANDLER();
     }
 }
Exemplo n.º 9
0
 controller(int index): ptr(SDL_GameControllerOpen(index)) {
     if(ptr == nullptr) {
         GUM_ERROR_HANDLER();
     }
 }
Exemplo n.º 10
0
 void to_fullscreen(bool b = true) {
     if(SDL_SetWindowFullscreen(ptr.get(), b ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)) {
         GUM_ERROR_HANDLER();
     }
 }
Exemplo n.º 11
0
 void brightness(float bright) {
     if(SDL_SetWindowBrightness(ptr.get(), bright)) {
         GUM_ERROR_HANDLER();
     }
 }