Skip to content

Commit

Permalink
Merge pull request #20 from Wolfy76700/docs
Browse files Browse the repository at this point in the history
Update controller list to be more readable
  • Loading branch information
Wolfy76700 authored Mar 20, 2024
2 parents 0c87180 + 681f5dd commit a27c4b6
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .utilities/consoles_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ps1": "Sony PlayStation 1",
"ps2" : "Sony PlayStation 2",
"ps3" : "Sony PlayStation 3",
"ps4" : "Sony PlayStation 4",
"ps5" : "Sony PlayStation 5",
"xbox" : "Xbox",
"xb360" : "Xbox 360",
"xb1" : "Xbox One",
"xbs" : "Xbox Series X|S",
"nes" : "Nintendo Entertainment System / Famicom",
"snes" : "Super Nintendo Entertainment System / Super Famicom",
"n64" : "Nintendo 64",
"ngc" : "Nintendo GameCube",
"wii" : "Nintendo Wii",
"wiiu" : "Nintendo Wii U",
"nsw" : "Nintendo Switch",
"smd" : "Sega Mega Drive / Sega Genesis",
"saturn" : "Sega Saturn",
"dc" : "Sega Dreamcast"
}
195 changes: 194 additions & 1 deletion .utilities/generate_controller_tables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import json
import textwrap
import glob
from copy import deepcopy

with open(".utilities/consoles_list.json") as json_file:
consoles_dict = json.loads(json_file.read())

def bool_to_emoji(boolean: bool):
if boolean:
return("✔️")
else:
return("❌")

def str_to_emoji(string: str):
if string:
return(string)
else:
return("❌")

