def keyPressEvent(self, event): modifier = event.modifiers() if modifier == Qt.NoModifier or modifier == Qt.KeypadModifier: key = event.key() else: key = modifier.__int__() if key == Qt.Key_Escape: text = self.key self.setCheckable(False) elif key == Qt.Key_Backspace: text = self.tr("Select...") self.setCheckable(False) else: if SDL2 or self.input.parent.worker.core.core_sdl2: from m64py.SDL2.keyboard import SDL_GetScancodeName text = SDL_GetScancodeName(QT2SDL2[key]) else: from m64py.SDL.keyboard import SDL_GetKeyName text = SDL_GetKeyName(QT2SDL[key]).title() text = text.decode() text = text.replace("Left ", "") self.setText(text.title()) self.clearFocus()
def get_key_name(self, sdl_key): if not sdl_key: return self.tr("Select...") if SDL2 or self.parent.worker.core.core_sdl2: from m64py.SDL2.keyboard import SDL_GetScancodeName try: text = SDL_GetScancodeName(KEYCODE2SCANCODE[int(sdl_key)]) except Exception: return self.tr("Select...") else: from m64py.SDL.keyboard import SDL_GetKeyName text = SDL_GetKeyName(int(sdl_key)).title() if not text: return self.tr("Select...") if "Shift" in text or "Ctrl" in text or "Alt" in text: text = text.replace("Left ", "") return text.title()