first commit
This commit is contained in:
284
pyprojs/xbox_py_screen.py.bk1
Executable file
284
pyprojs/xbox_py_screen.py.bk1
Executable 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()
|
||||
Reference in New Issue
Block a user