bool InputManager::ReadFrame()
{
	//result, for asserts
	bool result;

	//copy current keyboard and mouse states into previous states, to save previous frame states
	prev_keyboardState = input_keyboardState;
	prev_mouseState = input_mouseState;

	//copy current mousePos into the previous, as well
	prev_MousePos = input_MousePos;

	//read keyboard state
	result = ReadKeyboard();
	assert(result && "Keyboard Read Failed");

	//read mouse state
	result = ReadMouse();
	assert(result && "Mouse Read Failed");

	//process changes in mouse+keyboard
	ProcessInput();

	//return true, for success
	return true;
}
示例#2
0
void ReadInput( void )
{
	int i;

	if ( WaitingToQuit )
		return;

	old_input = new_input;
	new_input++;

	if ( new_input >= INPUT_BUFFERS )
		new_input = 0;

	ReadMouse();
	ReadKeyboard();

	if ( JoystickInput )
	{
		for (i = 0; i < Num_Joysticks; i++)
		{
			if (JoystickInfo[i].connected)
				joystick_poll(i);
		}
	}

	flush_input = false;
}
示例#3
0
bool InputClass::Frame()
{
	bool result;
	
	// Read the current state of the keyboard.
	result = ReadKeyboard();
	if(!result)
	{
		return false;
	}
	POINT pt;
	GetCursorPos( &pt );
	//ScreenToClient( hwnd, &pt );
	m_mouseX = pt.x;
	m_mouseY = pt.y;
	// Read the current state of the mouse.
	result = ReadMouse();
	if(!result)
	{
		return false;
	}

	// Process the changes in the mouse and keyboard.
	ProcessInput();

	return true;
}
示例#4
0
void DInput::Update() {
	// Grab this frames key presses
	ReadKeyboard();
	ReadMouse();

	// Update mouse positions
	mousePosX_ += mouse_state_.lX;
	mousePosY_ += mouse_state_.lY;
	mouseWheel_ += mouse_state_.lZ;
}
示例#5
0
void EventClass::Render()
{
    // Read the current state of the keyboard.
    ReadKeyboard();

    // Read the current state of the mouse.
    ReadMouse();

    // Process the changes in the mouse and keyboard.
    ProcessInput();
}
示例#6
0
// Update the keyboard and joystick inputs
void Input::Update ()
{
    // Update native keyboard state
    ReadKeyboard();

    // Read the joysticks, if present
    if (pdidJoystick1) ReadJoystick(0, pdidJoystick1);
    if (pdidJoystick2) ReadJoystick(1, pdidJoystick2);

    // Update the SAM keyboard matrix from the current key state (including joystick movement)
    Keyboard::Update();
}
		void InputManager::Update()
		{
			myRelMouseX = 0;
			myRelMouseY = 0;

			myPreviousMouseState = myMouseState;
			for (unsigned int i = 0; i < 256; i++)
			{
				myPreviousKeyboardState[i] = myKeyboardState[i];
			}
			ReadKeyboard();
			ReadMouse();
			HandleMouseInput();
			myScrollWheelPos += GetRelativeScrollWheel();
		}
