Ejemplo n.º 1
0
void InputMapper::poll() {
  activeState = !activeState;
  input.poll(stateTable[activeState]);

  modifier = 0;
  for(unsigned i = 0; i < Keyboard::Count; i++) {
    if(state(keyboard(i)[Keyboard::Shift])) modifier |= InputModifier::Shift;
    if(state(keyboard(i)[Keyboard::Control])) modifier |= InputModifier::Control;
    if(state(keyboard(i)[Keyboard::Alt])) modifier |= InputModifier::Alt;
    if(state(keyboard(i)[Keyboard::Super])) modifier |= InputModifier::Super;
  }

  for(unsigned i = 0; i < size(); i++) {
    (*this)[i]->poll();
  }

  for(unsigned i = 0; i < Scancode::Limit; i++) {
    if(state(i) != previousState(i)) {
      utility.inputEvent(i);
      diskBrowser->inputEvent(i);
      inputSettingsWindow->inputEvent(i);
    }
  }
}
Ejemplo n.º 2
0
QString XtgScanner::getToken()
{
	QChar temp;
	QString token;
	temp = lookAhead();
	if (currentState() == textMode)
	{
		/**
		This mode should return only '<' or '@' or newline. It also adds the text_to_be_appended to the QString textToAppend
		*/
		if (temp =='<' || temp =='@' || temp == '\n' || temp == '\r')
			token.append( nextSymbol() );
		else if (temp == '\\')
		{
			/**
			An escape sequence is occurred, hence we will just append 
			the next character in buffer to the text. This will automatically
			deal the occurrance of '\@' or '\:' or any other relevant escapes
			*/
			top = top+1;
			textToAppend.append( nextSymbol() );
		}
		else
			textToAppend.append( nextSymbol() );
	}
	
	if (currentState() == tagMode)
	{
		/**
		This mode should return attributes B|I|U|O|....|*L|*C|... and an inch character "
		*/
		if (temp == '@')
		{
			token.append( nextSymbol() ); // this will append @
			if (lookAhead() == '$')
			{
				token.append( nextSymbol() ); //this will result in @$ if $ is found
				if (lookAhead() == 'p' )
					token.append( nextSymbol() ); //this will result in @$p if p is found
			}
			else // to get the name of character stylesheet applied as <@stylesheetname>
			{
				while (lookAhead() != '>' )
					token.append( nextSymbol() );
				token.append('>');
			}
		}
		else if (temp == '*')
		{
			token.append( nextSymbol() );
			if (lookAhead() == 'r' || lookAhead() == 'k')
			{
				token.append( nextSymbol() );
				token.append( nextSymbol() );
			}
			else
				token.append( nextSymbol() );
		}
		else if (temp == '\\' )
		{
			/** append the * character and the nextSymbol to token so as to form a paragraph attribute and '\\' character to deal special characters that contain XPress Tags codes.
			*/
			token.append( nextSymbol() );
			token.append( nextSymbol() ); 
		}
		else if (temp == '\"')
		{
			/**If inch character is found, the scanner should enter the string mode and enter the corresponding string as the token
			*/
			enterState(stringMode);
			top = top+1;
			token = getToken();
			enterState( previousState() );
		} 
		else if (temp.isDigit())
		{
			while (lookAhead().isDigit() )
			{
				token.append( nextSymbol() );
				if (lookAhead() == '.' )
					token.append( nextSymbol() );
			}
		}
		else if (temp == 'A')
		{
			token.append(nextSymbol());
		}
		else if (temp == 'a')
		{
			token.append( nextSymbol() );
			//look for $ or $$ so as to form the token a$ and a$$
			token.append( getToken() );
		}
		else if (temp == '$') //look for tags like $,$$ etc
		{
			token.append( nextSymbol() );
			//check for existence one more $
			if (lookAhead() == '$' )
				token.append( nextSymbol() );
		}
		else if (temp == '>')
			token.append( nextSymbol() );
		else if (temp == '(')
		{
			top = top+1;
			token = getToken();
		}
		else if (temp == ',')
		{
			top = top+1;
			token=getToken();
		}
		else 
			token.append( nextSymbol() );
	}

	if (currentState() == nameMode)
	{
		/**
		This mode should return the name of stylesheet (or font set or color) or '=' or ':','[' etc. This mode works with the assumption that a character '@' have occurred prior to it.Hence inorder to obtain the tags like '@$:' or '@:' ,we will append @ symbol initially to the token.
		*/
		if ( (input_Buffer.at(top-1)=='@') && (temp == ':') ) // get the simplest token @
		{
			token.append('@');
		}
		else if ( (input_Buffer.at(top-1)=='@') && (temp == '$') ) //get the token @$
		{
			token.append('@');
			token.append( nextSymbol() );
		}
		else if (temp == '\"' )
		{
			enterState(stringMode);
			top = top+1;
			token = getToken();
			enterState( previousState() );
		}
		else if (temp == ',' )
			top = top+1;
		else if (temp == '[' )
		{
			//return [F] or [C] or [Sp or [St
			token.append( nextSymbol() );
			if (lookAhead() == 'F' || lookAhead() == 'C' || lookAhead() == 'S')
			{
				token.append( nextSymbol() );
				token.append( nextSymbol() ); //append ]
			}
		}
		else if (lookAhead() == '=')
			token.append( nextSymbol() );
		else if (lookAhead() == ':')
			token.append( nextSymbol() );
		else if (lookAhead() == '<')
		{
			token.append( nextSymbol() );
		}
		else
		{ // find the name and return it as a tag
			while( 1 )
			{
				temp = lookAhead();
				if (temp == ':' || temp == '=' )
					break;
				token.append( input_Buffer.at(top++) );
			}
		}
	}
	
	if ( currentState() == stringMode )
	{
		/* This mode should return those strings which are inside an inch character, while in tagMode. Hence this should set the mode to tagMode before returning the string value. This will call a function QString sliceString() which will return the required string and maintains the top correctly
		*/
		token = sliceString();
	}
	return token;
}
Ejemplo n.º 3
0
unsigned InputMapper::distance(uint16_t scancode) const { return abs(state(scancode) - previousState(scancode)); }