Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9019145
Initial Button Prompt detection support
AL2009man Jul 25, 2025
51204c7
rename "button icons" with "button prompt styles"
AL2009man Jul 25, 2025
a85ba05
updated Glyph naming scheme to closely follow device button layout
AL2009man Jul 25, 2025
aa7dcf2
changed Xbox Elite Paddle naming scheme to mirror device name
AL2009man Jul 25, 2025
cc5b7df
change glyph order
AL2009man Jul 28, 2025
8f9c13a
fixed Button Prompt override order
AL2009man Jul 28, 2025
ebc2207
Modularized `glyph.c` setup
AL2009man Jul 28, 2025
8535f87
cleaned up `inputGetButtonDisplayName`
AL2009man Jul 28, 2025
e5d642a
remove duplicated Switch-specific prompts to use `glyph standard`
AL2009man Jul 30, 2025
4c80023
restored original naming layout
AL2009man Jul 30, 2025
075618e
change notes one last time
AL2009man Jul 30, 2025
92a2870
Merge branch 'fgsfdsfgs:port' into ButtonPromptSupportInitial
AL2009man Jul 30, 2025
49cc29f
added Steam Controller/Deck prompts, slightly corrected Paddle placement
AL2009man Jul 31, 2025
1b787e4
fixed Steam Virtual Gamepad detection
AL2009man Jul 31, 2025
e16c0e4
Merge branch 'ButtonPromptSupportInitial' of https://github.com/AL200…
AL2009man Jul 31, 2025
d88b4e0
removed some leftover notes during testing Steam Virtual Gamepad
AL2009man Jul 31, 2025
92304bf
added VID/PID to Steam Virtual Gamepad
AL2009man Jul 31, 2025
3191b29
revised Steam Virtual Gamepad detection
AL2009man Jul 31, 2025
e83c9eb
second attempt on improving Steam Virtual Gamepad detection
AL2009man Jul 31, 2025
866480e
moved Steam Virtual Gamepad onto `SDL_CONTROLLER_TYPE_VIRTUAL`
AL2009man Jul 31, 2025
ed23dcd
Revert "moved Steam Virtual Gamepad onto `SDL_CONTROLLER_TYPE_VIRTUAL`"
AL2009man Jul 31, 2025
6460000
added Nintendo 64 Controller glyphs
AL2009man Aug 3, 2025
ab6d132
modularized Steam hardware vid/pid
AL2009man Aug 4, 2025
9b4e7e3
experimental simplified SteamVirtualGamepad function
AL2009man Aug 4, 2025
9381c41
changed some of the notes and name fuction
AL2009man Aug 4, 2025
62dd5f6
swapped Steam Deck and Steam Virtual Gamepad order
AL2009man Aug 4, 2025
f0fc210
Steam Deck and Steam Controller now uses `getSteamVirtualControllerDe…
AL2009man Aug 4, 2025
bed72f7
restored Steam Virtual Gamepad PID.
AL2009man Aug 4, 2025
6567f38
corrected Switch Joycon prompts layout
AL2009man Aug 5, 2025
7ce1f17
changed document notes
AL2009man Aug 5, 2025
6a29805
fixed Switch Joy-Con SL/SR position layout
AL2009man Aug 5, 2025
74351c0
slight change to how Controller Icon generic is handled
AL2009man Nov 13, 2025
0106c10
reaplce Joystick with GameControllerVendor/Product
AL2009man Nov 20, 2025
dbcdb0d
experimenting with Steam Virtual Gamepad, part 2
AL2009man Nov 20, 2025
ae2db33
Revert "experimenting with Steam Virtual Gamepad, part 2"
AL2009man Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions port/include/glyph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#ifndef _IN_GLYPH_H
#define _IN_GLYPH_H

#include <SDL.h>

// Controller Icon enumeration for button icon detection
typedef enum {
CONTROLLER_ICON_GENERIC,
CONTROLLER_ICON_XBOX360,
CONTROLLER_ICON_XBOXONE,
CONTROLLER_ICON_PS3,
CONTROLLER_ICON_PS4,
CONTROLLER_ICON_PS5,
CONTROLLER_ICON_NINTENDO_SWITCH,
CONTROLLER_ICON_NINTENDO_64,
CONTROLLER_ICON_STEAM_CONTROLLER,
CONTROLLER_ICON_STEAM_DECK,
} ControllerIconType;

// Valve Corporation VID/PID definitions
#define VALVE_VENDOR_ID 0x28de

// Steam Controller product IDs
#define STEAM_CONTROLLER_LEGACY_PID 0x1101 // Valve Legacy Steam Controller (CHELL)
#define STEAM_CONTROLLER_WIRED_PID 0x1102 // Valve wired Steam Controller (D0G)
#define STEAM_CONTROLLER_BT_1_PID 0x1105 // Valve Bluetooth Steam Controller (D0G)
#define STEAM_CONTROLLER_BT_2_PID 0x1106 // Valve Bluetooth Steam Controller (D0G)
#define STEAM_CONTROLLER_WIRELESS_PID 0x1142 // Valve wireless Steam Controller
#define STEAM_CONTROLLER_V2_WIRED_PID 0x1201 // Valve wired Steam Controller (HEADCRAB)
#define STEAM_CONTROLLER_V2_BT_PID 0x1202 // Valve Bluetooth Steam Controller (HEADCRAB)

// Other Valve product IDs
#define STEAM_VIRTUAL_GAMEPAD_PID 0x11ff // Steam Virtual Gamepad
#define STEAM_DECK_BUILTIN_PID 0x1205 // Valve Steam Deck Builtin

// Check if a product ID is any Steam Controller (2015) variant
static inline int isSteamControllerPID(unsigned short productId) {
return (productId == STEAM_CONTROLLER_LEGACY_PID ||
productId == STEAM_CONTROLLER_WIRED_PID ||
productId == STEAM_CONTROLLER_BT_1_PID ||
productId == STEAM_CONTROLLER_BT_2_PID ||
productId == STEAM_CONTROLLER_WIRELESS_PID ||
productId == STEAM_CONTROLLER_V2_WIRED_PID ||
productId == STEAM_CONTROLLER_V2_BT_PID);
}

// Steam Virtual Gamepad detection
static inline int getSteamVirtualControllerDetection(SDL_GameController* ctrl, int SDLControllerType) {
if (!ctrl) {
return SDLControllerType;
}

if (SDL_GameControllerGetVendor(ctrl) != VALVE_VENDOR_ID) {
return SDLControllerType;
}

unsigned short product = SDL_GameControllerGetProduct(ctrl);

// Steam Virtual Gamepad - pass through the underlying controller type
if (product == STEAM_VIRTUAL_GAMEPAD_PID) {
return SDLControllerType;
}

// Steam Deck
if (product == STEAM_DECK_BUILTIN_PID) {
return CONTROLLER_ICON_STEAM_DECK;
}

// Steam Controller (2015)
if (isSteamControllerPID(product)) {
return CONTROLLER_ICON_STEAM_CONTROLLER;
}

return SDLControllerType;
}

// Generic button names for glyphs
// this will cover generalized button names for glyphs based on SDL_GamepadButton
extern const char *vkJoyDisplayNames[];

// Controller-specific button glyphs
// this will grab the button glyphs based on the controller type and button index
const char *glyphGetControllerButtonName(int controllerType, int buttonIndex);

// Dynamic glyph input binding detection
// TODO: replace all baked-in button localization text with a dynamic glyph system
char* glyphInputBindingDetect(char* text, int textSize, const char* placeholder,
int controllerIndex, int controlKey, int forceController);

#endif
22 changes: 22 additions & 0 deletions port/include/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ enum mouselockmode {
MLOCK_AUTO = 2
};

enum buttonpromptmode {
GLYPH_AUTO = -1,
GLYPH_GENERIC = 0,
GLYPH_INTERNAL = 1,
GLYPH_XBOX360 = 2,
GLYPH_XBOXONE = 3,
GLYPH_PS3 = 4,
GLYPH_PS4 = 5,
GLYPH_PS5 = 6,
GLYPH_NINTENDO_SWITCH = 7,
GLYPH_NINTENDO_64 = 8,
GLYPH_STEAM_CONTROLLER = 9,
GLYPH_STEAM_DECK = 10,
};

// returns bitmask of connected controllers or -1 if failed
s32 inputInit(void);

Expand Down Expand Up @@ -193,6 +208,9 @@ s32 inputGetKeyByName(const char *name);
// get human-readable name from VK_ value
const char *inputGetKeyName(s32 vk);

// get human-readable controller button display name from VK_ value
const char *inputGetButtonDisplayName(s32 vk);

// get CK_ value from human-readable name
s32 inputGetContKeyByName(const char *name);

Expand Down Expand Up @@ -249,6 +267,10 @@ s32 inputGetLastKey(void);
s32 inputGetMouseLockMode(void);
void inputSetMouseLockMode(s32 lockmode);

// get/set button prompt override
s32 inputGetButtonPromptOverride(s32 cidx);
void inputSetButtonPromptOverride(s32 cidx, s32 override);

// same as inputLockMouse but works only if mouse is enabled and lockmode == MLOCK_AUTO
s32 inputAutoLockMouse(s32 wantlock);

Expand Down
Loading