|
@@ -79,6 +79,8 @@ var
|
|
KeyPut,
|
|
KeyPut,
|
|
KeySend : longint;
|
|
KeySend : longint;
|
|
|
|
|
|
|
|
+ PendingEnhancedKeyEvent: TEnhancedKeyEvent;
|
|
|
|
+
|
|
{ Buffered Input routines }
|
|
{ Buffered Input routines }
|
|
const
|
|
const
|
|
InSize=256;
|
|
InSize=256;
|
|
@@ -1407,6 +1409,46 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function EnhShiftState:TEnhancedShiftState;
|
|
|
|
+const
|
|
|
|
+ KG_SHIFT = 0;
|
|
|
|
+ KG_CTRL = 2;
|
|
|
|
+ KG_ALT = 3;
|
|
|
|
+ KG_ALTGR = 1;
|
|
|
|
+ KG_SHIFTL = 4;
|
|
|
|
+ KG_KANASHIFT = 4;
|
|
|
|
+ KG_SHIFTR = 5;
|
|
|
|
+ KG_CTRLL = 6;
|
|
|
|
+ KG_CTRLR = 7;
|
|
|
|
+ KG_CAPSSHIFT = 8;
|
|
|
|
+var
|
|
|
|
+ arg: longint;
|
|
|
|
+begin
|
|
|
|
+ EnhShiftState:=[];
|
|
|
|
+ arg:=6;
|
|
|
|
+ if fpioctl(StdInputHandle,TIOCLINUX,@arg)=0 then
|
|
|
|
+ begin
|
|
|
|
+ if (arg and (1 shl KG_ALT))<>0 then
|
|
|
|
+ Include(EnhShiftState,essAlt);
|
|
|
|
+ if (arg and (1 shl KG_CTRL))<>0 then
|
|
|
|
+ Include(EnhShiftState,essCtrl);
|
|
|
|
+ if (arg and (1 shl KG_CTRLL))<>0 then
|
|
|
|
+ Include(EnhShiftState,essLeftCtrl);
|
|
|
|
+ if (arg and (1 shl KG_CTRLR))<>0 then
|
|
|
|
+ Include(EnhShiftState,essRightCtrl);
|
|
|
|
+ { 2 corresponds to AltGr so set both kbAlt and kbCtrl PM }
|
|
|
|
+ if (arg and (1 shl KG_ALTGR))<>0 then
|
|
|
|
+ {shiftstate:=shiftstate or (kbAlt or kbCtrl);}
|
|
|
|
+ Include(EnhShiftState,essRightAlt);
|
|
|
|
+ if (arg and (1 shl KG_SHIFT))<>0 then
|
|
|
|
+ Include(EnhShiftState,essShift);
|
|
|
|
+ if (arg and (1 shl KG_SHIFTL))<>0 then
|
|
|
|
+ Include(EnhShiftState,essLeftShift);
|
|
|
|
+ if (arg and (1 shl KG_SHIFTR))<>0 then
|
|
|
|
+ Include(EnhShiftState,essRightShift);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure force_linuxtty;
|
|
procedure force_linuxtty;
|
|
|
|
|
|
var s:string[15];
|
|
var s:string[15];
|
|
@@ -1446,6 +1488,7 @@ end;
|
|
|
|
|
|
procedure SysInitKeyboard;
|
|
procedure SysInitKeyboard;
|
|
begin
|
|
begin
|
|
|
|
+ PendingEnhancedKeyEvent:=NilEnhancedKeyEvent;
|
|
Utf8KeyboardInputEnabled:=UnixKVMBase.UTF8Enabled;
|
|
Utf8KeyboardInputEnabled:=UnixKVMBase.UTF8Enabled;
|
|
SetRawMode(true);
|
|
SetRawMode(true);
|
|
{$ifdef logging}
|
|
{$ifdef logging}
|
|
@@ -1505,7 +1548,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-function SysGetKeyEvent: TKeyEvent;
|
|
|
|
|
|
+function SysGetEnhancedKeyEvent: TEnhancedKeyEvent;
|
|
|
|
|
|
function EvalScan(b:byte):byte;
|
|
function EvalScan(b:byte):byte;
|
|
const
|
|
const
|
|
@@ -1565,23 +1608,30 @@ var
|
|
MyScan:byte;
|
|
MyScan:byte;
|
|
MyChar : char;
|
|
MyChar : char;
|
|
EscUsed,AltPrefixUsed,CtrlPrefixUsed,ShiftPrefixUsed,IsAlt,Again : boolean;
|
|
EscUsed,AltPrefixUsed,CtrlPrefixUsed,ShiftPrefixUsed,IsAlt,Again : boolean;
|
|
- SState:byte;
|
|
|
|
|
|
+ SState: TEnhancedShiftState;
|
|
|
|
|
|
begin {main}
|
|
begin {main}
|
|
|
|
+ if PendingEnhancedKeyEvent<>NilEnhancedKeyEvent then
|
|
|
|
+ begin
|
|
|
|
+ SysGetEnhancedKeyEvent:=PendingEnhancedKeyEvent;
|
|
|
|
+ PendingEnhancedKeyEvent:=NilEnhancedKeyEvent;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ SysGetEnhancedKeyEvent:=NilEnhancedKeyEvent;
|
|
MyChar:=Readkey(IsAlt);
|
|
MyChar:=Readkey(IsAlt);
|
|
MyScan:=ord(MyChar);
|
|
MyScan:=ord(MyChar);
|
|
{$ifdef linux}
|
|
{$ifdef linux}
|
|
if is_console then
|
|
if is_console then
|
|
- SState:=ShiftState
|
|
|
|
|
|
+ SState:=EnhShiftState
|
|
else
|
|
else
|
|
{$endif}
|
|
{$endif}
|
|
- Sstate:=0;
|
|
|
|
|
|
+ Sstate:=[];
|
|
CtrlPrefixUsed:=false;
|
|
CtrlPrefixUsed:=false;
|
|
AltPrefixUsed:=false;
|
|
AltPrefixUsed:=false;
|
|
ShiftPrefixUsed:=false;
|
|
ShiftPrefixUsed:=false;
|
|
EscUsed:=false;
|
|
EscUsed:=false;
|
|
if IsAlt then
|
|
if IsAlt then
|
|
- SState:=SState or kbAlt;
|
|
|
|
|
|
+ Include(SState, essAlt);
|
|
repeat
|
|
repeat
|
|
again:=false;
|
|
again:=false;
|
|
if Mychar=#0 then
|
|
if Mychar=#0 then
|
|
@@ -1590,7 +1640,7 @@ begin {main}
|
|
if myscan=$01 then
|
|
if myscan=$01 then
|
|
mychar:=#27;
|
|
mychar:=#27;
|
|
{ Handle Ctrl-<x>, but not AltGr-<x> }
|
|
{ Handle Ctrl-<x>, but not AltGr-<x> }
|
|
- if ((SState and kbCtrl)<>0) and ((SState and kbAlt) = 0) then
|
|
|
|
|
|
+ if (essCtrl in SState) and (not (essAlt in SState)) then
|
|
case MyScan of
|
|
case MyScan of
|
|
kbShiftTab: MyScan := kbCtrlTab;
|
|
kbShiftTab: MyScan := kbCtrlTab;
|
|
kbHome..kbDel : { cArrow }
|
|
kbHome..kbDel : { cArrow }
|
|
@@ -1601,7 +1651,7 @@ begin {main}
|
|
MyScan:=MyScan+kbCtrlF11-kbF11;
|
|
MyScan:=MyScan+kbCtrlF11-kbF11;
|
|
end
|
|
end
|
|
{ Handle Alt-<x>, but not AltGr }
|
|
{ Handle Alt-<x>, but not AltGr }
|
|
- else if ((SState and kbAlt)<>0) and ((SState and kbCtrl) = 0) then
|
|
|
|
|
|
+ else if (essAlt in SState) and (not (essCtrl in SState)) then
|
|
case MyScan of
|
|
case MyScan of
|
|
kbShiftTab: MyScan := kbAltTab;
|
|
kbShiftTab: MyScan := kbAltTab;
|
|
kbHome..kbDel : { AltArrow }
|
|
kbHome..kbDel : { AltArrow }
|
|
@@ -1611,7 +1661,7 @@ begin {main}
|
|
kbF11..KbF12 : { aF11-aF12 }
|
|
kbF11..KbF12 : { aF11-aF12 }
|
|
MyScan:=MyScan+kbAltF11-kbF11;
|
|
MyScan:=MyScan+kbAltF11-kbF11;
|
|
end
|
|
end
|
|
- else if (SState and kbShift)<>0 then
|
|
|
|
|
|
+ else if essShift in SState then
|
|
case MyScan of
|
|
case MyScan of
|
|
kbIns: MyScan:=kbShiftIns;
|
|
kbIns: MyScan:=kbShiftIns;
|
|
kbDel: MyScan:=kbShiftDel;
|
|
kbDel: MyScan:=kbShiftDel;
|
|
@@ -1625,28 +1675,30 @@ begin {main}
|
|
if myscan <= kbShiftEnd then
|
|
if myscan <= kbShiftEnd then
|
|
begin
|
|
begin
|
|
myscan:=ShiftArrow[myscan];
|
|
myscan:=ShiftArrow[myscan];
|
|
- sstate:=sstate or kbshift;
|
|
|
|
|
|
+ Include(sstate, essShift);
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
myscan:=CtrlShiftArrow[myscan];
|
|
myscan:=CtrlShiftArrow[myscan];
|
|
- sstate:=sstate or kbshift or kbCtrl;
|
|
|
|
|
|
+ sstate:=sstate + [essShift, essCtrl];
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
if myscan=kbAltBack then
|
|
if myscan=kbAltBack then
|
|
- sstate:=sstate or kbalt;
|
|
|
|
- if (MyChar<>#0) or (MyScan<>0) or (SState<>0) then
|
|
|
|
- SysGetKeyEvent:=$3000000 or ord(MyChar) or (MyScan shl 8) or (SState shl 16)
|
|
|
|
- else
|
|
|
|
- SysGetKeyEvent:=0;
|
|
|
|
|
|
+ Include(sstate, essAlt);
|
|
|
|
+ if (MyChar<>#0) or (MyScan<>0) or (SState<>[]) then
|
|
|
|
+ begin
|
|
|
|
+ SysGetEnhancedKeyEvent.AsciiChar:=MyChar;
|
|
|
|
+ SysGetEnhancedKeyEvent.ShiftState:=SState;
|
|
|
|
+ SysGetEnhancedKeyEvent.VirtualScanCode:=(MyScan shl 8) or Ord(MyChar);
|
|
|
|
+ end;
|
|
exit;
|
|
exit;
|
|
end
|
|
end
|
|
else if MyChar=#27 then
|
|
else if MyChar=#27 then
|
|
begin
|
|
begin
|
|
if EscUsed then
|
|
if EscUsed then
|
|
- SState:=SState and not kbAlt
|
|
|
|
|
|
+ SState:=SState-[essAlt,essLeftAlt,essRightAlt]
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- SState:=SState or kbAlt;
|
|
|
|
|
|
+ Include(SState,essAlt);
|
|
Again:=true;
|
|
Again:=true;
|
|
EscUsed:=true;
|
|
EscUsed:=true;
|
|
end;
|
|
end;
|
|
@@ -1654,42 +1706,40 @@ begin {main}
|
|
else if (AltPrefix<>0) and (MyChar=chr(AltPrefix)) then
|
|
else if (AltPrefix<>0) and (MyChar=chr(AltPrefix)) then
|
|
begin { ^Z - replace Alt for Linux OS }
|
|
begin { ^Z - replace Alt for Linux OS }
|
|
if AltPrefixUsed then
|
|
if AltPrefixUsed then
|
|
- begin
|
|
|
|
- SState:=SState and not kbAlt;
|
|
|
|
- end
|
|
|
|
|
|
+ SState:=SState-[essAlt,essLeftAlt,essRightAlt]
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
AltPrefixUsed:=true;
|
|
AltPrefixUsed:=true;
|
|
- SState:=SState or kbAlt;
|
|
|
|
|
|
+ Include(SState,essAlt);
|
|
Again:=true;
|
|
Again:=true;
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
else if (CtrlPrefix<>0) and (MyChar=chr(CtrlPrefix)) then
|
|
else if (CtrlPrefix<>0) and (MyChar=chr(CtrlPrefix)) then
|
|
begin
|
|
begin
|
|
if CtrlPrefixUsed then
|
|
if CtrlPrefixUsed then
|
|
- SState:=SState and not kbCtrl
|
|
|
|
|
|
+ SState:=SState-[essCtrl,essLeftCtrl,essRightCtrl]
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
CtrlPrefixUsed:=true;
|
|
CtrlPrefixUsed:=true;
|
|
- SState:=SState or kbCtrl;
|
|
|
|
|
|
+ Include(SState,essCtrl);
|
|
Again:=true;
|
|
Again:=true;
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
else if (ShiftPrefix<>0) and (MyChar=chr(ShiftPrefix)) then
|
|
else if (ShiftPrefix<>0) and (MyChar=chr(ShiftPrefix)) then
|
|
begin
|
|
begin
|
|
if ShiftPrefixUsed then
|
|
if ShiftPrefixUsed then
|
|
- SState:=SState and not kbShift
|
|
|
|
|
|
+ SState:=SState-[essShift,essLeftShift,essRightShift]
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
ShiftPrefixUsed:=true;
|
|
ShiftPrefixUsed:=true;
|
|
- SState:=SState or kbShift;
|
|
|
|
|
|
+ Include(SState,essShift);
|
|
Again:=true;
|
|
Again:=true;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
if not again then
|
|
if not again then
|
|
begin
|
|
begin
|
|
MyScan:=EvalScan(ord(MyChar));
|
|
MyScan:=EvalScan(ord(MyChar));
|
|
- if ((SState and kbCtrl)<>0) and ((SState and kbAlt) = 0) then
|
|
|
|
|
|
+ if (essCtrl in SState) and (not (essAlt in SState)) then
|
|
begin
|
|
begin
|
|
if MyChar=#9 then
|
|
if MyChar=#9 then
|
|
begin
|
|
begin
|
|
@@ -1697,7 +1747,7 @@ begin {main}
|
|
MyScan:=kbCtrlTab;
|
|
MyScan:=kbCtrlTab;
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
- else if ((SState and kbAlt)<>0) and ((SState and kbCtrl) = 0) then
|
|
|
|
|
|
+ else if (essAlt in SState) and (not (essCtrl in SState)) then
|
|
begin
|
|
begin
|
|
if MyChar=#9 then
|
|
if MyChar=#9 then
|
|
begin
|
|
begin
|
|
@@ -1711,7 +1761,7 @@ begin {main}
|
|
MyChar:=chr(0);
|
|
MyChar:=chr(0);
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
- else if (SState and kbShift)<>0 then
|
|
|
|
|
|
+ else if essShift in SState then
|
|
if MyChar=#9 then
|
|
if MyChar=#9 then
|
|
begin
|
|
begin
|
|
MyChar:=#0;
|
|
MyChar:=#0;
|
|
@@ -1723,28 +1773,32 @@ begin {main}
|
|
MyChar:=Readkey(IsAlt);
|
|
MyChar:=Readkey(IsAlt);
|
|
MyScan:=ord(MyChar);
|
|
MyScan:=ord(MyChar);
|
|
if IsAlt then
|
|
if IsAlt then
|
|
- SState:=SState or kbAlt;
|
|
|
|
|
|
+ Include(SState,essAlt);
|
|
end;
|
|
end;
|
|
until not Again;
|
|
until not Again;
|
|
- if (MyChar<>#0) or (MyScan<>0) or (SState<>0) then
|
|
|
|
- SysGetKeyEvent:=$3000000 or ord(MyChar) or (MyScan shl 8) or (SState shl 16)
|
|
|
|
- else
|
|
|
|
- SysGetKeyEvent:=0;
|
|
|
|
|
|
+ if (MyChar<>#0) or (MyScan<>0) or (SState<>[]) then
|
|
|
|
+ begin
|
|
|
|
+ SysGetEnhancedKeyEvent.AsciiChar:=MyChar;
|
|
|
|
+ SysGetEnhancedKeyEvent.ShiftState:=SState;
|
|
|
|
+ SysGetEnhancedKeyEvent.VirtualScanCode:=(MyScan shl 8) or Ord(MyChar);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-function SysPollKeyEvent: TKeyEvent;
|
|
|
|
|
|
+function SysPollEnhancedKeyEvent: TEnhancedKeyEvent;
|
|
var
|
|
var
|
|
- KeyEvent : TKeyEvent;
|
|
|
|
|
|
+ KeyEvent : TEnhancedKeyEvent;
|
|
begin
|
|
begin
|
|
- if keypressed then
|
|
|
|
|
|
+ if PendingEnhancedKeyEvent<>NilEnhancedKeyEvent then
|
|
|
|
+ SysPollEnhancedKeyEvent:=PendingEnhancedKeyEvent
|
|
|
|
+ else if keypressed then
|
|
begin
|
|
begin
|
|
- KeyEvent:=SysGetKeyEvent;
|
|
|
|
- PutKeyEvent(KeyEvent);
|
|
|
|
- SysPollKeyEvent:=KeyEvent
|
|
|
|
|
|
+ KeyEvent:=SysGetEnhancedKeyEvent;
|
|
|
|
+ PendingEnhancedKeyEvent:=KeyEvent;
|
|
|
|
+ SysPollEnhancedKeyEvent:=KeyEvent;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- SysPollKeyEvent:=0;
|
|
|
|
|
|
+ SysPollEnhancedKeyEvent:=NilEnhancedKeyEvent;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1769,13 +1823,13 @@ const
|
|
SysKeyboardDriver : TKeyboardDriver = (
|
|
SysKeyboardDriver : TKeyboardDriver = (
|
|
InitDriver : @SysInitKeyBoard;
|
|
InitDriver : @SysInitKeyBoard;
|
|
DoneDriver : @SysDoneKeyBoard;
|
|
DoneDriver : @SysDoneKeyBoard;
|
|
- GetKeyevent : @SysGetKeyEvent;
|
|
|
|
- PollKeyEvent : @SysPollKeyEvent;
|
|
|
|
|
|
+ GetKeyevent : Nil;
|
|
|
|
+ PollKeyEvent : Nil;
|
|
GetShiftState : @SysGetShiftState;
|
|
GetShiftState : @SysGetShiftState;
|
|
TranslateKeyEvent : Nil;
|
|
TranslateKeyEvent : Nil;
|
|
TranslateKeyEventUnicode : Nil;
|
|
TranslateKeyEventUnicode : Nil;
|
|
- GetEnhancedKeyEvent : Nil;
|
|
|
|
- PollEnhancedKeyEvent : Nil;
|
|
|
|
|
|
+ GetEnhancedKeyEvent : @SysGetEnhancedKeyEvent;
|
|
|
|
+ PollEnhancedKeyEvent : @SysPollEnhancedKeyEvent;
|
|
);
|
|
);
|
|
|
|
|
|
begin
|
|
begin
|