Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/InputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ InputHandler* InputHandler::GetSingleton()
return &instance;
}

void InputHandler::SetButton(std::uint32_t a_keyCode, std::string a_name)
void InputHandler::SetButton(std::uint32_t a_keyCode, std::string a_name) noexcept
{
buttonKeyCode = a_keyCode;
buttonName = std::move(a_name);
Expand Down Expand Up @@ -105,16 +105,15 @@ bool InputHandler::ProcessButton(const RE::ButtonEvent* btn)
}

if (btn->IsUp() && _pressTime) {
const auto held = std::chrono::duration<float>(
std::chrono::steady_clock::now() - *_pressTime)
.count();
_pressTime.reset();

if (_mapTriggered) {
_mapTriggered = false;
} else {
const auto held = std::chrono::duration<float>(
std::chrono::steady_clock::now() - *_pressTime)
.count();
DispatchShortPress(held);
}
_pressTime.reset();
return true;
}

Expand Down
4 changes: 1 addition & 3 deletions src/InputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class InputHandler :
static InputHandler* GetSingleton();

InputHandler(const InputHandler&) = delete;
InputHandler(InputHandler&&) = delete;
InputHandler& operator=(const InputHandler&) = delete;
InputHandler& operator=(InputHandler&&) = delete;

RE::BSEventNotifyControl ProcessEvent(
RE::InputEvent* const* a_events,
Expand All @@ -26,7 +24,7 @@ class InputHandler :
};

void SetHoldDuration(float a_duration) noexcept { holdDuration = a_duration; }
void SetButton(std::uint32_t a_keyCode, std::string a_name);
void SetButton(std::uint32_t a_keyCode, std::string a_name) noexcept;

// Queries ControlMap for the user event bound to the configured button and caches it.
// Call at kInputLoaded, kPostLoadGame, and kNewGame.
Expand Down
6 changes: 3 additions & 3 deletions src/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct ButtonDef
std::string displayName;
};

std::pair<std::uint32_t, std::string> ReadButton(const CSimpleIniA& a_ini)
ButtonDef ReadButton(const CSimpleIniA& a_ini)
{
using Key = RE::BSWin32GamepadDevice::Key;

Expand All @@ -56,10 +56,10 @@ std::pair<std::uint32_t, std::string> ReadButton(const CSimpleIniA& a_ini)
const auto it = kButtonMap.find(lower);
if (it == kButtonMap.end()) {
logger::warn("sButton '{}' is not a recognised button (valid: Start, Back) — using Start", raw);
return { InputHandler::kDefaultButton, "Start" };
return { .keyCode = InputHandler::kDefaultButton, .displayName = "Start" };
}

return { it->second.keyCode, it->second.displayName };
return it->second;
}

void OnInputLoaded()
Expand Down
Loading