|
@@ -25,6 +25,8 @@ var
|
|
|
|
|
|
{$i keybrdh.inc}
|
|
|
|
|
|
+function KeyPressed:Boolean;
|
|
|
+
|
|
|
implementation
|
|
|
|
|
|
{ WARNING: Keyboard-Drivers (i.e. german) will only work under WinNT.
|
|
@@ -59,6 +61,10 @@ var
|
|
|
HasAltGr : Boolean = false;
|
|
|
|
|
|
|
|
|
+function KeyPressed:Boolean;
|
|
|
+begin
|
|
|
+ KeyPressed:=PollKeyEvent<>0;
|
|
|
+end;
|
|
|
|
|
|
procedure incqueueindex(var l : longint);
|
|
|
|
|
@@ -145,95 +151,95 @@ var
|
|
|
altc : char;
|
|
|
addThis: boolean;
|
|
|
begin
|
|
|
- with ir.Event.KeyEvent do
|
|
|
- begin
|
|
|
- { key up events are ignored (except alt) }
|
|
|
- if bKeyDown then
|
|
|
- begin
|
|
|
- EnterCriticalSection (lockVar);
|
|
|
- for i:=1 to wRepeatCount do
|
|
|
- begin
|
|
|
- addThis := true;
|
|
|
- if (dwControlKeyState and LEFT_ALT_PRESSED <> 0) or
|
|
|
- (dwControlKeyState and RIGHT_ALT_PRESSED <> 0) then {alt pressed}
|
|
|
- if ((wVirtualKeyCode >= $60) and (wVirtualKeyCode <= $69)) or
|
|
|
- ((dwControlKeyState and ENHANCED_KEY = 0) and
|
|
|
- (wVirtualKeyCode in [$C{VK_CLEAR generated by keypad 5},
|
|
|
- $21 {VK_PRIOR (PgUp) 9},
|
|
|
- $22 {VK_NEXT (PgDown) 3},
|
|
|
- $23 {VK_END 1},
|
|
|
- $24 {VK_HOME 7},
|
|
|
- $25 {VK_LEFT 4},
|
|
|
- $26 {VK_UP 8},
|
|
|
- $27 {VK_RIGHT 6},
|
|
|
- $28 {VK_DOWN 2},
|
|
|
- $2D {VK_INSERT 0}])) then {0..9 on NumBlock}
|
|
|
- begin
|
|
|
- if length (altNumBuffer) = 3 then
|
|
|
- delete (altNumBuffer,1,1);
|
|
|
- case wVirtualKeyCode of
|
|
|
- $60..$69 : altc:=char (wVirtualKeyCode-48);
|
|
|
- $c : altc:='5';
|
|
|
- $21 : altc:='9';
|
|
|
- $22 : altc:='3';
|
|
|
- $23 : altc:='1';
|
|
|
- $24 : altc:='7';
|
|
|
- $25 : altc:='4';
|
|
|
- $26 : altc:='8';
|
|
|
- $27 : altc:='6';
|
|
|
- $28 : altc:='2';
|
|
|
- $2D : altc:='0';
|
|
|
- end;
|
|
|
- altNumBuffer := altNumBuffer + altc;
|
|
|
- altNumActive := true;
|
|
|
- addThis := false;
|
|
|
- end else
|
|
|
- begin
|
|
|
- altNumActive := false;
|
|
|
- altNumBuffer := '';
|
|
|
- end;
|
|
|
- if addThis then
|
|
|
- begin
|
|
|
- keyboardeventqueue[nextfreekeyevent]:=
|
|
|
- ir.Event.KeyEvent;
|
|
|
- incqueueindex(nextfreekeyevent);
|
|
|
- end;
|
|
|
+ with ir.Event.KeyEvent do
|
|
|
+ begin
|
|
|
+ { key up events are ignored (except alt) }
|
|
|
+ if bKeyDown then
|
|
|
+ begin
|
|
|
+ EnterCriticalSection (lockVar);
|
|
|
+ for i:=1 to wRepeatCount do
|
|
|
+ begin
|
|
|
+ addThis := true;
|
|
|
+ if (dwControlKeyState and LEFT_ALT_PRESSED <> 0) or
|
|
|
+ (dwControlKeyState and RIGHT_ALT_PRESSED <> 0) then {alt pressed}
|
|
|
+ if ((wVirtualKeyCode >= $60) and (wVirtualKeyCode <= $69)) or
|
|
|
+ ((dwControlKeyState and ENHANCED_KEY = 0) and
|
|
|
+ (wVirtualKeyCode in [$C{VK_CLEAR generated by keypad 5},
|
|
|
+ $21 {VK_PRIOR (PgUp) 9},
|
|
|
+ $22 {VK_NEXT (PgDown) 3},
|
|
|
+ $23 {VK_END 1},
|
|
|
+ $24 {VK_HOME 7},
|
|
|
+ $25 {VK_LEFT 4},
|
|
|
+ $26 {VK_UP 8},
|
|
|
+ $27 {VK_RIGHT 6},
|
|
|
+ $28 {VK_DOWN 2},
|
|
|
+ $2D {VK_INSERT 0}])) then {0..9 on NumBlock}
|
|
|
+ begin
|
|
|
+ if length (altNumBuffer) = 3 then
|
|
|
+ delete (altNumBuffer,1,1);
|
|
|
+ case wVirtualKeyCode of
|
|
|
+ $60..$69 : altc:=char (wVirtualKeyCode-48);
|
|
|
+ $c : altc:='5';
|
|
|
+ $21 : altc:='9';
|
|
|
+ $22 : altc:='3';
|
|
|
+ $23 : altc:='1';
|
|
|
+ $24 : altc:='7';
|
|
|
+ $25 : altc:='4';
|
|
|
+ $26 : altc:='8';
|
|
|
+ $27 : altc:='6';
|
|
|
+ $28 : altc:='2';
|
|
|
+ $2D : altc:='0';
|
|
|
end;
|
|
|
-
|
|
|
- lastShiftState := transShiftState (dwControlKeyState); {save it for PollShiftStateEvent}
|
|
|
- SetEvent (newKeyEvent); {event that a new key is available}
|
|
|
- LeaveCriticalSection (lockVar);
|
|
|
- end
|
|
|
- else
|
|
|
- begin
|
|
|
- lastShiftState := transShiftState (dwControlKeyState); {save it for PollShiftStateEvent}
|
|
|
- {for alt-number we have to look for alt-key release}
|
|
|
- if altNumActive then
|
|
|
+ altNumBuffer := altNumBuffer + altc;
|
|
|
+ altNumActive := true;
|
|
|
+ addThis := false;
|
|
|
+ end else
|
|
|
begin
|
|
|
- if (wVirtualKeyCode = $12) then {alt-released}
|
|
|
- begin
|
|
|
- if altNumBuffer <> '' then {numbers with alt pressed?}
|
|
|
- begin
|
|
|
- Val (altNumBuffer, c, i);
|
|
|
- if (i = 0) and (c <= 255) then {valid number?}
|
|
|
- begin {add to queue}
|
|
|
- fillchar (ir, sizeof (ir), 0);
|
|
|
- bKeyDown := true;
|
|
|
- AsciiChar := char (c);
|
|
|
- {and add to queue}
|
|
|
- EnterCriticalSection (lockVar);
|
|
|
- keyboardeventqueue[nextfreekeyevent]:=ir.Event.KeyEvent;
|
|
|
- incqueueindex(nextfreekeyevent);
|
|
|
- SetEvent (newKeyEvent); {event that a new key is available}
|
|
|
- LeaveCriticalSection (lockVar);
|
|
|
- end;
|
|
|
- end;
|
|
|
- altNumActive := false; {clear alt-buffer}
|
|
|
- altNumBuffer := '';
|
|
|
- end;
|
|
|
+ altNumActive := false;
|
|
|
+ altNumBuffer := '';
|
|
|
end;
|
|
|
- end;
|
|
|
- end;
|
|
|
+ if addThis then
|
|
|
+ begin
|
|
|
+ keyboardeventqueue[nextfreekeyevent]:=
|
|
|
+ ir.Event.KeyEvent;
|
|
|
+ incqueueindex(nextfreekeyevent);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+ lastShiftState := transShiftState (dwControlKeyState); {save it for PollShiftStateEvent}
|
|
|
+ SetEvent (newKeyEvent); {event that a new key is available}
|
|
|
+ LeaveCriticalSection (lockVar);
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ lastShiftState := transShiftState (dwControlKeyState); {save it for PollShiftStateEvent}
|
|
|
+ {for alt-number we have to look for alt-key release}
|
|
|
+ if altNumActive then
|
|
|
+ begin
|
|
|
+ if (wVirtualKeyCode = $12) then {alt-released}
|
|
|
+ begin
|
|
|
+ if altNumBuffer <> '' then {numbers with alt pressed?}
|
|
|
+ begin
|
|
|
+ Val (altNumBuffer, c, i);
|
|
|
+ if (i = 0) and (c <= 255) then {valid number?}
|
|
|
+ begin {add to queue}
|
|
|
+ fillchar (ir, sizeof (ir), 0);
|
|
|
+ bKeyDown := true;
|
|
|
+ AsciiChar := char (c);
|
|
|
+ {and add to queue}
|
|
|
+ EnterCriticalSection (lockVar);
|
|
|
+ keyboardeventqueue[nextfreekeyevent]:=ir.Event.KeyEvent;
|
|
|
+ incqueueindex(nextfreekeyevent);
|
|
|
+ SetEvent (newKeyEvent); {event that a new key is available}
|
|
|
+ LeaveCriticalSection (lockVar);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ altNumActive := false; {clear alt-buffer}
|
|
|
+ altNumBuffer := '';
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
procedure CheckAltGr;
|