OVR: Change the way to walk and rotate with the controller
[mercenary-reloaded.git] / src / libsdl / sdl.c
index 0b17c16..804695c 100644 (file)
@@ -23,7 +23,6 @@
 #include "print.h"
 #include "../../include/keycodes.h"
 #include "sdl.h"
-#include "opengl.h"
 
 #include <SDL2/SDL.h>
 #define GL3_PROTOTYPES 1
@@ -64,6 +63,7 @@ int init_sdl(const char *progname, int width, int height, int sound_samplerate,
        }
        sdl_initialized = 1;
 
+retry_without_multisampling:
        if (multisampling > 1) {
                SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
                SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
@@ -77,7 +77,16 @@ int init_sdl(const char *progname, int width, int height, int sound_samplerate,
        /* open window */
        gl_window = SDL_CreateWindow(progname, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
        if (!gl_window) {
-               print_error("Failed to open SDL window: %s (try without multisampling)\n", SDL_GetError());
+               if (multisampling) {
+                       print_info("Failed to open SDL window: %s (retrying without multisampling)\n", SDL_GetError());
+                       SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
+                       SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
+                       multisampling = 0;
+                       goto retry_without_multisampling;
+               }
+               print_error("Failed to open SDL window: %s\n", SDL_GetError());
+               SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
+               SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multisampling);
                rc = EIO;
                goto error;
        }
@@ -193,6 +202,8 @@ static enum keycode sdl2keycode(SDL_Keycode sym)
        case SDLK_RCTRL: return KEYCODE_RCTRL;
        case SDLK_LSHIFT: return KEYCODE_LSHIFT;
        case SDLK_RSHIFT: return KEYCODE_RSHIFT;
+       case SDLK_LALT: return KEYCODE_LALT;
+       case SDLK_RALT: return KEYCODE_RALT;
        case SDLK_PAUSE: return KEYCODE_PAUSE;
        case SDLK_LEFT: return KEYCODE_LEFT;
        case SDLK_RIGHT: return KEYCODE_RIGHT;