change special key combos to more generic keys
authorTaylor Richards <taylor@icculus.org>
Sat, 10 Mar 2018 05:01:43 +0000 (00:01 -0500)
committerTaylor Richards <taylor@icculus.org>
Sat, 10 Mar 2018 05:01:43 +0000 (00:01 -0500)
 Fullscreen/Window: SUPER+f -> ALT+ENTER
 Minimize window: SUPER+z -> CTRL+ALT+z
 Screenshot: SUPER+p -> CTRL+ALT+p

include/platform.h
src/osapi/osapi.cpp
src/platform/unix.cpp
src/platform/win.cpp

index ddd02d4..7f93c51 100644 (file)
 
 void base_filename(const char *path, char *filename, const int max_fname);
 
-void platform_init();
-void platform_close();
-
 int platform_open_url(const char *url);
 
-unsigned int platform_get_kmod();
-
 #endif // PLATFORM_H
index 87b9536..48cd1b0 100644 (file)
@@ -359,17 +359,26 @@ void os_poll()
                        }
 
                        case SDL_KEYDOWN: {
-                               if ( (e.key.keysym.mod & KMOD_GUI) || (platform_get_kmod() & KMOD_GUI) ) {
+                               // flip between fullscreen and window: ALT+ENTER
+                               if ( (e.key.keysym.sym == SDLK_RETURN) && ( e.key.keysym.mod & KMOD_ALT) ) {
                                        if ( !e.key.repeat ) {
-                                               if (e.key.keysym.sym == SDLK_f) {
-                                                       gr_toggle_fullscreen();
-                                               } else if (e.key.keysym.sym == SDLK_z) {
-                                                       SDL_MinimizeWindow(Os_window);
-                                               } else if (e.key.keysym.sym == SDLK_p) {
-                                                       key_mark(SDL_SCANCODE_PRINTSCREEN, 1, 0, 0);
-                                               }
+                                               gr_toggle_fullscreen();
                                        }
-                               } else {
+                               }
+                               // minimize window: CTRL+ALT+z
+                               else if ( (e.key.keysym.sym == SDLK_z) && (e.key.keysym.mod & (KMOD_CTRL | KMOD_ALT)) ) {
+                                       if ( !e.key.repeat ) {
+                                               SDL_MinimizeWindow(Os_window);
+                                       }
+                               }
+                               // print screen / screenshot: CTRL+ALT+p
+                               else if ( (e.key.keysym.sym == SDLK_p) && (e.key.keysym.mod & (KMOD_CTRL | KMOD_ALT)) ) {
+                                       if ( !e.key.repeat ) {
+                                               key_mark(SDL_SCANCODE_PRINTSCREEN, 1, 0, 0);
+                                       }
+                               }
+                               // everything else is processed normally
+                               else {
                                        key_mark(e.key.keysym.scancode, 1, e.key.keysym.mod, 0);
                                }
 
@@ -377,12 +386,7 @@ void os_poll()
                        }
 
                        case SDL_KEYUP: {
-                               if ( (e.key.keysym.mod & KMOD_GUI) || (platform_get_kmod() & KMOD_GUI) ) {
-                                       // blank, just don't want to process up keys we skipped
-                                       // the down for
-                               } else {
-                                       key_mark(e.key.keysym.scancode, 0, e.key.keysym.mod, 0);
-                               }
+                               key_mark(e.key.keysym.scancode, 0, e.key.keysym.mod, 0);
 
                                break;
                        }
index f1f0498..9bf15f1 100644 (file)
@@ -75,19 +75,4 @@ int platform_open_url(const char *url)
        return -1;
 }
 
-unsigned int platform_get_kmod()
-{
-       return 0;
-}
-
-void platform_init()
-{
-       // nothing
-}
-
-void platform_close()
-{
-       // nothing
-}
-
 #endif
index a785395..f3994b0 100644 (file)
@@ -52,51 +52,4 @@ int platform_open_url(const char *url)
        return 0;
 }
 
-static HHOOK winHook;
-static unsigned int win_KMOD = 0;
-
-LRESULT CALLBACK winkeyEater(int nCode, WPARAM wParam, LPARAM lParam)
-{
-       if ( (nCode < 0) || (nCode != HC_ACTION) ) {
-               return CallNextHookEx(winHook, nCode, wParam, lParam);
-       }
-
-       bool eat_key = false;
-       KBDLLHOOKSTRUCT *p = (KBDLLHOOKSTRUCT *)lParam;
-
-       switch (wParam) {
-               case WM_KEYDOWN:
-               case WM_KEYUP: {
-                       eat_key = (os_foreground() && ((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)));
-                       break;
-               }
-
-               default:
-                       break;
-       }
-
-       if (eat_key) {
-               win_KMOD = (wParam == WM_KEYDOWN) ? KMOD_GUI : 0;
-               return 1;
-       } else {
-               return CallNextHookEx(winHook, nCode, wParam, lParam);
-       }
-}
-
-unsigned int platform_get_kmod()
-{
-       return win_KMOD;
-}
-
-void platform_init()
-{
-       // eat WIN/GUI key so that the OS doesn't mess us up
-       winHook = SetWindowsHookEx(WH_KEYBOARD_LL, winkeyEater, GetModuleHandle(NULL), 0);
-}
-
-void platform_close()
-{
-       UnhookWindowsHookEx(winHook);
-}
-
 #endif