InputHandler.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Implementation for handling user input from the User Interfaces.
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Setup.h"
/**
Get string or password input from user.
@param MenuOption Pointer to the current input menu.
@param Prompt The prompt string shown on popup window.
@param StringPtr Old user input and destination for use input string.
@retval EFI_SUCCESS If string input is read successfully
@retval EFI_DEVICE_ERROR If operation fails
**/
)
{
Space[0] = L' ';
IsPassword = TRUE;
} else {
IsPassword = FALSE;
}
ASSERT (TempString);
}
}
//
// Display prompt for string
//
if (CurrentCursor != 0) {
//
// Show the string which has beed saved before.
//
} else {
Index = 0;
}
if (IsPassword) {
}
if (IsPassword) {
PrintChar (L'*');
}
}
if (!IsPassword) {
}
}
do {
switch (Key.UnicodeChar) {
case CHAR_NULL:
case SCAN_LEFT:
if (CurrentCursor > 0) {
}
break;
case SCAN_RIGHT:
}
break;
case SCAN_ESC:
return EFI_DEVICE_ERROR;
default:
break;
}
break;
case CHAR_CARRIAGE_RETURN:
return EFI_SUCCESS;
} else {
//
// Simply create a popup to tell the user that they had typed in too few characters.
// To save code space, we can then treat this as an error and return back to the menu.
//
do {
return EFI_DEVICE_ERROR;
}
break;
case CHAR_BACKSPACE:
}
if (Count >= CurrentCursor) {
}
}
//
// Effectively truncate string by 1 character
//
CurrentCursor --;
}
default:
//
// If it is the beginning of the string, don't worry about checking maximum limits
//
} else if ((GetStringWidth (StringPtr) < ((Maximum + 1) * sizeof (CHAR16))) && (Key.UnicodeChar != CHAR_BACKSPACE)) {
if (CurrentCursor < Count) {
}
} else {
}
}
//
// If the width of the input string is now larger than the screen, we nee to
// adjust the index to start printing portions of the string
//
} else {
Index = 0;
}
if (IsPassword) {
}
if (IsPassword) {
PrintChar (L'*');
}
}
if (!IsPassword) {
}
break;
}
} while (TRUE);
}
/**
Adjust the value to the correct one. Rules follow the sample:
like: Year change: 2012.02.29 -> 2013.02.29 -> 2013.02.01
Month change: 2013.03.29 -> 2013.02.29 -> 2013.02.28
@param Question Pointer to current question.
@param Sequence The sequence of the field in the question.
**/
)
{
return;
}
Minimum = 1;
switch (Month) {
case 2:
Maximum = 29;
} else {
Maximum = 28;
}
break;
case 4:
case 6:
case 9:
case 11:
Maximum = 30;
break;
default:
Maximum = 31;
break;
}
//
// Change the month area.
//
if (Sequence == 0) {
}
}
//
// Change the Year area.
//
if (Sequence == 2) {
}
}
}
/**
This routine reads a numeric value from the user input.
@param Selection Pointer to current selection.
@param MenuOption Pointer to the current input menu.
@retval EFI_SUCCESS If numerical input is read successfully
@retval EFI_DEVICE_ERROR If operation fails
**/
)
{
PreviousNumber[0] = 0;
Count = 0;
InputWidth = 0;
Digital = 0;
//
// Only two case, user can enter to this function: Enter and +/- case.
// In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT
//
DateOrTime = TRUE;
} else {
DateOrTime = FALSE;
}
//
// Prepare Value to be edit
//
EraseLen = 0;
EditValue = 0;
Step = 1;
Minimum = 1;
switch (MenuOption->Sequence) {
case 0:
Maximum = 12;
EraseLen = 4;
break;
case 1:
case 2:
Maximum = 29;
} else {
Maximum = 28;
}
break;
case 4:
case 6:
case 9:
case 11:
Maximum = 30;
break;
default:
Maximum = 31;
break;
}
EraseLen = 3;
break;
case 2:
Maximum = 0xffff;
EraseLen = 5;
break;
default:
break;
}
Step = 1;
Minimum = 0;
switch (MenuOption->Sequence) {
case 0:
Maximum = 23;
EraseLen = 4;
break;
case 1:
Maximum = 59;
EraseLen = 3;
break;
case 2:
Maximum = 59;
EraseLen = 3;
break;
default:
break;
}
} else {
//
// Numeric
//
if (Maximum == 0) {
}
}
} else {
}
//
// Enter from "Enter" input, clear the old word showing.
//
if (ManualInput) {
if (HexInput) {
} else {
switch (Question->StorageWidth) {
case 1:
InputWidth = 3;
break;
case 2:
InputWidth = 5;
break;
case 4:
InputWidth = 10;
break;
case 8:
InputWidth = 20;
break;
default:
InputWidth = 0;
break;
}
}
Column++;
}
InputWidth = 4;
} else {
InputWidth = 2;
}
if (MenuOption->Sequence == 0) {
} else {
}
} else {
}
if (MenuOption->Sequence == 0) {
Column++;
}
}
InputWidth = 2;
if (MenuOption->Sequence == 0) {
} else {
}
} else {
}
if (MenuOption->Sequence == 0) {
Column++;
}
}
}
//
// First time we enter this handler, we need to check to see if
// we were passed an increment or decrement directive
//
do {
if (gDirection != 0) {
gDirection = 0;
goto TheKey2;
}
switch (Key.UnicodeChar) {
case '+':
case '-':
} else {
}
goto TheKey2;
case CHAR_NULL:
case SCAN_LEFT:
case SCAN_RIGHT:
if (DateOrTime && !ManualInput) {
//
// By setting this value, we will return back to the caller.
// We need to do this since an auto-refresh will destroy the adjustment
// based on what the real-time-clock is showing. So we always commit
// upon changing the value.
//
}
if ((Step != 0) && !ManualInput) {
} else {
}
} else {
}
}
//
// Year
//
} else {
//
//
}
if (MenuOption->Sequence == 0) {
}
if (MenuOption->Sequence == 0) {
}
} else {
}
}
gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextHighlightColor) | PcdGet8 (PcdBrowserFieldBackgroundHighlightColor));
if (MenuOption->Sequence == 0) {
}
}
}
goto EnterCarriageReturn;
break;
case SCAN_UP:
case SCAN_DOWN:
goto EnterCarriageReturn;
case SCAN_ESC:
return EFI_DEVICE_ERROR;
default:
break;
}
break;
case CHAR_CARRIAGE_RETURN:
//
// Validate input value with Minimum value.
//
break;
} else {
}
//
// Store Edit value back to Question
//
switch (MenuOption->Sequence) {
case 0:
break;
case 1:
break;
case 2:
break;
default:
break;
}
switch (MenuOption->Sequence) {
case 0:
break;
case 1:
break;
case 2:
break;
default:
break;
}
} else {
//
// Numeric
//
}
//
// Adjust the value to the correct one.
// Sample like: 2012.02.29 -> 2013.02.29 -> 2013.02.01
// 2013.03.29 -> 2013.02.29 -> 2013.02.28
//
}
//
// Check to see if the Value is something reasonable against consistency limitations.
// If not, let's kick the error specified.
//
//
// Input value is not valid, restore Question Value
//
} else {
//
//
}
}
return Status;
break;
case CHAR_BACKSPACE:
if (ManualInput) {
if (Count == 0) {
break;
}
//
// Remove a character
//
Count--;
Column--;
}
break;
default:
if (ManualInput) {
if (HexInput) {
} else {
break;
}
} else {
break;
}
}
//
// If Count exceed input width, there is no way more is valid
//
if (Count >= InputWidth) {
break;
}
//
// Someone typed something valid!
//
if (Count != 0) {
if (HexInput) {
} else {
}
} else {
if (HexInput) {
} else {
}
}
break;
} else {
}
Count++;
Column++;
}
break;
}
} while (TRUE);
}
/**
@param Selection Pointer to current selection.
@param MenuOption Pointer to the current input menu.
@retval EFI_SUCCESS If Option input is processed successfully
@retval EFI_DEVICE_ERROR If operation fails
**/
)
{
ValueArray = NULL;
ValueType = 0;
ShowUpArrow = FALSE;
OrderedList = TRUE;
} else {
OrderedList = FALSE;
}
//
// Calculate Option count
//
if (OrderedList) {
break;
}
}
OptionCount = Index;
} else {
OptionCount = 0;
OptionCount++;
}
}
//
// Prepare HiiValue array
//
if (OrderedList) {
} else {
}
}
//
// Move Suppressed Option to list tail
//
PopUpMenuLines = 0;
if (OneOfOption == NULL) {
return EFI_NOT_FOUND;
}
//
// This option is suppressed, insert to tail
//
} else {
//
// Insert to head
//
}
}
//
// Get the number of one of options present and its size
//
PopUpWidth = 0;
HighlightOptionIndex = 0;
}
if (!OrderedList && (CompareHiiValue (&Question->HiiValue, &OneOfOption->Value, &Result, NULL) == EFI_SUCCESS) && (Result == 0)) {
//
// Find current selected Option for OneOf
//
}
}
//
// Perform popup menu initialization.
//
}
if (MenuLinesInView >= PopUpMenuLines) {
} else {
}
} else {
TopOptionIndex = 0;
}
do {
//
// Clear that portion of the screen
//
//
// Draw "One of" pop-up menu
//
} else {
}
}
}
//
// Move to top Option
//
}
//
// Display the One of options
//
//
// If the string occupies multiple lines, truncate it to fit in one line,
// and append a "..." for indication.
//
}
if (Index == HighlightOptionIndex) {
//
// Highlight the selected one
//
} else {
}
Index2++;
}
} else {
}
}
//
// Get User selection
//
gDirection = 0;
goto TheKey;
}
switch (Key.UnicodeChar) {
case '+':
if (OrderedList) {
//
// Highlight reaches the top of the popup window, scroll one menu item.
//
}
if (TopOptionIndex == 0) {
ShowUpArrow = FALSE;
}
if (HighlightOptionIndex > 0) {
}
}
break;
case '-':
//
// If an ordered list op-code, we will allow for a popup of +/- keys
// to create an ordered list of items
//
if (OrderedList) {
//
// Highlight reaches the bottom of the popup window, scroll one menu item.
//
ShowUpArrow = TRUE;
}
}
}
}
break;
case CHAR_NULL:
case SCAN_UP:
case SCAN_DOWN:
//
// Highlight reaches the top of the popup window, scroll one menu item.
//
}
if (TopOptionIndex == 0) {
ShowUpArrow = FALSE;
}
if (HighlightOptionIndex > 0) {
}
} else {
//
// Highlight reaches the bottom of the popup window, scroll one menu item.
//
ShowUpArrow = TRUE;
}
}
}
}
break;
case SCAN_ESC:
//
// Restore link list order for orderedlist
//
if (OrderedList) {
break;
}
if (OneOfOption == NULL) {
return EFI_NOT_FOUND;
}
}
}
return EFI_DEVICE_ERROR;
default:
break;
}
break;
case CHAR_CARRIAGE_RETURN:
//
// return the current selection
//
if (OrderedList) {
Index = 0;
Index++;
break;
}
}
} else {
}
Status = ValidateQuestion (Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);
//
// Input value is not valid, restore Question Value
//
} else {
}
return Status;
default:
break;
}
} while (TRUE);
}
/**
Wait for a key to be pressed by user.
@param Key The key which is pressed by user.
@retval EFI_SUCCESS The function always completed successfully.
**/
)
{
do {
return Status;
}