Add option to check if hotkey is released

This was already possible previously by inverting the logic with a
"not", however, this should it make it more obvious that this type of
check is possible.
This commit is contained in:
WarmUpTill
2024-05-01 21:06:32 +02:00
committed by WarmUpTill
parent edb2952fd6
commit efaf9a2ef3
9 changed files with 70 additions and 36 deletions

View File

@@ -116,6 +116,9 @@ void Hotkey::Callback(void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed)
if (pressed) {
hotkey->_lastPressed =
std::chrono::high_resolution_clock::now();
} else {
hotkey->_lastReleased =
std::chrono::high_resolution_clock::now();
}
hotkey->_pressed = pressed;
}

View File

@@ -27,6 +27,7 @@ public:
bool GetPressed() const { return _pressed; }
auto GetLastPressed() const { return _lastPressed; }
auto GetLastReleased() const { return _lastReleased; }
std::string GetDescription() const { return _description; }
bool UpdateDescription(const std::string &);
@@ -43,6 +44,7 @@ private:
obs_hotkey_id _hotkeyID = OBS_INVALID_HOTKEY_ID;
bool _pressed = false;
std::chrono::high_resolution_clock::time_point _lastPressed{};
std::chrono::high_resolution_clock::time_point _lastReleased{};
// When set will not attempt to share settings with existing hotkey
bool _ignoreExistingHotkeys = false;
};