コード例 #1
0
void InputManager::MouseMove(int mouseNeg, int mousePos, int amount) {
   InputEvent *ie;

   if (amount < 0) {
      ie = mMouseInputEvents[mouseNeg];
   }
   else {
      ie = mMouseInputEvents[mousePos];
   }

   if (ie) {
      if (amount < 0) {
         ie->Press(-amount);
      }
      else {
         ie->Press(amount);
      }
      ie->Release();
   }
}
コード例 #2
0
void GameWindow::HandleEvents() {
	SDL_Event event;
	InputEvent *ie;

	while (SDL_PollEvent(&event)) {
		if (event.type == SDL_QUIT) {
			//mGameModeManager.Quit();
			done = true;
		}
		else if (event.type == SDL_KEYDOWN) {
			if (ie = inputManager->GetKeyEvent(event.key.keysym.sym))
				ie->Press();
		}
		else if (event.type == SDL_KEYUP) {
			if (ie = inputManager->GetKeyEvent(event.key.keysym.sym))
				ie->Release();
			//mGameModeManager.HandleKeyUp(event.key.keysym);
		}
		else if (event.type == SDL_MOUSEMOTION) {
			inputManager->MouseMove(IM_MOUSE_MOVE_LEFT, IM_MOUSE_MOVE_RIGHT, event.motion.xrel);
			inputManager->MouseMove(IM_MOUSE_MOVE_UP, IM_MOUSE_MOVE_DOWN, event.motion.yrel);
			//mGameModeManager.HandleMouseMotion(event.motion);
		}
		else if (event.type == SDL_MOUSEBUTTONDOWN) {
			if (ie = inputManager->GetMouseEvent(event.button.button))
				ie->Press();
		}
		else if (event.type == SDL_MOUSEBUTTONUP) {
			if (ie = inputManager->GetMouseEvent(event.button.button))
				ie->Release();
		}
		else if (event.type == SDL_VIDEORESIZE) {
			HandleResize(event.resize);
		}
	}
}