alt+esc on joystick yellow click
This commit is contained in:
@@ -3,15 +3,15 @@ import evdev
|
||||
import uinput
|
||||
import subprocess
|
||||
import time
|
||||
import os
|
||||
|
||||
DEVICE_NAMES = ["8BitDo NGC Modkit"]
|
||||
BUTTON_MAP = {
|
||||
"304": "KEY_ENTER",
|
||||
"305": None,
|
||||
"311": "KEY_LEFTALT",
|
||||
"307": "KEY_RIGHT",
|
||||
"308": "KEY_LEFT",
|
||||
"304": "KEY_ENTER", # A
|
||||
"305": None, # B (non utilisé)
|
||||
"311": "KEY_LEFTALT", # R
|
||||
"307": "KEY_RIGHT", # Stick droit → Droite
|
||||
"308": "KEY_LEFT", # Stick droit → Gauche
|
||||
# 318 (BTN_THUMBR) sera géré à part
|
||||
}
|
||||
|
||||
events = [
|
||||
@@ -39,8 +39,6 @@ def is_dolphin_running():
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
pressed_keys = set()
|
||||
|
||||
def handle_device(dev_path):
|
||||
dev = evdev.InputDevice(dev_path)
|
||||
try:
|
||||
@@ -50,24 +48,20 @@ def handle_device(dev_path):
|
||||
|
||||
key_code = str(event.code)
|
||||
|
||||
# mettre à jour l'état des touches pressées
|
||||
if event.value == 1:
|
||||
pressed_keys.add(key_code)
|
||||
elif event.value == 0:
|
||||
pressed_keys.discard(key_code)
|
||||
|
||||
# logique R + B → Alt+Esc
|
||||
if "311" in pressed_keys and "305" in pressed_keys:
|
||||
# cas spécial : joystick jaune (BTN_THUMBR, code 318)
|
||||
if key_code == "318" and event.value == 1: # pression
|
||||
keyboard.emit(uinput.KEY_LEFTALT, 1)
|
||||
keyboard.emit(uinput.KEY_ESC, 1)
|
||||
keyboard.emit(uinput.KEY_ESC, 0)
|
||||
keyboard.emit(uinput.KEY_LEFTALT, 0)
|
||||
else:
|
||||
# envoyer les touches normales sauf celles mappées à None
|
||||
continue
|
||||
|
||||
# touches normales selon le mapping
|
||||
if key_code in BUTTON_MAP:
|
||||
mapped_key = BUTTON_MAP[key_code]
|
||||
if mapped_key is not None: # uniquement si mapped_key n'est pas None ou vide
|
||||
if mapped_key is not None:
|
||||
keyboard.emit(getattr(uinput, mapped_key), event.value)
|
||||
|
||||
except OSError:
|
||||
dev.close()
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user