diff --git a/src/controller/controldevice/controller/ControllerButton.cpp b/src/controller/controldevice/controller/ControllerButton.cpp index 999eeb864..a127b6cb7 100644 --- a/src/controller/controldevice/controller/ControllerButton.cpp +++ b/src/controller/controldevice/controller/ControllerButton.cpp @@ -3,7 +3,7 @@ #include "controller/controldevice/controller/mapping/factories/ButtonMappingFactory.h" #include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.h" +#include "controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h" #include "public/bridge/consolevariablebridge.h" #include "utils/StringHelper.h" @@ -183,7 +183,7 @@ bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bi mapping = std::make_shared(mPortIndex, bitmask, mKeyboardScancodeForNewMapping); } else if (!ImGui::IsAnyItemHovered() && mMouseButtonForNewMapping != MouseBtn::MOUSE_BTN_UNKNOWN) { // TODO: I dont think direct ImGui calls should be here - mapping = std::make_shared(mPortIndex, bitmask, mMouseButtonForNewMapping); + mapping = std::make_shared(mPortIndex, bitmask, mMouseButtonForNewMapping); } else { mapping = ButtonMappingFactory::CreateButtonMappingFromSDLInput(mPortIndex, bitmask); } @@ -246,8 +246,8 @@ bool ControllerButton::ProcessMouseEvent(bool isPressed, MouseBtn button) { bool result = false; for (auto [id, mapping] : GetAllButtonMappings()) { if (mapping->GetMappingType() == MAPPING_TYPE_MOUSE) { - std::shared_ptr mtobMapping = - std::dynamic_pointer_cast(mapping); + std::shared_ptr mtobMapping = + std::dynamic_pointer_cast(mapping); if (mtobMapping != nullptr) { result = result || mtobMapping->ProcessMouseEvent(isPressed, button); } diff --git a/src/controller/controldevice/controller/ControllerStick.cpp b/src/controller/controldevice/controller/ControllerStick.cpp index 3d037ed30..3ad3c6a0f 100644 --- a/src/controller/controldevice/controller/ControllerStick.cpp +++ b/src/controller/controldevice/controller/ControllerStick.cpp @@ -2,7 +2,7 @@ #include #include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.h" +#include "controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h" #include "controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.h" @@ -278,7 +278,7 @@ bool ControllerStick::AddOrEditAxisDirectionMappingFromRawPress(Direction direct mKeyboardScancodeForNewMapping); } else if (!ImGui::IsAnyItemHovered() && mMouseButtonForNewMapping != MouseBtn::MOUSE_BTN_UNKNOWN) { // TODO: I dont think direct ImGui calls should be here (again) - mapping = std::make_shared(mPortIndex, mStickIndex, direction, + mapping = std::make_shared(mPortIndex, mStickIndex, direction, mMouseButtonForNewMapping); } else { mapping = @@ -364,8 +364,8 @@ bool ControllerStick::ProcessMouseEvent(bool isPressed, MouseBtn button) { for (auto [direction, mappings] : mAxisDirectionMappings) { for (auto [id, mapping] : mappings) { if (mapping->GetMappingType() == MAPPING_TYPE_MOUSE) { - std::shared_ptr mtoadMapping = - std::dynamic_pointer_cast(mapping); + std::shared_ptr mtoadMapping = + std::dynamic_pointer_cast(mapping); if (mtoadMapping != nullptr) { result = result || mtoadMapping->ProcessMouseEvent(isPressed, button); } diff --git a/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp b/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp index eb39ad5fd..5259c735e 100644 --- a/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp +++ b/src/controller/controldevice/controller/mapping/factories/AxisDirectionMappingFactory.cpp @@ -1,6 +1,6 @@ #include "AxisDirectionMappingFactory.h" #include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToAxisDirectionMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.h" +#include "controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h" #include "controller/controldevice/controller/mapping/sdl/SDLButtonToAxisDirectionMapping.h" #include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToAxisDirectionMapping.h" @@ -78,7 +78,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn portIndex, stickIndex, static_cast(direction), static_cast(scancode)); } - if (mappingClass == "MouseKeyToAxisDirectionMapping") { + if (mappingClass == "MouseButtonToAxisDirectionMapping") { int32_t direction = CVarGetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), -1); int mouseButton = CVarGetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), 0); @@ -89,7 +89,7 @@ AxisDirectionMappingFactory::CreateAxisDirectionMappingFromConfig(uint8_t portIn return nullptr; } - return std::make_shared( + return std::make_shared( portIndex, stickIndex, static_cast(direction), static_cast(mouseButton)); } diff --git a/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp b/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp index 640f8f06c..19052e813 100644 --- a/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp +++ b/src/controller/controldevice/controller/mapping/factories/ButtonMappingFactory.cpp @@ -4,7 +4,7 @@ #include "libultraship/libultra/controller.h" #include "Context.h" #include "controller/controldevice/controller/mapping/keyboard/KeyboardKeyToButtonMapping.h" -#include "controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.h" +#include "controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h" #include "controller/controldevice/controller/mapping/sdl/SDLButtonToButtonMapping.h" #include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h" #include "controller/deviceindex/ShipDeviceIndexToSDLDeviceIndexMapping.h" @@ -68,10 +68,10 @@ std::shared_ptr ButtonMappingFactory::CreateButtonMappi return std::make_shared(portIndex, bitmask, static_cast(scancode)); } - if (mappingClass == "MouseKeyToButtonMapping") { + if (mappingClass == "MouseButtonToButtonMapping") { int mouseButton = CVarGetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), 0); - return std::make_shared(portIndex, bitmask, static_cast(mouseButton)); + return std::make_shared(portIndex, bitmask, static_cast(mouseButton)); } return nullptr; diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAnyMapping.cpp b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp similarity index 50% rename from src/controller/controldevice/controller/mapping/mouse/MouseKeyToAnyMapping.cpp rename to src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp index 98afda036..cb9622e12 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAnyMapping.cpp +++ b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.cpp @@ -1,22 +1,22 @@ -#include "MouseKeyToAnyMapping.h" +#include "MouseButtonToAnyMapping.h" #include "Context.h" #include "utils/StringHelper.h" #include "window/gui/IconsFontAwesome4.h" namespace Ship { -MouseKeyToAnyMapping::MouseKeyToAnyMapping(MouseBtn button) +MouseButtonToAnyMapping::MouseButtonToAnyMapping(MouseBtn button) : ControllerInputMapping(ShipDeviceIndex::Mouse), mButton(button), mKeyPressed(false) { } -MouseKeyToAnyMapping::~MouseKeyToAnyMapping() { +MouseButtonToAnyMapping::~MouseButtonToAnyMapping() { } -std::string MouseKeyToAnyMapping::GetPhysicalInputName() { +std::string MouseButtonToAnyMapping::GetPhysicalInputName() { return mouseBtnNames[static_cast(mButton)]; } -bool MouseKeyToAnyMapping::ProcessMouseEvent(bool isPressed, MouseBtn button) { +bool MouseButtonToAnyMapping::ProcessMouseEvent(bool isPressed, MouseBtn button) { if (mButton != button) { return false; } @@ -25,11 +25,11 @@ bool MouseKeyToAnyMapping::ProcessMouseEvent(bool isPressed, MouseBtn button) { return true; } -std::string MouseKeyToAnyMapping::GetPhysicalDeviceName() { +std::string MouseButtonToAnyMapping::GetPhysicalDeviceName() { return "Mouse"; } -bool MouseKeyToAnyMapping::PhysicalDeviceIsConnected() { +bool MouseButtonToAnyMapping::PhysicalDeviceIsConnected() { return true; } } // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAnyMapping.h b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h similarity index 76% rename from src/controller/controldevice/controller/mapping/mouse/MouseKeyToAnyMapping.h rename to src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h index 7a1f1fbf0..20d106dae 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAnyMapping.h +++ b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAnyMapping.h @@ -4,10 +4,10 @@ #include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { -class MouseKeyToAnyMapping : virtual public ControllerInputMapping { +class MouseButtonToAnyMapping : virtual public ControllerInputMapping { public: - MouseKeyToAnyMapping(MouseBtn button); - ~MouseKeyToAnyMapping(); + MouseButtonToAnyMapping(MouseBtn button); + ~MouseButtonToAnyMapping(); std::string GetPhysicalInputName() override; bool ProcessMouseEvent(bool isPressed, MouseBtn button); std::string GetPhysicalDeviceName() override; diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.cpp b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp similarity index 73% rename from src/controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.cpp rename to src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp index aee10ecde..10ec75242 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.cpp +++ b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.cpp @@ -1,4 +1,4 @@ -#include "MouseKeyToAxisDirectionMapping.h" +#include "MouseButtonToAxisDirectionMapping.h" #include #include "utils/StringHelper.h" #include "window/gui/IconsFontAwesome4.h" @@ -6,13 +6,13 @@ #include "Context.h" namespace Ship { -MouseKeyToAxisDirectionMapping::MouseKeyToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, +MouseButtonToAxisDirectionMapping::MouseButtonToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, Direction direction, MouseBtn button) - : ControllerInputMapping(ShipDeviceIndex::Mouse), MouseKeyToAnyMapping(button), + : ControllerInputMapping(ShipDeviceIndex::Mouse), MouseButtonToAnyMapping(button), ControllerAxisDirectionMapping(ShipDeviceIndex::Mouse, portIndex, stickIndex, direction) { } -float MouseKeyToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { +float MouseButtonToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { if (Context::GetInstance()->GetControlDeck()->MouseGameInputBlocked()) { return 0.0f; } @@ -20,21 +20,21 @@ float MouseKeyToAxisDirectionMapping::GetNormalizedAxisDirectionValue() { return mKeyPressed ? MAX_AXIS_RANGE : 0.0f; } -std::string MouseKeyToAxisDirectionMapping::GetAxisDirectionMappingId() { +std::string MouseButtonToAxisDirectionMapping::GetAxisDirectionMappingId() { return StringHelper::Sprintf("P%d-S%d-D%d-MOUSE%d", mPortIndex, mStickIndex, mDirection, mButton); } -void MouseKeyToAxisDirectionMapping::SaveToConfig() { +void MouseButtonToAxisDirectionMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); CVarSetString(StringHelper::Sprintf("%s.AxisDirectionMappingClass", mappingCvarKey.c_str()).c_str(), - "MouseKeyToAxisDirectionMapping"); + "MouseButtonToAxisDirectionMapping"); CVarSetInteger(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str(), mStickIndex); CVarSetInteger(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str(), mDirection); CVarSetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), static_cast(mButton)); CVarSave(); } -void MouseKeyToAxisDirectionMapping::EraseFromConfig() { +void MouseButtonToAxisDirectionMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".AxisDirectionMappings." + GetAxisDirectionMappingId(); CVarClear(StringHelper::Sprintf("%s.Stick", mappingCvarKey.c_str()).c_str()); CVarClear(StringHelper::Sprintf("%s.Direction", mappingCvarKey.c_str()).c_str()); @@ -43,7 +43,7 @@ void MouseKeyToAxisDirectionMapping::EraseFromConfig() { CVarSave(); } -uint8_t MouseKeyToAxisDirectionMapping::GetMappingType() { +uint8_t MouseButtonToAxisDirectionMapping::GetMappingType() { return MAPPING_TYPE_MOUSE; } } // namespace Ship diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.h b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h similarity index 62% rename from src/controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.h rename to src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h index 11f955fdb..1ca59eda7 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToAxisDirectionMapping.h +++ b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToAxisDirectionMapping.h @@ -1,13 +1,13 @@ #pragma once #include "controller/controldevice/controller/mapping/ControllerAxisDirectionMapping.h" -#include "MouseKeyToAnyMapping.h" +#include "MouseButtonToAnyMapping.h" #include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { -class MouseKeyToAxisDirectionMapping final : public MouseKeyToAnyMapping, public ControllerAxisDirectionMapping { +class MouseButtonToAxisDirectionMapping final : public MouseButtonToAnyMapping, public ControllerAxisDirectionMapping { public: - MouseKeyToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, Direction direction, MouseBtn button); + MouseButtonToAxisDirectionMapping(uint8_t portIndex, StickIndex stickIndex, Direction direction, MouseBtn button); float GetNormalizedAxisDirectionValue() override; std::string GetAxisDirectionMappingId() override; uint8_t GetMappingType() override; diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.cpp b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp similarity index 69% rename from src/controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.cpp rename to src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp index 688ee5511..bcc639746 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.cpp +++ b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.cpp @@ -1,16 +1,16 @@ -#include "MouseKeyToButtonMapping.h" +#include "MouseButtonToButtonMapping.h" #include #include "utils/StringHelper.h" #include "public/bridge/consolevariablebridge.h" #include "Context.h" namespace Ship { -MouseKeyToButtonMapping::MouseKeyToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, MouseBtn button) - : ControllerInputMapping(ShipDeviceIndex::Mouse), MouseKeyToAnyMapping(button), +MouseButtonToButtonMapping::MouseButtonToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, MouseBtn button) + : ControllerInputMapping(ShipDeviceIndex::Mouse), MouseButtonToAnyMapping(button), ControllerButtonMapping(ShipDeviceIndex::Mouse, portIndex, bitmask) { } -void MouseKeyToButtonMapping::UpdatePad(CONTROLLERBUTTONS_T& padButtons) { +void MouseButtonToButtonMapping::UpdatePad(CONTROLLERBUTTONS_T& padButtons) { if (Context::GetInstance()->GetControlDeck()->MouseGameInputBlocked()) { return; } @@ -22,24 +22,24 @@ void MouseKeyToButtonMapping::UpdatePad(CONTROLLERBUTTONS_T& padButtons) { padButtons |= mBitmask; } -uint8_t MouseKeyToButtonMapping::GetMappingType() { +uint8_t MouseButtonToButtonMapping::GetMappingType() { return MAPPING_TYPE_MOUSE; } -std::string MouseKeyToButtonMapping::GetButtonMappingId() { +std::string MouseButtonToButtonMapping::GetButtonMappingId() { return StringHelper::Sprintf("P%d-B%d-MOUSE%d", mPortIndex, mBitmask, mButton); } -void MouseKeyToButtonMapping::SaveToConfig() { +void MouseButtonToButtonMapping::SaveToConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); CVarSetString(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str(), - "MouseKeyToButtonMapping"); + "MouseButtonToButtonMapping"); CVarSetInteger(StringHelper::Sprintf("%s.Bitmask", mappingCvarKey.c_str()).c_str(), mBitmask); CVarSetInteger(StringHelper::Sprintf("%s.MouseButton", mappingCvarKey.c_str()).c_str(), static_cast(mButton)); CVarSave(); } -void MouseKeyToButtonMapping::EraseFromConfig() { +void MouseButtonToButtonMapping::EraseFromConfig() { const std::string mappingCvarKey = CVAR_PREFIX_CONTROLLERS ".ButtonMappings." + GetButtonMappingId(); CVarClear(StringHelper::Sprintf("%s.ButtonMappingClass", mappingCvarKey.c_str()).c_str()); diff --git a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.h b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h similarity index 65% rename from src/controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.h rename to src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h index 0fe7f9897..9eb71308c 100644 --- a/src/controller/controldevice/controller/mapping/mouse/MouseKeyToButtonMapping.h +++ b/src/controller/controldevice/controller/mapping/mouse/MouseButtonToButtonMapping.h @@ -1,13 +1,13 @@ #pragma once #include "controller/controldevice/controller/mapping/ControllerButtonMapping.h" -#include "MouseKeyToAnyMapping.h" +#include "MouseButtonToAnyMapping.h" #include "controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h" namespace Ship { -class MouseKeyToButtonMapping final : public MouseKeyToAnyMapping, public ControllerButtonMapping { +class MouseButtonToButtonMapping final : public MouseButtonToAnyMapping, public ControllerButtonMapping { public: - MouseKeyToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, MouseBtn button); + MouseButtonToButtonMapping(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask, MouseBtn button); void UpdatePad(CONTROLLERBUTTONS_T& padButtons) override; uint8_t GetMappingType() override; std::string GetButtonMappingId() override;