by phantombeta » Sun Dec 02, 2018 6:58 pm
Nash wrote:Major Cooke wrote:I hijack the "slot X" commands via event handler.
Does this work when the player changes weapons with the mousewheel or something that isn't even a keyboard (like a gamepad)?
Yes. It works for any key bound to "slot [0-9]", "weapnext" or "weapprev". Basically, it checks every keypress - if it matches a key bound to one of those commands, it hijacks the keypress. This is actually a method of doing custom slots I developed for
my mod.
It's a somewhat janky way to do it, and it doesn't work with aliases. It also doesn't handle
doublebinds (that is, keybinds triggered by pressing the key twice) and automap binds. This means it blocks the default scrollwheel zoom commands, but this isn't really fixable, as there's no way to check whether a key has an automap bind. (You can only get what keys a command is bound to, but not the other way around)
In my case this hack is already unnecessary, as I can override the virtuals for slot, weapnext and weapprev with my own code, as I use it for limited, customizable slots anyway. I imagine Major Cooke would prefer something simpler and more easily maintained, however.
[quote="Nash"][quote="Major Cooke"]I hijack the "slot X" commands via event handler.[/quote]
Does this work when the player changes weapons with the mousewheel or something that isn't even a keyboard (like a gamepad)?[/quote]
Yes. It works for any key bound to "slot [0-9]", "weapnext" or "weapprev". Basically, it checks every keypress - if it matches a key bound to one of those commands, it hijacks the keypress. This is actually a method of doing custom slots I developed for [url=https://forum.zdoom.org/viewtopic.php?f=43&t=62668]my mod[/url].
It's a somewhat janky way to do it, and it doesn't work with aliases. It also doesn't handle [url=https://zdoom.org/wiki/CCMDs:Customization#doublebind]doublebinds[/url] (that is, keybinds triggered by pressing the key twice) and automap binds. This means it blocks the default scrollwheel zoom commands, but this isn't really fixable, as there's no way to check whether a key has an automap bind. (You can only get what keys a command is bound to, but not the other way around)
In my case this hack is already unnecessary, as I can override the virtuals for slot, weapnext and weapprev with my own code, as I use it for limited, customizable slots anyway. I imagine Major Cooke would prefer something simpler and more easily maintained, however.