示例#8
0
bool Input::Frame() {
	bool result;

	// Read the current state of the keyboard.
	result = ReadKeyboard();
	if(!result) return false;

	// Read the current state of the mouse.
	result = ReadMouse();
	if(!result) return false;

	// Process the changes in the mouse and keyboard.
	ProcessInput();

	return true;
}
示例#9
0
文件: Input.cpp 项目: ljkd/SAGE
//Each frame we read the input and then process it
bool Input::Frame()
{
	bool result;

	result=ReadKeyboard();
	if (!result)
		return false;

	result=ReadMouse();
	if (!result)
		return false;

	ProcessInput();

	return true;
}
bool ControlManager::QueryInputs(ControllerState& controller)
{
    bool result;

	// Read the current state of the keyboard.
	result = ReadKeyboard();
	if(!result)
	{
		return false;
	}

	// Process the changes in the keyboard.
	ProcessInput(controller);

    return true;
}
示例#11
0
bool Input::Frame()
{
	bool result;

	result = ReadKeyboard();
	if (!result)
		return false;

	result = UpdateControllerState();

	if(!result)
		return false;

	



	return true;
}
示例#12
0
//================================================================================
unsigned int ATHInputManager::Update()
{
	ReadKeyboard();

	m_fMouseDiffX = 0.0f;
	m_fMouseDiffY = 0.0f;

	if( ReadMouse() )
	{
		LONG lXMovement = m_diMouseState.lX;
		m_fMouseDiffX = lXMovement * m_fSensitivity;
		m_fMouseX += m_fMouseDiffX;

		LONG lYMovement = m_diMouseState.lY;
		m_fMouseDiffY = lYMovement * m_fSensitivity;
		m_fMouseY += m_fMouseDiffY;

		// Z is the scroll wheel, sensitivty doesnt change it
		LONG lZMovement = m_diMouseState.lZ;
		m_fMouseDiffZ = (float)lZMovement;

		if( m_fMouseX < 0 )
			m_fMouseX = 0;

		if (m_fMouseY < 0 )
			m_fMouseY = 0;

		if( m_fMouseX > (int)m_unScreenWidth )
			m_fMouseX = (float)m_unScreenWidth;

		if( m_fMouseY > (int)m_unScreenHeight )
			m_fMouseY = (float)m_unScreenHeight;

		//if (m_fMouseDiffY != 0.0f || m_fMouseDiffX != 0.0f)
			//std::cout << m_fMouseX << " " << m_fMouseY << '\n';
	}

	SendKeyboardEvent();
	SendMouseEvent();

	return 0;
}
示例#13
0
bool InputClass::Frame()
{
	bool result;

	result = ReadKeyboard();
	if(!result)
	{
		return false;
	}

	result = ReadMouse();
	if(!result)
	{
		return false;
	}

	ProcessInput();

	return true;
}
示例#14
0
bool InputReader::Update()
{
	bool result;

	result = ReadKeyboard();
	if(result == false)
	{
		return false;
	}

	result = ReadMouse();
	if(result == false)
	{
		return false;
	}
	
	ProcessInput();

	return true;
}
示例#15
0
	bool Input::Frame()
	{
		bool result;


		// Read the current state of the pKeyboard.
		result = ReadKeyboard();
		if(!result)
		{
			return false;
		}

		// Read the current state of the pMouse.
		result = ReadMouse();
		if(!result)
		{
			return false;
		}

		return true;
	}
示例#16
0
文件: Swipe.c 项目: dgastler/Door
int ProcessCardSwipe(int swipeFD,int arduinoFD, MYSQL * conn)
{
  int ret = 0;
  const unsigned bufferSize = 256;
  char buffer[bufferSize+1];
  buffer[bufferSize] = '\0';
  bzero(buffer,bufferSize);

  unsigned readSize = ReadKeyboard(swipeFD,buffer,bufferSize);
  if(readSize == 10)
    {
      int opendoor = 0;
      buffer[readSize] = '\0';
      //              0123456789012345678901234567890123 45678901
      char query[] = "select * from users where swipe = \"XXXXXXXXX\" limit 0,1 ";      
      memcpy(query+35,buffer,9); 
      //      printf("%s (%d)\n",query,sizeof(query));
      
      opendoor = RunSQLquery(conn,query,sizeof(query));
      if(opendoor == 1)
	{
	  alarm(0); //Cancel any previous alarms
	  OpenDoor(arduinoFD);
	  alarm(5);  //schedule an alarm to go off in 5 seconds to close the door
	}

      memcpy(query+35,"XXXXXXXXX",9); 
      ret = 1;
    }
  else if(readSize == 0)
    {
      ret = 1;
    }
  else
    {
      ret = 0;
    }
  return ret;
}
示例#17
0
	bool InputWrapper::Update()
	{
		if (myIsInitialized == true)
		{
			bool result;

			// Read the current state of the keyboard.
			result = ReadKeyboard();
			if (result == false)
			{
				return false;
			}

			// Read the current state of the mouse.
			result = ReadMouse();
			if (result == false)
			{
				return false;
			}
		}
		return true;
	}
