summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8b3c740)
raw | patch | inline | side by side (parent: 8b3c740)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 2 Oct 2017 17:19:38 +0000 (20:19 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 2 Oct 2017 23:34:42 +0000 (02:34 +0300) |
src/flexui/fui_events.pas | patch | blob | history | |
src/flexui/sdlcarcass.pas | patch | blob | history | |
src/flexui/sdlstandalone.pas | patch | blob | history | |
src/game/g_main.pas | patch | blob | history |
index a5fa38606137b0f938bf9fd09cdc9991faa28683..919227aeb87f30f27a49c680b96f363286b61b20 100644 (file)
public
kind: TKind;
- scan: Word; // SDL_SCANCODE_XXX
+ scan: Word; // SDL_SCANCODE_XXX or 0 for character event
//sym: LongWord; // SDLK_XXX
ch: AnsiChar; // converted to 1251; can be #0
x, y: Integer; // current mouse position
@@ -194,7 +194,7 @@ function THMouseEvent.motion (): Boolean; inline; begin result := (kind = TKind.
procedure THMouseEvent.eat (); inline; begin mEaten := true; end;
procedure THMouseEvent.cancel (); inline; begin mCancelled := true; end;
-procedure THKeyEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; end;
+procedure THKeyEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; ch := #0; scan := 0; end;
function THKeyEvent.press (): Boolean; inline; begin result := (kind = TKind.Press); end;
function THKeyEvent.release (): Boolean; inline; begin result := (kind = TKind.Release); end;
procedure THKeyEvent.eat (); inline; begin mEaten := true; end;
index 3b019a224ac8594c602466f96cccfe866ada1de6..33a4664d004d493228af37ce69701a4e04c47cee 100644 (file)
end;
+// ////////////////////////////////////////////////////////////////////////// //
+var
+ wc2shitmap: array[0..65535] of AnsiChar;
+ wc2shitmapInited: Boolean = false;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
+const
+ cp1251: array[0..127] of Word = (
+ $0402,$0403,$201A,$0453,$201E,$2026,$2020,$2021,$20AC,$2030,$0409,$2039,$040A,$040C,$040B,$040F,
+ $0452,$2018,$2019,$201C,$201D,$2022,$2013,$2014,$003F,$2122,$0459,$203A,$045A,$045C,$045B,$045F,
+ $00A0,$040E,$045E,$0408,$00A4,$0490,$00A6,$00A7,$0401,$00A9,$0404,$00AB,$00AC,$00AD,$00AE,$0407,
+ $00B0,$00B1,$0406,$0456,$0491,$00B5,$00B6,$00B7,$0451,$2116,$0454,$00BB,$0458,$0405,$0455,$0457,
+ $0410,$0411,$0412,$0413,$0414,$0415,$0416,$0417,$0418,$0419,$041A,$041B,$041C,$041D,$041E,$041F,
+ $0420,$0421,$0422,$0423,$0424,$0425,$0426,$0427,$0428,$0429,$042A,$042B,$042C,$042D,$042E,$042F,
+ $0430,$0431,$0432,$0433,$0434,$0435,$0436,$0437,$0438,$0439,$043A,$043B,$043C,$043D,$043E,$043F,
+ $0440,$0441,$0442,$0443,$0444,$0445,$0446,$0447,$0448,$0449,$044A,$044B,$044C,$044D,$044E,$044F
+ );
+
+
+procedure initShitMap ();
+var
+ f: Integer;
+begin
+ for f := 0 to High(wc2shitmap) do wc2shitmap[f] := '?';
+ for f := 0 to 127 do wc2shitmap[f] := AnsiChar(f);
+ for f := 0 to 127 do wc2shitmap[cp1251[f]] := AnsiChar(f+128);
+ wc2shitmapInited := true;
+end;
+
+
+function wchar2win (wc: WideChar): AnsiChar; inline;
+begin
+ if not wc2shitmapInited then initShitMap();
+ if (LongWord(wc) > 65535) then result := '?' else result := wc2shitmap[LongWord(wc)];
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
function fuiOnSDLEvent (var ev: TSDL_Event): Boolean;
var
mev: THMouseEvent;
kev: THKeyEvent;
+ uc: UnicodeChar;
+ keychr: Word;
function buildBut (b: Byte): Word;
begin
end;
end;
- {
SDL_TEXTINPUT:
+ if ((fuiModState and (not THKeyEvent.ModShift)) = 0) then
begin
Utf8ToUnicode(@uc, PChar(ev.text.text), 1);
keychr := Word(uc);
if (keychr > 127) then keychr := Word(wchar2win(WideChar(keychr)));
- CharPress(AnsiChar(keychr));
+ if (keychr > 0) and assigned(evKeyCB) then
+ begin
+ FillChar(kev, sizeof(kev), 0);
+ kev.intrInit();
+ kev.kind := THKeyEvent.TKind.Press;
+ kev.scan := 0;
+ kev.ch := AnsiChar(keychr);
+ kev.x := fuiMouseX;
+ kev.y := fuiMouseY;
+ kev.bstate := fuiButState;
+ kev.kstate := fuiModState;
+ evKeyCB(kev);
+ result := kev.eaten;
+ end;
end;
- }
end;
end;
index 6dd81c76203fdab15963a1b12c6dc77eb714ded5..3959b2a28d22e4b8577ac3a04fe3633a639c304b 100644 (file)
//SDL_Quit();
result := true;
fuiWinActive := fuiWinActive;
+ SDL_StartTextInput();
end;
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 94762c9be1f59e69f6716da4afc3def5221cf882..57f12e98a45349501ccb52fd666817503eae7731 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
if SDL_Init(sdlflags) < 0 then
raise Exception.Create('SDL: Init failed: ' + SDL_GetError());
-{$IFDEF HEADLESS}
+{$IFNDEF HEADLESS}
SDL_StartTextInput();
{$ENDIF}