SGG-Modding / Hell2Modding

Mod loader for Hades 2
MIT License
12 stars 2 forks source link

can an on_key_pressed bind be unbound? #14

Closed southpawgeek closed 1 month ago

southpawgeek commented 1 month ago

I couldn't find a way to unbind - is there/should there be a function for this, or should I force the mod to reload when updating a keybind?

xiaoxiao921 commented 1 month ago

Fixed by https://github.com/SGG-Modding/Hell2Modding/commit/434394bdb8c7ca65a9c1d39516d0a43c6e1f20e1

If it still happen post a message here

southpawgeek commented 1 month ago

Thanks for addressing this! Unbinding makes it stop calling the function which is good. But, it still shows up in the log so I think some remnant still exists somewhere. Here's how the log looks if I do the following:

  1. Bind ctrl P
  2. press ctrl P
  3. Bind ctrl O
  4. press ctrl O
  5. press ctrl P

You can see the previous ctrl P bind still exists, but it doesn't actually call the function

[18:29:50.0381155][INFO/inputs.cpp:396] Jowday-DamageMeter Keybind Registered: Ctrl P - Toggle Meter Visibility
[18:29:52.2025747][DEBUG/inputs.cpp:341] Ctrl P (Jowday-DamageMeter)
[18:29:52.2025757][DEBUG/inputs.cpp:345] Toggle Meter Visibility
[18:29:57.7829137][INFO/inputs.cpp:396] Jowday-DamageMeter Keybind Registered: Ctrl O - Toggle Meter Visibility
[18:30:1.1194603][DEBUG/inputs.cpp:341] Ctrl P (Jowday-DamageMeter)
[18:30:1.1840768][DEBUG/inputs.cpp:341] Ctrl O (Jowday-DamageMeter)
[18:30:1.1840778][DEBUG/inputs.cpp:345] Toggle Meter Visibility

Also here is the implementation

function setBind()
    if CurrentBind ~= nil then
        rom.inputs.remove_on_key_pressed(CurrentBind)
    end

    CurrentBind = rom.inputs.on_key_pressed({
        config.ToggleMeterBind,
        Name = "Toggle Meter Visibility",
        function()
            config.ShowMeter = not config.ShowMeter
        end
    })
end