Skip to content

Commit

Permalink
mUseKeydownEventToCreateNewMapping -> mUseInputToCreateNewMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
lightmanLP committed Dec 19, 2024
1 parent 478daf4 commit 1b4a616
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/controller/controldevice/controller/ControllerButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Ship {
ControllerButton::ControllerButton(uint8_t portIndex, CONTROLLERBUTTONS_T bitmask)
: mPortIndex(portIndex), mBitmask(bitmask), mUseKeydownEventToCreateNewMapping(false),
: mPortIndex(portIndex), mBitmask(bitmask), mUseInputToCreateNewMapping(false),
mKeyboardScancodeForNewMapping(LUS_KB_UNKNOWN), mMouseButtonForNewMapping(LUS_MOUSE_BTN_UNKNOWN) {
}

Expand Down Expand Up @@ -178,7 +178,7 @@ bool ControllerButton::HasMappingsForShipDeviceIndex(ShipDeviceIndex lusIndex) {
bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bitmask, std::string id) {
std::shared_ptr<ControllerButtonMapping> mapping = nullptr;

mUseKeydownEventToCreateNewMapping = true;
mUseInputToCreateNewMapping = true;
if (mKeyboardScancodeForNewMapping != LUS_KB_UNKNOWN) {
mapping = std::make_shared<KeyboardKeyToButtonMapping>(mPortIndex, bitmask, mKeyboardScancodeForNewMapping);
} else if (!Context::GetInstance()->GetWindow()->GetGui()->IsMouseOverAnyGuiItem() &&
Expand All @@ -194,7 +194,7 @@ bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bi

mKeyboardScancodeForNewMapping = LUS_KB_UNKNOWN;
mMouseButtonForNewMapping = LUS_MOUSE_BTN_UNKNOWN;
mUseKeydownEventToCreateNewMapping = false;
mUseInputToCreateNewMapping = false;

if (id != "") {
ClearButtonMapping(id);
Expand All @@ -211,7 +211,7 @@ bool ControllerButton::AddOrEditButtonMappingFromRawPress(CONTROLLERBUTTONS_T bi
}

bool ControllerButton::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) {
if (mUseKeydownEventToCreateNewMapping) {
if (mUseInputToCreateNewMapping) {
if (eventType == LUS_KB_EVENT_KEY_DOWN) {
mKeyboardScancodeForNewMapping = scancode;
return true;
Expand All @@ -234,7 +234,7 @@ bool ControllerButton::ProcessKeyboardEvent(KbEventType eventType, KbScancode sc
}

bool ControllerButton::ProcessMouseEvent(bool isPressed, MouseBtn button) {
if (mUseKeydownEventToCreateNewMapping) {
if (mUseInputToCreateNewMapping) {
if (isPressed) {
mMouseButtonForNewMapping = button;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldevice/controller/ControllerButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ControllerButton {
std::unordered_map<std::string, std::shared_ptr<ControllerButtonMapping>> mButtonMappings;
std::string GetConfigNameFromBitmask(CONTROLLERBUTTONS_T bitmask);

bool mUseKeydownEventToCreateNewMapping;
bool mUseInputToCreateNewMapping;
KbScancode mKeyboardScancodeForNewMapping;
MouseBtn mMouseButtonForNewMapping;
};
Expand Down
10 changes: 5 additions & 5 deletions src/controller/controldevice/controller/ControllerStick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace Ship {
ControllerStick::ControllerStick(uint8_t portIndex, StickIndex stickIndex)
: mPortIndex(portIndex), mStickIndex(stickIndex), mUseKeydownEventToCreateNewMapping(false),
: mPortIndex(portIndex), mStickIndex(stickIndex), mUseInputToCreateNewMapping(false),
mKeyboardScancodeForNewMapping(KbScancode::LUS_KB_UNKNOWN), mMouseButtonForNewMapping(LUS_MOUSE_BTN_UNKNOWN) {
mSensitivityPercentage = DEFAULT_STICK_SENSITIVITY_PERCENTAGE;
mSensitivity = 1.0f;
Expand Down Expand Up @@ -271,7 +271,7 @@ void ControllerStick::Process(int8_t& x, int8_t& y) {
bool ControllerStick::AddOrEditAxisDirectionMappingFromRawPress(Direction direction, std::string id) {
std::shared_ptr<ControllerAxisDirectionMapping> mapping = nullptr;

mUseKeydownEventToCreateNewMapping = true;
mUseInputToCreateNewMapping = true;
if (mKeyboardScancodeForNewMapping != LUS_KB_UNKNOWN) {
mapping = std::make_shared<KeyboardKeyToAxisDirectionMapping>(mPortIndex, mStickIndex, direction,
mKeyboardScancodeForNewMapping);
Expand All @@ -290,7 +290,7 @@ bool ControllerStick::AddOrEditAxisDirectionMappingFromRawPress(Direction direct

mKeyboardScancodeForNewMapping = LUS_KB_UNKNOWN;
mMouseButtonForNewMapping = LUS_MOUSE_BTN_UNKNOWN;
mUseKeydownEventToCreateNewMapping = false;
mUseInputToCreateNewMapping = false;

if (id != "") {
ClearAxisDirectionMapping(direction, id);
Expand Down Expand Up @@ -325,7 +325,7 @@ void ControllerStick::UpdatePad(int8_t& x, int8_t& y) {
}

bool ControllerStick::ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode) {
if (mUseKeydownEventToCreateNewMapping) {
if (mUseInputToCreateNewMapping) {
if (eventType == LUS_KB_EVENT_KEY_DOWN) {
mKeyboardScancodeForNewMapping = scancode;
return true;
Expand All @@ -350,7 +350,7 @@ bool ControllerStick::ProcessKeyboardEvent(KbEventType eventType, KbScancode sca
}

bool ControllerStick::ProcessMouseEvent(bool isPressed, MouseBtn button) {
if (mUseKeydownEventToCreateNewMapping) {
if (mUseInputToCreateNewMapping) {
if (isPressed) {
mMouseButtonForNewMapping = button;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/controller/controldevice/controller/ControllerStick.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ControllerStick {
std::unordered_map<Direction, std::unordered_map<std::string, std::shared_ptr<ControllerAxisDirectionMapping>>>
mAxisDirectionMappings;

bool mUseKeydownEventToCreateNewMapping;
bool mUseInputToCreateNewMapping;
KbScancode mKeyboardScancodeForNewMapping;
MouseBtn mMouseButtonForNewMapping;
};
Expand Down

0 comments on commit 1b4a616

Please sign in to comment.