first commit

This commit is contained in:
2026-03-30 14:53:09 -06:00
commit fbec1a6ade
81 changed files with 4479 additions and 0 deletions

18
pyprojs/xbox-buttons-test.py Executable file
View File

@@ -0,0 +1,18 @@
import pygame
pygame.init()
pygame.joystick.init()
joystick = pygame.joystick.Joystick(0)
joystick.init()
print(f"Control detectado: {joystick.get_name()}")
print("Presiona botones, Ctrl+C para salir.")
while True:
pygame.event.pump()
for i in range(joystick.get_numbuttons()):
if joystick.get_button(i):
print(f"Botón {i} presionado")
pygame.time.wait(100)

75
pyprojs/xbox_control.py Executable file
View File

@@ -0,0 +1,75 @@
import pyudev
import subprocess
def procesar_dispositivo_conectado(device, inicial=False):
vendor_id = device.get('ID_VENDOR_ID', '')
model_id = device.get('ID_MODEL_ID', '')
name = device.get('NAME', '')
device_str = f"{vendor_id}:{model_id} - {name}"
if "Xbox" in name:
print(f"{'🔍' if inicial else '🎮'} Xbox detectado: {device_str}")
if not inicial:
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-2"])
elif vendor_id.lower() == '2dc8':
print(f"{'🔍' if inicial else '🎮'} 8BitDo detectado: {device_str}")
if not inicial:
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-2"])
if not vendor_id:
return # Ignorar dispositivos sin vendor_id
def evento_callback(device):
if device.subsystem != 'input':
return
if device.action == 'add':
procesar_dispositivo_conectado(device)
elif device.action == 'remove':
print(f"❌ Dispositivo desconectado: {device.device_path}")
# --------------------------
# 🔍 Detectar dispositivos ya conectados
# --------------------------
context = pyudev.Context()
print(context.list_devices)
print("🔍 Buscando controles ya conectados...")
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-2"])
for device in context.list_devices(subsystem='input'):
vendor_id = device.get('ID_VENDOR_ID', '')
model_id = device.get('ID_MODEL_ID', '')
name = device.get('NAME', '')
device_str = f"{vendor_id}:{model_id} - {name}"
print(device_str)
if "8Bit" in name:
print("LOGRE DETECTAR EL CONTROL DE 8BIT")
positivo_conectado(device, inicial = False)
if "Xbox" in name:
print("LOGRE DETECTAR EL CONTROL DE XBOX")
procesar_dispositivo_conectado(device, inicial=True)
# --------------------------
# 👂 Escuchar nuevos eventos
# --------------------------
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by(subsystem='input')
observer = pyudev.MonitorObserver(monitor, callback=evento_callback)
observer.start()
print("👀 Escuchando eventos de controles...")
import signal
signal.pause()

347
pyprojs/xbox_py_screen.py Executable file
View File

