aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2024-04-14 14:12:22 +0200
committerkdx <kikoodx@paranoici.org>2024-04-14 14:19:26 +0200
commit1fe0d9dddd7b4b0fc59cb36570fa04ed52329a06 (patch)
treea2925694da725378e8eb24075e5f8296ef6ecede
parentca7deb67edcdd946173e63bfb89e04b33eb2eb64 (diff)
downloadinput-1fe0d9dddd7b4b0fc59cb36570fa04ed52329a06.tar.gz
check for reserved scancodesHEADmain
-rw-r--r--input.c11
-rw-r--r--input.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/input.c b/input.c
index 4f22530..275ab84 100644
--- a/input.c
+++ b/input.c
@@ -227,6 +227,17 @@ input_get_binds(const char *tag)
}
bool
+input_scancode_in_use(SDL_Scancode sc, bool only_locked)
+{
+ foreach (action, _actions.next)
+ foreach (bind, action->binds.next)
+ if (bind->type == IBT_SCANCODE && bind->sc == sc &&
+ (!only_locked || bind->lock))
+ return true;
+ return false;
+}
+
+bool
input_down(const char *tag)
{
InputAction *action = _input_get_action(tag);
diff --git a/input.h b/input.h
index 08a65da..e413033 100644
--- a/input.h
+++ b/input.h
@@ -66,6 +66,7 @@ void input_bind_action_tzr(const char *tag, TZR_Event e);
void input_bind_axis_gc(const char *tag, SDL_GameControllerAxis ax);
void input_bind_axis_act(const char *tag, const char *l, const char *r);
InputBind *input_get_binds(const char *tag);
+bool input_scancode_in_use(SDL_Scancode sc, bool only_locked);
bool input_down(const char *tag);
bool input_up(const char *tag);