You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2025/07/16 02:32:23 UTC
(nuttx-apps) 02/02: games/snake: Change consolekey magic numbers with ASCII macros
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit f3e1985b1e3d421d65eac66ac1d54f077c5dac97
Author: Eren Terzioglu <er...@espressif.com>
AuthorDate: Fri Jul 11 14:45:02 2025 +0200
games/snake: Change consolekey magic numbers with ASCII macros
Change consolekey magic numbers with ascii values to make it more understandable
Signed-off-by: Eren Terzioglu <er...@espressif.com>
---
games/snake/snake_input_console.h | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/games/snake/snake_input_console.h b/games/snake/snake_input_console.h
index 9f6f2bbea..03254f5d5 100644
--- a/games/snake/snake_input_console.h
+++ b/games/snake/snake_input_console.h
@@ -25,6 +25,7 @@
****************************************************************************/
#include <nuttx/config.h>
+#include <nuttx/ascii.h>
#include <termios.h>
#include "snake_inputs.h"
@@ -188,24 +189,24 @@ int dev_read_input(FAR struct input_state_s *dev)
/* Arrows keys return three bytes: 27 91 [65-68] */
- if ((ch = getch()) == 27)
+ if ((ch = getch()) == ASCII_ESC)
{
- if ((ch = getch()) == 91)
+ if ((ch = getch()) == ASCII_LBRACKET)
{
ch = getch();
- if (ch == 65)
+ if (ch == ASCII_A)
{
dev->dir = DIR_UP;
}
- else if (ch == 66)
+ else if (ch == ASCII_B)
{
dev->dir = DIR_DOWN;
}
- else if (ch == 67)
+ else if (ch == ASCII_C)
{
dev->dir = DIR_RIGHT;
}
- else if (ch == 68)
+ else if (ch == ASCII_D)
{
dev->dir = DIR_LEFT;
}