user failsafe false (#168)

user failsafe false 

for all games that use pydirectinput
This commit is contained in:
j-lin-lmg
2025-10-03 10:24:59 -07:00
committed by GitHub
parent 83486887ac
commit a9da3093f7
13 changed files with 75 additions and 28 deletions

View File

@@ -24,8 +24,9 @@ LOG_DIRECTORY = SCRIPT_DIRECTORY.joinpath("run")
PROCESS_NAME = "alanwake2.exe" PROCESS_NAME = "alanwake2.exe"
EXECUTABLE_PATH = find_epic_executable() EXECUTABLE_PATH = find_epic_executable()
GAME_ID = "c4763f236d08423eb47b4c3008779c84%3A93f2a8c3547846eda966cb3c152a026e%3Adc9d2e595d0e4650b35d659f90d41059?action=launch&silent=true" GAME_ID = "c4763f236d08423eb47b4c3008779c84%3A93f2a8c3547846eda966cb3c152a026e%3Adc9d2e595d0e4650b35d659f90d41059?action=launch&silent=true"
gamefoldername = "AlanWake2" GAMEFOLDERNAME = "AlanWake2"
user.FAILSAFE = False
def setup_logging(): def setup_logging():
"""default logging config""" """default logging config"""
@@ -169,7 +170,7 @@ try:
"resolution": f"{width}x{height}", "resolution": f"{width}x{height}",
"start_time": round((start_time * 1000)), "start_time": round((start_time * 1000)),
"end_time": round((end_time * 1000)), "end_time": round((end_time * 1000)),
"game_version": find_eg_game_version(gamefoldername) "game_version": find_eg_game_version(GAMEFOLDERNAME)
} }
am.create_manifest() am.create_manifest()

View File

@@ -29,7 +29,14 @@ PROCESS_NAME = "cs2.exe"
STEAM_GAME_ID = 730 STEAM_GAME_ID = 730
STEAM_USER_ID = get_registry_active_user() STEAM_USER_ID = get_registry_active_user()
cfg = Path(get_steam_folder_path(), "userdata", str(STEAM_USER_ID), str(STEAM_GAME_ID), "local", "cfg", "cs2_video.txt") cfg = Path(
get_steam_folder_path(),
"userdata", str(STEAM_USER_ID),
str(STEAM_GAME_ID),
"local", "cfg", "cs2_video.txt")
user.FAILSAFE = False
def setup_logging(): def setup_logging():
"""default logging config""" """default logging config"""
@@ -74,17 +81,24 @@ def run_benchmark(keras_service):
# We check the resolution so we know which screenshot to use for the locate on screen function # We check the resolution so we know which screenshot to use for the locate on screen function
match width: match width:
case "1920": case "1920":
location = gui.locateOnScreen(f"{SCRIPT_DIR}\\screenshots\\settings_1080.png", minSearchTime=5, confidence=0.6) location = gui.locateOnScreen(
f"{SCRIPT_DIR}\\screenshots\\settings_1080.png", minSearchTime=5, confidence=0.6)
case "2560": case "2560":
location = gui.locateOnScreen(f"{SCRIPT_DIR}\\screenshots\\settings_1440.png", minSearchTime=5, confidence=0.6) location = gui.locateOnScreen(
f"{SCRIPT_DIR}\\screenshots\\settings_1440.png", minSearchTime=5, confidence=0.6)
case "3840": case "3840":
location = gui.locateOnScreen(f"{SCRIPT_DIR}\\screenshots\\settings_2160.png", minSearchTime=5, confidence=0.6) location = gui.locateOnScreen(
f"{SCRIPT_DIR}\\screenshots\\settings_2160.png", minSearchTime=5, confidence=0.6)
case _: case _:
logging.error("Could not find the settings cog. The game resolution is currently %s, %s. Are you using a standard resolution?", height, width) logging.error(
"Could not find the settings cog. The game resolution is currently %s, %s. Are you using a standard resolution?",
height, width)
raise RuntimeError raise RuntimeError
if location is None: if location is None:
logging.error("Could not find the settings cog. The game resolution is currently %s, %s. Are you using a standard resolution?", height, width) logging.error(
"Could not find the settings cog. The game resolution is currently %s, %s. Are you using a standard resolution?",
height, width)
raise RuntimeError raise RuntimeError
click_me = gui.center(location) click_me = gui.center(location)
@@ -122,11 +136,13 @@ def run_benchmark(keras_service):
gui.mouseUp() gui.mouseUp()
time.sleep(0.2) time.sleep(0.2)
am.take_screenshot("advanced_video_1.png", ArtifactType.CONFIG_IMAGE, "first picture of advanced video settings") am.take_screenshot("advanced_video_1.png", ArtifactType.CONFIG_IMAGE,
"first picture of advanced video settings")
result = keras_service.look_for_word(word="boost", attempts=10, interval=1) result = keras_service.look_for_word(word="boost", attempts=10, interval=1)
if not result: if not result:
logging.info("Did not find the keyword 'Boost' in the advanced video menu. Did Keras click correctly?") logging.info(
"Did not find the keyword 'Boost' in the advanced video menu. Did Keras click correctly?")
raise RuntimeError raise RuntimeError
gui.moveTo(result["x"], result["y"]) gui.moveTo(result["x"], result["y"])
@@ -135,9 +151,11 @@ def run_benchmark(keras_service):
time.sleep(1) time.sleep(1)
if keras_service.wait_for_word(word="particle", timeout=30, interval=1) is None: if keras_service.wait_for_word(word="particle", timeout=30, interval=1) is None:
logging.info("Did not find the keyword 'Particle' in advanced video menu. Did Keras scroll correctly?") logging.info(
"Did not find the keyword 'Particle' in advanced video menu. Did Keras scroll correctly?")
raise RuntimeError raise RuntimeError
am.take_screenshot("advanced_video_2.png", ArtifactType.CONFIG_IMAGE, "second picture of advanced video settings") am.take_screenshot("advanced_video_2.png", ArtifactType.CONFIG_IMAGE,
"second picture of advanced video settings")
logging.info('Starting benchmark') logging.info('Starting benchmark')
user.press("`") user.press("`")
@@ -170,7 +188,7 @@ def run_benchmark(keras_service):
test_start_time = int(time.time()) test_start_time = int(time.time())
logging.info("Saw \'lets roll\'! Marking the time.") logging.info("Saw \'lets roll\'! Marking the time.")
time.sleep(112) # sleep duration during gameplay time.sleep(112) # sleep duration during gameplay
# Default fallback end time # Default fallback end time
test_end_time = int(time.time()) test_end_time = int(time.time())

