cleanup key handling

This commit is contained in:
April Ayres-Griffiths 2019-04-15 22:19:09 +10:00
parent 82aa2df3b4
commit 9e254d7273
3 changed files with 327 additions and 288 deletions

View File

@ -5764,6 +5764,249 @@ object GUIForm: TGUIForm
OnClick = MenuItem2Click
end
end
object miAudio: TMenuItem
Caption = 'Audio'
OnClick = miAudioClick
object miSNDMuted: TMenuItem
Caption = 'Mute'
OnClick = miSNDMutedClick
end
object miSNDMaster: TMenuItem
Caption = 'Master Volume'
OnClick = miSNDMasterClick
object miMVOL000: TMenuItem
Caption = '0'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL010: TMenuItem
Caption = '1'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL020: TMenuItem
Caption = '2'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL030: TMenuItem
Caption = '3'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL040: TMenuItem
Caption = '4'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL050: TMenuItem
Caption = '5'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL060: TMenuItem
Caption = '6'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL070: TMenuItem
Caption = '7'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL080: TMenuItem
Caption = '8'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL090: TMenuItem
Caption = '9'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL100: TMenuItem
Caption = '10'
RadioItem = True
OnClick = miMVOL000Click
end
end
object miSNDSpeaker: TMenuItem
Caption = 'Speaker Volume'
OnClick = miSNDSpeakerClick
object miSVOL000: TMenuItem
Caption = '0'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL010: TMenuItem
Caption = '1'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL020: TMenuItem
Caption = '2'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL030: TMenuItem
Caption = '3'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL040: TMenuItem
Caption = '4'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL050: TMenuItem
Caption = '5'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL060: TMenuItem
Caption = '6'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL070: TMenuItem
Caption = '7'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL080: TMenuItem
Caption = '8'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL090: TMenuItem
Caption = '9'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL100: TMenuItem
Caption = '10'
RadioItem = True
OnClick = miSVOL000Click
end
end
object miSNDMockingboard: TMenuItem
Caption = 'Mockingboard'
object miSNDPSG0: TMenuItem
Caption = 'PSG0 Balance'
OnClick = miSNDPSG0Click
object miPSG0m100: TMenuItem
Tag = -100
Caption = 'Left'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0m75: TMenuItem
Tag = -75
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0m50: TMenuItem
Tag = -50
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0m25: TMenuItem
Tag = -25
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p0: TMenuItem
Caption = 'Center'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p25: TMenuItem
Tag = 25
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p50: TMenuItem
Tag = 50
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p75: TMenuItem
Tag = 75
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p100: TMenuItem
Tag = 100
Caption = 'Right'
RadioItem = True
OnClick = miPSG0m100Click
end
end
object miSNDPSG1: TMenuItem
Caption = 'PSG1 Balance'
OnClick = miSNDPSG1Click
object miPSG1m100: TMenuItem
Tag = -100
Caption = 'Left'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1m75: TMenuItem
Tag = -75
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1m50: TMenuItem
Tag = -50
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1m25: TMenuItem
Tag = -25
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p0: TMenuItem
Caption = 'Center'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p25: TMenuItem
Tag = 25
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p50: TMenuItem
Tag = 50
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p75: TMenuItem
Tag = 75
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p100: TMenuItem
Tag = 100
Caption = 'Right'
RadioItem = True
OnClick = miPSG1m100Click
end
end
end
end
object miVideo: TMenuItem
Caption = 'Video'
object miScanLineInt: TMenuItem
@ -6157,249 +6400,6 @@ object GUIForm: TGUIForm
OnClick = miPasteTextClick
end
end
object miAudio: TMenuItem
Caption = 'Audio'
OnClick = miAudioClick
object miSNDMuted: TMenuItem
Caption = 'Mute'
OnClick = miSNDMutedClick
end
object miSNDMaster: TMenuItem
Caption = 'Master Volume'
OnClick = miSNDMasterClick
object miMVOL000: TMenuItem
Caption = '0'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL010: TMenuItem
Caption = '1'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL020: TMenuItem
Caption = '2'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL030: TMenuItem
Caption = '3'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL040: TMenuItem
Caption = '4'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL050: TMenuItem
Caption = '5'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL060: TMenuItem
Caption = '6'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL070: TMenuItem
Caption = '7'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL080: TMenuItem
Caption = '8'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL090: TMenuItem
Caption = '9'
RadioItem = True
OnClick = miMVOL000Click
end
object miMVOL100: TMenuItem
Caption = '10'
RadioItem = True
OnClick = miMVOL000Click
end
end
object miSNDSpeaker: TMenuItem
Caption = 'Speaker Volume'
OnClick = miSNDSpeakerClick
object miSVOL000: TMenuItem
Caption = '0'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL010: TMenuItem
Caption = '1'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL020: TMenuItem
Caption = '2'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL030: TMenuItem
Caption = '3'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL040: TMenuItem
Caption = '4'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL050: TMenuItem
Caption = '5'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL060: TMenuItem
Caption = '6'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL070: TMenuItem
Caption = '7'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL080: TMenuItem
Caption = '8'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL090: TMenuItem
Caption = '9'
RadioItem = True
OnClick = miSVOL000Click
end
object miSVOL100: TMenuItem
Caption = '10'
RadioItem = True
OnClick = miSVOL000Click
end
end
object miSNDMockingboard: TMenuItem
Caption = 'Mockingboard'
object miSNDPSG0: TMenuItem
Caption = 'PSG0 Balance'
OnClick = miSNDPSG0Click
object miPSG0m100: TMenuItem
Tag = -100
Caption = 'Left'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0m75: TMenuItem
Tag = -75
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0m50: TMenuItem
Tag = -50
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0m25: TMenuItem
Tag = -25
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p0: TMenuItem
Caption = 'Center'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p25: TMenuItem
Tag = 25
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p50: TMenuItem
Tag = 50
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p75: TMenuItem
Tag = 75
Caption = '...'
RadioItem = True
OnClick = miPSG0m100Click
end
object miPSG0p100: TMenuItem
Tag = 100
Caption = 'Right'
RadioItem = True
OnClick = miPSG0m100Click
end
end
object miSNDPSG1: TMenuItem
Caption = 'PSG1 Balance'
OnClick = miSNDPSG1Click
object miPSG1m100: TMenuItem
Tag = -100
Caption = 'Left'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1m75: TMenuItem
Tag = -75
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1m50: TMenuItem
Tag = -50
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1m25: TMenuItem
Tag = -25
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p0: TMenuItem
Caption = 'Center'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p25: TMenuItem
Tag = 25
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p50: TMenuItem
Tag = 50
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p75: TMenuItem
Tag = 75
Caption = '...'
RadioItem = True
OnClick = miPSG1m100Click
end
object miPSG1p100: TMenuItem
Tag = 100
Caption = 'Right'
RadioItem = True
OnClick = miPSG1m100Click
end
end
end
end
object miHardware: TMenuItem
Caption = 'Hardware'
object miSerial: TMenuItem

