Created
August 3, 2022 03:35
-
-
Save mrowrpurr/d7f4102347444856d534e1d4da5e03a0 to your computer and use it in GitHub Desktop.
Override Keys via Sfall Hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// register_hook_proc in a glz script works :) | |
#include "sfall/sfall.h" | |
#include "sfall/dik.h" | |
// int arg0 - event type: 1 - pressed, 0 - released | |
// int arg1 - key DX scancode | |
// int arg2 - key VK code (very similar to ASCII codes) | |
// int ret0 - overrides the pressed key (a new key DX scancode or 0 for no override) | |
procedure on_keypress begin | |
variable pressed = ("pressed" if get_sfall_arg else "released"), | |
keycode = get_sfall_arg; | |
display_msg("glz key: " + keycode + " (" + pressed + ")"); | |
if keycode == DIK_W then begin | |
display_msg("glz OVERRIDE to 255"); | |
set_sfall_arg(1, 255); // <--- make it so other folks see 255 | |
set_sfall_return(255); | |
end | |
end | |
procedure start begin | |
display_msg("glz"); | |
register_hook_proc(HOOK_KEYPRESS, on_keypress); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment