mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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:
parent
9ea3fc6995
commit
f3e1985b1e
1 changed files with 7 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue