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 <eren.terzioglu@espressif.com>
This commit is contained in:
Eren Terzioglu 2025-07-11 14:45:02 +02:00 committed by Xiang Xiao
parent 9ea3fc6995
commit f3e1985b1e

View file

@ -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;
}