示例#18
0
int main(void)
   {
   ItemType Item;
   KeyFieldType SearchKey;
   BTTableClass BTTable('r', "btree.dat");

   if (BTTable.Empty())
      Error("Table is empty");

   cout << "Enter the word to be looked up (or . to quit): ";

   while (ReadKeyboard(SearchKey))
      {
      if (BTTable.Retrieve(SearchKey, Item))
         cout << " Definition:   " << Item.DataField << endl;
      else
         cout << " Not found" << endl;
      cout << endl << "Enter the word to be looked up (or . to quit): ";
      }

   return 0;
   }
bool DirectInput::Update()
{
    bool result;

    //Read the current state of the keyboard
    result = ReadKeyboard();
    if(!result)
    {
        return false;
    }

    //Raad the current state of the mouse
    result = ReadMouse();
    if(!result)
    {
        return false;
    }

    //Process the changes in the mouse and keyboard
    ProcessInput();

    return true;
}
示例#20
0
void Input::Pole()
{
	ReadKeyboard();
	ReadMouse();
}
示例#21
0
void Input::Update ()
{
    ReadKeyboard();
    SetSamKeyState();
}
示例#22
0
void GameController::Run()
{
    Player* me = new Player(0,0,1);

    sObjMgr->CreateWorld();
    sObjMgr->Update();

    DWORD realCurrTime = 0;
    DWORD realPrevTime = GetMSTime();

    DWORD diff;

    /* Example for using the sScreenLog class */
    sScreenLog->AddTrack(&diff,ScreenLog::Track::UINT,20,30,0xFFFF0000);

//	sScreenLog->AddTrack(&me->X,ScreenLog::Track::INT,20,50,0xFFFF0000);
//	sScreenLog->AddTrack(&me->Y,ScreenLog::Track::INT,20,70,0xFFFF0000);
    while(true)
    {
        realCurrTime = GetMSTime();
        diff = GetMSTimeDiff(realPrevTime,realCurrTime);

        Player* me = sObjMgr->Me();

        ReadKeyboard();

        if(KEY_PRESSED(DIK_F))
            me->Fire();

        if(KEY_DOWN(DIK_ESCAPE))
            break;
        if(KEY_DOWN(DIK_W))
            me->SetYVelocity(-3);
        if(KEY_DOWN(DIK_S))
            me->SetYVelocity(3);
        if(KEY_DOWN(DIK_A)) {
            me->SetXVelocity(-3);
            if(KEY_DOWN(DIK_D)) {
                new Explosion(me,me->GetX()+4,me->GetY()+(me->GetHeight()/2),19,0,false);
            }
        }
        if(KEY_DOWN(DIK_D)) {
            me->SetXVelocity(3);
            if(KEY_DOWN(DIK_A)) {
                new Explosion(me,me->GetX()+me->GetWidth()-4,me->GetY()+(me->GetHeight()/2),19,0,false);
            }
        }

        /* Oops :< */
        //if(KEY_UP(DIK_W) && KEY_UP(DIK_A) && KEY_UP(DIK_S) && KEY_UP(DIK_D))
        //	{
        //	me->SetXVelocity(0);
        //	me->SetYVelocity(0);
        //	}

        if(KEY_DOWN(DIK_R))
            me->SetPos(30,70);

        if(KEY_DOWN(DIK_Q))
            me->SetAngle(me->GetAngle()+0.1f);

        if(KEY_DOWN(DIK_E))
            me->SetAngle(me->GetAngle()-0.1f);

        if(KEY_DOWN(DIK_M))
            sWorld->PrintMap();

        if(KEY_DOWN(DIK_SPACE))
        {
            me->SetXVelocity(0);
            me->SetYVelocity(0);
        }

        sObjMgr->Update(/* diff */);
        FollowUnit(me);
        Render();

        realPrevTime = realCurrTime;
    }
}