+static const char *controller_glyphs[ SDL_CONTROLLER_BUTTON_MAX ][2] =
+{ /* xbox/generic playstation */
+ [ SDL_CONTROLLER_BUTTON_A ] = { "\x1e\x85","\x1e\x82" },
+ [ SDL_CONTROLLER_BUTTON_B ] = { "\x1e\x86","\x1e\x81" },
+ [ SDL_CONTROLLER_BUTTON_X ] = { "\x1e\x83","\x1e\x7f" },
+ [ SDL_CONTROLLER_BUTTON_Y ] = { "\x1e\x84","\x1e\x80" },
+ [ SDL_CONTROLLER_BUTTON_LEFTSTICK ] = { "\x87", "\x87" },
+ [ SDL_CONTROLLER_BUTTON_RIGHTSTICK ] = { "\x8b", "\x8b" },
+ [ SDL_CONTROLLER_BUTTON_LEFTSHOULDER ] = { "\x91", "\x91" },
+ [ SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ]= { "\x92", "\x92" },
+ [ SDL_CONTROLLER_BUTTON_DPAD_LEFT ] = { "\x1e\x93","\x1e\x93" },
+ [ SDL_CONTROLLER_BUTTON_DPAD_UP ] = { "\x1e\x94","\x1e\x94" },
+ [ SDL_CONTROLLER_BUTTON_DPAD_RIGHT ] = { "\x1e\x95","\x1e\x95" },
+ [ SDL_CONTROLLER_BUTTON_DPAD_DOWN ] = { "\x1e\x96","\x1e\x96" },
+ [ SDL_CONTROLLER_BUTTON_GUIDE ] = { "\x91", "\x91" },
+};
+
+static const char *controller_glyph( u32 sdl_index )
+{
+ if( vg_input.display_input_type == SDL_CONTROLLER_TYPE_PS3 ||
+ vg_input.display_input_type == SDL_CONTROLLER_TYPE_PS4 ||
+ vg_input.display_input_type == SDL_CONTROLLER_TYPE_PS5 )
+ {
+ return controller_glyphs[ sdl_index ][ 1 ];
+ }
+ else if( vg_input.display_input_type ==
+ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO ||
+ vg_input.display_input_type ==
+ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT ||
+ vg_input.display_input_type ==
+ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR ||
+ vg_input.display_input_type ==
+ SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT )
+ {
+ return NULL;
+ }
+ else
+ return controller_glyphs[ sdl_index ][ 0 ];
+}
+
+#define KEYBOARD_GLYPH( X ) "\x1f" X " "
+
+static const char *button_display_string( enum sr_bind button )
+{
+ const char *controller_table[ k_srbind_max ] = {
+ [k_srbind_jump] = controller_glyph( SDL_CONTROLLER_BUTTON_A ),
+ [k_srbind_push] = controller_glyph( SDL_CONTROLLER_BUTTON_B ),
+ [k_srbind_trick0] = controller_glyph( SDL_CONTROLLER_BUTTON_A ),
+ [k_srbind_trick1] = controller_glyph( SDL_CONTROLLER_BUTTON_B ),
+ [k_srbind_trick2] = controller_glyph( SDL_CONTROLLER_BUTTON_X ),
+ [k_srbind_use] = controller_glyph( SDL_CONTROLLER_BUTTON_Y ),
+ [k_srbind_reset] = controller_glyph( SDL_CONTROLLER_BUTTON_LEFTSHOULDER ),
+ [k_srbind_camera] = controller_glyph( SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ),
+ [k_srbind_mleft] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_LEFT ),
+ [k_srbind_mright] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_RIGHT ),
+ [k_srbind_mup] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_UP ),
+ [k_srbind_mdown] = controller_glyph( SDL_CONTROLLER_BUTTON_DPAD_DOWN ),
+ [k_srbind_mback] = controller_glyph( SDL_CONTROLLER_BUTTON_B ),
+ [k_srbind_maccept]= controller_glyph( SDL_CONTROLLER_BUTTON_A ),
+ [k_srbind_mopen] = controller_glyph( SDL_CONTROLLER_BUTTON_GUIDE )
+ };
+
+ const char *keyboard_table[ k_srbind_max ] = {
+ [k_srbind_jump] = KEYBOARD_GLYPH( "A" ),
+ [k_srbind_push] = KEYBOARD_GLYPH( "W" ),
+ [k_srbind_trick0] = "\x99",
+ [k_srbind_trick1] = "\x9a",
+ [k_srbind_trick2] = "\x9b",
+ [k_srbind_use] = KEYBOARD_GLYPH( "E" ),
+ [k_srbind_reset] = KEYBOARD_GLYPH( "R" ),
+ [k_srbind_camera] = KEYBOARD_GLYPH( "C" ),
+ [k_srbind_mleft] = KEYBOARD_GLYPH( "\x93" ),
+ [k_srbind_mright] = KEYBOARD_GLYPH( "\x95" ),
+ [k_srbind_mup] = KEYBOARD_GLYPH( "\x94" ),
+ [k_srbind_mdown] = KEYBOARD_GLYPH( "\x96" ),
+ [k_srbind_mback] = "\xa3",
+ [k_srbind_maccept]= "\xa2",
+ [k_srbind_mopen] = "\xa3" ,
+ };
+
+ if( vg_input.display_input_method == k_input_method_controller )
+ return controller_table[ button ];
+ else
+ return keyboard_table[ button ];
+}
+
+static const char *axis_display_string( enum sr_axis axis )
+{
+ const char *controller_table[ k_sraxis_max ] = {
+ [k_sraxis_grab] = "\x90",
+ [k_sraxis_mbrowse_h] = "\x88",
+ [k_sraxis_mbrowse_v] = "\x89"
+ };
+
+ const char *keyboard_table[ k_sraxis_max ] = {
+ [k_sraxis_grab] = "\x9e",
+ [k_sraxis_mbrowse_h] = KEYBOARD_GLYPH("\x93")KEYBOARD_GLYPH("\x95"),
+ [k_sraxis_mbrowse_v] = KEYBOARD_GLYPH("\x96")KEYBOARD_GLYPH("\x94")
+ };
+
+ if( vg_input.display_input_method == k_input_method_controller )
+ return controller_table[ axis ];
+ else
+ return keyboard_table[ axis ];
+}
+
+static const char *joystick_display_string( enum sr_joystick joystick )
+{
+ const char *controller_table[ k_srjoystick_max ] = {
+ [k_srjoystick_steer] = "\x88",
+ [k_srjoystick_grab] = "\x8e",
+ [k_srjoystick_look] = "\x8e"
+ };
+
+ const char *keyboard_table[ k_srjoystick_max ] = {
+ [k_srjoystick_steer] = KEYBOARD_GLYPH( "\x93" )KEYBOARD_GLYPH( "\x95" ),
+ [k_srjoystick_grab] = "\xa4",
+ [k_srjoystick_look] = "\xa4"
+ };
+
+ if( vg_input.display_input_method == k_input_method_controller )
+ return controller_table[ joystick ];
+ else
+ return keyboard_table[ joystick ];
+}
+
+static int buttons_filter_fixed(void)