View File

@ -2796,82 +2796,95 @@ const
PAGE_DOWN = $e005;
SHIFT_CSR_LEFT = $e05b;
SHIFT_CSR_RIGHT = $e05c;
var
isShift: boolean;
isCtrl: boolean;
isAlt: boolean;
begin
isShift := (ssShift in Shift);
isCtrl := (ssCtrl in Shift);
isAlt := (ssAlt in Shift);
case Key of
219:
if ssShift in Shift then
Result := Ord('{')
if (isShift and not isCtrl) then
Result := Ord('{')
else if not isShift then
Result := Ord('[')
else
Result := Ord('[');
Result := 0;
221:
if ssShift in Shift then
Result := Ord('}')
if (isShift and not isCtrl) then
Result := Ord('}')
else if not isShift then
Result := Ord(']')
else
Result := Ord(']');
Result := 0;
222:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('"')
else
Result := Ord('''');
186:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord(':')
else
Result := Ord(';');
220:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('|')
else
Result := Ord('\');
191:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('?')
else
Result := Ord('/');
190:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('>')
else
Result := Ord('.');
188:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('<')
else
Result := Ord(',');
187:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('+')
else
Result := Ord('=');
189:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('_')
else
Result := Ord('-');
192:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('~')
else
Result := Ord('`');
VK_Up: if (ssShift in Shift) then
VK_Up: if (isShift and not isCtrl) then
Result := PAGE_UP
else
Result := CSR_UP;
VK_Down: if (ssShift in Shift) then
VK_Down: if (isShift and not isCtrl) then
Result := PAGE_DOWN
else
Result := CSR_DOWN;
VK_Left: if (ssShift in Shift) then
VK_Left: if (isShift and not isCtrl) then
Result := SHIFT_CSR_LEFT
else
Result := CSR_LEFT;
VK_Right: if (ssShift in Shift) then
VK_Right: if (isShift and not isCtrl) then
Result := SHIFT_CSR_RIGHT
else
Result := CSR_RIGHT;
VK_0..VK_9:
begin
if ssShift in Shift then
if (isShift and not isCtrl) then
case Key of
VK_0: Result := Ord(')');
VK_9: Result := Ord('(');
@ -2889,7 +2902,7 @@ begin
end;
VK_A..VK_Z:
begin
if (ssCtrl in Shift) and (ssShift in Shift) then
if (isShift and isCtrl) then
begin
//StatusBar1.SimpleText := 'Shift+Ctrl+'+char(Key);
Result := (Integer(Key) - 65) + SHIFT_CTRL_A;
@ -2927,8 +2940,12 @@ end;
procedure TGUIForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
var
code: integer;
begin
SendKey( MapKeyCode(Key, Shift), 0, 1, MapShiftState(Key, Shift) );
code := MapKeyCode(Key,Shift);
SendKey( code, 0, 1, MapShiftState(Key, Shift) );
StatusBar1.SimpleText := 'keycode = '+IntToStr(code);
end;
procedure TGUIForm.FormKeyPress(Sender: TObject; var Key: char);

View File

@ -2796,82 +2796,95 @@ const
PAGE_DOWN = $e005;
SHIFT_CSR_LEFT = $e05b;
SHIFT_CSR_RIGHT = $e05c;
var
isShift: boolean;
isCtrl: boolean;
isAlt: boolean;
begin
isShift := (ssShift in Shift);
isCtrl := (ssCtrl in Shift);
isAlt := (ssAlt in Shift);
case Key of
219:
if ssShift in Shift then
Result := Ord('{')
if (isShift and not isCtrl) then
Result := Ord('{')
else if not isShift then
Result := Ord('[')
else
Result := Ord('[');
Result := 0;
221:
if ssShift in Shift then
Result := Ord('}')
if (isShift and not isCtrl) then
Result := Ord('}')
else if not isShift then
Result := Ord(']')
else
Result := Ord(']');
Result := 0;
222:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('"')
else
Result := Ord('''');
186:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord(':')
else
Result := Ord(';');
220:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('|')
else
Result := Ord('\');
191:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('?')
else
Result := Ord('/');
190:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('>')
else
Result := Ord('.');
188:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('<')
else
Result := Ord(',');
187:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('+')
else
Result := Ord('=');
189:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('_')
else
Result := Ord('-');
192:
if ssShift in Shift then
if (isShift and not isCtrl) then
Result := Ord('~')
else
Result := Ord('`');
VK_Up: if (ssShift in Shift) then
VK_Up: if (isShift and not isCtrl) then
Result := PAGE_UP
else
Result := CSR_UP;
VK_Down: if (ssShift in Shift) then
VK_Down: if (isShift and not isCtrl) then
Result := PAGE_DOWN
else
Result := CSR_DOWN;
VK_Left: if (ssShift in Shift) then
VK_Left: if (isShift and not isCtrl) then
Result := SHIFT_CSR_LEFT
else
Result := CSR_LEFT;
VK_Right: if (ssShift in Shift) then
VK_Right: if (isShift and not isCtrl) then
Result := SHIFT_CSR_RIGHT
else
Result := CSR_RIGHT;
VK_0..VK_9:
begin
if ssShift in Shift then
if (isShift and not isCtrl) then
case Key of
VK_0: Result := Ord(')');
VK_9: Result := Ord('(');
@ -2889,7 +2902,7 @@ begin
end;
VK_A..VK_Z:
begin
if (ssCtrl in Shift) and (ssShift in Shift) then
if (isShift and isCtrl) then
begin
//StatusBar1.SimpleText := 'Shift+Ctrl+'+char(Key);
Result := (Integer(Key) - 65) + SHIFT_CTRL_A;
@ -2927,8 +2940,13 @@ end;
procedure TGUIForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
var
code: integer;
begin
SendKey( MapKeyCode(Key, Shift), 0, 1, MapShiftState(Key, Shift) );
code := MapKeyCode(Key,Shift);
if code <> 0 then
SendKey( code, 0, 1, MapShiftState(Key, Shift) );
StatusBar1.SimpleText := 'keycode = '+IntToStr(code);
end;
procedure TGUIForm.FormKeyPress(Sender: TObject; var Key: char);
@ -2937,8 +2955,12 @@ begin
end;
procedure TGUIForm.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
var
code: integer;
begin
SendKey( MapKeyCode(Key, Shift), 0, 0, MapShiftState(Key, Shift) );
code := MapKeyCode(Key,Shift);
if code <> 0 then
SendKey( code, 0, 0, MapShiftState(Key, Shift) );
//StatusBar1.SimpleText := 'keycode ' + IntToStr(Key);
end;