@@ -0,0 +1,347 @@
import pygame
import os
import pyautogui
import time
import subprocess
import math
import time
class Timer:
def __init__(self):
self.last_time = time.time()
def elapsed_time(self):
current_time = time.time()
elapsed = current_time - self.last_time
self.last_time = current_time
return elapsed
# Inicializa pygame
#variable que indica si ya se conecto el mando y ya se cambio de pantalla
pantalla_pp = False
pygame.init()
pygame.joystick.init()
hay_mando = False
# Inicializa el mando de Xbox
# Define los códigos de los botones que deseas detectar
BOTON_A = 0
BOTON_B = 1
BOTON_X = 3
BOTON_Y = 4
BOTON_START = 11
BOTON_SELECT = 10
BOTON_L1 = 6
BOTON_R1 = 7
BOTON_L3 = 13
BOTON_R3 = 14
HOME = 12
flag_display = True
#CEMU PATHS
path_8bitdo_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/8bit.xml"
path_Sunshine_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/sunshine.xml"
path_switch_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/switch.xml"
path_xbox_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/xbox.xml"
path_ps4_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/ps4.xml"
path_controller0 = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/controller0.xml"
path_controller1 = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/controller1.xml"
path_controller2 = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/controller2.xml"
path_controller3 = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/controller3.xml"
#RIUJINX PATHS
path_xbox_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/xbox.json"
path_8bitdo_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/8bit.json"
path_sunshine_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/sunshine.json"
path_ps4_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/ps4.json"
path_switch_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/switch.json"
path_config_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/Config.json"
# Función para cambiar al modo de pantalla principal
def salida():
return
def cambiar_ventana():
pyautogui.hotkey("alt", "tab")
def cambiar_ventana2():
pyautogui.keyDown("alt")
pyautogui.hotkey("tab", "tab","Enter")
pyautogui.keyUp("alt")
def ctrl_alt_sprm():
pyautogui.hotkey("ctrl","alt","del")
def f11():
pyautogui.hotkey("F11")
def WinLeft():
pyautogui.hotkey("win","shift","left")
def WinRight():
pyautogui.hotkey("win","shift","right")
def Up():
pyautogui.hotkey("up", "up")
def Down():
pyautogui.hotkey("down","down")
def Enter():
pyautogui.hotkey("enter")
def TAB():
pyautogui.hotkey("tab")
def Space():
pyautogui.hotkey("space")
def Kill():
pyautogui.hotkey("alt","F4")
def Esc():
#pyautogui.hotkey("win","shift","1")
subprocess.run(["xdotool", "key", "Super_L+Shift+1"])
def Insert():
pyautogui.hotkey("insert")
def NextDevice():
pyautogui.hotkey('ctrl','o')
def PrevDevice():
pyautogui.hotkey('ctrl','p')
def Click():
pyautogui.click()
def Minimize():
pyautogui.hotkey("win","m")
def SwitchScreens1():
print("switchScreen1")
#TurnScreen('Disable',1)
#T#urnScreen('Disable',2)
#TurnScreen('Enable',3)
def SwitchScreens2():
print("switchScreen2")
#TurnScreen('Enable',1)
#TurnScreen('Enable',2)
#TurnScreen('Disable',3)
def TurnScreen(mode,display):
print("TurnScreen")
#os.system(f'powershell {mode}-Display {display}')
def main():
timer = Timer()
# Función para detectar la conexión del mando de Xbox
while not hay_mando:
pygame.event.get()
pygame.time.delay(935)
num_joysticks = pygame.joystick.get_count()
num_joysticks_b = num_joysticks
if num_joysticks >= 1:
name_control = "-"
print(name_control)
try:
joystick = pygame.joystick.Joystick(0)
joystick.init()
name_control = joystick.get_name()
print("Mando detectado:", name_control)
except pygame.error as e:
print("Error al inicializar el joystick:", e)
joystick = None
indexi = name_control.find("8BitDo")
if indexi != -1:
print("FLUJO 8BITDO ***")
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-3"])
subprocess.run(["cp", path_8bitdo_CEMU, path_controller0])
subprocess.run(["cp", path_xbox_CEMU, path_controller1])
subprocess.run(["cp", path_ps4_CEMU, path_controller2])
subprocess.run(["cp", path_8bitdo_RYUJINX, path_config_RYUJINX])
# Define los códigos de los botones que deseas detectar
BOTON_A = 0
BOTON_B = 1
BOTON_X = 2
BOTON_Y = 3
BOTON_START = 7
BOTON_SELECT = 6
BOTON_L1 = 4
BOTON_R1 = 5
BOTON_L3 = 9
BOTON_R3 = 10
HOME = 8
indexi = name_control.find("One")
if indexi != -1:
print("FLUJO SUNSHINE ***")
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-3"])
subprocess.run(["cp", path_Sunshine_CEMU, path_controller0])
subprocess.run(["cp", path_sunshine_RYUJINX, path_config_RYUJINX])
# Define los códigos de los botones que deseas detectar
BOTON_A = 0
BOTON_B = 1
BOTON_X = 2
BOTON_Y = 3
BOTON_START = 7
BOTON_SELECT = 6
BOTON_L1 = 4
BOTON_R1 = 5
BOTON_L3 = 9
BOTON_R3 = 10
HOME = 8
indexi = name_control.find("Nintendo")
if indexi != -1:
print("FLUJO SUNSHINE N.SWITCH ***")
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-3"])
subprocess.run(["cp", path_switch_CEMU, path_controller0])
subprocess.run(["cp", path_switch_RYUJINX, path_config_RYUJINX])
# Define los códigos de los botones que deseas detectar
BOTON_A = 0
BOTON_B = 1
BOTON_X = 2
BOTON_Y = 3
BOTON_START = 10
BOTON_SELECT = 9
BOTON_L1 = 5
BOTON_R1 = 6
BOTON_L3 = 12
BOTON_R3 = 13
HOME = 11
indexi = name_control.find("Series")
if indexi != -1:
print("FLUJO XBOX ***" )
print(name_control)
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-3"])
subprocess.run(["cp", path_8bitdo_CEMU, path_controller1])
subprocess.run(["cp", path_xbox_CEMU, path_controller0])
subprocess.run(["cp", path_ps4_CEMU, path_controller2])
subprocess.run(["cp", path_xbox_RYUJINX, path_config_RYUJINX])
BOTON_A = 0
BOTON_B = 1
BOTON_X = 3
BOTON_Y = 4
BOTON_START = 11
BOTON_SELECT = 10
BOTON_L1 = 6
BOTON_R1 = 7
BOTON_L3 = 13
BOTON_R3 = 14
HOME = 12
indexi = name_control.find("PS4")
if indexi != -1:
print("FLUJO PS4 ***" )
print(name_control)
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-3"])
subprocess.run(["cp", path_8bitdo_CEMU, path_controller2])
subprocess.run(["cp", path_xbox_CEMU, path_controller1])
subprocess.run(["cp", path_ps4_CEMU, path_controller0])
subprocess.run(["cp", path_ps4_RYUJINX, path_config_RYUJINX])
BOTON_A = 0
BOTON_B = 1
BOTON_X = 2
BOTON_Y = 3
BOTON_START = 6
BOTON_SELECT = 4
BOTON_L1 = 9
BOTON_R1 = 10
BOTON_L3 = 7
BOTON_R3 = 8
HOME = 5
sensitivity = 10
elapsed_time = 0.0
elapsed_time_past = 0.0
while True:
#for event in pygame.event.get():
event = pygame.event.wait()
############ START BOTON ################
#PREVIOS VOLUME DEVICE
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_A)):
subprocess.run(["hyprctl", "dispatch", "movetoworkspace", "8"])
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_L1)):
subprocess.run(["killall", "pcsx2-qt"])
subprocess.run(["hyprctl", "dispatch", "killactive"])
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_R1)):
subprocess.run(["hyprctl", "dispatch", "togglefloating"])
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_X)):
subprocess.run(["hyprctl", "dispatch", "workspace", "8"])
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_B)):
subprocess.run(["sh", "/home/arthur/scripts/pulseaudio.sh"])
############ SELECT BOTON ################
if (joystick.get_button(BOTON_SELECT) and
joystick.get_button(BOTON_L1)):
subprocess.run(["hyprctl", "dispatch","fullscreen"])
if (joystick.get_button(BOTON_SELECT) and
joystick.get_button(BOTON_Y)):
subprocess.run(["wofi", "--show","drun"])
if (joystick.get_button(BOTON_SELECT) and
joystick.get_button(BOTON_X)):
subprocess.run(["hyprctl","dispatch","exec", "firefox","default-release", "http://192.168.1.131:3000", "&"])
num_joysticks = pygame.joystick.get_count()
if num_joysticks <=0:
print("discornected")
break
def is_joystick_disconnected(joystick):
# Verificar si el joystick está inicializado
return not joystick.get_init()
if __name__ == "__main__":
main()

