Skip to content

Commit 6289917

Browse files
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 <[email protected]>
1 parent 44321ba commit 6289917

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

games/snake/snake_input_console.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
****************************************************************************/
2626

2727
#include <nuttx/config.h>
28+
#include <nuttx/ascii.h>
2829
#include <termios.h>
2930

3031
#include "snake_inputs.h"
@@ -207,24 +208,24 @@ int dev_read_input(FAR struct input_state_s *dev)
207208

208209
/* Arrows keys return three bytes: 27 91 [65-68] */
209210

210-
if ((ch = getch()) == 27)
211+
if ((ch = getch()) == ASCII_ESC)
211212
{
212-
if ((ch = getch()) == 91)
213+
if ((ch = getch()) == ASCII_LBRACKET)
213214
{
214215
ch = getch();
215-
if (ch == 65)
216+
if (ch == ASCII_A)
216217
{
217218
dev->dir = DIR_UP;
218219
}
219-
else if (ch == 66)
220+
else if (ch == ASCII_B)
220221
{
221222
dev->dir = DIR_DOWN;
222223
}
223-
else if (ch == 67)
224+
else if (ch == ASCII_C)
224225
{
225226
dev->dir = DIR_RIGHT;
226227
}
227-
else if (ch == 68)
228+
else if (ch == ASCII_D)
228229
{
229230
dev->dir = DIR_LEFT;
230231
}

0 commit comments

Comments
 (0)