From 663a30a13bec3b5a29aaf506c6a50eaec99cec34 Mon Sep 17 00:00:00 2001 From: Cedric Hombourger Date: Tue, 12 Dec 2023 08:17:38 +0100 Subject: [PATCH] keyboard/qemu: translate symbols into key codes understood by QEMU's sendkey Signed-off-by: Cedric Hombourger --- mtda/keyboard/qemu.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mtda/keyboard/qemu.py b/mtda/keyboard/qemu.py index e97353d3..d36feabd 100644 --- a/mtda/keyboard/qemu.py +++ b/mtda/keyboard/qemu.py @@ -42,10 +42,23 @@ def idle(self): def press(self, key, repeat=1): self.mtda.debug(3, "keyboard.qemu.press()") + symbols = { + ',': 'comma', + '.': 'dot', + '*': 'asterisk', + '/': 'slash', + '-': 'minus', + '=': 'equal', + ' ': 'spc', + '\t': 'tab', + '\n': 'ret' + } + result = True while repeat > 0: repeat = repeat - 1 - self.qemu.cmd("sendkey %s" % key) + key = symbols[key] if key in symbols else key + self.qemu.cmd("sendkey {}".format(key)) time.sleep(0.1) return result