View File

@@ -27,6 +27,8 @@ LOG_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, "run")
PROCESS_NAME = "cyberpunk2077.exe" PROCESS_NAME = "cyberpunk2077.exe"
user.FAILSAFE = False
def start_game(): def start_game():
"""Launch the game with no launcher or start screen""" """Launch the game with no launcher or start screen"""
return exec_steam_game(STEAM_GAME_ID, game_params=["--launcher-skip", "-skipStartScreen"]) return exec_steam_game(STEAM_GAME_ID, game_params=["--launcher-skip", "-skipStartScreen"])

View File

@@ -34,6 +34,8 @@ STEAM_GAME_ID = 3017860
username = os.getlogin() username = os.getlogin()
BENCHMARK_RESULTS_PATH = f"C:\\Users\\{username}\\Saved Games\\id Software\\DOOMTheDarkAges\\base\\benchmark" BENCHMARK_RESULTS_PATH = f"C:\\Users\\{username}\\Saved Games\\id Software\\DOOMTheDarkAges\\base\\benchmark"
user.FAILSAFE = False
def start_game(): def start_game():
"""Launch the game with no launcher or start screen""" """Launch the game with no launcher or start screen"""
copy_launcher_config() copy_launcher_config()

View File

@@ -40,6 +40,7 @@ logging.getLogger('').addHandler(console)
args = get_args() args = get_args()
kerasService = KerasService(args.keras_host, args.keras_port) kerasService = KerasService(args.keras_host, args.keras_port)
user.FAILSAFE = False
def start_game(): def start_game():
"""Launch the game with console enabled and FPS unlocked""" """Launch the game with console enabled and FPS unlocked"""

View File

