From 0f0bbba31925ea56eef3ff25469723fe59c2cae1 Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Wed, 11 Dec 2019 12:06:19 -0500 Subject: [PATCH] GetGlyphForActionOrigin implementation. --- dll/settings.h | 1 + dll/settings_parser.cpp | 2 + dll/steam_controller.h | 83 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/dll/settings.h b/dll/settings.h index cfb06b09..e422dc01 100644 --- a/dll/settings.h +++ b/dll/settings.h @@ -135,6 +135,7 @@ public: //controller struct Controller_Settings controller_settings; + std::string glyphs_directory; //networking bool disable_networking = false; diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index dc46f59d..ebbec1c0 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -104,6 +104,8 @@ static void load_gamecontroller_settings(Settings *settings) PRINT_DEBUG("Added %u action names to %s\n", button_pairs.size(), action_set_name.c_str()); } } + + settings->glyphs_directory = path + (PATH_SEPARATOR "glyphs" PATH_SEPARATOR); } uint32 create_localstorage_settings(Settings **settings_client_out, Settings **settings_server_out, Local_Storage **local_storage_out) diff --git a/dll/steam_controller.h b/dll/steam_controller.h index 1cd15e4c..613da651 100644 --- a/dll/steam_controller.h +++ b/dll/steam_controller.h @@ -129,6 +129,9 @@ public ISteamInput std::map controller_maps; std::map controllers; + std::map steaminput_glyphs; + std::map steamcontroller_glyphs; + bool disabled; void set_handles(std::map, std::string>>> action_sets) { @@ -788,14 +791,86 @@ const char *GetStringForActionOrigin( EInputActionOrigin eOrigin ) // Get a local path to art for on-screen glyph for a particular origin const char *GetGlyphForActionOrigin( EControllerActionOrigin eOrigin ) { - PRINT_DEBUG("Steam_Controller::GetGlyphForActionOrigin\n"); - return ""; + PRINT_DEBUG("Steam_Controller::GetGlyphForActionOrigin %i\n", eOrigin); + + if (steamcontroller_glyphs.empty()) { + std::string dir = settings->glyphs_directory; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_A] = dir + "button_a.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_B] = dir + "button_b.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_X] = dir + "button_x.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_Y] = dir + "button_y.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftBumper] = dir + "shoulder_l.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightBumper] = dir + "shoulder_r.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_Start] = dir + "xbox_button_start.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_Back] = dir + "xbox_button_select.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftTrigger_Pull] = dir + "trigger_l_pull.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftTrigger_Click] = dir + "trigger_l_click.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightTrigger_Pull] = dir + "trigger_r_pull.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightTrigger_Click] = dir + "trigger_r_click.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftStick_Move] = dir + "stick_l_move.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftStick_Click] = dir + "stick_l_click.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftStick_DPadNorth] = dir + "stick_dpad_n.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftStick_DPadSouth] = dir + "stick_dpad_s.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftStick_DPadWest] = dir + "stick_dpad_w.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_LeftStick_DPadEast] = dir + "stick_dpad_e.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightStick_Move] = dir + "stick_r_move.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightStick_Click] = dir + "stick_r_click.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightStick_DPadNorth] = dir + "stick_dpad_n.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightStick_DPadSouth] = dir + "stick_dpad_s.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightStick_DPadWest] = dir + "stick_dpad_w.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_RightStick_DPadEast] = dir + "stick_dpad_e.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_DPad_North] = dir + "xbox_button_dpad_n.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_DPad_South] = dir + "xbox_button_dpad_s.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_DPad_West] = dir + "xbox_button_dpad_w.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_DPad_East] = dir + "xbox_button_dpad_e.png"; + steamcontroller_glyphs[k_EControllerActionOrigin_XBox360_DPad_Move] = dir + "xbox_button_dpad_move.png"; + } + + auto glyph = steamcontroller_glyphs.find(eOrigin); + if (glyph == steamcontroller_glyphs.end()) return ""; + return glyph->second.c_str(); } const char *GetGlyphForActionOrigin( EInputActionOrigin eOrigin ) { - PRINT_DEBUG("Steam_Controller::GetGlyphForActionOrigin steaminput\n"); - return ""; + PRINT_DEBUG("Steam_Controller::GetGlyphForActionOrigin steaminput %i\n", eOrigin); + if (steaminput_glyphs.empty()) { + std::string dir = settings->glyphs_directory; + steaminput_glyphs[k_EInputActionOrigin_XBox360_A] = dir + "button_a.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_B] = dir + "button_b.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_X] = dir + "button_x.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_Y] = dir + "button_y.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftBumper] = dir + "shoulder_l.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightBumper] = dir + "shoulder_r.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_Start] = dir + "xbox_button_start.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_Back] = dir + "xbox_button_select.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftTrigger_Pull] = dir + "trigger_l_pull.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftTrigger_Click] = dir + "trigger_l_click.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightTrigger_Pull] = dir + "trigger_r_pull.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightTrigger_Click] = dir + "trigger_r_click.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftStick_Move] = dir + "stick_l_move.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftStick_Click] = dir + "stick_l_click.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftStick_DPadNorth] = dir + "stick_dpad_n.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftStick_DPadSouth] = dir + "stick_dpad_s.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftStick_DPadWest] = dir + "stick_dpad_w.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_LeftStick_DPadEast] = dir + "stick_dpad_e.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightStick_Move] = dir + "stick_r_move.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightStick_Click] = dir + "stick_r_click.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightStick_DPadNorth] = dir + "stick_dpad_n.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightStick_DPadSouth] = dir + "stick_dpad_s.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightStick_DPadWest] = dir + "stick_dpad_w.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_RightStick_DPadEast] = dir + "stick_dpad_e.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_DPad_North] = dir + "xbox_button_dpad_n.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_DPad_South] = dir + "xbox_button_dpad_s.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_DPad_West] = dir + "xbox_button_dpad_w.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_DPad_East] = dir + "xbox_button_dpad_e.png"; + steaminput_glyphs[k_EInputActionOrigin_XBox360_DPad_Move] = dir + "xbox_button_dpad_move.png"; + //steaminput_glyphs[] = dir + ""; + } + + auto glyph = steaminput_glyphs.find(eOrigin); + if (glyph == steaminput_glyphs.end()) return ""; + return glyph->second.c_str(); } // Returns the input type for a particular handle