Example #1
0
static void getCommand(char *cmd)
{
	unsigned char c=0;
	int i=0;
	memset((unsigned char*)cmd,0,CMD_LENGTH);
	while(1){
		c=getLastKeyPressed();
		switch(c){
			case 0x0:
				continue;
			case 0x8:{
				/*delete only the command characters */
				if(getXCursor() > CURSOR_START_XPOS){
					putChar(0x8);
					cmd[--i]=0;
				}
				break;
			}
			case 0x11:{
				/*
				if(getXCursor() > CURSOR_START_XPOS){
					putChar(0x11);
					i--;
				}*/
				break;
			}
			case 0x12:{
				/*
				if(getXCursor() < (strlen(cmd)+CURSOR_START_XPOS)){
					putChar(0x12);
					i++;
				}*/
				break;
			}
			case 0x13:{
        			/* Mapped as up arrow: create history command */
				continue;
			}
			case 0x14:{
				/* Mapped as down arrow:create history command */
				continue;
			}
			case '\r':
			case '\n':
				return;
			default:{
				if(i<CMD_LENGTH){
					cmd[i++]=c;
					putChar(c);
				}
			}
		}
	}
}
Example #2
0
void menu(struct menuInfo* theSelectedInfo, int *theConfHasBeenUpdated)
{
  ENTER("menu");
  enum MENU_State aMenuState=MENU_Volume;
  struct menuInfo aOldInfo;
  
  if (!theSelectedInfo || !theConfHasBeenUpdated)
    {
      return;
    }

  memcpy( &aOldInfo, theSelectedInfo, sizeof(struct menuInfo));

  if (mustSetPreferences())
    {
      *theConfHasBeenUpdated=1;
    }
  else
    {
      setTextToSpeech( &(theSelectedInfo->myTextToSpeech), 
		       theSelectedInfo->myMenuLanguage,
		       theSelectedInfo->myDesktop,
		       0);
      aMenuState=MENU_End;
      *theConfHasBeenUpdated=0;
    }

  serialPortInit();

  while(aMenuState != MENU_End)
    {
      switch(aMenuState)
	{
	case MENU_Volume:
	  setVolume();
	  aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_QuitExpected : MENU_Language;
	  break;

	case MENU_Language:
	  if (setMenuLanguage( &theSelectedInfo->myMenuLanguage))
	    {
	      theSelectedInfo->myUserConfIsKnown=1;
	      if (!aOldInfo.myUserConfIsKnown)
		{ /* The default keyboard must match the selected language */
		  theSelectedInfo->myKeyboard = getProbableKeyboard(theSelectedInfo->myMenuLanguage);
		  loadkeys( theSelectedInfo->myKeyboard);
		}

	      buildI18n( theSelectedInfo->myMenuLanguage, 
			 theSelectedInfo->myTextToSpeech, 
			 theSelectedInfo->myKeyboard,
			 theSelectedInfo->myKeyboardFeatures,
			 theSelectedInfo->myDesktop,
			 theSelectedInfo->myUserConfIsKnown);
	    }
	  aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_Volume : MENU_Keyboard;
	  break;

	case MENU_Keyboard:
	  {
	    if(setKeyboard(&theSelectedInfo->myKeyboard, 
			   theSelectedInfo->myMenuLanguage))
	      {
		theSelectedInfo->myUserConfIsKnown=1;

		// The keyboard is available as soon as it is selected.
		loadkeys( theSelectedInfo->myKeyboard);

		buildI18n( theSelectedInfo->myMenuLanguage, 
			   theSelectedInfo->myTextToSpeech, 
			   theSelectedInfo->myKeyboard,
			   theSelectedInfo->myKeyboardFeatures,
			   theSelectedInfo->myDesktop,
			   theSelectedInfo->myUserConfIsKnown);
	      }
	    aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_Language : MENU_KeyboardFeatures;	  
	  }
	  break;

	case MENU_KeyboardFeatures:
	  if (setKeyboardFeatures(& theSelectedInfo->myKeyboardFeatures))
	    {
	      theSelectedInfo->myUserConfIsKnown=1;
	      buildI18n( theSelectedInfo->myMenuLanguage, 
			 theSelectedInfo->myTextToSpeech, 
			 theSelectedInfo->myKeyboard,
			 theSelectedInfo->myKeyboardFeatures,
			 theSelectedInfo->myDesktop,
			 theSelectedInfo->myUserConfIsKnown);
	    }
	  aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_Keyboard : MENU_Braille;	  
	  break;

	case MENU_Braille:
	  {
	    // The braille driver is installed as soon as it is selected.
	    struct brailleInfo aBrailleInfo;
	    getDefaultConf( theSelectedInfo->myKeyboard, & aBrailleInfo );
	    setBraille( &aBrailleInfo);
	    
	    aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_KeyboardFeatures : MENU_Desktop;
	  }
	  break;

	case MENU_Desktop:
	  if (setDesktop( &(theSelectedInfo->myDesktop)))
	    {
	      theSelectedInfo->myUserConfIsKnown=1;	      
	      buildI18n( theSelectedInfo->myMenuLanguage, 
			 theSelectedInfo->myTextToSpeech, 
			 theSelectedInfo->myKeyboard,
			 theSelectedInfo->myKeyboardFeatures,
			 theSelectedInfo->myDesktop,
			 theSelectedInfo->myUserConfIsKnown);
	    }
	  aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_Braille : MENU_TTS;
	  break;

	case MENU_TTS:
	  if (setTextToSpeech( &(theSelectedInfo->myTextToSpeech),
			       theSelectedInfo->myMenuLanguage,
			       theSelectedInfo->myDesktop,
			       1))
	    {
	      theSelectedInfo->myUserConfIsKnown=1;	      
	      buildI18n( theSelectedInfo->myMenuLanguage, 
			 theSelectedInfo->myTextToSpeech, 
			 theSelectedInfo->myKeyboard,
			 theSelectedInfo->myKeyboardFeatures,
			 theSelectedInfo->myDesktop,
			 theSelectedInfo->myUserConfIsKnown);
	    }
	  aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_Desktop : MENU_Internet;
	  break;

	case MENU_Internet:
	  {
	    setInternet( theSelectedInfo);
	    aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_TTS : MENU_PersistentStorage;
	  }
	  break;

	case MENU_PersistentStorage:
	  {
	    setPersistentStorage( theSelectedInfo);
	    aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_Internet : MENU_QuitExpected;
	  }
	  break;

	case MENU_QuitExpected:
	  {
	    if (setQuitExpected())
	      {
		aMenuState = MENU_End;
	      }
	    else
	      {
		aMenuState = (GNC_UpArrowKey == getLastKeyPressed()) ? MENU_PersistentStorage : MENU_Volume;
	      }
	  }
	  break;

	default:
	  aMenuState = MENU_End; // Security
	  break;
	}
    }
  clearStoredSentences();

  if (!*theConfHasBeenUpdated)
    {
      *theConfHasBeenUpdated=(0!=memcmp( &aOldInfo, theSelectedInfo, sizeof(struct menuInfo)));

/* 	((aOldInfo.myMenuLanguage != theSelectedInfo->myMenuLanguage) */
/* 	 || (aOldInfo.myKeyboard != theSelectedInfo->myKeyboard) */
/* 	 || (aOldInfo.myKeyboardFeatures.myStickyKeysAreAvailable != theSelectedInfo->myKeyboardFeatures.myStickyKeysAreAvailable) */
/* 	 || (aOldInfo.myKeyboardFeatures.myRepeatKeysAreAvailable != theSelectedInfo->myKeyboardFeatures.myRepeatKeysAreAvailable) */
/* 	 || (aOldInfo.myTextToSpeech.myIdentifier != theSelectedInfo->myTextToSpeech.myIdentifier) */
/* 	 || (aOldInfo.myTextToSpeech.myLanguage != theSelectedInfo->myTextToSpeech.myLanguage) */
/* 	 || (aOldInfo.myTextToSpeech.myPort != theSelectedInfo->myTextToSpeech.myPort) */
/* 	 || (aOldInfo.myDesktop != theSelectedInfo->myDesktop)); */
    }
}