mirror of
https://github.com/rzzzwilson/pymlac.git
synced 2025-06-10 09:32:41 +00:00
Done for now, CTRL chars not working?
This commit is contained in:
parent
f0894c1bde
commit
4d0930cc0b
@ -44,57 +44,6 @@ We must emulate funny Imlac key values.
|
||||
|
||||
class Kbd(object):
|
||||
|
||||
######
|
||||
# This string has a \000 char at the PC key ordinal position if the key is dead.
|
||||
# Anything else and the key is live and the value is the unshifted value.
|
||||
######
|
||||
|
||||
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
KeyVal = ('\000\000\000\000\000\000\000\000\000\211\000\000\000\215\000\000' #00
|
||||
'\000\000\000\231\000\000\000\000\000\000\000\233\000\000\000\000' #01
|
||||
'\240\000\000\000\000\000\000\247\000\000\000\000\254\255\256\257' #02
|
||||
'\260\261\262\263\264\265\266\267\270\271\000\273\000\275\000\000' #03
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #04
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\212\000\000\000' #05
|
||||
'\000\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357' #06
|
||||
'\360\361\362\363\364\365\366\367\370\371\372\000\000\000\000\377' #07
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #08
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #09
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #0A
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #0B
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #0C
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #0D
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #0E
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #0F
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000' #10
|
||||
'\000\206\204\205\210\202\217\216\000\214\000\000\000\000\000\000' #11
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000') #12
|
||||
|
||||
######
|
||||
# This string has the shifted values for the key, indexed by PC key number.
|
||||
######
|
||||
|
||||
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
SKeyVal = ('\000\000\000\000\000\000\000\000\000\211\000\000\000\215\000\000'#00
|
||||
'\000\000\000\231\000\000\000\000\000\000\000\233\000\000\000\000'#01
|
||||
'\240\000\000\000\000\000\000\242\000\000\000\000\274\255\276\277'#02
|
||||
'\251\241\262\243\244\245\266\246\252\250\000\272\000\253\000\000'#03
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#04
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\212\000\000\000'#05
|
||||
'\000\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317'#06
|
||||
'\320\321\322\323\324\325\326\327\330\331\332\000\000\000\000\377'#07
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#08
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#09
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#0A
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#0B
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#0C
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#0D
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#0E
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#0F
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000'#10
|
||||
'\000\206\204\205\210\202\217\216\000\214\000\000\000\000\000\000'#11
|
||||
'\000\000\000\000\000\000\000\000\000\000\000\000\000') #12
|
||||
|
||||
# define the keycode values for modifier keys
|
||||
KeyShift = 0x0132
|
||||
KeyControl = 0x018c
|
||||
@ -106,9 +55,10 @@ class Kbd(object):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
# initialize keyboard device
|
||||
self.clear()
|
||||
|
||||
# .clear() doesn't clear flags
|
||||
# .clear() doesn't clear flags, so
|
||||
self.FlagR = 0
|
||||
self.FlagC = 0
|
||||
self.FlagS = 0
|
||||
@ -119,11 +69,8 @@ class Kbd(object):
|
||||
This is only to track modifier keys.
|
||||
"""
|
||||
|
||||
modifiers = event.GetModifiers()
|
||||
keycode = event.GetKeyCode()
|
||||
|
||||
print('DOWN: Modifiers=%04x, GetKeyCode=%04x' % (modifiers, keycode))
|
||||
|
||||
if keycode == self.KeyShift:
|
||||
self.FlagS = 1
|
||||
elif keycode == self.KeyControl:
|
||||
@ -137,11 +84,8 @@ class Kbd(object):
|
||||
This is only to track modifier keys.
|
||||
"""
|
||||
|
||||
modifiers = event.GetModifiers()
|
||||
keycode = event.GetKeyCode()
|
||||
|
||||
print(' UP: Modifiers=%04x, GetKeyCode=%04x' % (modifiers, keycode))
|
||||
|
||||
if keycode == self.KeyShift:
|
||||
self.FlagS = 0
|
||||
elif keycode == self.KeyControl:
|
||||
@ -153,7 +97,6 @@ class Kbd(object):
|
||||
"""Handle a CHAR key event."""
|
||||
|
||||
self.buffer = event.GetKeyCode()
|
||||
print('NEW: %04x' % ord(self.buffer))
|
||||
self.ready = True
|
||||
|
||||
def clear(self):
|
||||
|
||||
@ -81,6 +81,13 @@ class TestFrame(wx.Frame):
|
||||
char_str = chr(char)
|
||||
if char_str not in string.printable:
|
||||
char_str = '<unprintable>'
|
||||
elif char_str in string.whitespace:
|
||||
if char_str == '\t':
|
||||
char_str = '<TAB>'
|
||||
elif char_str == ' ':
|
||||
char_str = '<SPACE>'
|
||||
else:
|
||||
char_str = '<whitespace>'
|
||||
R = (value >> 10) & 0x01
|
||||
C = (value >> 9) & 0x01
|
||||
S = (value >> 8) & 0x01
|
||||
@ -89,22 +96,19 @@ class TestFrame(wx.Frame):
|
||||
% (R, C, S, char, char_str))
|
||||
self.display.Refresh()
|
||||
|
||||
|
||||
def OnKeyDown(self, event):
|
||||
"""Handle a "key down" event."""
|
||||
|
||||
# self.display.AppendText('DOWN: Modifiers=%04x, GetKeyCode=%04x\n'
|
||||
# % (event.GetModifiers(), event.GetKeyCode()))
|
||||
# self.display.Refresh()
|
||||
print('DOWN: Modifiers=%04x, GetKeyCode=%04x'
|
||||
% (event.GetModifiers(), event.GetKeyCode()))
|
||||
|
||||
self.kbd.handle_down_event(event)
|
||||
|
||||
def OnKeyUp(self, event):
|
||||
"""Handle a "key up" event."""
|
||||
|
||||
# self.display.AppendText('UP: Modifiers=%04x, GetKeyCode=%04x\n'
|
||||
# % (event.GetModifiers(), event.GetKeyCode()))
|
||||
# self.display.Refresh()
|
||||
print('UP: Modifiers=%04x, GetKeyCode=%04x'
|
||||
% (event.GetModifiers(), event.GetKeyCode()))
|
||||
|
||||
self.kbd.handle_up_event(event)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user