From c5998c3b53b264bc2e159310278e4905f55092e3 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Mon, 16 Jan 2023 10:32:18 +0800 Subject: [PATCH 1/6] Laying out foundations for input editor UI --- .../InputBindings/SHInputBindingsPanel.cpp | 15 +++++++++++++++ .../InputBindings/SHInputBindingsPanel.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp create mode 100644 SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp new file mode 100644 index 00000000..f05440dc --- /dev/null +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp @@ -0,0 +1,15 @@ +#include "SHpch.h" +#include "SHInputBindingsPanel.h" +#include "Input/SHInputManager.h" +#include "Editor/SHEditorWidgets.hpp" + +namespace SHADE +{ + void SHInputBindingsPanel::Update() + { + if (Begin()) + { + + } + } +} \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h new file mode 100644 index 00000000..c29a68c5 --- /dev/null +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Editor/EditorWindow/SHEditorWindow.h" +#include + +namespace SHADE +{ + class SH_API SHInputBindingsPanel final : public SHEditorWindow + { + public: + SHInputBindingsPanel() : SHEditorWindow("Input Bindings Panel", ImGuiWindowFlags_MenuBar) {} + + void Update() override; + }; +} \ No newline at end of file -- 2.40.1 From 71572381f71fbde71da73c3656a7174f23d329ff Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Fri, 20 Jan 2023 14:00:24 +0800 Subject: [PATCH 2/6] Progress on input bindings in editor --- .../InputBindings/SHInputBindingsPanel.cpp | 184 +++++++++++++++++- .../InputBindings/SHInputBindingsPanel.h | 2 + .../EditorWindow/SHEditorWindowIncludes.h | 3 +- SHADE_Engine/src/Editor/SHEditor.cpp | 1 + SHADE_Engine/src/Input/SHInputManager.h | 10 + 5 files changed, 198 insertions(+), 2 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp index f05440dc..5dc9e17a 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp @@ -5,11 +5,193 @@ namespace SHADE { + //Internal Helper function + std::string labelConcat(char const* label, size_t entryNumber) + { + std::string concat = label; + concat += std::to_string(entryNumber); + return concat; + } + + void SHInputBindingsPanel::Init() + { + SHEditorWindow::Init(); + } + void SHInputBindingsPanel::Update() { - if (Begin()) + if (SHEditorWindow::Begin()) { + //Binding count + ImGui::Text("Binding Count: %d", SHInputManager::CountBindings()); + //Button to add new binding + if (ImGui::Button("Add New Binding")) + { + std::string newBindingName = "Binding" + std::to_string(SHInputManager::CountBindings()); + SHInputManager::AddBinding(newBindingName); + } + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("Add a new binding to the list"); + ImGui::EndTooltip(); + } + + //Ensure unique label for entries + size_t entryNumber = 0; + + //Listing for each binding + for (auto& binding : SHInputManager::GetBindings()) + { + ImGui::Separator(); + std::string bindingName = binding.first; //Binding name to use as argument when modifying binding values + + //Non-modifiable binding name + ImGui::Text("Binding Name: %s", binding.first); + std::string bindingModifiedName; + //MAKE THE INPUTTEXT WORK + ImGui::InputText(labelConcat("##bindingModifyName", entryNumber).c_str(), &bindingModifiedName); + ImGui::SameLine(); + if (ImGui::Button(labelConcat("Rename##bindingRename", entryNumber).c_str())) + { + SHLOGV_CRITICAL("\"{0}\" > \"{1}\"", bindingName, bindingModifiedName); + SHInputManager::RenameBinding(bindingName, bindingModifiedName); + } + + //Modifiable binding name + /*size_t constexpr maxLen = 256; //Maximum binding name length + static char bindingNameCStr[maxLen]; + std::copy(bindingName.begin(), + bindingName.length() >= maxLen ? + bindingName.begin() + maxLen : + bindingName.end(), //Does not take into account null terminator + bindingNameCStr); + bindingNameCStr[bindingName.length()] = '\0'; //Null terminator + + //First character + char firstChar = bindingNameCStr[0]; + //If the input text is modified, modify the binding's name + if (ImGui::InputText("Binding Name", bindingNameCStr, maxLen)) + { + //Ensure name does not get shorter than 1 character long + if (std::strlen(bindingNameCStr) < 1) + bindingNameCStr[0] = firstChar; + //Rename binding in the input manager + SHInputManager::RenameBinding(bindingName, std::string{ bindingNameCStr }); + bindingName = std::string{ bindingNameCStr }; + } + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("The name of this binding"); + ImGui::EndTooltip(); + }*/ + + //Binding value test + //TODO + ImGui::Text("Value"); + + + //Binding Type Combo Box + int bindingType = static_cast(SHInputManager::GetBindingType(bindingName)); + if (ImGui::Combo(labelConcat("Input Type##", entryNumber).c_str(), &bindingType, "Keyboard / Mouse Buttons / Controller\0Mouse Horizontal\0Mouse Vertical\0Mouse Scroll Wheel")) + SHInputManager::SetBindingType(bindingName, static_cast(bindingType)); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("Which of the four types the binding uses"); + ImGui::Text("Keyboard / Mouse Buttons / Controller = Keys, mouse buttons and ALL controller inputs"); + ImGui::Text("Mouse Horizontal = Horizontal movement of the mouse"); + ImGui::Text("Mouse Vertical = Vertical movement of the mouse"); + ImGui::Text("Mouse Scroll Wheel = The scroll wheel found at the middle of most mouses"); + ImGui::EndTooltip(); + } + + //Inversion + bool bindingInvert = SHInputManager::GetBindingInverted(bindingName); + if (ImGui::Checkbox(labelConcat("Inverted##", entryNumber).c_str(), &bindingInvert)) + SHInputManager::SetBindingInverted(bindingName, bindingInvert); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("If inverted:"); + ImGui::Text("Positive inputs mean negative value of the binding"); + ImGui::Text("Negative inputs mean positive value of the binding"); + ImGui::Text("Mouse moving up / right means negative value of the binding"); + ImGui::Text("Scrolling the mouse wheel up means negative value of the binding"); + ImGui::EndTooltip(); + } + + //Sensitivity + double bindingSensitivity = SHInputManager::GetBindingSensitivity(bindingName); + if (ImGui::InputDouble(labelConcat("Sensitivity##", entryNumber).c_str(), &bindingSensitivity)) + SHInputManager::SetBindingSensitivity(bindingName, bindingSensitivity); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("Value multiplier for mouse movement and scrolling"); + ImGui::Text("For other digital inputs, serves as a rate of how fast axis value goes to maximum positive/negative"); + ImGui::Text("For other analog inputs, serves as a multiplier, but axis value magnitude will still be capped at 1"); + ImGui::EndTooltip(); + } + + //Below this section is only for KB/M type bindings + //Not relevant for mouse movement and scrolling + if (SHInputManager::GetBindingType(bindingName) == SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER) + { + //Dead + float bindingDead = static_cast(SHInputManager::GetBindingDead(bindingName)); + if (ImGui::SliderFloat(labelConcat("Deadzone##", entryNumber).c_str(), &bindingDead, 0.0f, 1.0f)) + SHInputManager::SetBindingDead(bindingName, static_cast(bindingDead)); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("Any positive or negative analog input with magnitude less than this will be registered as neutral"); + ImGui::EndTooltip(); + } + + //Gravity + double bindingGravity = SHInputManager::GetBindingGravity(bindingName); + if (ImGui::InputDouble(labelConcat("Gravity##", entryNumber).c_str(), &bindingGravity)) + SHInputManager::SetBindingGravity(bindingName, static_cast(bindingGravity)); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("The rate at which the value moves to neutral if no input in the direction is read"); + ImGui::TextColored(ImVec4{ 1.0f, 0.5f, 0.5f, 1.0f }, "Should be non-negative"); + ImGui::EndTooltip(); + } + + //Snap + bool bindingSnap = SHInputManager::GetBindingSnap(bindingName); + if (ImGui::Checkbox(labelConcat("Snap##", entryNumber).c_str(), &bindingSnap)) + SHInputManager::SetBindingSnap(bindingName, bindingSnap); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("If no other input on the axis is present and a input is made in the opposite direction of the current value,"); + ImGui::Text("the binding's value will jump to neutral 0 before resuming in the input direction"); + ImGui::EndTooltip(); + } + + //Positive key codes + + //Negative key codes + + //Positive controller codes + + //Negative controller codes + } + + ++entryNumber; //Next entry + } } + ImGui::End(); + } + + void SHInputBindingsPanel::Exit() + { + SHEditorWindow::Exit(); } } \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h index c29a68c5..db2ec0c8 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.h @@ -10,6 +10,8 @@ namespace SHADE public: SHInputBindingsPanel() : SHEditorWindow("Input Bindings Panel", ImGuiWindowFlags_MenuBar) {} + void Init() override; void Update() override; + void Exit() override; }; } \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h b/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h index 9aad6ede..290ed622 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h +++ b/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h @@ -6,4 +6,5 @@ #include "ViewportWindow/SHEditorViewport.h" //Editor Viewport #include "AssetBrowser/SHAssetBrowser.h" //Asset Browser #include "MaterialInspector/SHMaterialInspector.h" //Material Inspector -#include "ColliderTagPanel/SHColliderTagPanel.h" //Collider Tag Panel \ No newline at end of file +#include "ColliderTagPanel/SHColliderTagPanel.h" //Collider Tag Panel +#include "InputBindings/SHInputBindingsPanel.h" //Input Bindings \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 2b8ddbb5..b99d9f32 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -104,6 +104,7 @@ namespace SHADE SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); + SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); diff --git a/SHADE_Engine/src/Input/SHInputManager.h b/SHADE_Engine/src/Input/SHInputManager.h index 680035c3..5698f4c1 100644 --- a/SHADE_Engine/src/Input/SHInputManager.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -738,6 +738,16 @@ namespace SHADE return bindings.erase(bindingName); } + //Rename a binding + static inline void RenameBinding(std::string const& oldBindingName, std::string const& newBindingName) noexcept + { + //https://stackoverflow.com/a/44883472 + //https://en.cppreference.com/w/cpp/container/map/extract + auto nodeHandler = bindings.extract(oldBindingName); + nodeHandler.key() = newBindingName; + bindings.insert(std::move(nodeHandler)); + } + //Clears all bindings from the list static inline void ClearBindings() noexcept { -- 2.40.1 From dddb556553737387ac9ef4538fba8759766595e8 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Sun, 22 Jan 2023 17:59:36 +0800 Subject: [PATCH 3/6] Progress --- .../InputBindings/SHInputBindingsPanel.cpp | 60 +++--- SHADE_Engine/src/Input/SHInputManager.cpp | 181 ++++++++++++++++++ SHADE_Engine/src/Input/SHInputManager.h | 3 + 3 files changed, 216 insertions(+), 28 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp index 5dc9e17a..ca9e263f 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp @@ -5,6 +5,9 @@ namespace SHADE { + static std::vector bindingRenames; + static std::vector positiveKeyListening; + //Internal Helper function std::string labelConcat(char const* label, size_t entryNumber) { @@ -30,6 +33,9 @@ namespace SHADE { std::string newBindingName = "Binding" + std::to_string(SHInputManager::CountBindings()); SHInputManager::AddBinding(newBindingName); + bindingRenames.resize(SHInputManager::CountBindings()); + for (auto& s : bindingRenames) + s.clear(); } if (ImGui::IsItemHovered()) { @@ -45,29 +51,28 @@ namespace SHADE for (auto& binding : SHInputManager::GetBindings()) { ImGui::Separator(); - std::string bindingName = binding.first; //Binding name to use as argument when modifying binding values + + ImGui::Text("Entry Number %d", entryNumber); //Non-modifiable binding name ImGui::Text("Binding Name: %s", binding.first); - std::string bindingModifiedName; - //MAKE THE INPUTTEXT WORK - ImGui::InputText(labelConcat("##bindingModifyName", entryNumber).c_str(), &bindingModifiedName); + ImGui::InputText(labelConcat("##bindingModifyName", entryNumber).c_str(), &bindingRenames[entryNumber]); ImGui::SameLine(); if (ImGui::Button(labelConcat("Rename##bindingRename", entryNumber).c_str())) { - SHLOGV_CRITICAL("\"{0}\" > \"{1}\"", bindingName, bindingModifiedName); - SHInputManager::RenameBinding(bindingName, bindingModifiedName); + SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]); + bindingRenames[entryNumber].clear(); } //Modifiable binding name /*size_t constexpr maxLen = 256; //Maximum binding name length static char bindingNameCStr[maxLen]; - std::copy(bindingName.begin(), - bindingName.length() >= maxLen ? - bindingName.begin() + maxLen : - bindingName.end(), //Does not take into account null terminator + std::copy(binding.first.begin(), + binding.first.length() >= maxLen ? + binding.first.begin() + maxLen : + binding.first.end(), //Does not take into account null terminator bindingNameCStr); - bindingNameCStr[bindingName.length()] = '\0'; //Null terminator + bindingNameCStr[binding.first.length()] = '\0'; //Null terminator //First character char firstChar = bindingNameCStr[0]; @@ -78,8 +83,8 @@ namespace SHADE if (std::strlen(bindingNameCStr) < 1) bindingNameCStr[0] = firstChar; //Rename binding in the input manager - SHInputManager::RenameBinding(bindingName, std::string{ bindingNameCStr }); - bindingName = std::string{ bindingNameCStr }; + SHInputManager::RenameBinding(binding.first, std::string{ bindingNameCStr }); + binding.first = std::string{ bindingNameCStr }; } if (ImGui::IsItemHovered()) { @@ -92,11 +97,10 @@ namespace SHADE //TODO ImGui::Text("Value"); - //Binding Type Combo Box - int bindingType = static_cast(SHInputManager::GetBindingType(bindingName)); + int bindingType = static_cast(SHInputManager::GetBindingType(binding.first)); if (ImGui::Combo(labelConcat("Input Type##", entryNumber).c_str(), &bindingType, "Keyboard / Mouse Buttons / Controller\0Mouse Horizontal\0Mouse Vertical\0Mouse Scroll Wheel")) - SHInputManager::SetBindingType(bindingName, static_cast(bindingType)); + SHInputManager::SetBindingType(binding.first, static_cast(bindingType)); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -109,9 +113,9 @@ namespace SHADE } //Inversion - bool bindingInvert = SHInputManager::GetBindingInverted(bindingName); + bool bindingInvert = SHInputManager::GetBindingInverted(binding.first); if (ImGui::Checkbox(labelConcat("Inverted##", entryNumber).c_str(), &bindingInvert)) - SHInputManager::SetBindingInverted(bindingName, bindingInvert); + SHInputManager::SetBindingInverted(binding.first, bindingInvert); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -124,9 +128,9 @@ namespace SHADE } //Sensitivity - double bindingSensitivity = SHInputManager::GetBindingSensitivity(bindingName); + double bindingSensitivity = SHInputManager::GetBindingSensitivity(binding.first); if (ImGui::InputDouble(labelConcat("Sensitivity##", entryNumber).c_str(), &bindingSensitivity)) - SHInputManager::SetBindingSensitivity(bindingName, bindingSensitivity); + SHInputManager::SetBindingSensitivity(binding.first, bindingSensitivity); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -138,12 +142,12 @@ namespace SHADE //Below this section is only for KB/M type bindings //Not relevant for mouse movement and scrolling - if (SHInputManager::GetBindingType(bindingName) == SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER) + if (SHInputManager::GetBindingType(binding.first) == SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER) { //Dead - float bindingDead = static_cast(SHInputManager::GetBindingDead(bindingName)); + float bindingDead = static_cast(SHInputManager::GetBindingDead(binding.first)); if (ImGui::SliderFloat(labelConcat("Deadzone##", entryNumber).c_str(), &bindingDead, 0.0f, 1.0f)) - SHInputManager::SetBindingDead(bindingName, static_cast(bindingDead)); + SHInputManager::SetBindingDead(binding.first, static_cast(bindingDead)); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -152,9 +156,9 @@ namespace SHADE } //Gravity - double bindingGravity = SHInputManager::GetBindingGravity(bindingName); + double bindingGravity = SHInputManager::GetBindingGravity(binding.first); if (ImGui::InputDouble(labelConcat("Gravity##", entryNumber).c_str(), &bindingGravity)) - SHInputManager::SetBindingGravity(bindingName, static_cast(bindingGravity)); + SHInputManager::SetBindingGravity(binding.first, static_cast(bindingGravity)); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -164,9 +168,9 @@ namespace SHADE } //Snap - bool bindingSnap = SHInputManager::GetBindingSnap(bindingName); + bool bindingSnap = SHInputManager::GetBindingSnap(binding.first); if (ImGui::Checkbox(labelConcat("Snap##", entryNumber).c_str(), &bindingSnap)) - SHInputManager::SetBindingSnap(bindingName, bindingSnap); + SHInputManager::SetBindingSnap(binding.first, bindingSnap); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); @@ -174,7 +178,7 @@ namespace SHADE ImGui::Text("the binding's value will jump to neutral 0 before resuming in the input direction"); ImGui::EndTooltip(); } - + //Positive key codes //Negative key codes diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index b8f329b9..c33b36b6 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -100,6 +100,187 @@ namespace SHADE } } + std::string SHInputManager::getKeycodeName(SH_KEYCODE k) noexcept + { + int kInt = static_cast(k); + //Numbers + if (kInt >= static_cast(SH_KEYCODE::NUMBER_0) && kInt <= static_cast(SH_KEYCODE::NUMBER_9)) + { + return std::to_string(kInt - 48); + } + //Letters + if (kInt >= static_cast(SH_KEYCODE::A) && kInt <= static_cast(SH_KEYCODE::Z)) + { + return std::string(1, static_cast(kInt)); + } + //Numpads + if (kInt >= static_cast(SH_KEYCODE::NUMPAD_0) && kInt <= static_cast(SH_KEYCODE::NUMPAD_9)) + { + return "Keypad " + std::to_string(kInt - 96); + } + + //Other keys + switch (k) + { + case SH_KEYCODE::LMB: + return "Left Mouse Button"; + break; + case SH_KEYCODE::RMB: + return "Right Mouse Button"; + break; + case SH_KEYCODE::CANCEL: + return "Cancel"; + break; + case SH_KEYCODE::MMB: + return "Middle Mouse Button"; + break; + case SH_KEYCODE::XMB1: + return "X1 Mouse Button"; + break; + case SH_KEYCODE::XMB2: + return "X2 Mouse Button"; + break; + case SH_KEYCODE::BACKSPACE: + return "Backspace"; + break; + case SH_KEYCODE::TAB: + return "Tab"; + break; + case SH_KEYCODE::CLEAR: + return "Clear"; + break; + case SH_KEYCODE::ENTER: + return "Enter"; + break; + case SH_KEYCODE::SHIFT: + return "Shift"; + break; + case SH_KEYCODE::CTRL: + return "Ctrl"; + break; + case SH_KEYCODE::ALT: + return "Alt"; + break; + case SH_KEYCODE::PAUSE: + return "Pause"; + break; + case SH_KEYCODE::CAPS_LOCK: + return "Caps Lock"; + break; + case SH_KEYCODE::IME_KANA: + return "IME Kana / Hangul Mode"; + break; + case SH_KEYCODE::IME_ON: + return "IME On"; + break; + case SH_KEYCODE::IME_JUNJA: + return "IME Junja Mode"; + break; + case SH_KEYCODE::IME_FINAL: + return "IME Final Mode"; + break; + case SH_KEYCODE::IME_HANJA: + return "IME Kanji / Hanja Mode"; + break; + case SH_KEYCODE::IME_OFF: + return "IME Off"; + break; + case SH_KEYCODE::ESCAPE: + return "Esc"; + break; + case SH_KEYCODE::IME_CONVERT: + return "IME Convert"; + break; + case SH_KEYCODE::IME_NONCONVERT: + return "IME Nonconvert"; + break; + case SH_KEYCODE::IME_ACCEPT: + return "IME Accept"; + break; + case SH_KEYCODE::IME_MODECHANGE: + return "IME Mode Change Request"; + break; + case SH_KEYCODE::SPACE: + return "Spacebar"; + break; + case SH_KEYCODE::PAGE_UP: + return "Page Up"; + break; + case SH_KEYCODE::PAGE_DOWN: + return "Page Down"; + break; + case SH_KEYCODE::END: + return "End"; + break; + case SH_KEYCODE::HOME: + return "Home"; + break; + case SH_KEYCODE::LEFT_ARROW: + return "Left Arrow"; + break; + case SH_KEYCODE::UP_ARROW: + return "Up Arrow"; + break; + case SH_KEYCODE::RIGHT_ARROW: + return "Right Arrow"; + break; + case SH_KEYCODE::DOWN_ARROW: + return "Down Arrow"; + break; + case SH_KEYCODE::SELECT: + return "Select"; + break; + case SH_KEYCODE::PRINT: + return "Print"; + break; + case SH_KEYCODE::EXECUTE: + return "Execute"; + break; + case SH_KEYCODE::PRINT_SCREEN: + return "Print Screen"; + break; + case SH_KEYCODE::INSERT: + return "Insert"; + break; + case SH_KEYCODE::DEL: + return "Delete"; + break; + case SH_KEYCODE::HELP: + return "Help"; + break; + case SH_KEYCODE::NUMBER_0: + return "0"; + break; + case SH_KEYCODE::NUMBER_1: + return "1"; + break; + case SH_KEYCODE::NUMBER_2: + return "2"; + break; + case SH_KEYCODE::NUMBER_3: + return "3"; + break; + case SH_KEYCODE::NUMBER_4: + return "4"; + break; + case SH_KEYCODE::NUMBER_5: + return "5"; + break; + case SH_KEYCODE::NUMBER_6: + return "6"; + break; + case SH_KEYCODE::NUMBER_7: + return "7"; + break; + case SH_KEYCODE::NUMBER_8: + return "8"; + break; + case SH_KEYCODE::NUMBER_9: + return "9"; + break; + } + } + //The Binding File format presently goes as such: /* * Binding count diff --git a/SHADE_Engine/src/Input/SHInputManager.h b/SHADE_Engine/src/Input/SHInputManager.h index 5698f4c1..2a9b9dcd 100644 --- a/SHADE_Engine/src/Input/SHInputManager.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -415,6 +415,9 @@ namespace SHADE return controllerInUse; } + //Get the name of keycode + static std::string getKeycodeName(SH_KEYCODE const keycode) noexcept; + //For testing purposes //static void PrintCurrentState() noexcept; -- 2.40.1 From e70354df74a8ce51b4da456f422c46ce915f4cf5 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Tue, 24 Jan 2023 19:17:27 +0800 Subject: [PATCH 4/6] Get input code name functions --- SHADE_Engine/src/Input/SHInputManager.cpp | 324 ++++++++++++++++++++-- SHADE_Engine/src/Input/SHInputManager.h | 7 +- 2 files changed, 308 insertions(+), 23 deletions(-) diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index c33b36b6..87ea3aa5 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -100,7 +100,7 @@ namespace SHADE } } - std::string SHInputManager::getKeycodeName(SH_KEYCODE k) noexcept + std::string SHInputManager::getKeyCodeName(SH_KEYCODE k) noexcept { int kInt = static_cast(k); //Numbers @@ -118,6 +118,11 @@ namespace SHADE { return "Keypad " + std::to_string(kInt - 96); } + //Function keys + if (kInt >= static_cast(SH_KEYCODE::F1) && kInt <= static_cast(SH_KEYCODE::F24)) + { + return "F" + std::to_string(kInt - 111); + } //Other keys switch (k) @@ -248,35 +253,312 @@ namespace SHADE case SH_KEYCODE::HELP: return "Help"; break; - case SH_KEYCODE::NUMBER_0: - return "0"; + case SH_KEYCODE::LEFT_WINDOWS: + return "Left Windows"; break; - case SH_KEYCODE::NUMBER_1: - return "1"; + case SH_KEYCODE::RIGHT_WINDOWS: + return "Right Windows"; break; - case SH_KEYCODE::NUMBER_2: - return "2"; + case SH_KEYCODE::APPS: + return "Applications"; break; - case SH_KEYCODE::NUMBER_3: - return "3"; + case SH_KEYCODE::SLEEP: + return "Sleep"; break; - case SH_KEYCODE::NUMBER_4: - return "4"; + case SH_KEYCODE::MULTIPLY: + return "Multiply"; break; - case SH_KEYCODE::NUMBER_5: - return "5"; + case SH_KEYCODE::ADD: + return "Add"; break; - case SH_KEYCODE::NUMBER_6: - return "6"; + case SH_KEYCODE::SEPARATOR: + return "Separator"; break; - case SH_KEYCODE::NUMBER_7: - return "7"; + case SH_KEYCODE::SUBTRACT: + return "Subtract"; break; - case SH_KEYCODE::NUMBER_8: - return "8"; + case SH_KEYCODE::DECIMAL: + return "Decimal"; break; - case SH_KEYCODE::NUMBER_9: - return "9"; + case SH_KEYCODE::DIVIDE: + return "Divide"; + break; + case SH_KEYCODE::NUM_LOCK: + return "Num Lock"; + break; + case SH_KEYCODE::SCROLL_LOCK: + return "Scroll Lock"; + break; + case SH_KEYCODE::OEM_PC98_NUMPAD_EQUAL: + return "OEM PC98 Numpad Equal / Fujitsu Dictionary"; + break; + case SH_KEYCODE::OEM_FUJITSU_UNREGISTER: + return "OEM Fujitsu Unregister"; + break; + case SH_KEYCODE::OEM_FUJITSU_REGISTER: + return "OEM Fujitsu Register"; + break; + case SH_KEYCODE::OEM_FUJITSU_LEFT_THUMB: + return "OEM Fujitsu Left Thumb"; + break; + case SH_KEYCODE::OEM_FUJITSU_RIGHT_THUMB: + return "OEM Fujitsu Right Thumb"; + break; + case SH_KEYCODE::LEFT_SHIFT: + return "Left Shift"; + break; + case SH_KEYCODE::RIGHT_SHIFT: + return "Right Shift"; + break; + case SH_KEYCODE::LEFT_CTRL: + return "Left Ctrl"; + break; + case SH_KEYCODE::RIGHT_CTRL: + return "Right Ctrl"; + break; + case SH_KEYCODE::LEFT_ALT: + return "Left Alt"; + break; + case SH_KEYCODE::RIGHT_ALT: + return "Right Alt"; + break; + case SH_KEYCODE::BROWSER_BACK: + return "Browser Back"; + break; + case SH_KEYCODE::BROWSER_FORWARD: + return "Browser Forward"; + break; + case SH_KEYCODE::BROWSER_REFRESH: + return "Browser Refresh"; + break; + case SH_KEYCODE::BROWSER_STOP: + return "Browser Stop"; + break; + case SH_KEYCODE::BROWSER_SEARCH: + return "Browser Search"; + break; + case SH_KEYCODE::BROWSER_FAVOURITES: + return "Browser Favourites"; + break; + case SH_KEYCODE::BROWSER_HOME: + return "Browser Start and Home"; + break; + case SH_KEYCODE::VOLUME_MUTE: + return "Volume Mute"; + break; + case SH_KEYCODE::VOLUME_DOWN: + return "Volume Down"; + break; + case SH_KEYCODE::VOLUME_UP: + return "Volume Up"; + break; + case SH_KEYCODE::MEDIA_NEXT_TRACK: + return "Media Next Track"; + break; + case SH_KEYCODE::MEDIA_PREVIOUS_TRACK: + return "Media Previous Track"; + break; + case SH_KEYCODE::MEDIA_STOP: + return "Media Stop"; + break; + case SH_KEYCODE::MEDIA_PLAY_PAUSE: + return "Media Play/Pause"; + break; + case SH_KEYCODE::LAUNCH_MAIL: + return "Launch Mail"; + break; + case SH_KEYCODE::LAUNCH_MEDIA_SELECT: + return "Select Media"; + break; + case SH_KEYCODE::LAUNCH_APP_1: + return "Launch App 1"; + break; + case SH_KEYCODE::LAUNCH_APP_2: + return "Launch App 2"; + break; + case SH_KEYCODE::OEM_1: + return "; or :"; + break; + case SH_KEYCODE::OEM_PLUS: + return "+"; + break; + case SH_KEYCODE::OEM_COMMA: + return ","; + break; + case SH_KEYCODE::OEM_2: + return "/ or ?"; + break; + case SH_KEYCODE::OEM_3: + return "` or ~"; + break; + case SH_KEYCODE::OEM_4: + return "[ or {"; + break; + case SH_KEYCODE::OEM_5: + return "\\ or |"; + break; + case SH_KEYCODE::OEM_6: + return "] or }"; + break; + case SH_KEYCODE::OEM_7: + return "\' or \""; + break; + case SH_KEYCODE::OEM_8: + return "OEM 8"; + break; + case SH_KEYCODE::OEM_AX: + return "OEM AX"; + break; + case SH_KEYCODE::OEM_102: + return "< or > or \\ or |"; + break; + case SH_KEYCODE::OEM_ICO_HELP: + return "ICO Help"; + break; + case SH_KEYCODE::OEM_ICO_00: + return "ICO 00"; + break; + case SH_KEYCODE::IME_PROCESS: + return "IME Process"; + break; + case SH_KEYCODE::OEM_ICO_CLEAR: + return "ICO Clear"; + break; + case SH_KEYCODE::PACKET: + return "Packet"; + break; + case SH_KEYCODE::OEM_RESET: + return "OEM Reset"; + break; + case SH_KEYCODE::OEM_JUMP: + return "OEM Jump"; + break; + case SH_KEYCODE::OEM_PA1: + return "OEM PA1"; + break; + case SH_KEYCODE::OEM_PA2: + return "OEM PA2"; + break; + case SH_KEYCODE::OEM_PA3: + return "OEM PA3"; + break; + case SH_KEYCODE::OEM_WSCTRL: + return "OEM WSCTRL"; + break; + case SH_KEYCODE::OEM_CUSEL: + return "OEM CuSel"; + break; + case SH_KEYCODE::OEM_ATTN: + return "OEM Attn"; + break; + case SH_KEYCODE::OEM_FINISH: + return "OEM Finish"; + break; + case SH_KEYCODE::OEM_COPY: + return "OEM Copy"; + break; + case SH_KEYCODE::OEM_AUTO: + return "OEM Auto"; + break; + case SH_KEYCODE::OEM_ENLW: + return "OEM ENLW"; + break; + case SH_KEYCODE::OEM_BACKTAB: + return "OEM Backtab"; + break; + case SH_KEYCODE::ATTN: + return "Attn"; + break; + case SH_KEYCODE::CRSEL: + return "CrSel"; + break; + case SH_KEYCODE::EXSEL: + return "ExSel"; + break; + case SH_KEYCODE::EREOF: + return "Erase EOF"; + break; + case SH_KEYCODE::PLAY: + return "Play"; + break; + case SH_KEYCODE::ZOOM: + return "Zoom"; + break; + case SH_KEYCODE::NONAME: + return "No Name Key"; + break; + case SH_KEYCODE::PA_1: + return "PA1"; + break; + case SH_KEYCODE::OEM_CLEAR: + return "OEM Clear"; + break; + } + } + + std::string SHInputManager::getControllerCodeName(SH_CONTROLLERCODE c) noexcept + { + switch (c) + { + case SH_CONTROLLERCODE::DPAD_UP: + return "D-Pad Up"; + break; + case SH_CONTROLLERCODE::DPAD_DOWN: + return "D-Pad Down"; + break; + case SH_CONTROLLERCODE::DPAD_LEFT: + return "D-Pad Left"; + break; + case SH_CONTROLLERCODE::DPAD_RIGHT: + return "D-Pad Right"; + break; + case SH_CONTROLLERCODE::START: + return "Start Button"; + break; + case SH_CONTROLLERCODE::BACK: + return "Back Button"; + break; + case SH_CONTROLLERCODE::LEFT_THUMBSTICK: + return "Left Thumbstick Button"; + break; + case SH_CONTROLLERCODE::RIGHT_THUMBSTICK: + return "Right Thumbstick Button"; + break; + case SH_CONTROLLERCODE::LEFT_SHOULDER: + return "Left Shoulder Button"; + break; + case SH_CONTROLLERCODE::RIGHT_SHOULDER: + return "Right Shoulder Button"; + break; + case SH_CONTROLLERCODE::A: + return "A Button"; + break; + case SH_CONTROLLERCODE::B: + return "B Button"; + break; + case SH_CONTROLLERCODE::X: + return "X Button"; + break; + case SH_CONTROLLERCODE::Y: + return "Y Button"; + break; + case SH_CONTROLLERCODE::LEFT_TRIGGER: + return "Left Trigger"; + break; + case SH_CONTROLLERCODE::RIGHT_TRIGGER: + return "Right Trigger"; + break; + case SH_CONTROLLERCODE::LEFT_THUMBSTICK_X: + return "Left Thumbstick Horizontal"; + break; + case SH_CONTROLLERCODE::LEFT_THUMBSTICK_Y: + return "Left Thumbstick Vertical"; + break; + case SH_CONTROLLERCODE::RIGHT_THUMBSTICK_X: + return "Right Thumbstick Horizontal"; + break; + case SH_CONTROLLERCODE::RIGHT_THUMBSTICK_Y: + return "Right Thumbstick Vertical"; break; } } diff --git a/SHADE_Engine/src/Input/SHInputManager.h b/SHADE_Engine/src/Input/SHInputManager.h index 2a9b9dcd..52322f0c 100644 --- a/SHADE_Engine/src/Input/SHInputManager.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -415,8 +415,11 @@ namespace SHADE return controllerInUse; } - //Get the name of keycode - static std::string getKeycodeName(SH_KEYCODE const keycode) noexcept; + //Get the name of key code + static std::string getKeyCodeName(SH_KEYCODE const keyCode) noexcept; + + //Get the name of controller code + static std::string getControllerCodeName(SH_CONTROLLERCODE const controllerCode) noexcept; //For testing purposes //static void PrintCurrentState() noexcept; -- 2.40.1 From bde191aeca68eae05e6bae9e6374a8facab30b51 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Wed, 25 Jan 2023 23:22:15 +0800 Subject: [PATCH 5/6] Input Bindings Panel Done --- Assets/Bindings.SHConfig | 95 +++ .../InputBindings/SHInputBindingsPanel.cpp | 541 ++++++++++++++---- SHADE_Engine/src/Input/SHInputManager.cpp | 50 +- SHADE_Engine/src/Input/SHInputManager.h | 11 +- 4 files changed, 550 insertions(+), 147 deletions(-) diff --git a/Assets/Bindings.SHConfig b/Assets/Bindings.SHConfig index 573541ac..bdc254b5 100644 --- a/Assets/Bindings.SHConfig +++ b/Assets/Bindings.SHConfig @@ -1 +1,96 @@ +7 +Controller Look Horizontal 0 +0 +5 +0.2 +5 +0 +0 +0 +1 +18 +0 +Controller Look Vertical +0 +0 +5 +0.2 +5 +0 +0 +0 +1 +19 +0 +Horizontal +0 +0 +5 +0.2 +5 +1 +2 +39 +68 +2 +37 +65 +2 +3 +16 +1 +2 +Jump +0 +0 +1000 +0.2 +1000 +0 +1 +32 +0 +1 +10 +0 +Mouse Look Horizontal +1 +0 +1 +0.2 +1 +0 +0 +0 +0 +0 +Mouse Look Vertical +2 +0 +1 +0.2 +1 +0 +0 +0 +0 +0 +Vertical +0 +0 +5 +0.2 +5 +1 +2 +38 +87 +2 +40 +83 +2 +0 +17 +1 +1 diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp index ca9e263f..c304c1b0 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp @@ -5,8 +5,29 @@ namespace SHADE { + //Vectors containing data for elements for different bindings static std::vector bindingRenames; - static std::vector positiveKeyListening; + + //Flags to prevent unwanted editing of bindings + static size_t positiveKeyListeningFor; + static bool positiveKeyListening; + + static size_t negativeKeyListeningFor; + static bool negativeKeyListening; + + static size_t positiveControllerListeningFor; + static bool positiveControllerListening; + + static size_t negativeControllerListeningFor; + static bool negativeControllerListening; + + //Internal Helper function + void resizeVectors(size_t newSize) + { + bindingRenames.resize(newSize); + for (auto& s : bindingRenames) + s.clear(); + } //Internal Helper function std::string labelConcat(char const* label, size_t entryNumber) @@ -25,17 +46,63 @@ namespace SHADE { if (SHEditorWindow::Begin()) { + //ImGui::ShowDemoWindow(); + //Binding count ImGui::Text("Binding Count: %d", SHInputManager::CountBindings()); + //Binding file name + static std::string bindingFileName; + ImGui::InputText("Binding File Path", &bindingFileName); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text(".SHConfig will be appeneded to file name"); + ImGui::Text("If no name is provided, saves to \"Assets/Bindings.SHConfig\""); + ImGui::EndTooltip(); + } + + //Save bindings to... + if (ImGui::Button("Save Bindings")) + { + if (bindingFileName.empty()) + { + SHInputManager::SaveBindings(); + } + else + { + std::string filePath = std::string(ASSET_ROOT); + filePath += "/"; + filePath += bindingFileName; + filePath += ".SHConfig"; + SHInputManager::SaveBindings(filePath); + } + } + + //Load bindings from... + if (ImGui::Button("Load Bindings")) + { + if (bindingFileName.empty()) + { + SHInputManager::LoadBindings(); + } + else + { + std::string filePath = std::string(ASSET_ROOT); + filePath += "/"; + filePath += bindingFileName; + filePath += ".SHConfig"; + SHInputManager::LoadBindings(filePath); + } + resizeVectors(SHInputManager::CountBindings()); + } + //Button to add new binding if (ImGui::Button("Add New Binding")) { std::string newBindingName = "Binding" + std::to_string(SHInputManager::CountBindings()); SHInputManager::AddBinding(newBindingName); - bindingRenames.resize(SHInputManager::CountBindings()); - for (auto& s : bindingRenames) - s.clear(); + resizeVectors(SHInputManager::CountBindings()); } if (ImGui::IsItemHovered()) { @@ -50,144 +117,378 @@ namespace SHADE //Listing for each binding for (auto& binding : SHInputManager::GetBindings()) { - ImGui::Separator(); - - ImGui::Text("Entry Number %d", entryNumber); - - //Non-modifiable binding name - ImGui::Text("Binding Name: %s", binding.first); - ImGui::InputText(labelConcat("##bindingModifyName", entryNumber).c_str(), &bindingRenames[entryNumber]); - ImGui::SameLine(); - if (ImGui::Button(labelConcat("Rename##bindingRename", entryNumber).c_str())) + if (ImGui::CollapsingHeader(binding.first.c_str())) { - SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]); - bindingRenames[entryNumber].clear(); - } + //Modifiable binding name + ImGui::Text("Binding Name: %s", binding.first.c_str()); + ImGui::InputText(labelConcat("##bindingModifyName", entryNumber).c_str(), &bindingRenames[entryNumber]); + ImGui::SameLine(); + if (ImGui::Button(labelConcat("Rename##bindingRename", entryNumber).c_str())) + { + SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]); + bindingRenames[entryNumber].clear(); + } - //Modifiable binding name - /*size_t constexpr maxLen = 256; //Maximum binding name length - static char bindingNameCStr[maxLen]; - std::copy(binding.first.begin(), - binding.first.length() >= maxLen ? - binding.first.begin() + maxLen : - binding.first.end(), //Does not take into account null terminator - bindingNameCStr); - bindingNameCStr[binding.first.length()] = '\0'; //Null terminator - - //First character - char firstChar = bindingNameCStr[0]; - //If the input text is modified, modify the binding's name - if (ImGui::InputText("Binding Name", bindingNameCStr, maxLen)) - { - //Ensure name does not get shorter than 1 character long - if (std::strlen(bindingNameCStr) < 1) - bindingNameCStr[0] = firstChar; - //Rename binding in the input manager - SHInputManager::RenameBinding(binding.first, std::string{ bindingNameCStr }); - binding.first = std::string{ bindingNameCStr }; - } - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("The name of this binding"); - ImGui::EndTooltip(); - }*/ - - //Binding value test - //TODO - ImGui::Text("Value"); - - //Binding Type Combo Box - int bindingType = static_cast(SHInputManager::GetBindingType(binding.first)); - if (ImGui::Combo(labelConcat("Input Type##", entryNumber).c_str(), &bindingType, "Keyboard / Mouse Buttons / Controller\0Mouse Horizontal\0Mouse Vertical\0Mouse Scroll Wheel")) - SHInputManager::SetBindingType(binding.first, static_cast(bindingType)); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Which of the four types the binding uses"); - ImGui::Text("Keyboard / Mouse Buttons / Controller = Keys, mouse buttons and ALL controller inputs"); - ImGui::Text("Mouse Horizontal = Horizontal movement of the mouse"); - ImGui::Text("Mouse Vertical = Vertical movement of the mouse"); - ImGui::Text("Mouse Scroll Wheel = The scroll wheel found at the middle of most mouses"); - ImGui::EndTooltip(); - } - - //Inversion - bool bindingInvert = SHInputManager::GetBindingInverted(binding.first); - if (ImGui::Checkbox(labelConcat("Inverted##", entryNumber).c_str(), &bindingInvert)) - SHInputManager::SetBindingInverted(binding.first, bindingInvert); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("If inverted:"); - ImGui::Text("Positive inputs mean negative value of the binding"); - ImGui::Text("Negative inputs mean positive value of the binding"); - ImGui::Text("Mouse moving up / right means negative value of the binding"); - ImGui::Text("Scrolling the mouse wheel up means negative value of the binding"); - ImGui::EndTooltip(); - } - - //Sensitivity - double bindingSensitivity = SHInputManager::GetBindingSensitivity(binding.first); - if (ImGui::InputDouble(labelConcat("Sensitivity##", entryNumber).c_str(), &bindingSensitivity)) - SHInputManager::SetBindingSensitivity(binding.first, bindingSensitivity); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("Value multiplier for mouse movement and scrolling"); - ImGui::Text("For other digital inputs, serves as a rate of how fast axis value goes to maximum positive/negative"); - ImGui::Text("For other analog inputs, serves as a multiplier, but axis value magnitude will still be capped at 1"); - ImGui::EndTooltip(); - } - - //Below this section is only for KB/M type bindings - //Not relevant for mouse movement and scrolling - if (SHInputManager::GetBindingType(binding.first) == SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER) - { - //Dead - float bindingDead = static_cast(SHInputManager::GetBindingDead(binding.first)); - if (ImGui::SliderFloat(labelConcat("Deadzone##", entryNumber).c_str(), &bindingDead, 0.0f, 1.0f)) - SHInputManager::SetBindingDead(binding.first, static_cast(bindingDead)); + if (ImGui::Button(labelConcat("Delete Binding##", entryNumber).c_str())) + { + SHInputManager::RemoveBinding(binding.first); + resizeVectors(SHInputManager::CountBindings()); + ImGui::End(); + return; + } if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("Any positive or negative analog input with magnitude less than this will be registered as neutral"); + ImGui::Text("Delete this binding from the list"); ImGui::EndTooltip(); } - //Gravity - double bindingGravity = SHInputManager::GetBindingGravity(binding.first); - if (ImGui::InputDouble(labelConcat("Gravity##", entryNumber).c_str(), &bindingGravity)) - SHInputManager::SetBindingGravity(binding.first, static_cast(bindingGravity)); + //Binding value test + ImGui::BeginDisabled(); + float val = SHInputManager::GetBindingAxis(binding.first); + ImGui::SliderFloat(labelConcat("Value##", entryNumber).c_str(), &val, -1.0f, 1.0f); + ImGui::EndDisabled(); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("The rate at which the value moves to neutral if no input in the direction is read"); - ImGui::TextColored(ImVec4{ 1.0f, 0.5f, 0.5f, 1.0f }, "Should be non-negative"); + ImGui::Text("Test the current value of the binding"); + ImGui::Text("For mouse movement/wheel inputs, will be multiplied by Sensitivity, with 0 being neutral (no input detected)"); + ImGui::Text("Between -1 and 1 for other inputs, with 0 still being neutral (no input detected)"); ImGui::EndTooltip(); } - - //Snap - bool bindingSnap = SHInputManager::GetBindingSnap(binding.first); - if (ImGui::Checkbox(labelConcat("Snap##", entryNumber).c_str(), &bindingSnap)) - SHInputManager::SetBindingSnap(binding.first, bindingSnap); + ImGui::BeginDisabled(); + float rawVal = SHInputManager::GetBindingAxisRaw(binding.first); + ImGui::SliderFloat(labelConcat("Raw Value##", entryNumber).c_str(), &rawVal, -1.0f, 1.0f); + ImGui::EndDisabled(); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::Text("If no other input on the axis is present and a input is made in the opposite direction of the current value,"); - ImGui::Text("the binding's value will jump to neutral 0 before resuming in the input direction"); + ImGui::Text("Test the current value of the binding"); + ImGui::Text("Raw value means it will be fixed among -1, 0 and 1 for non-mouse movement/wheel inputs"); + ImGui::Text("No difference between this and Value for mouse movement/wheel inputs"); + ImGui::Text("But for other inputs, does not consider smoothing options such as gravity and sensitivity"); + ImGui::Text("If both positive and negative input is detected, returns neutral 0"); ImGui::EndTooltip(); } - - //Positive key codes - //Negative key codes + //Binding Type Combo Box + int bindingType = static_cast(SHInputManager::GetBindingType(binding.first)); + if (ImGui::Combo(labelConcat("Input Type##", entryNumber).c_str(), &bindingType, "Keyboard / Mouse Buttons / Controller\0Mouse Horizontal\0Mouse Vertical\0Mouse Scroll Wheel")) + SHInputManager::SetBindingType(binding.first, static_cast(bindingType)); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("Which of the four types the binding uses"); + ImGui::Text("Keyboard / Mouse Buttons / Controller = Keys, mouse buttons and ALL controller inputs"); + ImGui::Text("Mouse Horizontal = Horizontal movement of the mouse"); + ImGui::Text("Mouse Vertical = Vertical movement of the mouse"); + ImGui::Text("Mouse Scroll Wheel = The scroll wheel found at the middle of most mouses"); + ImGui::EndTooltip(); + } - //Positive controller codes + //Inversion + bool bindingInvert = SHInputManager::GetBindingInverted(binding.first); + if (ImGui::Checkbox(labelConcat("Inverted##", entryNumber).c_str(), &bindingInvert)) + SHInputManager::SetBindingInverted(binding.first, bindingInvert); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("If inverted:"); + ImGui::Text("Positive inputs mean negative value of the binding"); + ImGui::Text("Negative inputs mean positive value of the binding"); + ImGui::Text("Mouse moving up / right means negative value of the binding"); + ImGui::Text("Scrolling the mouse wheel up means negative value of the binding"); + ImGui::EndTooltip(); + } - //Negative controller codes + //Sensitivity + double bindingSensitivity = SHInputManager::GetBindingSensitivity(binding.first); + if (ImGui::InputDouble(labelConcat("Sensitivity##", entryNumber).c_str(), &bindingSensitivity)) + SHInputManager::SetBindingSensitivity(binding.first, bindingSensitivity); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("Value multiplier for mouse movement and scrolling"); + ImGui::Text("For other digital inputs, serves as a rate of how fast axis value goes to maximum positive/negative"); + //ImGui::Text("For other analog inputs, serves as a multiplier, but axis value magnitude will still be capped at 1"); + ImGui::Text("Irrelevant for other analog inputs"); + ImGui::EndTooltip(); + } + + //Below this section is only for KB/M type bindings + //Not relevant for mouse movement and scrolling + if (SHInputManager::GetBindingType(binding.first) == SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER) + { + //Dead + float bindingDead = static_cast(SHInputManager::GetBindingDead(binding.first)); + if (ImGui::SliderFloat(labelConcat("Deadzone##", entryNumber).c_str(), &bindingDead, 0.0f, 1.0f)) + SHInputManager::SetBindingDead(binding.first, static_cast(bindingDead)); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("Any positive or negative analog input with magnitude less than this will be registered as neutral"); + ImGui::EndTooltip(); + } + + //Gravity + double bindingGravity = SHInputManager::GetBindingGravity(binding.first); + if (ImGui::InputDouble(labelConcat("Gravity##", entryNumber).c_str(), &bindingGravity)) + SHInputManager::SetBindingGravity(binding.first, static_cast(bindingGravity)); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("The rate at which the value moves to neutral if no input in the direction is read"); + ImGui::TextColored(ImVec4{ 1.0f, 0.5f, 0.5f, 1.0f }, "Should be non-negative"); + ImGui::EndTooltip(); + } + + //Snap + bool bindingSnap = SHInputManager::GetBindingSnap(binding.first); + if (ImGui::Checkbox(labelConcat("Snap##", entryNumber).c_str(), &bindingSnap)) + SHInputManager::SetBindingSnap(binding.first, bindingSnap); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("If no other input on the axis is present and a input is made in the opposite direction of the current value,"); + ImGui::Text("the binding's value will jump to neutral 0 before resuming in the input direction"); + ImGui::EndTooltip(); + } + + size_t keycodeIndex = 0; + //Positive key codes + ImGui::Separator(); + ImGui::Text("Positive Key Codes:"); + + ImGui::SameLine(); + //Button to ask for inputs + if (!positiveKeyListening) + { + if (ImGui::Button(labelConcat("New##positiveKeyCode", entryNumber).c_str())) + { + positiveKeyListening = true; + positiveKeyListeningFor = entryNumber; + } + } + else + { + if (positiveKeyListeningFor == entryNumber) + { + //Listening for inputs + ImGui::Button(labelConcat("Press##positiveKeyCode", entryNumber).c_str()); + + SHInputManager::SH_KEYCODE k; + if (SHInputManager::AnyKey(&k)) + { + positiveKeyListening = false; + SHInputManager::AddBindingPositiveKeyCode(binding.first, k); + } + } + else + { + //Not listening + ImGui::BeginDisabled(); + ImGui::Button(labelConcat("New##positiveKeyCode", entryNumber).c_str()); + ImGui::EndDisabled(); + } + } + + //List and remove bindings + ImGui::Indent(); + keycodeIndex = 0; + for (auto& k : binding.second.positiveKeyCodes) + { + //ImGui::Text("%d", static_cast(k)); + ImGui::Text(SHInputManager::GetKeyCodeName(k).c_str()); + ImGui::SameLine(); + std::string labelString = "X##KeyPositive"; + labelString += binding.first; + + //Delete button + if (ImGui::SmallButton(labelConcat(labelString.c_str(), keycodeIndex).c_str())) + { + SHInputManager::RemoveBindingPositiveKeyCode(binding.first, k); + break; + } + ++keycodeIndex; + } + ImGui::Unindent(); + + + //Negative key codes + ImGui::Separator(); + ImGui::Text("Negative Key Codes:"); + + ImGui::SameLine(); + //Button to ask for inputs + if (!negativeKeyListening) + { + if (ImGui::Button(labelConcat("New##negativeKeyCode", entryNumber).c_str())) + { + negativeKeyListening = true; + negativeKeyListeningFor = entryNumber; + } + } + else + { + if (negativeKeyListeningFor == entryNumber) + { + //Listening for inputs + ImGui::Button(labelConcat("Press##negativeKeyCode", entryNumber).c_str()); + + SHInputManager::SH_KEYCODE k; + if (SHInputManager::AnyKey(&k)) + { + negativeKeyListening = false; + SHInputManager::AddBindingNegativeKeyCode(binding.first, k); + } + } + else + { + //Not listening + ImGui::BeginDisabled(); + ImGui::Button(labelConcat("New##negativeKeyCode", entryNumber).c_str()); + ImGui::EndDisabled(); + } + } + + //List and remove bindings + ImGui::Indent(); + keycodeIndex = 0; + for (auto& k : binding.second.negativeKeyCodes) + { + //ImGui::Text("%d", static_cast(k)); + ImGui::Text(SHInputManager::GetKeyCodeName(k).c_str()); + ImGui::SameLine(); + std::string labelString = "X##KeyNegative"; + labelString += binding.first; + + //Delete button + if (ImGui::SmallButton(labelConcat(labelString.c_str(), keycodeIndex).c_str())) + { + SHInputManager::RemoveBindingNegativeKeyCode(binding.first, k); + break; + } + ++keycodeIndex; + } + ImGui::Unindent(); + + //Positive controller codes + ImGui::Separator(); + ImGui::Text("Positive Controller Codes:"); + + ImGui::SameLine(); + //Button to ask for inputs + if (!positiveControllerListening) + { + if (ImGui::Button(labelConcat("New##positiveControllerCode", entryNumber).c_str())) + { + positiveControllerListening = true; + positiveControllerListeningFor = entryNumber; + } + } + else + { + if (positiveControllerListeningFor == entryNumber) + { + //Listening for inputs + ImGui::Button(labelConcat("Press##positiveControllerCode", entryNumber).c_str()); + + SHInputManager::SH_CONTROLLERCODE c; + if (SHInputManager::AnyControllerInput(&c)) + { + positiveControllerListening = false; + SHInputManager::AddBindingPositiveControllerCode(binding.first, c); + } + } + else + { + //Not listening + ImGui::BeginDisabled(); + ImGui::Button(labelConcat("New##positiveControllerCode", entryNumber).c_str()); + ImGui::EndDisabled(); + } + } + + //List and remove bindings + ImGui::Indent(); + keycodeIndex = 0; + for (auto& c : binding.second.positiveControllerCodes) + { + //ImGui::Text("%d", static_cast(k)); + ImGui::Text(SHInputManager::GetControllerCodeName(c).c_str()); + ImGui::SameLine(); + std::string labelString = "X##ControllerPositive"; + labelString += binding.first; + + //Delete button + if (ImGui::SmallButton(labelConcat(labelString.c_str(), keycodeIndex).c_str())) + { + SHInputManager::RemoveBindingPositiveControllerCode(binding.first, c); + break; + } + ++keycodeIndex; + } + ImGui::Unindent(); + + //Negative controller codes + ImGui::Separator(); + ImGui::Text("Negative Controller Codes:"); + + ImGui::SameLine(); + //Button to ask for inputs + if (!negativeControllerListening) + { + if (ImGui::Button(labelConcat("New##negativeControllerCode", entryNumber).c_str())) + { + negativeControllerListening = true; + negativeControllerListeningFor = entryNumber; + } + } + else + { + if (negativeControllerListeningFor == entryNumber) + { + //Listening for inputs + ImGui::Button(labelConcat("Press##negativeControllerCode", entryNumber).c_str()); + + SHInputManager::SH_CONTROLLERCODE c; + if (SHInputManager::AnyControllerInput(&c)) + { + negativeControllerListening = false; + SHInputManager::AddBindingNegativeControllerCode(binding.first, c); + } + } + else + { + //Not listening + ImGui::BeginDisabled(); + ImGui::Button(labelConcat("New##negativeControllerCode", entryNumber).c_str()); + ImGui::EndDisabled(); + } + } + + //List and remove bindings + ImGui::Indent(); + keycodeIndex = 0; + for (auto& c : binding.second.negativeControllerCodes) + { + //ImGui::Text("%d", static_cast(k)); + ImGui::Text(SHInputManager::GetControllerCodeName(c).c_str()); + ImGui::SameLine(); + std::string labelString = "X##ControllerNegative"; + labelString += binding.first; + + //Delete button + if (ImGui::SmallButton(labelConcat(labelString.c_str(), keycodeIndex).c_str())) + { + SHInputManager::RemoveBindingNegativeControllerCode(binding.first, c); + break; + } + ++keycodeIndex; + } + ImGui::Unindent(); + } } - ++entryNumber; //Next entry } } diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index 87ea3aa5..2f0ab6d6 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -100,7 +100,7 @@ namespace SHADE } } - std::string SHInputManager::getKeyCodeName(SH_KEYCODE k) noexcept + std::string SHInputManager::GetKeyCodeName(SH_KEYCODE k) noexcept { int kInt = static_cast(k); //Numbers @@ -116,7 +116,7 @@ namespace SHADE //Numpads if (kInt >= static_cast(SH_KEYCODE::NUMPAD_0) && kInt <= static_cast(SH_KEYCODE::NUMPAD_9)) { - return "Keypad " + std::to_string(kInt - 96); + return "Numpad " + std::to_string(kInt - 96); } //Function keys if (kInt >= static_cast(SH_KEYCODE::F1) && kInt <= static_cast(SH_KEYCODE::F24)) @@ -266,22 +266,22 @@ namespace SHADE return "Sleep"; break; case SH_KEYCODE::MULTIPLY: - return "Multiply"; + return "Numpad *"; break; case SH_KEYCODE::ADD: - return "Add"; + return "Numpad +"; break; case SH_KEYCODE::SEPARATOR: return "Separator"; break; case SH_KEYCODE::SUBTRACT: - return "Subtract"; + return "Numpad -"; break; case SH_KEYCODE::DECIMAL: - return "Decimal"; + return "Numpad ."; break; case SH_KEYCODE::DIVIDE: - return "Divide"; + return "Numpad /"; break; case SH_KEYCODE::NUM_LOCK: return "Num Lock"; @@ -380,10 +380,16 @@ namespace SHADE return "; or :"; break; case SH_KEYCODE::OEM_PLUS: - return "+"; + return "= or +"; break; case SH_KEYCODE::OEM_COMMA: - return ","; + return ", or <"; + break; + case SH_KEYCODE::OEM_MINUS: + return "- or _"; + break; + case SH_KEYCODE::OEM_PERIOD: + return ". or >"; break; case SH_KEYCODE::OEM_2: return "/ or ?"; @@ -496,7 +502,7 @@ namespace SHADE } } - std::string SHInputManager::getControllerCodeName(SH_CONTROLLERCODE c) noexcept + std::string SHInputManager::GetControllerCodeName(SH_CONTROLLERCODE c) noexcept { switch (c) { @@ -1143,7 +1149,7 @@ namespace SHADE digitalInput = true; } if (std::abs(newValue) > std::abs(largestMagnitude)) - largestMagnitude = newValue * data.sensitivity * (data.inverted ? -1.0 : 1.0); + largestMagnitude = newValue * (data.inverted ? -1.0 : 1.0); } } @@ -1159,7 +1165,7 @@ namespace SHADE digitalInput = true; } if (std::abs(newValue) > std::abs(largestMagnitude)) - largestMagnitude = -newValue * data.sensitivity * (data.inverted ? -1.0 : 1.0); + largestMagnitude = -newValue * (data.inverted ? -1.0 : 1.0); } } @@ -1203,21 +1209,23 @@ namespace SHADE if (data.value > 1.0) data.value = 1.0; else if (data.value < -1.0) data.value = -1.0; } - //If analog input was in, - //sensitivity is instead used as a multiplier + //If analog input was in, raw value taken else { - data.value = largestMagnitude * data.sensitivity; + data.value = largestMagnitude; if (data.value > 1.0) data.value = 1.0; else if (data.value < -1.0) data.value = -1.0; } if (data.snap) //Snapping { - if (data.value > 0.0 && data.negativeInputHeld) - data.value = 0.0; - if (data.value < 0.0 && data.positiveInputHeld) - data.value = 0.0; + if (digitalInput) //Only for digital inputs + { + if (data.value > 0.0 && data.negativeInputHeld) + data.value = 0.0; + if (data.value < 0.0 && data.positiveInputHeld) + data.value = 0.0; + } } } } @@ -1399,11 +1407,11 @@ namespace SHADE { return 0.0; } - else if (bindings[bindingName].positiveInputHeld) + else if (GetBindingAxis(bindingName, cNum) > 0.0) { return 1.0; } - else if (bindings[bindingName].negativeInputHeld) + else if (GetBindingAxis(bindingName, cNum) < 0.0) { return -1.0; } diff --git a/SHADE_Engine/src/Input/SHInputManager.h b/SHADE_Engine/src/Input/SHInputManager.h index 52322f0c..1bcafa7d 100644 --- a/SHADE_Engine/src/Input/SHInputManager.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -363,6 +363,7 @@ namespace SHADE //Speed in units per second that the axis will move toward target value for digital //For mouse movement / scrolling, serves as multiplier + //Irrelevant for other analog inputs double sensitivity = 1.0; //If enabled, axis value will reset to zero when pressing a button @@ -416,10 +417,10 @@ namespace SHADE } //Get the name of key code - static std::string getKeyCodeName(SH_KEYCODE const keyCode) noexcept; + static std::string GetKeyCodeName(SH_KEYCODE const keyCode) noexcept; //Get the name of controller code - static std::string getControllerCodeName(SH_CONTROLLERCODE const controllerCode) noexcept; + static std::string GetControllerCodeName(SH_CONTROLLERCODE const controllerCode) noexcept; //For testing purposes //static void PrintCurrentState() noexcept; @@ -825,7 +826,7 @@ namespace SHADE //Get the sensitivity of the binding //Serves as a multiplier for mouse movement/scrolling //For other digital inputs, serves as a rate of how fast axis value goes to maximum positive/negative - //For other analog inputs, serves as a multiplier, but axis value magnitude will still be capped at 1 + //Irrelevant for other analog inputs static inline double GetBindingSensitivity(std::string const& bindingName) { return bindings[bindingName].sensitivity; @@ -834,7 +835,7 @@ namespace SHADE //Set the sensitivity of the binding //Serves as a multiplier for mouse movement/scrolling //For other digital inputs, serves as a rate of how fast axis value goes to maximum positive/negative - //For other analog inputs, serves as a multiplier, but axis value magnitude will still be capped at 1 + //Irrelevant for other analog inputs static inline void SetBindingSensitivity(std::string const& bindingName, double const newValue) { bindings[bindingName].sensitivity = newValue; @@ -1000,8 +1001,6 @@ namespace SHADE //Get the axis value of binding, between -1 and 1 for non-mouse movement/wheel //For mouse movement/wheel, it won't be between -1 and 1. It will also be multiplied by sensitivity - //To avoid interference between mouse movement/wheel and keyboard/mouse/controller input, - //Set mouseXBound, mouseYBound and mouseScrollBound to false //controllerNumber is not used static double GetBindingAxis(std::string const& bindingName, size_t controllerNumber = 0) noexcept; -- 2.40.1 From ac10b95b0175ff95e567fea18a2621ecd8e89871 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Wed, 25 Jan 2023 23:54:04 +0800 Subject: [PATCH 6/6] Tooltips --- .../InputBindings/SHInputBindingsPanel.cpp | 54 +++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp index c304c1b0..d3fa33fa 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp @@ -58,7 +58,7 @@ namespace SHADE { ImGui::BeginTooltip(); ImGui::Text(".SHConfig will be appeneded to file name"); - ImGui::Text("If no name is provided, saves to \"Assets/Bindings.SHConfig\""); + ImGui::Text("If no name is provided, saves to or loads from \"Assets/Bindings.SHConfig\""); ImGui::EndTooltip(); } @@ -258,6 +258,12 @@ namespace SHADE //Positive key codes ImGui::Separator(); ImGui::Text("Positive Key Codes:"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("When this keyboard or mouse button is held, causes the value to go positive, or negative when inverted"); + ImGui::EndTooltip(); + } ImGui::SameLine(); //Button to ask for inputs @@ -274,7 +280,12 @@ namespace SHADE if (positiveKeyListeningFor == entryNumber) { //Listening for inputs - ImGui::Button(labelConcat("Press##positiveKeyCode", entryNumber).c_str()); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.4f, 0.4f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 0.5f, 0.5f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.6f, 0.3f, 0.3f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); + ImGui::Button(labelConcat("PRESS##positiveKeyCode", entryNumber).c_str()); + ImGui::PopStyleColor(4); SHInputManager::SH_KEYCODE k; if (SHInputManager::AnyKey(&k)) @@ -317,6 +328,12 @@ namespace SHADE //Negative key codes ImGui::Separator(); ImGui::Text("Negative Key Codes:"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("When this keyboard or mouse button is held, causes the value to go negative, or positive when inverted"); + ImGui::EndTooltip(); + } ImGui::SameLine(); //Button to ask for inputs @@ -333,7 +350,12 @@ namespace SHADE if (negativeKeyListeningFor == entryNumber) { //Listening for inputs - ImGui::Button(labelConcat("Press##negativeKeyCode", entryNumber).c_str()); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.4f, 0.4f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 0.5f, 0.5f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.6f, 0.3f, 0.3f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); + ImGui::Button(labelConcat("PRESS##negativeKeyCode", entryNumber).c_str()); + ImGui::PopStyleColor(4); SHInputManager::SH_KEYCODE k; if (SHInputManager::AnyKey(&k)) @@ -375,6 +397,12 @@ namespace SHADE //Positive controller codes ImGui::Separator(); ImGui::Text("Positive Controller Codes:"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("When this controller button is held, causes the value to go positive, or negative when inverted"); + ImGui::EndTooltip(); + } ImGui::SameLine(); //Button to ask for inputs @@ -391,7 +419,12 @@ namespace SHADE if (positiveControllerListeningFor == entryNumber) { //Listening for inputs - ImGui::Button(labelConcat("Press##positiveControllerCode", entryNumber).c_str()); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.4f, 0.4f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 0.5f, 0.5f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.6f, 0.3f, 0.3f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); + ImGui::Button(labelConcat("PRESS##positiveControllerCode", entryNumber).c_str()); + ImGui::PopStyleColor(4); SHInputManager::SH_CONTROLLERCODE c; if (SHInputManager::AnyControllerInput(&c)) @@ -433,6 +466,12 @@ namespace SHADE //Negative controller codes ImGui::Separator(); ImGui::Text("Negative Controller Codes:"); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text("When this controller button is pressed, causes the value to go negative, or positive when inverted"); + ImGui::EndTooltip(); + } ImGui::SameLine(); //Button to ask for inputs @@ -449,7 +488,12 @@ namespace SHADE if (negativeControllerListeningFor == entryNumber) { //Listening for inputs - ImGui::Button(labelConcat("Press##negativeControllerCode", entryNumber).c_str()); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.4f, 0.4f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 0.5f, 0.5f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.6f, 0.3f, 0.3f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); + ImGui::Button(labelConcat("PRESS##negativeControllerCode", entryNumber).c_str()); + ImGui::PopStyleColor(4); SHInputManager::SH_CONTROLLERCODE c; if (SHInputManager::AnyControllerInput(&c)) -- 2.40.1