Commit aa5e18ba authored by Denis Budyak's avatar Denis Budyak

Вроде справился с автономизацией обработки клавиатуры

parent d083c4de
System.PowerDown ~
System.Reboot ~
TFPET.Open Windows.Display.Mod V.Display.Mod BIOS.Keyboard.Mod ~
r.PokazhiSostojanieModulja Inputs~
TFPET.Open WindowManager.Mod Windows.Display.Mod WMKeyCode.Mod V.Display.Mod BIOS.Keyboard.Mod ~
Compiler.Compile IP.Mod IPv4.Mod IPv6.Mod ICMP.Mod Ping.Mod~
WMKeyCode.Open ~
WMKeyCode.StartLog ~
WMKeyCode.StopLog ~
TFPET.Open PodrobnajaPechatq.Mod r.Mod PrimerPodrobnajaPechatq.Mod ~
......@@ -13,7 +18,7 @@ System.FreeDownTo TFTypeSys BimboScanner.Mod ~
Compiler.Compile BimboScanner.Mod TFDumpTS.Mod TFModuleTrees.Mod TFAOParser.Mod TFTypeSys.Mod TFScopeTools.Mod TFDocGenerator.Mod ~
TFPET.Open BtDTraps.Mod WMDebugger.Mod FoxAMDBackend.Mod TestDbg.Mod ~
TFPET.Open BtDTraaps.Mod WMDebugger.Mod FoxAMDBackend.Mod TestDbg.Mod ~
Compiler.Compile TestDbg.Mod~
WMDebugger.Open TestDbg.Mod~
TestDbg.TestSort~
......
......@@ -570,14 +570,15 @@ VAR
PROCEDURE Report(VAR msg: AosInputs.KeyboardMsg; wParamS : SIGNED32);
BEGIN
PodrobnajaPechatq.ZadajjKontekstPechatiPoUmolch(kkk);
KernelLog.String("wParam: "); KernelLog.Int(wParamS, 0); KernelLog.Ln;
(* PodrobnajaPechatq.ZadajjKontekstPechatiPoUmolch(kkk);
Streams.OpenWriter(ww, KernelLog.Send);
kkk.w := ww;
kkk.pechKomandy := FALSE;
NEW(r1);
r1.wParamS := wParamS;
r1.msg := msg;
PodrobnajaPechatq.PechVKontekste(kkk, r1, TRUE);
PodrobnajaPechatq.PechVKontekste(kkk, r1, TRUE); *)
END Report;
......@@ -597,8 +598,7 @@ VAR
IF (msg.flags * AosInputs.Ctrl # {}) & (msg.flags * AosInputs.Alt = {}) & (VK0 <= wParam) & (wParam <= VK9) THEN
(* Same behaviour as AOS - naskolqko mogu ponjatq, Ctrl-0 .. Ctrl-9 dolzhny rabotatq kak prosto 0..9,
no na samom dele mozhno pereopredelitq ikh *)
(* Same behaviour as AOS - ne ponjal, chto ehto. Po-moemu, esli ehto ubratq, nichego ne izmenitsja *)
ch := CHR(wParam); key := SIGNED32(wParam);
END;
......@@ -649,80 +649,113 @@ VAR
END;
END HandleKey;
TYPE keyCodesToLowerUpperCaseCharsType = ARRAY[256] OF ARRAY[2] OF UNSIGNED8;
VAR keyCodesToLowerUpperCaseChars : keyCodesToLowerUpperCaseCharsType;
PROCEDURE Init_keyCodesToLowerUpperCaseChars;
(* flags: shift = 1, capslock = 2, control = 4 *)
CONST NumVirtualKeys = 256;
(* v tablice dlja kazhdogo vozmozhnogo koda naznachen massiv char-ov. Pri ehtom char = 0 oznachaetq,
chto ehta knopka dolzhna obrabatyvatqsja windows (tut my nadeemsja, chto raskladka bolee-menee
standartnaja, v protivnom sluchae u nas budut problemy - i togda budetq nado vnesti vse bukvy bez nulejj
i vsegda ignorirovatq WM).
char = CharIgnoreThisKey oznachaet, chto my knotim proignorirovatq ehtu knopku
*)
TYPE keyCodesToLowerUpperControlCharsType = ARRAY[NumVirtualKeys+1] OF ARRAY[8] OF UNSIGNED16;
VAR keyCodesToLowerUpperControlChars : keyCodesToLowerUpperControlCharsType;
PROCEDURE Init_keyCodesToLowerUpperControlChars;
VAR i:UNSIGNED8; a : keyCodesToLowerUpperControlCharsType;
VAR shift, caps, ctrl : UNSIGNED8;
PROCEDURE Digit(keyCode: UNSIGNED8; shifted : UNSIGNED8);
BEGIN
a[keyCode][shift] := shifted;
a[keyCode][shift + caps] := shifted;
(* dlja Ctrl nichego ne delaem - ehtot sluchajj obrabatyvaetsja otdelqnym kostyljom v
HandleKey *)
(* Ctrl+Shift ne dolzhny rabotatq, no dlja igr - dolzhny, poehtomu ostavim ikh zhitq *)
a[keyCode][ctrl+shift] := keyCode;
a[keyCode][ctrl+caps+shift] := keyCode;
END Digit;
PROCEDURE KirillicaIZnakPrepinanija(virtualKeyCode, normal, shifted : UNSIGNED8);
BEGIN
a[virtualKeyCode][0] := normal;
a[virtualKeyCode][shift] := shifted;
a[virtualKeyCode][caps] := shifted;
a[virtualKeyCode][caps + shift] := normal;
a[virtualKeyCode][ctrl] := normal;
a[virtualKeyCode][ctrl + shift ] := normal;
a[virtualKeyCode][ctrl + caps] := normal;
a[virtualKeyCode][ctrl + caps + shift] := normal
END KirillicaIZnakPrepinanija;
BEGIN
keyCodesToLowerUpperCaseChars[192][0] := 96; (* knopka ` *)
keyCodesToLowerUpperCaseChars[192][1] := 126;
keyCodesToLowerUpperCaseChars[48][1] := 41; (* 030H - knopka 0 *)
keyCodesToLowerUpperCaseChars[50][1] := 64; (* knopka 2 *)
keyCodesToLowerUpperCaseChars[51][1] := 35; (* knopka 3 *)
keyCodesToLowerUpperCaseChars[52][1] := 36; (* knopka 4 *)
keyCodesToLowerUpperCaseChars[53][1] := 37; (* knopka 5 *)
keyCodesToLowerUpperCaseChars[54][1] := 94; (* knopka 6*)
keyCodesToLowerUpperCaseChars[55][1] := 38; (* knopka 7*)
keyCodesToLowerUpperCaseChars[56][1] := 42; (* knopka 8 *)
keyCodesToLowerUpperCaseChars[57][1] := 40; (* knopka 9*)
keyCodesToLowerUpperCaseChars[219][0] := 91; (* knopka ` *)
keyCodesToLowerUpperCaseChars[219][1] := 123;
keyCodesToLowerUpperCaseChars[221][0] := 93; (* knopka ` *)
keyCodesToLowerUpperCaseChars[221][1] := 125;
keyCodesToLowerUpperCaseChars[189][1] := 45; (* knopka - *)
keyCodesToLowerUpperCaseChars[187][1] := 61; (* knopka =*)
keyCodesToLowerUpperCaseChars[186][0] := 59; (* knopka : *)
keyCodesToLowerUpperCaseChars[186][1] := 58;
shift := 1;
caps := 2;
ctrl := 4;
FOR i := 65 TO 90 DO (* A..Z = 041H .. 05AH *)
a[i][0] := i + 32;
a[i][shift] := i;
a[i][caps] := i;
a[i][caps + shift] := i + 32;
a[i][ctrl] := i - 64;
a[i][ctrl + shift ] := i - 64;
a[i][ctrl + caps] := i - 64;
a[i][ctrl + caps + shift] := i - 64; END;
Digit(48,41); (* 030H - knopka 0 *)
Digit(49,33); (* knopka 1 *)
Digit(50,64); (* knopka 2 *)
Digit(51,35); (* knopka 3 *)
Digit(52,36); (* knopka 4 *)
Digit(53,37); (* knopka 5 *)
Digit(54,94); (* knopka 6 *)
Digit(55,38); (* knopka 7 *)
Digit(56,42); (* knopka 8 *)
Digit(57,40); (* knopka 9 *)
KirillicaIZnakPrepinanija(192, 96, 126); (* knopka ` = jo *)
KirillicaIZnakPrepinanija(219,91,123); (* knopka [ *)
KirillicaIZnakPrepinanija(221,93,125); (* knopka ] *)
KirillicaIZnakPrepinanija(189,45,95); (* knopka - *)
KirillicaIZnakPrepinanija(187,61,43); (* knopka =*)
KirillicaIZnakPrepinanija(186,59,58); (* knopka : *)
KirillicaIZnakPrepinanija(222,39,34); (* knopka '*)
KirillicaIZnakPrepinanija(188,44,60); (* knopka ,*)
KirillicaIZnakPrepinanija(190,46,62); (* knopka . *)
KirillicaIZnakPrepinanija(191,47,63); (* knopka / *)
keyCodesToLowerUpperCaseChars[222][0] := 39; (* knopka '*)
keyCodesToLowerUpperCaseChars[222][1] := 34;
keyCodesToLowerUpperCaseChars[188][0] := 44; (* knopka ,*)
keyCodesToLowerUpperCaseChars[188][1] := 60;
keyCodesToLowerUpperCaseChars[190][0] := 46; (* knopka . *)
keyCodesToLowerUpperCaseChars[190][1] := 62;
keyCodesToLowerUpperCaseChars[191][0] := 47; (* knopka *)
keyCodesToLowerUpperCaseChars[191][1] := 63;
END Init_keyCodesToLowerUpperCaseChars;
keyCodesToLowerUpperControlChars := a;
END Init_keyCodesToLowerUpperControlChars;
PROCEDURE ObrabotajjCifroBukvy(VAR msg : AosInputs.KeyboardMsg; virtualKeyCode: SIGNED32);
VAR upperCase : BOOLEAN; upperCaseIndex : UNSIGNED8;
VAR ShiftCapsCtrl : UNSIGNED8;
(* virtual key codes = https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes *)
ord : SIGNED32;
controlHeld : BOOLEAN;
shiftHeld : BOOLEAN;
BEGIN
(* a = 97, z = 122, A = 65, Z = 90
KernelLog.String("UchtiShiftICapsLock: "); KernelLog.Int(ORD(msg.ch),0); KernelLog.Ln;
RETURN;*)
IF msg.flags * (AosInputs.Ctrl + AosInputs.Alt) # {} THEN
KernelLog.String("ObrobotajjCifroBukvy: avoiding processing key combination"); KernelLog.Ln;
IF msg.flags * AosInputs.Alt # {} THEN
KernelLog.String("ObrobotajjCifroBukvy: avoiding processing Alt-key combination"); KernelLog.Ln;
RETURN END;
IF msg.flags * AosInputs.Shift # {} THEN
INC(ShiftCapsCtrl,1) END;
IF CapsLockOn THEN
INC(ShiftCapsCtrl,2) END;
IF msg.flags * AosInputs.Ctrl # {} THEN
INC(ShiftCapsCtrl,4) END;
upperCase := CapsLockOn;
IF (AosInputs.LeftShift IN msg.flags) OR (AosInputs.RightShift IN msg.flags) THEN
upperCase := ~upperCase END;
IF (65 <= virtualKeyCode) & (virtualKeyCode <= 90) THEN (* A..Z = 041H .. 05AH *)
IF upperCase THEN
ord := virtualKeyCode
ELSE
ord := virtualKeyCode + 32 END
ELSIF virtualKeyCode < 256 THEN
IF upperCase THEN upperCaseIndex := 1 END;
ord := keyCodesToLowerUpperCaseChars[virtualKeyCode][upperCaseIndex] END;
IF virtualKeyCode < NumVirtualKeys THEN
ord := keyCodesToLowerUpperControlChars[virtualKeyCode][ShiftCapsCtrl] END;
IF ord # 0 THEN
msg.ch := CHR(ord);
msg.keysym := ord;
KernelLog.String("ObrabotajjCifroBukvy itog"); KernelLog.Ln;
Report(msg, virtualKeyCode) END END ObrabotajjCifroBukvy;
Report(msg, virtualKeyCode);
RETURN END END ObrabotajjCifroBukvy;
(* default handler for WMKeyDown or WMKeyUp messages *)
PROCEDURE HandleKeyUp( win: Window; wParam: User32.WParam; lParam: User32.LParam );
......@@ -1328,7 +1361,7 @@ BEGIN
traceDisplay := FALSE;
format := Displays.color8888;
InitMod(); Modules.InstallTermHandler( Shutdown ); KeyHandled := FALSE; CapsLockOn := FALSE;
Init_keyCodesToLowerUpperCaseChars;
Init_keyCodesToLowerUpperControlChars;
END Display.
Aos.Call Display.Install 1024 768 ~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment