Beispiel #1
0
void Mouse::getPressedButtons(std::list<MouseButtons::Value> &list)
{
	for (std::map<MouseButtons::Value, OIS::MouseButtonID>::iterator it = mOISButtonValues.begin(); it != mOISButtonValues.end(); ++it)
	{
		if (isButtonDown((*it).first))
			list.push_back((*it).first);
	}
	if (isButtonDown(MouseButtons::SCROLLWHEELDOWN))
		list.push_back(MouseButtons::SCROLLWHEELDOWN);
	if (isButtonDown(MouseButtons::SCROLLWHEELUP))
		list.push_back(MouseButtons::SCROLLWHEELUP);
}
Beispiel #2
0
void gkButtonNode::update(gkScalar tick)
{
	bool isPressed = isButtonDown();

	SET_SOCKET_VALUE(IS_DOWN, isPressed);
	SET_SOCKET_VALUE(NOT_IS_DOWN, !isPressed);

	if (isPressed && !m_pressed)
	{
		m_pressed = true;
		SET_SOCKET_VALUE(PRESS, true);
		SET_SOCKET_VALUE(RELEASE, false);
	}
	else if (!isPressed && m_pressed)
	{
		m_pressed = false;
		SET_SOCKET_VALUE(PRESS, false);
		SET_SOCKET_VALUE(RELEASE, true);
	}
	else
	{
		SET_SOCKET_VALUE(PRESS, false);
		SET_SOCKET_VALUE(RELEASE, false);
	}
}
bool XBOXController::isButtonReleased(JoyButtons button)
{
	bool curPressed = isButtonDown(button);
	bool prevPressed = (m_prevJoyInfoEx.dwButtons & button) ? true : false;

	return !curPressed && prevPressed;
}
IButtonHW::ButtonState sekvojHW::getButtonState(uint8_t number) {

	if (isButtonDown(number)) {
		return IButtonHW::DOWN;
	} else {
		return IButtonHW::UP;
	}

}
Beispiel #5
0
void Mouse::getAllButtonsStatus(std::list<MouseButtons::Value> &pressed, std::list<MouseButtons::Value> &notpressed)
{
	for (std::map<MouseButtons::Value, OIS::MouseButtonID>::iterator it = mOISButtonValues.begin(); it != mOISButtonValues.end(); ++it)
	{
		if (isButtonDown((*it).first))
			pressed.push_back((*it).first);
		else
			notpressed.push_back((*it).first);
	}
	if (isButtonDown(MouseButtons::SCROLLWHEELDOWN))
		pressed.push_back(MouseButtons::SCROLLWHEELDOWN);
	else
		notpressed.push_back(MouseButtons::SCROLLWHEELDOWN);
	if (isButtonDown(MouseButtons::SCROLLWHEELUP))
		pressed.push_back(MouseButtons::SCROLLWHEELUP);
	else
		notpressed.push_back(MouseButtons::SCROLLWHEELUP);
}
/**
* CXInputWrapper::isButtonDownBuffered
* @date Created March 06, 2006
*/
bool CXInputWrapper::isButtonDownBuffered(DWORD dwIndex, DWORD dwButton)
{
	// make sure the index is valid
	if (dwIndex < 0 || dwIndex >= XI_MAX_CONTROLLERS)
		return false;

	if (isButtonDown(dwIndex, dwButton))
	{
		if (!(m_sButtons[dwIndex] & dwButton))
		{
			m_sButtons[dwIndex] |= dwButton;
			return true;
		}
	}
	else if (!isButtonDown(dwIndex, dwButton))
		m_sButtons[dwIndex] &= ~dwButton;

	return false;
}
Beispiel #7
0
void Utility::inputEvent(uint16_t code) {
  //forward key-press event
  //(in case window is currently active and capturing a new button / axis assignment)
  winInputCapture->inputEvent(code);

  //if escape key is pressed on *any* keyboard; release the mouse if it is acquired
  for(unsigned i = 0; i < keyboard<>::count; i++) {
    if(code == keyboard<>::index(i, keyboard<>::escape) && inputManager.state(code) && input.acquired()) {
      input.unacquire();
      return;  //do not trigger other UI actions that may be bound to escape key
    }
  }

  if(winMain->window->isActiveWindow()) {
    bool resizeWindow = false;

    if(isButtonDown(code, inputUiGeneral.loadCartridge)) {
      string filename = selectCartridge();
      if(filename.length() > 0) loadCartridge(filename);
    }

    if(isButtonDown(code, inputUiGeneral.pauseEmulation)) {
      application.pause = !application.pause;
    }

    if(isButtonDown(code, inputUiGeneral.resetSystem)) {
      modifySystemState(Reset);
    }

    if(isButtonDown(code, inputUiGeneral.powerCycleSystem)) {
      modifySystemState(PowerCycle);
    }

    if(isButtonDown(code, inputUiGeneral.lowerSpeed)) {
      config.system.speed--;
      updateEmulationSpeed();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.raiseSpeed)) {
      config.system.speed++;
      updateEmulationSpeed();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleCheatSystem)) {
      if(cheat.enabled() == false) {
        cheat.enable();
        showMessage("Cheat system enabled.");
      } else {
        cheat.disable();
        showMessage("Cheat system disabled.");
      }
    }

    if(isButtonDown(code, inputUiGeneral.toggleFullscreen)) {
      config.video.isFullscreen = !config.video.isFullscreen;
      updateFullscreenState();
      winMain->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleMenu)) {
      winMain->window->menuBar()->setVisible(!winMain->window->menuBar()->isVisibleTo(winMain->window));
      resizeWindow = true;
    }

    if(isButtonDown(code, inputUiGeneral.toggleStatus)) {
      winMain->window->statusBar()->setVisible(!winMain->window->statusBar()->isVisibleTo(winMain->window));
      resizeWindow = true;
    }

    //prevent calling twice when toggleMenu == toggleStatus
    if(resizeWindow == true) {
      resizeMainWindow();
    }

    if(isButtonDown(code, inputUiGeneral.exitEmulator)) {
      application.terminate = true;
    }
  }
}
bool Palette::isShiftDown() {
	return ( isButtonDown("UL3"));
}
/**
* CXInputWrapper::getKey
* @date Created June 18, 2006
*/
bool CXInputWrapper::getKey(DWORD dwIndex, DWORD &dwKey)
{
	// make sure the index is valid
	if (dwIndex < 0 || dwIndex >= XI_MAX_CONTROLLERS)
		return false;

	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_DPAD_UP)) { dwKey = XINPUT_GAMEPAD_DPAD_UP; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_DPAD_DOWN)) { dwKey = XINPUT_GAMEPAD_DPAD_DOWN; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_DPAD_LEFT)) { dwKey = XINPUT_GAMEPAD_DPAD_LEFT; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_DPAD_RIGHT)) { dwKey = XINPUT_GAMEPAD_DPAD_RIGHT; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_START)) { dwKey = XINPUT_GAMEPAD_START; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_BACK)) { dwKey = XINPUT_GAMEPAD_BACK; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_LEFT_THUMB)) { dwKey = XINPUT_GAMEPAD_LEFT_THUMB; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_RIGHT_THUMB)) { dwKey = XINPUT_GAMEPAD_RIGHT_THUMB; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_LEFT_SHOULDER)) { dwKey = XINPUT_GAMEPAD_LEFT_SHOULDER; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_RIGHT_SHOULDER)) { dwKey = XINPUT_GAMEPAD_RIGHT_SHOULDER; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_A)) { dwKey = XINPUT_GAMEPAD_A; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_B)) { dwKey = XINPUT_GAMEPAD_B; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_X)) { dwKey = XINPUT_GAMEPAD_X; return true; }
	if (isButtonDown(dwIndex, XINPUT_GAMEPAD_Y)) { dwKey = XINPUT_GAMEPAD_Y; return true; }

	if (getTriggerData(dwIndex, true) >= XINPUT_GAMEPAD_TRIGGER_THRESHOLD)
	{
		dwKey = XIT_LEFT_TRIGGER;
		return true;
	}
	if (getTriggerData(dwIndex, false) >= XINPUT_GAMEPAD_TRIGGER_THRESHOLD)
	{
		dwKey = XIT_RIGHT_TRIGGER;
		return true;
	}

	return false;
}
Beispiel #10
0
void HdrApp::update(float dt)
{
	// Quit application
	if (isKeyDown(SDLK_ESCAPE))
		requestQuit();

	// Camera zoom in and out
	if (isButtonDown(2))
		cam->zoom(getMouseRelY() * dt * 10.0f);

	// Camera rotate
	if (isButtonDown(0))
	{
		cam->rotateX(getMouseRelX()*dt*10.0f);
		cam->rotateY(getMouseRelY()*dt*10.0f);		
	}

	// Change mid point
	if (isKeyDown(SDLK_LEFT))
		cam->setMid(mid = Math::clamp(mid-0.01f, 0.0f, 1.0f));
	if (isKeyDown(SDLK_RIGHT))
		cam->setMid(mid = Math::clamp(mid+0.01f, 0.0f, 1.0f));

	// Reset effect parameters
	if (isKeyJustDown(SDLK_SPACE))
		resetEffect();

	// Exposure control
	keyIncControlDec(SDLK_e, exposureControl, 0.01f, 0.1f, 3.0f);
	exposure = Math::exp(exposureControl*exposureControl) - 1.0f;

	// Bloom factor
	keyIncControlDec(SDLK_o, bloomFactor, 0.01f, 0.0f, 1.0f);

	// Brightness threshold
	keyIncControlDec(SDLK_t, brightThreshold, 0.05f);

	// Reflection factor
	keyIncControlDec(SDLK_r, reflectionFactor, 0.01f, 0.0f, 1.0f);

	// Change mesh
	if (keyIncControlDecLoop(SDLK_m, currentMesh, (int)fileMesh.size()))
	{
		// If textured effect : block change to textured mesh
		if (currentEffect == 1 && currentMesh != 1)
				currentMesh = 1;
		mesh = TriMeshManager::get()->getTriMesh(fileMesh[currentMesh]);
	}

	// Change cube map
	if (keyIncControlDecLoop(SDLK_c, currentCubeMap, (int)fileCubeMap.size()))
	{
		cubeMapHdr.release();
		cubeMapHdr.load(fileCubeMap.at(currentCubeMap), GL_RGBA16F_ARB);

		cubeMapRgb.release();
		cubeMapRgb.load(fileCubeMap.at(currentCubeMap), GL_RGBA);
	}

	// Change shader effect
	if (keyIncControlDecLoop(SDLK_h, currentEffect, (int)shaderEffect.size()))
	{
		// If textured effect : block change to textured mesh (1 & 2)
		if (currentEffect == 1 && currentMesh != 1)
		{
			currentMesh = 1;
			mesh = TriMeshManager::get()->getTriMesh(fileMesh[currentMesh]);
		}
	}

	// Change fresnel parameters
	keyIncControlDec(SDLK_b, fresnelBias, 0.05f);
	keyIncControlDec(SDLK_s, fresnelScale, 0.05f);
	keyIncControlDec(SDLK_p, fresnelPower, 0.05f);

	// Change eta ratio
	keyIncControlDec(SDLK_5, etaRatio.x, 0.01f);
	keyIncControlDec(SDLK_6, etaRatio.y, 0.01f);
	keyIncControlDec(SDLK_7, etaRatio.z, 0.01f);
	keyIncControlDec(SDLK_a, etaRatio.x, 0.01f);
	keyIncControlDec(SDLK_a, etaRatio.y, 0.01f);
	keyIncControlDec(SDLK_a, etaRatio.z, 0.01f);

	// Change material color
	keyIncControlDec(SDLK_1, matColor.r, 0.01f);
	keyIncControlDec(SDLK_2, matColor.g, 0.01f);
	keyIncControlDec(SDLK_3, matColor.b, 0.01f);
}
Beispiel #11
0
void Utility::inputEvent(uint16_t code) {
  //forward key-press event
  //(in case window is currently active and capturing a new button / axis assignment)
  winInputCapture->inputEvent(code);

  for(unsigned i = 0; i < keyboard<>::count; i++) {
    if(code == keyboard<>::index(i, keyboard<>::escape) && inputManager.state(code)) {
      if(mainWindow->window->isActiveWindow() && input.acquired()) {
        //release mouse capture
        input.unacquire();
        return;  //do not trigger other UI actions that may be bound to escape key
      } else if(settingsWindow->window->isActiveWindow()) {
        settingsWindow->window->hide();
        return;
      } else if(toolsWindow->window->isActiveWindow()) {
        toolsWindow->window->hide();
        return;
      }
    }
  }

  if(mainWindow->window->isActiveWindow()) {
    bool resizeWindow = false;

    if(isButtonDown(code, inputUiGeneral.loadCartridge)) {
      string filename = selectCartridge();
      if(filename.length() > 0) loadCartridge(filename);
    }

    if(isButtonDown(code, inputUiGeneral.pauseEmulation)) {
      application.pause = !application.pause;
      if(application.pause) audio.clear();
    }

    if(isButtonDown(code, inputUiGeneral.resetSystem)) {
      modifySystemState(Reset);
    }

    if(isButtonDown(code, inputUiGeneral.powerCycleSystem)) {
      modifySystemState(PowerCycle);
    }

    if(isButtonDown(code, inputUiGeneral.saveScreenshot)) {
      //tell SNES::Interface to save a screenshot at the next video_refresh() event
      interface.saveScreenshot = true;
    }

    if(isButtonDown(code, inputUiGeneral.showStateManager)) {
      toolsWindow->showStateManager();
    }

    if(isButtonDown(code, inputUiGeneral.quickLoad1)) utility.quickLoad(0);
    if(isButtonDown(code, inputUiGeneral.quickLoad2)) utility.quickLoad(1);
    if(isButtonDown(code, inputUiGeneral.quickLoad3)) utility.quickLoad(2);
    if(isButtonDown(code, inputUiGeneral.quickSave1)) utility.quickSave(0);
    if(isButtonDown(code, inputUiGeneral.quickSave2)) utility.quickSave(1);
    if(isButtonDown(code, inputUiGeneral.quickSave3)) utility.quickSave(2);

    if(isButtonDown(code, inputUiGeneral.lowerSpeed)) {
      config.system.speed--;
      updateEmulationSpeed();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.raiseSpeed)) {
      config.system.speed++;
      updateEmulationSpeed();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleCheatSystem)) {
      if(SNES::cheat.enabled() == false) {
        SNES::cheat.enable();
        showMessage("Cheat system enabled.");
      } else {
        SNES::cheat.disable();
        showMessage("Cheat system disabled.");
      }
    }

    if(isButtonDown(code, inputUiGeneral.toggleFullscreen)) {
      config.video.isFullscreen = !config.video.isFullscreen;
      updateFullscreenState();
      mainWindow->syncUi();
    }

    if(isButtonDown(code, inputUiGeneral.toggleMenu)) {
      mainWindow->window->menuBar()->setVisible(!mainWindow->window->menuBar()->isVisibleTo(mainWindow->window));
      resizeWindow = true;
    }

    if(isButtonDown(code, inputUiGeneral.toggleStatus)) {
      mainWindow->window->statusBar()->setVisible(!mainWindow->window->statusBar()->isVisibleTo(mainWindow->window));
      resizeWindow = true;
    }

    //prevent calling twice when toggleMenu == toggleStatus
    if(resizeWindow == true) {
      resizeMainWindow();
    }

    if(isButtonDown(code, inputUiGeneral.exitEmulator)) {
      application.terminate = true;
    }
  }
}