From fe64844c4e429194f6bd9e9071e35e726d539b55 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Tue, 21 Feb 2023 09:55:14 +0800 Subject: [PATCH 1/3] Mouse Centering --- Assets/Scenes/MainGame.shade | 1 + SHADE_Engine/src/Input/SHInputManager.cpp | 20 ++++++++++++++++++++ SHADE_Managed/src/Input/Input.hxx | 22 +++++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 87343839..3e52198d 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -9682,6 +9682,7 @@ aimingLength: 1 throwItem: false rayDistance: 0.75 + rayHeight: 0.100000001 - EID: 3 Name: HoldingPoint IsActive: true diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index 2f0ab6d6..d3ce59d5 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -14,6 +14,9 @@ #include #include "SHInputManager.h" #include "../Tools/SHException.h" +#include +#include +#include namespace SHADE { @@ -801,6 +804,23 @@ namespace SHADE mouseVelocityX = static_cast(mouseScreenX - mouseScreenXLast) / dt; mouseVelocityY = static_cast(mouseScreenY - mouseScreenYLast) / dt; + + //Mouse Centering + if (GetKey(SH_KEYCODE::Q)) + { + uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth(); + uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight(); + SetMouseWindowPosition(width / 2, height / 2); + + //This four lines help a lot + POINT p; + GetCursorPos(&p); + + mouseVelocityX -= static_cast(p.x - mouseScreenX) / dt; + mouseVelocityY -= static_cast(p.y - mouseScreenY) / dt; + } + + //Mouse wheel vertical delta updating mouseWheelVerticalDelta = 0; mouseWheelVerticalDelta = mouseWheelVerticalDeltaPoll; diff --git a/SHADE_Managed/src/Input/Input.hxx b/SHADE_Managed/src/Input/Input.hxx index 875054cc..2a6689aa 100644 --- a/SHADE_Managed/src/Input/Input.hxx +++ b/SHADE_Managed/src/Input/Input.hxx @@ -181,7 +181,6 @@ namespace SHADE //Break //Menu //Mouse buttons use mouse codes, which are enums declared later - //TODO Controller input #if 0 Space = static_cast(SHInputManager::SH_KEYCODE::SPACE), //Apostrophe = static_cast(SHInputManager::SH_KEYCODE::APOSTROPHE), @@ -355,6 +354,27 @@ namespace SHADE Button3 = static_cast(SHInputManager::SH_KEYCODE::XMB1), Button4 = static_cast(SHInputManager::SH_KEYCODE::XMB2) }; + enum class ControllerCode : int + { + DpadUp = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_UP), + DpadDown = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_DOWN), + DpadLeft = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_LEFT), + DpadRight = static_cast(SHInputManager::SH_CONTROLLERCODE::DPAD_RIGHT), + Start = static_cast(SHInputManager::SH_CONTROLLERCODE::START), + Back = static_cast(SHInputManager::SH_CONTROLLERCODE::BACK), + LeftThumbstickButton = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK), + RightThumbstickButton = static_cast(SHInputManager::SH_CONTROLLERCODE::RIGHT_THUMBSTICK), + LeftShoulder = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_SHOULDER), + RightShoulder = static_cast(SHInputManager::SH_CONTROLLERCODE::RIGHT_SHOULDER), + AButton = static_cast(SHInputManager::SH_CONTROLLERCODE::A), + BButton = static_cast(SHInputManager::SH_CONTROLLERCODE::B), + XButton = static_cast(SHInputManager::SH_CONTROLLERCODE::X), + YButton = static_cast(SHInputManager::SH_CONTROLLERCODE::Y), + LeftTrigger = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_TRIGGER), + RightTrigger = static_cast(SHInputManager::SH_CONTROLLERCODE::RIGHT_TRIGGER), + LeftThumbStickX = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_X), + LeftThumbStickY = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_Y) + }; /*-----------------------------------------------------------------------------*/ /* Properites */ From 0e572d7f8957aa25ed1597244df8de22def6b825 Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Wed, 22 Feb 2023 15:15:38 +0800 Subject: [PATCH 2/3] progress --- SHADE_Engine/src/Input/SHInputManager.cpp | 6 +++--- SHADE_Engine/src/Input/SHInputManager.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index d3ce59d5..c28636d3 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -24,6 +24,7 @@ namespace SHADE /* Static defines */ /*------------------------------------------------------------------------*/ + bool SHInputManager::mouseCentering = false; bool SHInputManager::controllerInUse = false; std::map SHInputManager::bindings; @@ -806,16 +807,15 @@ namespace SHADE //Mouse Centering - if (GetKey(SH_KEYCODE::Q)) + if (mouseCentering) { uint32_t width = SHADE::SHGraphicsSystemInterface::GetWindowWidth(); uint32_t height = SHADE::SHGraphicsSystemInterface::GetWindowHeight(); SetMouseWindowPosition(width / 2, height / 2); - //This four lines help a lot + //These four lines help a lot POINT p; GetCursorPos(&p); - mouseVelocityX -= static_cast(p.x - mouseScreenX) / dt; mouseVelocityY -= static_cast(p.y - mouseScreenY) / dt; } diff --git a/SHADE_Engine/src/Input/SHInputManager.h b/SHADE_Engine/src/Input/SHInputManager.h index 1bcafa7d..dcfcdf57 100644 --- a/SHADE_Engine/src/Input/SHInputManager.h +++ b/SHADE_Engine/src/Input/SHInputManager.h @@ -1074,6 +1074,18 @@ namespace SHADE SetCursorPos(p.x, p.y); } + //Call to set the flag to start mouse centering every frame + static inline void SetMouseCentering(bool state) noexcept + { + mouseCentering = state; + } + + //Get the flag whether mouse centering is on or not + static inline bool GetMouseCentering() noexcept + { + return mouseCentering; + } + private: /*------------------------------------------------------------------------*/ /* Constants */ @@ -1097,6 +1109,9 @@ namespace SHADE /* Data Members */ /*------------------------------------------------------------------------*/ + //Whether mouse centering will be called every frame or not + static bool mouseCentering; + //If the last input is from controller(s) or KB/M //True if from controller(s), False if from KB/M //Useful for switching control hints between controllers and KB/M From dbe9b4d13363c4f5a6cccc22e4d2e01748c4ee9a Mon Sep 17 00:00:00 2001 From: mushgunAX Date: Wed, 22 Feb 2023 23:50:39 +0800 Subject: [PATCH 3/3] Controller, Bindings and Mouse Centre via C# --- .../InputBindings/SHInputBindingsPanel.cpp | 4 + SHADE_Engine/src/Input/SHInputManager.cpp | 4 + SHADE_Managed/src/Input/Input.cxx | 297 ++++++++++++++++++ SHADE_Managed/src/Input/Input.hxx | 103 ++++++ 4 files changed, 408 insertions(+) diff --git a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp index d3fa33fa..9aa5e579 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/InputBindings/SHInputBindingsPanel.cpp @@ -47,6 +47,8 @@ namespace SHADE if (SHEditorWindow::Begin()) { //ImGui::ShowDemoWindow(); + if (bindingRenames.size() != SHInputManager::CountBindings()) + resizeVectors(SHInputManager::CountBindings()); //Binding count ImGui::Text("Binding Count: %d", SHInputManager::CountBindings()); @@ -127,6 +129,8 @@ namespace SHADE { SHInputManager::RenameBinding(binding.first, bindingRenames[entryNumber]); bindingRenames[entryNumber].clear(); + ImGui::End(); + return; } if (ImGui::Button(labelConcat("Delete Binding##", entryNumber).c_str())) diff --git a/SHADE_Engine/src/Input/SHInputManager.cpp b/SHADE_Engine/src/Input/SHInputManager.cpp index c28636d3..dd3cfe80 100644 --- a/SHADE_Engine/src/Input/SHInputManager.cpp +++ b/SHADE_Engine/src/Input/SHInputManager.cpp @@ -755,6 +755,7 @@ namespace SHADE { ++keyCount; keys[i] = true; + controllerInUse = false; } else keys[i] = false; @@ -819,6 +820,9 @@ namespace SHADE mouseVelocityX -= static_cast(p.x - mouseScreenX) / dt; mouseVelocityY -= static_cast(p.y - mouseScreenY) / dt; } + + if (mouseVelocityX != 0.0 || mouseVelocityY != 0.0) + controllerInUse = false; //Mouse wheel vertical delta updating diff --git a/SHADE_Managed/src/Input/Input.cxx b/SHADE_Managed/src/Input/Input.cxx index f0ea0edc..ee628523 100644 --- a/SHADE_Managed/src/Input/Input.cxx +++ b/SHADE_Managed/src/Input/Input.cxx @@ -30,10 +30,29 @@ namespace SHADE { return SHInputManager::GetMouseWheelVerticalDelta(); } + bool Input::ControllerInUse::get() + { + return SHInputManager::GetControllerInUse(); + } /*---------------------------------------------------------------------------------*/ /* Usage Functions */ /*---------------------------------------------------------------------------------*/ + bool Input::AnyKey() + { + return SHInputManager::AnyKey(); + } + + bool Input::AnyKeyDown() + { + return SHInputManager::AnyKeyDown(); + } + + bool Input::AnyKeyUp() + { + return SHInputManager::AnyKeyUp(); + } + bool Input::GetKey(KeyCode key) { return SHInputManager::GetKey(static_cast(key)); @@ -64,6 +83,50 @@ namespace SHADE return SHInputManager::GetKeyUp(static_cast(mouseButton)); } + bool Input::AnyControllerInput() + { + return SHInputManager::AnyControllerInput(); + } + bool Input::AnyControllerInputDown() + { + return SHInputManager::AnyControllerInputDown(); + } + bool Input::AnyControllerInputUp() + { + return SHInputManager::AnyControllerInputUp(); + } + bool Input::AnyControllerButton() + { + return SHInputManager::AnyControllerButton(); + } + bool Input::AnyControllerButtonDown() + { + return SHInputManager::AnyControllerButtonDown(); + } + bool Input::AnyControllerButtonUp() + { + return SHInputManager::AnyControllerButtonUp(); + } + + bool Input::GetControllerInput(Input::ControllerCode code) + { + return SHInputManager::GetControllerInput(static_cast(code)); + } + double Input::GetControllerInputNormalisedValue(Input::ControllerCode code) + { + double toReturn = 0.0; + SHInputManager::GetControllerInput(static_cast(code), &toReturn); + return toReturn; + } + bool Input::GetControllerInputDown(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputDown(static_cast(code)); + } + bool Input::GetControllerInputUp(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputUp(static_cast(code)); + } + /*---------------------------------------------------------------------------------*/ /* Cursor Functions */ /*---------------------------------------------------------------------------------*/ @@ -76,6 +139,24 @@ namespace SHADE ); } + Vector2 Input::GetMousePosition() + { + int x = 0; + int y = 0; + SHInputManager::GetMouseWindowPosition(&x, &y); + return Convert::ToCLI(SHVec2{ (float)x,(float)y }); + } + + void Input::SetMouseCentering(bool state) + { + SHInputManager::SetMouseCentering(state); + } + + bool Input::GetMouseCentering() + { + return SHInputManager::GetMouseCentering(); + } + /*---------------------------------------------------------------------------------*/ /* Time Functions */ /*---------------------------------------------------------------------------------*/ @@ -106,4 +187,220 @@ namespace SHADE return Convert::ToCLI(SHVec2{ (float)velX,(float)velY }); } + + double Input::GetControllerInputHeldTime(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputHeldTime(static_cast(code)); + } + double Input::GetControllerInputReleasedTime(Input::ControllerCode code) + { + return SHInputManager::GetControllerInputReleasedTime(static_cast(code)); + } + + /*-----------------------------------------------------------------------------*/ + /* Binding Functions */ + /*-----------------------------------------------------------------------------*/ + void Input::SaveBindings() + { + SHInputManager::SaveBindings(); + } + + void Input::SaveBindings(System::String^ targetFile) + { + SHInputManager::SaveBindings(Convert::ToNative(targetFile)); + } + + void Input::LoadBindings() + { + SHInputManager::LoadBindings(); + } + + void Input::LoadBindings(System::String^ sourceFile) + { + SHInputManager::LoadBindings(Convert::ToNative(sourceFile)); + } + + bool Input::GetBindingInverted(System::String^ bindingName) + { + return SHInputManager::GetBindingInverted(Convert::ToNative(bindingName)); + } + void Input::SetBindingInverted(System::String^ bindingName, bool newValue) + { + SHInputManager::SetBindingInverted(Convert::ToNative(bindingName), newValue); + } + double Input::GetBindingGravity(System::String^ bindingName) + { + return SHInputManager::GetBindingGravity(Convert::ToNative(bindingName)); + } + void Input::SetBindingGravity(System::String^ bindingName, double newValue) + { + SHInputManager::SetBindingGravity(Convert::ToNative(bindingName), newValue); + } + double Input::GetBindingDead(System::String^ bindingName) + { + return SHInputManager::GetBindingDead(Convert::ToNative(bindingName)); + } + void Input::SetBindingDead(System::String^ bindingName, double newValue) + { + SHInputManager::SetBindingDead(Convert::ToNative(bindingName), newValue); + } + double Input::GetBindingSensitivity(System::String^ bindingName) + { + return SHInputManager::GetBindingSensitivity(Convert::ToNative(bindingName)); + } + void Input::SetBindingSensitivity(System::String^ bindingName, double newValue) + { + SHInputManager::SetBindingSensitivity(Convert::ToNative(bindingName), newValue); + } + bool Input::GetBindingSnap(System::String^ bindingName) + { + return SHInputManager::GetBindingSnap(Convert::ToNative(bindingName)); + } + void Input::SetBindingSnap(System::String^ bindingName, bool newValue) + { + SHInputManager::SetBindingSnap(Convert::ToNative(bindingName), newValue); + } + + + System::Collections::Generic::HashSet^ Input::GetBindingPositiveKeyCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingPositiveKeyCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd) + { + SHInputManager::AddBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove) + { + SHInputManager::RemoveBindingPositiveKeyCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingPositiveKeyCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingPositiveKeyCodes(Convert::ToNative(bindingName)); + } + + System::Collections::Generic::HashSet^ Input::GetBindingNegativeKeyCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingNegativeKeyCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd) + { + SHInputManager::AddBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove) + { + SHInputManager::RemoveBindingNegativeKeyCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingNegativeKeyCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingNegativeKeyCodes(Convert::ToNative(bindingName)); + } + + System::Collections::Generic::HashSet^ Input::GetBindingPositiveControllerCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingPositiveControllerCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd) + { + SHInputManager::AddBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove) + { + SHInputManager::RemoveBindingPositiveControllerCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingPositiveControllerCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingPositiveControllerCodes(Convert::ToNative(bindingName)); + } + + System::Collections::Generic::HashSet^ Input::GetBindingNegativeControllerCodes(System::String^ bindingName) + { + System::Collections::Generic::HashSet^ toReturn = gcnew System::Collections::Generic::HashSet(); + std::set list = SHInputManager::GetBindingNegativeControllerCodes(Convert::ToNative(bindingName)); + for (auto kc : list) + { + toReturn->Add(static_cast(kc)); + } + return toReturn; + } + void Input::AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd) + { + SHInputManager::AddBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast(toAdd)); + } + void Input::RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove) + { + SHInputManager::RemoveBindingNegativeControllerCode(Convert::ToNative(bindingName), static_cast(toRemove)); + } + void Input::ClearBindingNegativeControllerCodes(System::String^ bindingName) + { + SHInputManager::ClearBindingNegativeControllerCodes(Convert::ToNative(bindingName)); + } + + double Input::GetBindingAxis(System::String^ bindingName) + { + return SHInputManager::GetBindingAxis(Convert::ToNative(bindingName)); + } + double Input::GetBindingAxisRaw(System::String^ bindingName) + { + return SHInputManager::GetBindingAxisRaw(Convert::ToNative(bindingName)); + } + bool Input::GetBindingPositiveButton(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveButton(Convert::ToNative(bindingName)); + } + bool Input::GetBindingNegativeButton(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeButton(Convert::ToNative(bindingName)); + } + bool Input::GetBindingPositiveButtonDown(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveButtonDown(Convert::ToNative(bindingName)); + } + bool Input::GetBindingNegativeButtonDown(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeButtonDown(Convert::ToNative(bindingName)); + } + bool Input::GetBindingPositiveButtonUp(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveButtonUp(Convert::ToNative(bindingName)); + } + bool Input::GetBindingNegativeButtonUp(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeButtonUp(Convert::ToNative(bindingName)); + } + + double Input::GetBindingPositiveHeldTime(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveHeldTime(Convert::ToNative(bindingName)); + } + double Input::GetBindingNegativeHeldTime(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeHeldTime(Convert::ToNative(bindingName)); + } + double Input::GetBindingPositiveReleasedTime(System::String^ bindingName) + { + return SHInputManager::GetBindingPositiveReleasedTime(Convert::ToNative(bindingName)); + } + double Input::GetBindingNegativeReleasedTime(System::String^ bindingName) + { + return SHInputManager::GetBindingNegativeReleasedTime(Convert::ToNative(bindingName)); + } } \ No newline at end of file diff --git a/SHADE_Managed/src/Input/Input.hxx b/SHADE_Managed/src/Input/Input.hxx index 2a6689aa..f62e0cab 100644 --- a/SHADE_Managed/src/Input/Input.hxx +++ b/SHADE_Managed/src/Input/Input.hxx @@ -376,6 +376,14 @@ namespace SHADE LeftThumbStickY = static_cast(SHInputManager::SH_CONTROLLERCODE::LEFT_THUMBSTICK_Y) }; + enum class BindingType : int + { + KbMbController = static_cast(SHInputManager::SH_BINDINGTYPE::KB_MB_CONTROLLER), + mouseX = static_cast(SHInputManager::SH_BINDINGTYPE::MOUSE_X), + mouseY = static_cast(SHInputManager::SH_BINDINGTYPE::MOUSE_Y), + mouseScroll = static_cast(SHInputManager::SH_BINDINGTYPE::MOUSE_SCROLL) + }; + /*-----------------------------------------------------------------------------*/ /* Properites */ /*-----------------------------------------------------------------------------*/ @@ -396,9 +404,25 @@ namespace SHADE int get(); } + static property bool ControllerInUse + { + bool get(); + } + /*-----------------------------------------------------------------------------*/ /* Usage Functions */ /*-----------------------------------------------------------------------------*/ + + /// + /// Checks if any key is being held down. + /// This will also be true if GetKeyDown() is true. + /// + /// KeyCode of the first key that was detected to be pressed. + /// True while the user holds down the key specified. + static bool AnyKey(); + static bool AnyKeyDown(); + static bool AnyKeyUp(); + /// /// Checks if a specified key is being held down. /// This will also be true if GetKeyDown() is true. @@ -447,6 +471,20 @@ namespace SHADE /// True during the frame the user releases the given mouse button. /// static bool GetMouseButtonUp(MouseCode mouseButton); + + //For controller + + static bool AnyControllerInput(); + static bool AnyControllerInputDown(); + static bool AnyControllerInputUp(); + static bool AnyControllerButton(); + static bool AnyControllerButtonDown(); + static bool AnyControllerButtonUp(); + + static bool GetControllerInput(ControllerCode code); + static double GetControllerInputNormalisedValue(ControllerCode code); + static bool GetControllerInputDown(ControllerCode code); + static bool GetControllerInputUp(ControllerCode code); /*-----------------------------------------------------------------------------*/ /* Cursor Functions */ @@ -460,6 +498,11 @@ namespace SHADE /// static void SetMousePosition(Vector2 pos); + static Vector2 GetMousePosition(); + + static void SetMouseCentering(bool state); + static bool GetMouseCentering(); + /*-----------------------------------------------------------------------------*/ /* Timing Functions */ /*-----------------------------------------------------------------------------*/ @@ -492,6 +535,66 @@ namespace SHADE /// Time in seconds that the key was held. static double GetMouseReleasedTime(MouseCode mouseButton); + static double GetControllerInputHeldTime(ControllerCode code); + static double GetControllerInputReleasedTime(ControllerCode code); + static Vector2 GetMouseVelocity(); + + /*-----------------------------------------------------------------------------*/ + /* Binding Functions */ + /*-----------------------------------------------------------------------------*/ + static void SaveBindings(); //To default file + static void SaveBindings(System::String^ targetFile); + static void LoadBindings(); //From default file + static void LoadBindings(System::String^ sourceFile); + + static bool GetBindingInverted(System::String^ bindingName); + static void SetBindingInverted(System::String^ bindingName, bool newValue); + static double GetBindingGravity(System::String^ bindingName); + static void SetBindingGravity(System::String^ bindingName, double newValue); + static double GetBindingDead(System::String^ bindingName); + static void SetBindingDead(System::String^ bindingName, double newValue); + static double GetBindingSensitivity(System::String^ bindingName); + static void SetBindingSensitivity(System::String^ bindingName, double newValue); + static bool GetBindingSnap(System::String^ bindingName); + static void SetBindingSnap(System::String^ bindingName, bool newValue); + + static System::Collections::Generic::HashSet^ GetBindingPositiveKeyCodes(System::String^ bindingName); + static void AddBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toAdd); + static void RemoveBindingPositiveKeyCode(System::String^ bindingName, Input::KeyCode toRemove); + static void ClearBindingPositiveKeyCodes(System::String^ bindingName); + + static System::Collections::Generic::HashSet^ GetBindingNegativeKeyCodes(System::String^ bindingName); + static void AddBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toAdd); + static void RemoveBindingNegativeKeyCode(System::String^ bindingName, Input::KeyCode toRemove); + static void ClearBindingNegativeKeyCodes(System::String^ bindingName); + + static System::Collections::Generic::HashSet^ GetBindingPositiveControllerCodes(System::String^ bindingName); + static void AddBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toAdd); + static void RemoveBindingPositiveControllerCode(System::String^ bindingName, Input::ControllerCode toRemove); + static void ClearBindingPositiveControllerCodes(System::String^ bindingName); + + static System::Collections::Generic::HashSet^ GetBindingNegativeControllerCodes(System::String^ bindingName); + static void AddBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toAdd); + static void RemoveBindingNegativeControllerCode(System::String^ bindingName, Input::ControllerCode toRemove); + static void ClearBindingNegativeControllerCodes(System::String^ bindingName); + + //Binding states + + static double GetBindingAxis(System::String^ bindingName); + static double GetBindingAxisRaw(System::String^ bindingName); + static bool GetBindingPositiveButton(System::String^ bindingName); + static bool GetBindingNegativeButton(System::String^ bindingName); + static bool GetBindingPositiveButtonDown(System::String^ bindingName); + static bool GetBindingNegativeButtonDown(System::String^ bindingName); + static bool GetBindingPositiveButtonUp(System::String^ bindingName); + static bool GetBindingNegativeButtonUp(System::String^ bindingName); + + //Binding times + + static double GetBindingPositiveHeldTime(System::String^ bindingName); + static double GetBindingNegativeHeldTime(System::String^ bindingName); + static double GetBindingPositiveReleasedTime(System::String^ bindingName); + static double GetBindingNegativeReleasedTime(System::String^ bindingName); }; } \ No newline at end of file