Index: trunk/i386/libsaio/term.h =================================================================== --- trunk/i386/libsaio/term.h (revision 0) +++ trunk/i386/libsaio/term.h (revision 1528) @@ -0,0 +1,59 @@ +/* + * term.h + * Chameleon + * + * Created by JrCs on 30/08/11. + * Copyright 2011. All rights reserved. + * + */ + +#ifndef __LIBSAIO_TERM_H +#define __LIBSAIO_TERM_H + +#define ASCII_KEY_MASK 0x7f +#define ASCII_KEY(x) ((x & ASCII_KEY_MASK)) + +#define KEY_BKSP 0x0008 +#define KEY_TAB 0x0009 +#define KEY_ENTER 0x000d +#define KEY_ESC 0x001b +#define KEY_PRTSC 0x002a +#define KEY_LEFT 0x4b00 +#define KEY_RIGHT 0x4d00 +#define KEY_UP 0x4800 +#define KEY_DOWN 0x5000 +#define KEY_HOME 0x4700 +#define KEY_END 0x4f00 +#define KEY_CENTER 0x4c00 +#define KEY_INS 0x5200 +#define KEY_DEL 0x5300 +#define KEY_PGUP 0x4900 +#define KEY_PGDN 0x5100 +#define KEY_F1 0x3b00 +#define KEY_F2 0x3c00 +#define KEY_F3 0x3d00 +#define KEY_F4 0x3e00 +#define KEY_F5 0x3f00 +#define KEY_F6 0x4000 +#define KEY_F7 0x4100 +#define KEY_F8 0x4200 +#define KEY_F9 0x4300 +#define KEY_F10 0x4400 +#define KEY_F11 0x5700 +#define KEY_F12 0x5800 + +// Key code for input that shouldn't echoed back +#define KEY_NOECHO 0xff00 + +/* Bitmasks for modifier keys */ +#define STATUS_RSHIFT (1 << 0) +#define STATUS_LSHIFT (1 << 1) +#define STATUS_RCTRL (1 << 2) +#define STATUS_RALT (1 << 3) +#define STATUS_SCROLL (1 << 4) +#define STATUS_NUM (1 << 5) +#define STATUS_CAPS (1 << 6) +#define STATUS_LCTRL (1 << 8) +#define STATUS_LALT (1 << 9) + +#endif /* !__LIBSAIO_TERM_H */ Index: trunk/i386/boot2/gui.c =================================================================== --- trunk/i386/boot2/gui.c (revision 1527) +++ trunk/i386/boot2/gui.c (revision 1528) @@ -9,6 +9,7 @@ */ #include "gui.h" +#include "term.h" #include "appleboot.h" #include "vers.h" @@ -1604,15 +1605,15 @@ key = getchar(); - if( key == kUpArrowkey ) + if( key == KEY_UP ) if( currentline > 0 ) currentline--; - if( key == kDownArrowkey ) + if( key == KEY_DOWN ) if( lines > ( currentline + visiblelines ) ) currentline++; - if( key == kEscapeKey || key == 'q' || key == 'Q') + if( key == KEY_ESC || key == 'q' || key == 'Q') { gui.infobox.draw = false; gui.redraw = true; @@ -1762,7 +1763,7 @@ switch (key) { - case kUpArrowkey: // up arrow + case KEY_UP: // up arrow if (infoMenuSelection > 0) { if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_END + 1) @@ -1784,7 +1785,7 @@ } break; - case kDownArrowkey: // down arrow + case KEY_DOWN: // down arrow if (infoMenuSelection < infoMenuItemsCount - 1) { if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_START - 1) @@ -1796,7 +1797,7 @@ } break; - case kReturnKey: + case KEY_ENTER: key = 0; if( infoMenuSelection == MENU_SHOW_MEMORY_INFO ) showInfoBox( "Memory Info. Press q to quit.\n", getMemoryInfoString()); Index: trunk/i386/boot2/gui.h =================================================================== --- trunk/i386/boot2/gui.h (revision 1527) +++ trunk/i386/boot2/gui.h (revision 1528) @@ -38,18 +38,6 @@ VerticalLayout = 1 }; -enum { - kBackspaceKey = 0x08, - kTabKey = 0x09, - kReturnKey = '\r', - kEscapeKey = 0x1b, - kUpArrowkey = 0x4800, - kDownArrowkey = 0x5000, - kASCIIKeyMask = 0x7f, - kF5Key = 0x3f00, - kF10Key = 0x4400 -}; - /* * Menu item structure. */ Index: trunk/i386/boot2/options.c =================================================================== --- trunk/i386/boot2/options.c (revision 1527) +++ trunk/i386/boot2/options.c (revision 1528) @@ -27,6 +27,7 @@ #include "fdisk.h" #include "ramdisk.h" #include "gui.h" +#include "term.h" #include "embedded.h" #include "pci.h" @@ -235,11 +236,11 @@ static void updateBootArgs( int key ) { - key &= kASCIIKeyMask; + key = ASCII_KEY(key); switch ( key ) { - case kBackspaceKey: + case KEY_BKSP: if ( gBootArgsPtr > gBootArgs ) { *--gBootArgsPtr = '\0'; @@ -927,7 +928,7 @@ } switch (key) { - case kReturnKey: + case KEY_ENTER: if (gui.menu.draw) { key=0; break; @@ -978,11 +979,11 @@ gBIOSDev = menuBVR->biosdev; break; - case kEscapeKey: + case KEY_ESC: clearBootArgs(); break; - case kF5Key: + case KEY_F5: // New behavior: // Clear gBootVolume to restart the loop // if the user enabled rescanning the optical drive. @@ -993,14 +994,14 @@ } break; - case kF10Key: + case KEY_F10: gScanSingleDrive = false; scanDisks(gBIOSDev, &bvCount); gBootVolume = NULL; clearBootArgs(); break; - case kTabKey: + case KEY_TAB: // New behavior: // Switch between text & graphic interfaces // Only Permitted if started in graphics interface @@ -1460,8 +1461,8 @@ printf("Enter two-digit hexadecimal boot device [%02x]: ", bootdevice); do { key = getchar(); - switch (key & kASCIIKeyMask) { - case kBackspaceKey: + switch (ASCII_KEY(key)) { + case KEY_BKSP: if (digitsI > 0) { int x, y, t; getCursorPositionAndType(&x, &y, &t); @@ -1476,7 +1477,7 @@ } break; - case kReturnKey: + case KEY_ENTER: digits[digitsI] = '\0'; newbootdevice = strtol(digits, &end, 16); if (end == digits && *end == '\0') { @@ -1494,9 +1495,9 @@ break; default: - if (isxdigit(key & kASCIIKeyMask) && digitsI < 2) { - putchar(key & kASCIIKeyMask); - digits[digitsI++] = key & kASCIIKeyMask; + if (isxdigit(ASCII_KEY(key)) && digitsI < 2) { + putchar(ASCII_KEY(key)); + digits[digitsI++] = ASCII_KEY(key); } else { // TODO: Beep or something } @@ -1510,7 +1511,7 @@ bool promptForRescanOption(void) { printf("\nWould you like to enable media rescan option?\nPress ENTER to enable or any key to skip.\n"); - if (getchar() == kReturnKey) { + if (getchar() == KEY_ENTER) { return true; } else { return false;