def process_list(source: list, level = 1):
result = ""
Expand Down Expand Up @@ -63,6 +79,176 @@ def process_dict(source: dict, level = 1):
"""
return(result)

def process_socd(list_socd):
result = ""
if list_socd:
for i in range(len(list_socd)):
if i != 0:
if i == len(list_socd)-1:
result += " or "
else:
result += ", "
if list_socd[i] == "disable":
result += "Disabled"
if list_socd[i] == "neutral":
result += "Neutral"
if list_socd[i] == "last_input":
result += "Last Direction"
if list_socd[i] == "first_input":
result += "First Direction"
if list_socd[i] == "up":
result += "Always Up"
else:
result += bool_to_emoji(False)
return(result)

def process_directional_buttons(list_buttons, title="Directional Buttons", level = 1):
result =""
if list_buttons:
result += f"""{'#'*level} {title}
"""
for i in range(len(list_buttons)):
button_set = list_buttons[i]
result += process_list_string(button_set["set"], title=f"Set #{i+1}", level=level+1)
result += "**SOCD Cleaning**\n\n"
result += f"- Hardware SOCD Cleaning: {bool_to_emoji(button_set['socd_prevention']['hardware'])}\n"
if button_set['socd_prevention']['software']:
result += f"- Software SOCD Cleaning:\n"
result += f" - Left + Right: {process_socd(button_set['socd_prevention']['software']['left_right'])}\n"
result += f" - Up + Down: {process_socd(button_set['socd_prevention']['software']['up_down'])}\n"
else:
result += f"- Software SOCD Cleaning: {bool_to_emoji(False)}\n"

result += "\n"
return(result)


def process_stick_or_trackpad(list_stick, title="Analog Sticks", level = 1):
result =""
if list_stick:
result += f"""{'#'*level} {title}
| Name | Clickable |
| :---: | :---: |
"""
for stick in list_stick:
clickable = stick.get("has_button") or stick.get("clickable")
result += f"| {stick['name']} | {bool_to_emoji(clickable)} |\n"
result += "\n"
return(result)

def process_screen(list_screen, title="Touch Screens", level = 1):
result = ""
if list_screen:
result += f"""{'#'*level} {title}
| Index | Resolution | Type |
| :---: | :---: | :---: |
"""
for i in range(len(list_screen)):
screen = list_screen[i]
resolution = f"{screen['resolution'][0]}x{screen['resolution'][1]}"
result += f"| {i+1} | {resolution} | {screen['type'].title()} |\n"
result += "\n"
return(result)

def process_list_string(list_str, title="Menu Buttons", level = 1):
result = ""
if list_str:
result += f"""{'#'*level} {title}
"""
for button_name in list_str:
result += f"- {button_name}\n"
result += "\n"
return(result)

def process_digital_to_analog(list_digital_analog, title="Digital-to-Analog Conversion Features", level = 1):
result = ""
if list_digital_analog:
result += f"""{'#'*level} {title}
| Emulated Input | Type of conversion | Associated Modifier Buttons |
| :---: | :---: | :---: |
"""
for conversion in list_digital_analog:
if conversion["type"] == "8_way":
type_conversion = "8-way Movement"
if conversion["type"] == "button":
type_conversion = "Full Button Press"
if conversion["type"] == "precision":
type_conversion = "Precise Input"
result += f"| {conversion['emulated_analog']} | {type_conversion} | {conversion['modifier_buttons']} |\n"
result += "\n"
return(result)

def process_functions(functions:dict, level=1):
result = ""

# Sticks / Trackpads
result += process_stick_or_trackpad(functions["analog_sticks"], title="Analog Sticks", level=level)
result += process_stick_or_trackpad(functions["digital_sticks"], title="Digital Sticks", level=level)
result += process_stick_or_trackpad(functions["trackpads"], title="Trackpads", level=level)

# Directional Buttons
result += process_directional_buttons(functions["directional_buttons"], title="Directional Buttons", level=level)

# Action Buttons
if functions.get("action_buttons"):
result += f"""{'#'*level} Action Buttons
| Name | Analog |
| :---: | :---: |
"""
for button in functions.get("action_buttons"):
result += f"| {button['name']} | {bool_to_emoji(button['analog'])} |\n"
result += "\n"

# Other Buttons
result += process_list_string(functions.get("menu_buttons"), title="Menu Buttons", level=level)
result += process_list_string(functions.get("system_buttons"), title="System Buttons", level=level)
result += process_list_string(functions.get("other_buttons"), title="Other Buttons", level=level)

# Digital-to-Analog conversion
result += process_digital_to_analog(functions.get("digital_to_analog_conversion"), title="Digital-to-Analog Conversion Features", level=level)

# Touch Screens
result += process_screen(functions.get("touch_screens"), title="Touch Screens", level=level)

# Cable info
if functions.get("cable"):
result += f"""{'#'*level} Cable
- Interface: {functions['cable']['interface']}
- Removable: {bool_to_emoji(functions['cable']['removable'])}
"""

# Other functions
rumble = str_to_emoji(functions['rumble'])

result += f"""{'#'*level} Other Features
| Feature | Value |
| :---: | :---: |
| Macro | {bool_to_emoji(functions['macro'])} |
| Turbo | {bool_to_emoji(functions['turbo'])} |
| Accelerometer | {bool_to_emoji(functions['accelerometer'])} |
| Gyroscope | {bool_to_emoji(functions['gyroscope'])} |
| IR Reciever | {bool_to_emoji(functions['ir_reciever'])} |
| Extension Ports | {functions['extension_ports']} |
| Headset Port | {bool_to_emoji(functions['headset_port'])} |
| Speaker | {bool_to_emoji(functions['speaker'])} |
| Microphone | {bool_to_emoji(functions['microphone'])} |
| Rumble | {rumble.title()} |
| Bluetooth | {bool_to_emoji(functions['bluetooth'])} |
| 2.4GHz Wireless | {bool_to_emoji(functions['2_4ghz'])} |
| XInput | {bool_to_emoji(functions['pc_xinput'])} |
| Steam Input Compatibility | {bool_to_emoji(functions['pc_steaminput'])} |"""

return(result)

def process_controller(path, level = 1):
with open(f"{path}/config.json", "rt", encoding="utf-8") as json_file:
controller = json.loads(json_file.read())
Expand All @@ -76,11 +262,18 @@ def process_controller(path, level = 1):
"""
if controller.get("source"):
result += f"*More information: {controller.get('source')}*\n\n"
if controller["functions"].get("native_consoles"):
result += f"{'#'*(level+1)} Native console compatibility\n\n"
sorted_list = deepcopy(controller["functions"].get("native_consoles"))
sorted_list.sort()
for console in sorted_list:
result += f"- {consoles_dict[console]}\n"
result += "\n"
result += f"""{'#'*(level+1)} Functions
<details>
{process_dict(controller["functions"], level=level+2)}
{process_functions(controller["functions"], level=level+2)}
</details>
Expand Down

0 comments on commit a27c4b6

Please sign in to comment.