From e05ff65f9204824ff8704880914b27ac21b91703 Mon Sep 17 00:00:00 2001 From: Lluciocc <114759545+Lluciocc@users.noreply.github.com> Date: Fri, 17 Apr 2026 01:16:57 +0200 Subject: [PATCH] Update 2048.c with new input ref --- src/userland/games/2048.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/userland/games/2048.c b/src/userland/games/2048.c index 3700d25..2b032a5 100644 --- a/src/userland/games/2048.c +++ b/src/userland/games/2048.c @@ -1,6 +1,7 @@ #include "libc/syscall.h" #include "libc/libui.h" #include "libc/stdlib.h" +#include "libc/input.h" #include #include #include @@ -412,31 +413,20 @@ static bool point_in_rect(int px, int py, int x, int y, int w, int h) { return px >= x && px < x + w && py >= y && py < y + h; } -/* -37 = left arrow -38 = up arrow -39 = right arrow -40 = down arrow -72 = numpad 8 -75 = numpad 4 -77 = numpad 6 -80 = numpad 2 -key = letter -*/ static bool is_left_key(int key) { - return key == 'a' || key == 'A' || key == 37 || key == 75; + return key == 'a' || key == 'A' || key == KEY_LEFT; } static bool is_right_key(int key) { - return key == 'd' || key == 'D' || key == 39 || key == 77; + return key == 'd' || key == 'D' || key == KEY_RIGHT; } static bool is_up_key(int key) { - return key == 'w' || key == 'W' || key == 38 || key == 72; + return key == 'w' || key == 'W' || key == KEY_UP; } static bool is_down_key(int key) { - return key == 's' || key == 'S' || key == 40 || key == 80; + return key == 's' || key == 'S' || key == KEY_DOWN; } static void handle_click(int x, int y) {