From 70c63572b240080b2f1cb8a8507af2732d5aef09 Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 6 Mar 2024 20:34:13 +0100 Subject: [PATCH] 2048: Use the arrow keys and the Home key as input --- apps/2048.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/2048.cpp b/apps/2048.cpp index cbda65b3..039981f0 100644 --- a/apps/2048.cpp +++ b/apps/2048.cpp @@ -50,9 +50,9 @@ class GameWidget final : public ui::Widget bool should_add_tile = false; - switch (request.key) + switch (request.code) { - case 'w': { + case moon::K_UpArrow: { bool changed; changed = move_up(); if (changed) should_add_tile = true; @@ -61,7 +61,7 @@ class GameWidget final : public ui::Widget if (changed) should_add_tile = true; } break; - case 'a': { + case moon::K_LeftArrow: { bool changed; changed = move_left(); if (changed) should_add_tile = true; @@ -70,7 +70,7 @@ class GameWidget final : public ui::Widget if (changed) should_add_tile = true; } break; - case 's': { + case moon::K_DownArrow: { bool changed; changed = move_down(); if (changed) should_add_tile = true; @@ -79,7 +79,7 @@ class GameWidget final : public ui::Widget if (changed) should_add_tile = true; } break; - case 'd': { + case moon::K_RightArrow: { bool changed; changed = move_right(); if (changed) should_add_tile = true; @@ -88,7 +88,7 @@ class GameWidget final : public ui::Widget if (changed) should_add_tile = true; } break; - case 'r': { + case moon::K_Home: { reset(); return ui::EventResult::DidHandle; }