[PATCH 2/4] readkey: add define for Ascii keys
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Tue Feb 14 09:31:19 EST 2012
this will simplify the usage of gpio keyboard
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
common/menu.c | 6 +++---
include/readkey.h | 4 ++++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/common/menu.c b/common/menu.c
index 5291fcb..fd21e52 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -296,7 +296,7 @@ int menu_show(struct menu *m)
do {
if (m->auto_select >= 0)
- ch = '\n';
+ ch = KEY_ENTER;
else
ch = getc();
@@ -339,8 +339,8 @@ int menu_show(struct menu *m)
m->selected->action(m, m->selected);
print_menu_entry(m, m->selected, 1);
break;
- case '\n':
- case '\r':
+ case KEY_ENTER:
+ case KEY_RETURN:
clear();
gotoXY(1,1);
m->selected->action(m, m->selected);
diff --git a/include/readkey.h b/include/readkey.h
index aabb835..f134846 100644
--- a/include/readkey.h
+++ b/include/readkey.h
@@ -3,6 +3,10 @@
#define CTL_CH(c) ((c) - 'a' + 1)
+/* Ascii keys */
+#define KEY_ENTER '\n'
+#define KEY_RETURN '\r'
+
/* Misc. non-Ascii keys */
#define KEY_UP CTL_CH('p') /* cursor key Up */
#define KEY_DOWN CTL_CH('n') /* cursor key Down */
--
1.7.7
More information about the barebox
mailing list