284
pyprojs/xbox_py_screen.py.bk1 Executable file
View File

@@ -0,0 +1,284 @@
import pygame
import os
import pyautogui
import time
import subprocess
import math
import time
class Timer:
def __init__(self):
self.last_time = time.time()
def elapsed_time(self):
current_time = time.time()
elapsed = current_time - self.last_time
self.last_time = current_time
return elapsed
# Inicializa pygame
#variable que indica si ya se conecto el mando y ya se cambio de pantalla
pantalla_pp = False
pygame.init()
pygame.joystick.init()
hay_mando = False
# Inicializa el mando de Xbox
# Define los códigos de los botones que deseas detectar
BOTON_A = 0
BOTON_B = 1
BOTON_X = 3
BOTON_Y = 4
BOTON_START = 11
BOTON_SELECT = 10
BOTON_L1 = 6
BOTON_R1 = 7
BOTON_L3 = 13
BOTON_R3 = 14
HOME = 12
flag_display = True
#CEMU PATHS
path_8bitdo_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/8bit.xml"
path_Sunshine_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/sunshine.xml"
path_xbox_CEMU = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/xbox.xml"
path_controller0 = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/controller0.xml"
path_controller1 = "/home/arthur/.var/app/info.cemu.Cemu/config/Cemu/controllerProfiles/controller1.xml"
#RIUJINX PATHS
path_xbox_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/xbox.json"
path_8bitdo_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/8bit.json"
path_sunshine_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/sunshine.json"
path_config_RYUJINX = "/home/arthur/.var/app/io.github.ryubing.Ryujinx/config/Ryujinx/Config.json"
# Función para cambiar al modo de pantalla principal
def salida():
return
def cambiar_ventana():
pyautogui.hotkey("alt", "tab")
def cambiar_ventana2():
pyautogui.keyDown("alt")
pyautogui.hotkey("tab", "tab","Enter")
pyautogui.keyUp("alt")
def ctrl_alt_sprm():
pyautogui.hotkey("ctrl","alt","del")
def f11():
pyautogui.hotkey("F11")
def WinLeft():
pyautogui.hotkey("win","shift","left")
def WinRight():
pyautogui.hotkey("win","shift","right")
def Up():
pyautogui.hotkey("up", "up")
def Down():
pyautogui.hotkey("down","down")
def Enter():
pyautogui.hotkey("enter")
def TAB():
pyautogui.hotkey("tab")
def Space():
pyautogui.hotkey("space")
def Kill():
pyautogui.hotkey("alt","F4")
def Esc():
#pyautogui.hotkey("win","shift","1")
subprocess.run(["xdotool", "key", "Super_L+Shift+1"])
def Insert():
pyautogui.hotkey("insert")
def NextDevice():
pyautogui.hotkey('ctrl','o')
def PrevDevice():
pyautogui.hotkey('ctrl','p')
def Click():
pyautogui.click()
def Minimize():
pyautogui.hotkey("win","m")
def SwitchScreens1():
print("switchScreen1")
#TurnScreen('Disable',1)
#T#urnScreen('Disable',2)
#TurnScreen('Enable',3)
def SwitchScreens2():
print("switchScreen2")
#TurnScreen('Enable',1)
#TurnScreen('Enable',2)
#TurnScreen('Disable',3)
def TurnScreen(mode,display):
print("TurnScreen")
#os.system(f'powershell {mode}-Display {display}')
def main():
timer = Timer()
# Función para detectar la conexión del mando de Xbox
while not hay_mando:
pygame.event.get()
pygame.time.delay(535)
num_joysticks = pygame.joystick.get_count()
num_joysticks_b = num_joysticks
if num_joysticks >= 1:
name_control = "-"
print(name_control)
try:
joystick = pygame.joystick.Joystick(0)
joystick.init()
name_control = joystick.get_name()
print("Mando detectado:", name_control)
except pygame.error as e:
print("Error al inicializar el joystick:", e)
joystick = None
indexi = name_control.find("8BitDo")
if indexi != -1:
print("FLUJO 8BITDO ***")
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "DP-3"])
subprocess.run(["cp", path_8bitdo_CEMU, path_controller0])
subprocess.run(["cp", path_xbox_CEMU, path_controller1])
subprocess.run(["cp", path_8bitdo_RYUJINX, path_config_RYUJINX])
# Define los códigos de los botones que deseas detectar
BOTON_A = 0
BOTON_B = 1
BOTON_X = 2
BOTON_Y = 3
BOTON_START = 7
BOTON_SELECT = 6
BOTON_L1 = 4
BOTON_R1 = 5
BOTON_L3 = 9
BOTON_R3 = 10
HOME = 8
else:
indexi = name_control.find("One")
if indexi != -1:
print("FLUJO SUNSHINE ***")
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-3"])
subprocess.run(["cp", path_Sunshine_CEMU, path_controller0])
subprocess.run(["cp", path_sunshine_RYUJINX, path_config_RYUJINX])
# Define los códigos de los botones que deseas detectar
BOTON_A = 0
BOTON_B = 1
BOTON_X = 2
BOTON_Y = 3
BOTON_START = 7
BOTON_SELECT = 6
BOTON_L1 = 4
BOTON_R1 = 5
BOTON_L3 = 9
BOTON_R3 = 10
HOME = 8
else:
print("FLUJO XBOX ELSE ***" )
print(name_control)
subprocess.run(["hyprctl", "dispatch", "dpms", "on", "HDMI-A-1"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-2"])
subprocess.run(["hyprctl", "dispatch", "dpms", "off", "DP-3"])
subprocess.run(["cp", path_8bitdo_CEMU, path_controller1])
subprocess.run(["cp", path_xbox_CEMU, path_controller0])
subprocess.run(["cp", path_xbox_RYUJINX, path_config_RYUJINX])
BOTON_A = 0
BOTON_B = 1
BOTON_X = 3
BOTON_Y = 4
BOTON_START = 11
BOTON_SELECT = 10
BOTON_L1 = 6
BOTON_R1 = 7
BOTON_L3 = 13
BOTON_R3 = 14
HOME = 12
sensitivity = 10
elapsed_time = 0.0
elapsed_time_past = 0.0
while True:
#for event in pygame.event.get():
event = pygame.event.wait()
############ START BOTON ################
#PREVIOS VOLUME DEVICE
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_A)):
subprocess.run(["hyprctl", "dispatch", "movetoworkspace", "8"])
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_L1)):
subprocess.run(["hyprctl", "dispatch", "killactive"])
subprocess.run(["killall", "Ryujinx"])
subprocess.run(["killall", "pcsx2-qt"])
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_R1)):
subprocess.run(["hyprctl", "dispatch", "togglefloating"])
if (joystick.get_button(BOTON_START) and
joystick.get_button(BOTON_X)):
subprocess.run(["hyprctl", "dispatch", "workspace", "8"])
#if (joystick.get_button(BOTON_START) and
# joystick.get_button(BOTON_B)):
#subprocess.run(["sh", "/home/arthur/scripts/pulseaudio.sh"])
############ SELECT BOTON ################
if (joystick.get_button(BOTON_SELECT) and
joystick.get_button(BOTON_L1)):
subprocess.run(["hyprctl", "dispatch","fullscreen"])
num_joysticks = pygame.joystick.get_count()
if num_joysticks <=0:
print("discornected")
break
def is_joystick_disconnected(joystick):
# Verificar si el joystick está inicializado
return not joystick.get_init()
if __name__ == "__main__":
main()