fixed check_key_combo

This commit is contained in:
Alessandro Mauri 2025-09-13 20:02:21 +02:00
parent 34b92c93b4
commit d33d72a074

View File

@ -69,15 +69,13 @@ const MouseButtons BTN_5 = {.btn_5 = true};
const ModKeys KEY_ANY = (ModKeys)(ModKeys.inner.max); const ModKeys KEY_ANY = (ModKeys)(ModKeys.inner.max);
fn bool Ctx.check_key_combo(&ctx, ModKeys mod, String keys) fn bool Ctx.check_key_combo(&ctx, ModKeys mod, String ...keys)
{ {
bool is_mod = (bool)(ctx.input.keyboard.modkeys & mod); bool is_mod = (bool)(ctx.input.keyboard.modkeys & mod);
bool is_keys = true; bool is_keys = true;
String haystack = (String)ctx.input.keyboard.text[0..ctx.input.keyboard.text_len]; String haystack = (String)ctx.get_keys();
char[2] needle; foreach (needle: keys) {
foreach (c: keys) { is_keys = is_keys && haystack.contains(needle);
needle[0] = c;
is_keys = is_keys && haystack.contains((String)needle[..]);
} }
return is_mod && is_keys; return is_mod && is_keys;
} }