Advertisement
Ri0n

Switchres ES Interlace emulatorlauncher.py

Nov 1st, 2024 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.98 KB | Gaming | 0 0
  1. Add this under ### import always needed ### at the bottom
  2.  
  3. import re
  4. import logging
  5.  
  6.  
  7. Paste code in after
  8.  
  9.         # run a script before emulator starts
  10.         callExternalScripts("/usr/share/batocera/configgen/scripts", "gameStart", [systemName, system.config['emulator'], effectiveCore, effectiveRom])
  11.         callExternalScripts("/userdata/system/scripts", "gameStart", [systemName, system.config['emulator'], effectiveCore, effectiveRom])
  12.  
  13.  
  14.         # Set up logging
  15.         logging.basicConfig(level=logging.DEBUG)
  16.         logger = logging.getLogger(__name__)
  17.  
  18.         # switchres interlace
  19.         def set_interlace(interlace_on=True):
  20.             config_file = "/etc/switchres.ini"
  21.  
  22.             # Read the current content of the config file
  23.             with open(config_file, 'r') as file:
  24.                 config_content = file.readlines()
  25.  
  26.             # Modify the interlace setting
  27.             with open(config_file, 'w') as file:
  28.                 modified = False
  29.                 for line in config_content:
  30.                     # Replace the interlace setting based on interlace_on value
  31.                     if re.match(r'^\s*interlace\s+', line):  # Allow any leading whitespace
  32.                         file.write(f"        interlace                 {1 if interlace_on else 0}\n")  # Keep 8 spaces
  33.                         modified = True
  34.                         logger.debug(f"Updated interlace to {1 if interlace_on else 0}")
  35.                     else:
  36.                         file.write(line)
  37.  
  38.                 # Log if no interlace setting was found
  39.                 if not modified:
  40.                     logger.warning("No interlace setting found in /etc/switchres.ini to modify.")
  41.  
  42.         # Call the set_interlace function based on system options
  43.         if system.isOptSet('interlace'):
  44.             interlace_on = system.config["interlace"] == "" or system.config["interlace"] == "1"
  45.             set_interlace(interlace_on)
  46.         else:
  47.             set_interlace(True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement