DEADSOFTWARE

Added touchscreen controls
[d2df-sdl.git] / src / game / g_window.pas
index 90c5950caa830d59d0670e3aba4e3f4eed6fb6a8..3a29d0803081a585868b03fdd87b0bd01b7e8748 100644 (file)
@@ -1,4 +1,4 @@
- (* Copyright (C)  Doom 2D: Forever Developers
+(* Copyright (C)  Doom 2D: Forever Developers
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -61,7 +61,8 @@ uses
   g_console, e_input, g_options, g_game,
   g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net,
   g_map, g_gfx, g_monsters, g_holmes, xprofiler,
-  sdlcarcass, fui_ctls;
+  sdlcarcass, fui_ctls,
+  g_touch;
 
 
 const
@@ -93,9 +94,9 @@ begin
   if (h_Wnd <> nil) then SDL_DestroyWindow(h_Wnd);
   if (h_GL <> nil) and (not preserveGL) then
   begin
-    {$IFDEF USE_NANOGL}
-      nanoGL_Destroy;
-    {$ENDIF USE_NANOGL}
+{$IFDEF USE_NANOGL}
+    nanoGL_Destroy;
+{$ENDIF USE_NANOGL}
     SDL_GL_DeleteContext(h_GL);
   end;
   h_Wnd := nil;
@@ -471,6 +472,8 @@ begin
     SDL_KEYDOWN, SDL_KEYUP:
       begin
         key := ev.key.keysym.scancode;
+        if key = SDL_SCANCODE_AC_BACK then
+          key := SDL_SCANCODE_ESCAPE;
         down := (ev.type_ = SDL_KEYDOWN);
         {$IF not DEFINED(HEADLESS)}
         if fuiOnSDLEvent(ev) then
@@ -497,6 +500,9 @@ begin
         if (keychr > 0) and (keychr <= 255) then CharPress(AnsiChar(keychr));
       end;
 
+    SDL_FINGERMOTION, SDL_FINGERDOWN, SDL_FINGERUP:
+      g_Touch_HandleEvent(ev.tfinger);
+
     // other key presses and joysticks are handled in e_input
   end;
 end;
@@ -542,7 +548,7 @@ begin
     e_WriteLog('nanoGL initialization error', TMsgType.Fatal);
     exit;
   end;
-{$ENDIF USE_NANOGL}
+{$ENDIF}
   if (assigned(oglInitCB)) then oglInitCB();
   if (h_GL <> nil) then g_SetVSync(gVSync);
 {$ENDIF}