@@ -1,4 +1,6 @@
"""Far Cry 6 test script""" """Far Cry 6 test script"""
# pylint: disable = C0116, W0621
import os import os
import logging import logging
import time import time
@@ -30,25 +32,31 @@ LOG_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, "run")
PROCESS_NAME = "FarCry6.exe" PROCESS_NAME = "FarCry6.exe"
GAME_ID = 5266 GAME_ID = 5266
username = os.getlogin() username = os.getlogin()
xml_file = rf"C:\Users\{username}\Documents\My Games\Far Cry 6\gamerprofile.xml" XML_FILE = rf"C:\Users\{username}\Documents\My Games\Far Cry 6\gamerprofile.xml"
user.FAILSAFE = False
def start_game(): def start_game():
subprocess.run(f'start uplay://launch/{GAME_ID}/0', shell=True) subprocess.run(f'start uplay://launch/{GAME_ID}/0', shell=True, check=True)
def skip_logo_screens() -> None: def skip_logo_screens() -> None:
"""Simulate input to skip logo screens""" """Simulate input to skip logo screens"""
logging.info("Skipping logo screens") logging.info("Skipping logo screens")
#skipping the logo screens # skipping the logo screens
press_n_times("escape", 8, 1) press_n_times("escape", 8, 1)
def run_benchmark(): def run_benchmark():
am = ArtifactManager(LOG_DIRECTORY) am = ArtifactManager(LOG_DIRECTORY)
start_game() start_game()
setup_start_time = int(time.time()) setup_start_time = int(time.time())
time.sleep(25) time.sleep(25)
#skipping game intros # skipping game intros
result = kerasService.look_for_word("warning", attempts=20, interval=1) result = kerasService.look_for_word("warning", attempts=20, interval=1)
if not result: if not result:
logging.info("Did not see warnings. Did the game start?") logging.info("Did not see warnings. Did the game start?")
@@ -66,7 +74,7 @@ def run_benchmark():
time.sleep(2) time.sleep(2)
#navigating the menus to get to the video settings # navigating the menus to get to the video settings
result = kerasService.look_for_word("later", attempts=5, interval=1) result = kerasService.look_for_word("later", attempts=5, interval=1)
if result: if result:
user.press("escape") user.press("escape")
@@ -95,10 +103,11 @@ def run_benchmark():
gui.mouseUp() gui.mouseUp()
time.sleep(2) time.sleep(2)
#grabbing screenshots of all the video settings # grabbing screenshots of all the video settings
result = kerasService.look_for_word("adapter", attempts=10, interval=1) result = kerasService.look_for_word("adapter", attempts=10, interval=1)
if not result: if not result:
logging.info("Did not find the Video Adapter setting in the monitor options. Did keras navigate wrong?") logging.info(
"Did not find the Video Adapter setting in the monitor options. Did keras navigate wrong?")
sys.exit(1) sys.exit(1)
am.take_screenshot("video.png", ArtifactType.CONFIG_IMAGE, "picture of video settings") am.take_screenshot("video.png", ArtifactType.CONFIG_IMAGE, "picture of video settings")
@@ -109,18 +118,20 @@ def run_benchmark():
result = kerasService.look_for_word("filtering", attempts=10, interval=1) result = kerasService.look_for_word("filtering", attempts=10, interval=1)
if not result: if not result:
logging.info("Did not find the Texture Filtering setting in the quality options. Did keras navigate wrong?") logging.info(
"Did not find the Texture Filtering setting in the quality options. Did keras navigate wrong?")
sys.exit(1) sys.exit(1)
am.take_screenshot("quality1.png", ArtifactType.CONFIG_IMAGE, "1st picture of quality settings") am.take_screenshot("quality1.png", ArtifactType.CONFIG_IMAGE, "1st picture of quality settings")
time.sleep(2) time.sleep(2)
mouse_scroll_n_times(8, -800, 0.2) mouse_scroll_n_times(8, -800, 0.2)
result = kerasService.look_for_word("shading", attempts=10, interval=1) result = kerasService.look_for_word("shading", attempts=10, interval=1)
if not result: if not result:
logging.info("Did not find the FidelityFX Variable Shading setting in the quality options. Did keras navigate wrong?") logging.info(
"Did not find the FidelityFX Variable Shading setting in the quality options. Did keras navigate wrong?")
sys.exit(1) sys.exit(1)
am.take_screenshot("quality2.png", ArtifactType.CONFIG_IMAGE, "2nd picture of quality settings") am.take_screenshot("quality2.png", ArtifactType.CONFIG_IMAGE, "2nd picture of quality settings")
@@ -131,12 +142,13 @@ def run_benchmark():
result = kerasService.look_for_word("lock", attempts=10, interval=1) result = kerasService.look_for_word("lock", attempts=10, interval=1)
if not result: if not result:
logging.info("Did not find the Enable Framerate Lock setting in the advanced options. Did keras navigate wrong?") logging.info(
"Did not find the Enable Framerate Lock setting in the advanced options. Did keras navigate wrong?")
sys.exit(1) sys.exit(1)
am.take_screenshot("advanced.png", ArtifactType.CONFIG_IMAGE, "picture of advanced settings") am.take_screenshot("advanced.png", ArtifactType.CONFIG_IMAGE, "picture of advanced settings")
#starting the benchmark # starting the benchmark
time.sleep(2) time.sleep(2)
user.press("f5") user.press("f5")
elapsed_setup_time = round(int(time.time()) - setup_start_time, 2) elapsed_setup_time = round(int(time.time()) - setup_start_time, 2)
@@ -148,7 +160,7 @@ def run_benchmark():
sys.exit(1) sys.exit(1)
test_start_time = int(time.time()) test_start_time = int(time.time())
time.sleep(60) # wait for benchmark to complete time.sleep(60) # wait for benchmark to complete
result = kerasService.wait_for_word("results", interval=0.5, timeout=100) result = kerasService.wait_for_word("results", interval=0.5, timeout=100)
if not result: if not result:
@@ -165,11 +177,12 @@ def run_benchmark():
# Exit # Exit
terminate_processes(PROCESS_NAME) terminate_processes(PROCESS_NAME)
am.copy_file(xml_file, ArtifactType.CONFIG_TEXT, "config file") am.copy_file(XML_FILE, ArtifactType.CONFIG_TEXT, "config file")
am.create_manifest() am.create_manifest()
return test_start_time, test_end_time return test_start_time, test_end_time
setup_log_directory(LOG_DIRECTORY) setup_log_directory(LOG_DIRECTORY)
logging.basicConfig(filename=f'{LOG_DIRECTORY}/harness.log', logging.basicConfig(filename=f'{LOG_DIRECTORY}/harness.log',
@@ -204,4 +217,4 @@ except Exception as e:
logging.error("Something went wrong running the benchmark!") logging.error("Something went wrong running the benchmark!")
logging.exception(e) logging.exception(e)
terminate_processes(PROCESS_NAME) terminate_processes(PROCESS_NAME)
sys.exit(1) sys.exit(1)

View File

@@ -34,6 +34,7 @@ CONFIG_LOCATION = (
CONFIG_FILENAME = "UserConfigSelections" CONFIG_FILENAME = "UserConfigSelections"
PROCESSES = ["ForzaHorizon5.exe", "RTSS.exe"] PROCESSES = ["ForzaHorizon5.exe", "RTSS.exe"]
user.FAILSAFE = False
def start_rtss(): def start_rtss():
"""Sets up the RTSS process""" """Sets up the RTSS process"""

View File

@@ -33,6 +33,8 @@ CONFIG_PATH = f"C:\\Users\\{username}\\Documents\\My Games\\GRID Legends\\hardwa
CONFIG_FILENAME = "hardware_settings_config.xml" CONFIG_FILENAME = "hardware_settings_config.xml"
CONFIG_FULL_PATH = f"{CONFIG_PATH}\\{CONFIG_FILENAME}" CONFIG_FULL_PATH = f"{CONFIG_PATH}\\{CONFIG_FILENAME}"
user.FAILSAFE = False
def get_resolution() -> tuple[int]: def get_resolution() -> tuple[int]:
"""Gets resolution width and height from local xml file created by game.""" """Gets resolution width and height from local xml file created by game."""
resolution = re.compile(r"<resolution width=\"(\d+)\" height=\"(\d+)\"") resolution = re.compile(r"<resolution width=\"(\d+)\" height=\"(\d+)\"")

View File

@@ -13,6 +13,7 @@ import json
import re import re
import sys import sys
user.FAILSAFE = False
class LTTGamePad360(vg.VX360Gamepad): class LTTGamePad360(vg.VX360Gamepad):
""" """

View File

@@ -35,6 +35,8 @@ CONFIG_LOCATION = f"{APPDATA}\\Marvel\\Saved\\Config\\Windows"
CONFIG_FILENAME = "GameUserSettings.ini" CONFIG_FILENAME = "GameUserSettings.ini"
CFG = f"{CONFIG_LOCATION}\\{CONFIG_FILENAME}" CFG = f"{CONFIG_LOCATION}\\{CONFIG_FILENAME}"
user.FAILSAFE = False
am = ArtifactManager(LOG_DIR) am = ArtifactManager(LOG_DIR)
def setup_logging(): def setup_logging():

View File

@@ -32,6 +32,7 @@ SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
LOG_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, "run") LOG_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, "run")
CONFIG_FULL_PATH = Path("C:/Users/", getpass.getuser(), "Documents", "Rockstar Games", "Red Dead Redemption 2", "Settings", "system.xml") CONFIG_FULL_PATH = Path("C:/Users/", getpass.getuser(), "Documents", "Rockstar Games", "Red Dead Redemption 2", "Settings", "system.xml")
user.FAILSAFE = False
def run_benchmark(): def run_benchmark():
"""Starts the benchmark""" """Starts the benchmark"""

View File

@@ -27,6 +27,7 @@ PROCESS_NAME = "SOTTR.exe"
SCRIPT_DIR = Path(__file__).resolve().parent SCRIPT_DIR = Path(__file__).resolve().parent
LOG_DIR = SCRIPT_DIR.joinpath("run") LOG_DIR = SCRIPT_DIR.joinpath("run")
user.FAILSAFE = False
def setup_logging(): def setup_logging():
"""default logging config""" """default logging config"""

View File

@@ -22,6 +22,8 @@ LOG_DIRECTORY = SCRIPT_DIRECTORY.joinpath("run")
STEAM_GAME_ID = 1286680 STEAM_GAME_ID = 1286680
EXECUTABLE = "Wonderlands.exe" EXECUTABLE = "Wonderlands.exe"
user.FAILSAFE = False
def setup_logging(): def setup_logging():
"""default logging config""" """default logging config"""
setup_log_directory(LOG_DIRECTORY) setup_log_directory(LOG_DIRECTORY)