mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Update hotkey name when description is changed
This makes it easier to identify the hotkey in external tools
This commit is contained in:
parent
71a887db03
commit
9c4fdc9803
|
|
@ -5,7 +5,7 @@
|
|||
namespace advss {
|
||||
|
||||
std::vector<std::weak_ptr<Hotkey>> Hotkey::_registeredHotkeys = {};
|
||||
uint32_t Hotkey::_hotkeyCounter = 1;
|
||||
uint32_t Hotkey::_hotkeyCounter = 0;
|
||||
|
||||
static bool setup()
|
||||
{
|
||||
|
|
@ -48,10 +48,9 @@ std::shared_ptr<Hotkey> Hotkey::GetHotkey(const std::string &description,
|
|||
|
||||
Hotkey::Hotkey(const std::string &description) : _description(description)
|
||||
{
|
||||
std::string name =
|
||||
"macro_condition_hotkey_" + std::to_string(_hotkeyCounter);
|
||||
_hotkeyID = obs_hotkey_register_frontend(
|
||||
name.c_str(), _description.c_str(), Callback, this);
|
||||
GetNameFromDescription(description).c_str(),
|
||||
_description.c_str(), Callback, this);
|
||||
_hotkeyCounter++;
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +89,8 @@ bool Hotkey::UpdateDescription(const std::string &descritpion)
|
|||
return false;
|
||||
}
|
||||
_description = descritpion;
|
||||
obs_hotkey_set_name(_hotkeyID,
|
||||
GetNameFromDescription(descritpion).c_str());
|
||||
obs_hotkey_set_description(_hotkeyID, descritpion.c_str());
|
||||
return true;
|
||||
}
|
||||
|
|
@ -119,6 +120,11 @@ void Hotkey::Callback(void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed)
|
|||
hotkey->_pressed = pressed;
|
||||
}
|
||||
|
||||
std::string Hotkey::GetNameFromDescription(const std::string &description)
|
||||
{
|
||||
return "macro_condition_hotkey_" + description;
|
||||
}
|
||||
|
||||
void Hotkey::ClearAllHotkeys()
|
||||
{
|
||||
_registeredHotkeys.clear();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ private:
|
|||
static bool DescriptionAvailable(const std::string &);
|
||||
static void Callback(void *data, obs_hotkey_id, obs_hotkey_t *,
|
||||
bool pressed);
|
||||
static std::string GetNameFromDescription(const std::string &desc);
|
||||
|
||||
static std::vector<std::weak_ptr<Hotkey>> _registeredHotkeys;
|
||||
static uint32_t _hotkeyCounter;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user