[ipxe-devel] [PATCH] [iPXE] Add compile-time support for no modifier keys

Michael Bazzinotti bazz at cs.umb.edu
Tue May 26 14:24:26 UTC 2015


From: "Michael J. Bazzinotti" <mbazzinotti at gmail.com>

This is a patch stemming from the discussion at
http://lists.ipxe.org/pipermail/ipxe-devel/2015-May/004237.html

This patch makes sure to add functionality without doing the following:

* break existing behavior
* add behavior inconsistent with on-screen instructions
* generate overly verbose on-screen instructions

It does this by adding a new preprocessor definition
MENU_KEYS_NO_MODIFIER, disabled by default. It can be enabled by
uncommenting the relative line in config/general.h.

Signed-off-by: Michael J. Bazzinotti <mbazzinotti at gmail.com>
---
 src/config/general.h      | 11 +++++++++++
 src/hci/tui/settings_ui.c | 30 ++++++++++++++++++++++++------
 src/usr/autoboot.c        |  7 +++++++
 3 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/src/config/general.h b/src/config/general.h
index 7676f15..7087a63 100644
--- a/src/config/general.h
+++ b/src/config/general.h
@@ -30,6 +30,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define ROM_BANNER_TIMEOUT	( 2 * BANNER_TIMEOUT )
 
 /*
+ * Keyboard -- use of Modifier keys
+ *
+ * Some platforms do not support modifier keys, such as those using EFI
+ * 1.1 without support for the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL (ie. Mac)
+ *
+ * If you are using a mac, or find that you cannot use Ctrl-B to cancel the
+ * autoboot process and enter a shell, try enabling this configuration option.
+ */
+//#define MENU_KEYS_NO_MODIFIER
+
+/*
  * Network protocols
  *
  */
diff --git a/src/hci/tui/settings_ui.c b/src/hci/tui/settings_ui.c
index be421cc..0970c12 100644
--- a/src/hci/tui/settings_ui.c
+++ b/src/hci/tui/settings_ui.c
@@ -35,6 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/ansicol.h>
 #include <ipxe/jumpscroll.h>
 #include <ipxe/settings_ui.h>
+#include <config/general.h>
 #include <config/branding.h>
 
 /** @file
@@ -43,6 +44,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  *
  */
 
+/* Keys Configuration */
+#ifdef MENU_KEYS_NO_MODIFIER
+#define KEY_DISCARD_CHANGES ESC
+#define KEY_DELETE_SETTING BACKSPACE
+#define KEY_EXIT ESC
+#define KEY_DISCARD_CHANGES_STR "ESC"
+#define KEY_DELETE_SETTING_STR "BACKSPACE"
+#define KEY_EXIT_STR "ESC"
+#else
+#define KEY_DISCARD_CHANGES CTRL_C
+#define KEY_DELETE_SETTING CTRL_D
+#define KEY_EXIT CTRL_X
+#define KEY_DISCARD_CHANGES_STR "Ctrl-C"
+#define KEY_DELETE_SETTING_STR "Ctrl-D"
+#define KEY_EXIT_STR "Ctrl-X"
+#endif /* MENU_KEYS_NO_MODIFIER */
+
 /* Screen layout */
 #define TITLE_ROW		1U
 #define SETTINGS_LIST_ROW	3U
@@ -384,12 +402,12 @@ static void draw_instruction_row ( struct settings_ui *ui ) {
 	if ( ui->row.editing ) {
 		msg ( INSTRUCTION_ROW,
 		      "Enter - accept changes" INSTRUCTION_PAD
-		      "Ctrl-C - discard changes" );
+		      KEY_DISCARD_CHANGES_STR " - discard changes" );
 	} else {
 		msg ( INSTRUCTION_ROW,
-		      "%sCtrl-X - exit configuration utility",
+		      "%s" KEY_EXIT_STR " - exit configuration utility",
 		      ( ( ui->row.origin == ui->settings ) ?
-			"Ctrl-D - delete setting" INSTRUCTION_PAD : "" ) );
+			KEY_DELETE_SETTING_STR " - delete setting" INSTRUCTION_PAD : "" ) );
 	}
 }
 
@@ -486,7 +504,7 @@ static int main_loop ( struct settings *settings ) {
 				if ( ( rc = save_setting ( &ui ) ) != 0 )
 					alert ( " %s ", strerror ( rc ) );
 				/* Fall through */
-			case CTRL_C:
+			case KEY_DISCARD_CHANGES:
 				select_setting_row ( &ui, ui.scroll.current );
 				redraw = 1;
 				break;
@@ -516,7 +534,7 @@ static int main_loop ( struct settings *settings ) {
 
 		/* Handle non-navigation keys */
 		switch ( key ) {
-		case CTRL_D:
+		case KEY_DELETE_SETTING:
 			if ( ! ui.row.setting.name )
 				break;
 			if ( ( rc = delete_setting ( ui.settings,
@@ -526,7 +544,7 @@ static int main_loop ( struct settings *settings ) {
 			select_setting_row ( &ui, ui.scroll.current );
 			redraw = 1;
 			break;
-		case CTRL_X:
+		case KEY_EXIT:
 			return 0;
 		case CR:
 		case LF:
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index ccafeae..8d8c508 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -532,10 +532,17 @@ static int shell_banner ( void ) {
 
 	/* Prompt user */
 	printf ( "\n" );
+#ifdef MENU_KEYS_NO_MODIFIER
+	return ( prompt ( "Press ESC for the " PRODUCT_SHORT_NAME
+			  " command line...",
+			  ( ( BANNER_TIMEOUT * TICKS_PER_SEC ) / 10 ),
+			  ESC ) == 0 );
+#else
 	return ( prompt ( "Press Ctrl-B for the " PRODUCT_SHORT_NAME
 			  " command line...",
 			  ( ( BANNER_TIMEOUT * TICKS_PER_SEC ) / 10 ),
 			  CTRL_B ) == 0 );
+#endif /* MENU_KEYS_NO_MODIFIER */
 }
 
 /**
-- 
2.3.6




More information about the ipxe-devel mailing list