diff --git a/src/sdl2/main.c b/src/sdl2/main.c
index a6b98d6813f6020130572574a6ea010cc6025694..5b111de3af1ca4196a4165bed012aad3849a7dd6 100644 (file)
--- a/src/sdl2/main.c
+++ b/src/sdl2/main.c
#include "system.h"
#include "input.h"
+#include "cp866.h"
+
#include "my.h" // fexists
#include "player.h" // pl1 pl2
#include "menu.h" // G_keyf
static SDL_Window *window;
static SDL_GLContext context;
static SDL_Surface *surf;
+static videomode_t vlist;
/* --- error.h --- */
}
}
+static void init_videomode_list (void) {
+ int i, j, k;
+ SDL_DisplayMode m;
+ int n = SDL_GetNumDisplayModes(0);
+ if (vlist.modes != NULL) {
+ free(vlist.modes);
+ vlist.modes = NULL;
+ vlist.n = 0;
+ }
+ if (n > 0) {
+ vlist.modes = malloc(n * sizeof(videomode_size_t));
+ if (vlist.modes != NULL) {
+ j = 0;
+ for (i = 0; i < n; i++) {
+ SDL_GetDisplayMode(0, i, &m);
+ k = 0;
+ while (k < j && (m.w != vlist.modes[k].w || m.h != vlist.modes[k].h)) {
+ k++;
+ }
+ if (k >= j) {
+ vlist.modes[j] = (videomode_size_t) {
+ .w = m.w,
+ .h = m.h
+ };
+ j++;
+ }
+ }
+ vlist.n = j;
+ }
+ }
+}
+
+const videomode_t *Y_get_videomode_list_opengl (int fullscreen) {
+ init_videomode_list();
+ return &vlist;
+}
+
+const videomode_t *Y_get_videomode_list_software (int fullscreen) {
+ init_videomode_list();
+ return &vlist;
+}
+
void Y_set_fullscreen (int yes) {
if (window != NULL) {
SDL_SetWindowFullscreen(window, yes ? SDL_WINDOW_FULLSCREEN : 0);
break;
case SDL_TEXTINPUT:
uch = utf8_to_wchar(ev.text.text);
- ch = wchar_to_cp866(uch);
- GM_input(ch);
+ ch = cp866_utoc(uch);
+ if (ch >= 0) {
+ GM_input(ch);
+ }
break;
}
}