summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 15184bf)
raw | patch | inline | side by side (parent: 15184bf)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 6 Oct 2019 20:06:45 +0000 (23:06 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 13 Oct 2019 14:19:20 +0000 (17:19 +0300) |
src/engine/e_input_stub.inc | patch | blob | history | |
src/game/sdl/g_system.pas | patch | blob | history | |
src/shared/utils.pas | patch | blob | history |
index b2ca332a9b73aad172ffb06e8f43025366e77dca..670390a2b4c256f2ac257e35e4c972c79ee75c69 100644 (file)
IK_Y = 106;
IK_Z = 107;
IK_MINUS = 108;
+ IK_RMETA = 109;
+ IK_LMETA = 110;
// TODO: think of something better than this shit
IK_LASTKEY = e_MaxKbdKeys-1;
e_KeyNames[IK_DOT] := '.';
e_KeyNames[IK_MINUS] := '-';
e_KeyNames[IK_EQUALS] := '=';
+ e_KeyNames[IK_RMETA] := 'RMETA';
+ e_KeyNames[IK_LMETA] := 'LMETA';
// joysticks
for j := 0 to e_MaxJoys-1 do
index a72f6584446c64c1065ac8ec236fb0934b0c9a58..81b1ca3dc6ade228ac39c49b5d7cbc1e41409252 100644 (file)
interface
(* To fix:
- * - Text input
* - Joystick support
* - Window resizing using SDL_VIDEORESIZE
+ * -- Linux: GL drawing area have wrong size
+ * -- OSX: GL context are recreated
*)
uses Utils;
uses
SysUtils, SDL, GL,
e_log, e_graphics, e_input,
- g_options, g_window, g_console, g_game, g_menu;
+ g_options, g_window, g_console, g_game, g_menu, g_gui, g_main;
var
screen: PSDL_Surface;
SDLK_PAUSE: x := IK_PAUSE;
SDLK_A..SDLK_Z: x := IK_A + (key - SDLK_A);
SDLK_MINUS: x := IK_MINUS;
+ SDLK_RMETA: x := IK_RMETA;
+ SDLK_LMETA: x := IK_LMETA;
else
x := IK_INVALID
end;
end;
procedure HandleKeyboard (var ev: TSDL_KeyboardEvent);
- var down: Boolean; key, stb: Integer;
+ var down, repeated: Boolean; key: Integer; ch: Char;
begin
+ key := Key2Stub(ev.keysym.sym);
down := (ev.type_ = SDL_KEYDOWN);
- key := ev.keysym.sym;
- stb := Key2Stub(key);
+ repeated := down and e_KeyPressed(key);
+ ch := wchar2win(WideChar(ev.keysym.unicode));
if g_dbg_input then
- e_LogWritefln('Input Debug: keysym, press=%s, scancode=%s SDL.ev.key.state=%s', [down, key, ev.state]);
- e_KeyUpDown(stb, down);
- g_Console_ProcessBind(stb, down);
- (* !!! need text input -- console, cheaats, fields *)
+ e_LogWritefln('Input Debug: keysym, down=%s, sym=%s, state=%s, unicode=%s, stubsym=%s, cp1251=%s', [down, ev.keysym.sym, ev.state, ev.keysym.unicode, key, Ord(ch)]);
+ if not repeated then
+ begin
+ e_KeyUpDown(key, down);
+ g_Console_ProcessBind(key, down);
+ end
+ else if gConsoleShow or gChatShow or (g_ActiveWindow <> nil) then
+ begin
+ KeyPress(key)
+ end;
+ if down and (ev.keysym.unicode <= $44F) then
+ begin
+ if IsPrintable1251(ch) then
+ CharPress(ch)
+ end
end;
function sys_HandleInput (): Boolean;
raise Exception.Create('SDL: Init failed: ' + SDL_GetError());
ok := InitWindow(gScreenWidth, gScreenHeight, gBPP, gFullScreen);
if not ok then
- raise Exception.Create('SDL: failed to set videomode: ' + SDL_GetError)
+ raise Exception.Create('SDL: failed to set videomode: ' + SDL_GetError);
+ SDL_EnableUNICODE(1);
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
end;
procedure sys_Final;
diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index 867f0dcbef1befffb33b7d3a66cc40b57eeb360e..4c4db7b0df59997698bca6e3d5861cb9ba9a01a0 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
function upcase1251 (ch: AnsiChar): AnsiChar; inline;
function locase1251 (ch: AnsiChar): AnsiChar; inline;
+function IsPrintable1251 (ch: AnsiChar): Boolean;
function toLowerCase1251 (const s: AnsiString): AnsiString;
result := ch;
end;
+function IsPrintable1251 (ch: AnsiChar): Boolean;
+begin
+ result := (ch >= #32) and (ch <> #127)
+end;
+
function strEquCI1251 (const s0, s1: AnsiString): Boolean;
var