From 8b3e4f033a853758f9054867f737416ce1a14da0 Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Sun, 5 Apr 2020 01:40:52 +0200 Subject: [PATCH] Handle case where key is not in keymap --- src/m64py/ui/inputbutton.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/m64py/ui/inputbutton.py b/src/m64py/ui/inputbutton.py index c5516f7..2307c5c 100644 --- a/src/m64py/ui/inputbutton.py +++ b/src/m64py/ui/inputbutton.py @@ -19,6 +19,7 @@ from PyQt5.QtCore import Qt from sdl2.keyboard import SDL_GetScancodeName +from m64py.frontend.log import log from m64py.frontend.keymap import QT2SDL2 SDL_HAT_UP = 0x01 @@ -66,8 +67,12 @@ class InputButton(QPushButton): text = self.tr("Select...") self.setCheckable(False) else: - text = SDL_GetScancodeName(QT2SDL2[key]) - text = text.decode() + if key in QT2SDL2: + text = SDL_GetScancodeName(QT2SDL2[key]) + text = text.decode() + else: + log.warn("key %d not in keymap", key) + text = "" text = text.replace("Left ", "") self.setText(text.title())