Esempio n. 1
0
static bool xdk_input_set_rumble(void *data, unsigned port,
      enum retro_rumble_effect effect, uint16_t strength)
{
   xdk_input_t *xdk = (xdk_input_t*)data;
   (void)xdk;
   bool val = false;

  
#if 0
#if defined(_XBOX360)
   XINPUT_VIBRATION rumble_state;

   if (effect == RETRO_RUMBLE_STRONG)
      rumble_state.wLeftMotorSpeed = strength;
   else if (effect == RETRO_RUMBLE_WEAK)
      rumble_state.wRightMotorSpeed = strength;
   val = XInputSetState(port, &rumble_state) == ERROR_SUCCESS;
#elif defined(_XBOX1)
#if 0
   XINPUT_FEEDBACK rumble_state;

   if (effect == RETRO_RUMBLE_STRONG)
      rumble_state.Rumble.wLeftMotorSpeed = strength;
   else if (effect == RETRO_RUMBLE_WEAK)
      rumble_state.Rumble.wRightMotorSpeed = strength;
   val = XInputSetState(xdk->gamepads[port], &rumble_state) == ERROR_SUCCESS;
#endif
#endif
#endif
   return val;
}
void XBox360XInput::setVibration( unsigned short left , unsigned short right , unsigned int player )
{
	XINPUT_VIBRATION vibration;
	vibration.wLeftMotorSpeed = left;
	vibration.wRightMotorSpeed = right;
	XInputSetState( player , &vibration );
}
void InputGamePad::Vibrate(float _LMotorSpeed, float _RMotorSpeed)
{
	// Check if the controler allows vibrate
	if (m_allowVibrate)
	{
		if ((_LMotorSpeed > 0.0f) || (_RMotorSpeed > 0.0f))
		{
			m_vibrating = true;
		}
		else
		{
			m_vibrating = false;
		}

		// Vibration State
		XINPUT_VIBRATION VibrationState;

		// Clear the memory of the vibration state
		ZeroMemory(&VibrationState, sizeof(XINPUT_VIBRATION));

		// Calculate the vibration values 
		// XInput’s default vibration values range from 0 to 65535
		// So convert the passed in 0.0f to 1.0f values to that
		int LMotorSpeed = int(_LMotorSpeed * 65535.0f);
		int RMotorSpeed = int(_RMotorSpeed * 65535.0f);

		// Set the vibrations
		VibrationState.wLeftMotorSpeed = LMotorSpeed;
		VibrationState.wRightMotorSpeed = RMotorSpeed;

		// Set the Vibration state
		XInputSetState(m_gamepadIndex, &VibrationState);
	}
}
Esempio n. 4
0
	void CInputManager::SetMotorSpeed(UINT gamepad, USHORT speedLeft, USHORT speedRight)
	{
		XINPUT_VIBRATION vib;
		vib.wLeftMotorSpeed = speedLeft;
		vib.wRightMotorSpeed = speedRight;
		XInputSetState(gamepad, &vib);
	}
void WINAPI XInputEnable
(
__in bool enable										// [in] Indicates whether xinput is enabled or disabled. 
)
{
	writeLog("XInputEnable", "controllerInit = %d - enable = %d \n", controllerInit, enable);
	if (!controllerInit)
	{
		connectController(true);
	}

	if (controllerInit && !enable)
	{
		XINPUT_VIBRATION Vibration = { 0, 0 };
		int xboxControllerCounter = 0;

		while (xboxControllerCounter < 4)
		{
			if (controllerHandler[xboxControllerCounter])
			{
				XInputSetState(xboxControllerCounter, &Vibration);
			}
			xboxControllerCounter++;
		}
	}
}
Esempio n. 6
0
void Controller::SetRightVibrationRaw(unsigned int newVibration)
{
#if defined(WIN32)
	XINPUT_VIBRATION vibration;
	ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));
	vibration.wLeftMotorSpeed = _currentLeftVibration;
	vibration.wRightMotorSpeed = _currentRightVibration = newVibration;
	XInputSetState(0, &vibration);
#elif defined(__APPLE__)
	newVibration = 0;
#elif defined(__linux__)
	_ffEffect.u.rumble.strong_magnitude = _currentLeftVibration;
	_ffEffect.u.rumble.weak_magnitude = _currentRightVibration = newVibration;
	if (ioctl(_ffFD, EVIOCSFF, &_ffEffect) == -1)
	{
		sysLog.Printf("Error writing force feedback effect!");
		return;
	}
	_ffPlay.code = _ffEffect.id;
	if (write(_ffFD, &_ffPlay, sizeof(_ffPlay)) == -1)
	{
		sysLog.Printf("Error playing force feedback effect!");
	}
#endif
}
Esempio n. 7
0
void XInput::update_stick( int index, float timeStep )
{
#ifdef HAVOK_COMPILE
    const XINPUT_GAMEPAD& xGamePad = g_states[index].Gamepad;
    caculate_value(xGamePad.sThumbLX,  xGamePad.sThumbLY,  XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, m_LSSmooth[index]);
    caculate_value(xGamePad.sThumbRX, xGamePad.sThumbRY,  XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE, m_RSSmooth[index]);

    m_LSRaw[index][0] = (float)xGamePad.sThumbLX/32767.0f;
    m_LSRaw[index][1] = (float)xGamePad.sThumbLY/32767.0f;

    m_RSRaw[index][0] = (float)xGamePad.sThumbRX/32767.0f;
    m_RSRaw[index][1] = (float)xGamePad.sThumbRY/32767.0f;

    float oldTime = m_vibrateTime[index];
    float& vTime = m_vibrateTime[index];
    vTime -= timeStep;
    if(vTime < 0.0f)
        vTime = 0.0f;
    if(oldTime > 0.0f && vTime <= 0.0f)
    {
        XINPUT_VIBRATION tmpVibration;
        ZeroMemory(&tmpVibration, sizeof(tmpVibration));
        XInputSetState((DWORD)index, &tmpVibration);
    }
#endif
}
Esempio n. 8
0
//------------------------------------------------
// dtor
//------------------------------------------------
InputXInput::~InputXInput() {
	XINPUT_VIBRATION vibration = { 0, 0 };
	XInputSetState( padID_, &vibration );

	// XInput無効にする
	XInputEnable( FALSE );
}
Esempio n. 9
0
void CleanupVibrationAtExit()
{
	// Kill vibration on exit
	XINPUT_VIBRATION vibration;
	ZeroMemory( &vibration, sizeof(XINPUT_VIBRATION) );
	for (int i = 0; i < 4; i++)
		XInputSetState( i, &vibration );
}
Esempio n. 10
0
void Input::SetVibrationLevel(int p_ControllerID, float LRotationAmmount, float RRotationAmmount)
{
	XINPUT_VIBRATION _Data;
	_Data.wLeftMotorSpeed = LRotationAmmount * 65535;
	_Data.wRightMotorSpeed = RRotationAmmount * 65535;

	XInputSetState(p_ControllerID, &_Data);
}
Esempio n. 11
0
//----------------------------------
//機能:バイブレーション処理
//引数:leftSpeed	左のモーターの速さ
//引数:rightSpeed	右のモーターの速さ
//戻値:傾き具合
//----------------------------------
void Input::Vibration(float leftSpeed, float rightSpeed)
{
	XINPUT_VIBRATION vibration;
	ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));
	vibration.wLeftMotorSpeed = leftSpeed * 065535;  // 左モーター
	vibration.wRightMotorSpeed = rightSpeed * 65535; // 右モーター
	XInputSetState(0, &vibration);
}
Esempio n. 12
0
void XboxController::Vibrate(int leftVal, int rightVal)
{
    XINPUT_VIBRATION vibration;
    SecureZeroMemory(&vibration,sizeof(XINPUT_VIBRATION));
    vibration.wLeftMotorSpeed = leftVal;
    vibration.wRightMotorSpeed = rightVal;
    XInputSetState(m_controllerNumber,&vibration);
}
Esempio n. 13
0
//----------------------------------------------------------------------------------------------------
void Xbox::Controller::Vibrate( float leftIntensityZeroToOne, float rightIntensityZeroToOne, float durationSeconds )
{
	m_vibration.wLeftMotorSpeed = static_cast< WORD >( leftIntensityZeroToOne * VIBRATION_MAXIMUM ); 
	m_vibration.wRightMotorSpeed = static_cast< WORD >( rightIntensityZeroToOne * VIBRATION_MAXIMUM ); 
	m_vibrationTimeSeconds = durationSeconds;

	//Vibrate the controller 
	XInputSetState( m_padNumber, &m_vibration ); 
}
Esempio n. 14
0
void CGamePad::SetVibrationR(float right,int frameR)
{
	VibrationState[RIGHT] = right;
	VibrationFrame[RIGHT] = frameR;
	XINPUT_VIBRATION vibration;
	vibration.wLeftMotorSpeed = (WORD)(VibrationState[LEFT] * VIBRATION_MULTI);
	vibration.wRightMotorSpeed = (WORD)(VibrationState[RIGHT] * VIBRATION_MULTI);
	XInputSetState(ConnectedId,&vibration);
}
Esempio n. 15
0
void GamepadSetRumble(GAMEPAD_DEVICE gamepad, float left, float right) {
	if ((STATE[gamepad].flags & FLAG_RUMBLE) != 0) {
		XINPUT_VIBRATION vib;
		ZeroMemory(&vib, sizeof(vib));
		vib.wLeftMotorSpeed = (WORD)(left * 65535);
		vib.wRightMotorSpeed = (WORD)(right * 65535);
		XInputSetState(gamepad, &vib);
	}
}
Esempio n. 16
0
///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
void Vibrate( const int controllerNumber, int leftVal, int rightVal )
{
	XINPUT_VIBRATION Vibration;

	memset( &Vibration, 0, sizeof(XINPUT_VIBRATION) );

	Vibration.wLeftMotorSpeed = leftVal;
	Vibration.wRightMotorSpeed = rightVal;

	XInputSetState(controllerNumber, &Vibration);
}
Esempio n. 17
0
void Controller::vibrate(int left, int right)
{
    XINPUT_VIBRATION vibration;

    ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION));

    vibration.wLeftMotorSpeed = (WORD)left;
    vibration.wRightMotorSpeed = (WORD)right;

    XInputSetState(_controllerNumber, &vibration);

}
Esempio n. 18
0
//-----------------------------------------------------------------------------------------------
void InputHandler::Vibrate(int leftVal, int rightVal, uint playerIndex)
{
	XINPUT_VIBRATION Vibration;
	memset(&Vibration,0,sizeof(XINPUT_VIBRATION));

	// Set the Vibration Values
	Vibration.wLeftMotorSpeed = (WORD)leftVal;
	Vibration.wRightMotorSpeed = (WORD)rightVal;

	// Vibrate the controller
	XInputSetState(playerIndex, &Vibration);
}
Esempio n. 19
0
//-----------------------------------------------------------------------------
//!	振動停止
//-----------------------------------------------------------------------------
void Controller::DisableVibration()
{
	//	振動用の構造体
	XINPUT_VIBRATION	vibration;
	//	初期化
	ZeroMemory( &vibration, sizeof(XINPUT_VIBRATION) );
	//	振動値代入
	vibration.wLeftMotorSpeed  = 0;
	vibration.wRightMotorSpeed = 0;
	//	結果転送
	XInputSetState( _controllerNum, &vibration);
}
Esempio n. 20
0
// Set vibration (0.0 to 1.0)
// 0 stops the vibration
void InputHandler::setVibration(  float leftMotor, float rightMotor, t_joyNum joyNum)
{

	XINPUT_VIBRATION vib;
	ZeroMemory(&vib, sizeof(XINPUT_VIBRATION));

	vib.wLeftMotorSpeed = static_cast <WORD> (leftMotor  * 65535.0f);
	vib.wRightMotorSpeed = static_cast <WORD> (rightMotor * 65535.0f);

	XInputSetState(joyNum, &vib);

}
Esempio n. 21
0
void XInput::vibrate( int index, float leftVal, float rightVal, float fTime )
{
    if(!is_connected(index)) return;
    if(fTime <= 0.0f) return;
    leftVal = bx::fclamp(leftVal, 0.0f, 1.0f);
    rightVal = bx::fclamp(rightVal, 0.0f, 1.0f);
#ifdef HAVOK_COMPILE
    XINPUT_VIBRATION tmpVibration;
    tmpVibration.wLeftMotorSpeed = (WORD)(leftVal * VIBRATION_MAX);
    tmpVibration.wRightMotorSpeed = (WORD)(rightVal * VIBRATION_MAX);
    m_vibrateTime[index] = fTime;
    XInputSetState(index, &tmpVibration);
#endif
}
/**
*
* This function Sets the vibration of the Xbox controller
*
* @Author Carsten Scholz
* @_fMagnitude is the strength of the vibration
* @_eMotor is the motor which you want to vibrate
* 
*/
void 
CXInputController::SetVibration(float32 _fMagnitude, EMotor _eMotor)
{
	if (_eMotor & MOTOR_LEFT)
	{
		m_Vibration.wLeftMotorSpeed = static_cast<uint16>(_fMagnitude * (float32)VIBRATION_MODIFIER);
	}
	if (_eMotor & MOTOR_RIGHT)
	{
		m_Vibration.wRightMotorSpeed = static_cast<uint16>(_fMagnitude * (float32)VIBRATION_MODIFIER);
	}

	XInputSetState(m_uiController, &m_Vibration);
}
void XboxController::Vibrate(int leftVal, int rightVal) const {
	// Create a Vibraton State
	XINPUT_VIBRATION Vibration;

	// Zeroise the Vibration
	ZeroMemory(&Vibration, sizeof(XINPUT_VIBRATION));

	// Set the Vibration Values
	Vibration.wLeftMotorSpeed = leftVal;
	Vibration.wRightMotorSpeed = rightVal;

	// Vibrate the controller
	XInputSetState(controllerNum, &Vibration);
}
Esempio n. 24
0
void CGamePad::Update()
{
	for( uint32 i = 0; i < MAX_CONTROLLERS; i++ )
  {

		m_Controllers[i].m_bConnected = (XInputGetState(i, &m_Controllers[i].m_pState) == ERROR_SUCCESS);
 
  	if(m_Controllers[i].m_bConnected)
  	{
  	  if(m_bDeadZoneOn)
  	  {
  	      // Zero value if thumbsticks are within the dead zone 
  	      if( m_Controllers[i].m_pState.Gamepad.sThumbLX < INPUT_DEADZONE && m_Controllers[i].m_pState.Gamepad.sThumbLX > -INPUT_DEADZONE )
					{
  	          m_Controllers[i].m_pState.Gamepad.sThumbLX = 0;
					}
  	      if( m_Controllers[i].m_pState.Gamepad.sThumbLY < INPUT_DEADZONE && m_Controllers[i].m_pState.Gamepad.sThumbLY > -INPUT_DEADZONE )
					{
  	          m_Controllers[i].m_pState.Gamepad.sThumbLY = 0;
					}

  	      if( m_Controllers[i].m_pState.Gamepad.sThumbRX < INPUT_DEADZONE && m_Controllers[i].m_pState.Gamepad.sThumbRX > -INPUT_DEADZONE )
					{
  	        m_Controllers[i].m_pState.Gamepad.sThumbRX = 0;
					}
  	      if( m_Controllers[i].m_pState.Gamepad.sThumbRY < INPUT_DEADZONE && m_Controllers[i].m_pState.Gamepad.sThumbRY > -INPUT_DEADZONE )
					{
  	          m_Controllers[i].m_pState.Gamepad.sThumbRY = 0;
					}
  	  }

			m_Controllers[i].m_Pos.x += (uint32)(m_Controllers[i].m_pState.Gamepad.sThumbRX * 0.0001f);
			if (m_Controllers[i].m_Pos.x < 0)
				 m_Controllers[i].m_Pos.x = 0;
			else if (m_Controllers[i].m_Pos.x > m_ScreenResolution.x)
				 m_Controllers[i].m_Pos.x = m_ScreenResolution.x;

			m_Controllers[i].m_Pos.y -= (uint32)(m_Controllers[i].m_pState.Gamepad.sThumbRY * 0.0001f);
			if (m_Controllers[i].m_Pos.y < 0)
				 m_Controllers[i].m_Pos.y = 0;
			else if (m_Controllers[i].m_Pos.y > m_ScreenResolution.y)
				 m_Controllers[i].m_Pos.y = m_ScreenResolution.y;

			m_Controllers[i].m_wOldButtons = m_Controllers[i].m_wNewButtons;
  	  m_Controllers[i].m_wNewButtons = m_Controllers[i].m_pState.Gamepad.wButtons;

			XInputSetState( 0, &m_Controllers[i].m_vibration );
  	}
	}
}
Esempio n. 25
0
//-----------------------------------------------------------------------------
//!	振動開始
//!	@param [in] L_vib	左振動値(0.0f ~ 1.0f)
//!	@param [in] R_vib	右振動値(0.0f ~ 1.0f)
//-----------------------------------------------------------------------------
void Controller::EnableVibration( f32 L_vib, f32 R_vib )
{
	//	振動値を0.0~1.0fから 0 ~ 65535に変換
	L_vib = 65535 * L_vib;
	R_vib = 65535 * R_vib;
	//	振動用の構造体
	XINPUT_VIBRATION	vibration;
	//	初期化
	ZeroMemory( &vibration, sizeof(XINPUT_VIBRATION) );
	//	振動値代入
	vibration.wLeftMotorSpeed  = L_vib;
	vibration.wRightMotorSpeed = R_vib;
	//	結果転送
	XInputSetState( _controllerNum, &vibration);
}
Esempio n. 26
0
void Gamepad::Rumble(float leftmotor, float rightmotor) {

	XINPUT_VIBRATION VibrationState;

	ZeroMemory(&VibrationState, sizeof(XINPUT_VIBRATION));

	int ileftmotor = int(leftmotor*65535.0f);
	int irightmotor = int(rightmotor*65535.0f);

	VibrationState.wLeftMotorSpeed = ileftmotor;
	VibrationState.wRightMotorSpeed = irightmotor;

	XInputSetState(m_iGamepadIndex, &VibrationState);

}
void CXBoxController::Vibrate( unsigned int leftVal, unsigned int rightVal )
{
	XINPUT_VIBRATION vibration;
	ZeroMemory( &vibration, sizeof( vibration ) );
	vibration.wLeftMotorSpeed = static_cast<WORD>(leftVal);
	vibration.wRightMotorSpeed = static_cast<WORD>(rightVal);

#ifdef _DEBUG
	// Call the pointer functions (from GetProcAddress)
	if ( !CXBoxController::bGetProcCompleted ) { return; }
	DWORD returnVal = CXBoxController::pXboxInputSetState( this->m_playerNumber, &vibration );
#else
	DWORD returnVal = XInputSetState( this->m_playerNumber, &vibration );
#endif
	return;
}
Esempio n. 28
0
void
X360Controller::setMotorSpeeds (uint32_t gamePadIndex, float left, float right)
{
    if (gamePadIndex < MAX_GAME_PAD_COUNT)
    {
        XINPUT_VIBRATION vibration;
        memset( &vibration, 0, sizeof(XINPUT_VIBRATION) );
        vibration.wLeftMotorSpeed = WORD(left * 65535.0f); // use any value between 0-65535 here
        vibration.wRightMotorSpeed = WORD(right * 65535.0f); // use any value between 0-65535 here
        XInputSetState(gamePadIndex, &vibration );
    }
    else
    {
        LOG("Invalid X360 gamepadIndex " << gamePadIndex);
    }
}
Esempio n. 29
0
void XBoxController::vibrate(float motorL = 0.0f, float motorR = 0.0f)
{
		// Create new vibration.
		XINPUT_VIBRATION vibration;

		memset(&vibration, 0, sizeof(XINPUT_VIBRATION));

		int vibrationL = (int)(motorL * MAX_VIBRATION);
		int vibrationR = (int)(motorR * MAX_VIBRATION);

		// Set the vibration values.
		vibration.wLeftMotorSpeed = vibrationL;
		vibration.wRightMotorSpeed = vibrationR;

		// Vibrate the controller.
		XInputSetState((int)_player_index, &vibration);
}
///////////////////////////////////////
///VIBRATION FUNCTION
///SET BOTH TO 0 TO STOP VIBRATION
///////////////////////////////////////
void ControllerInputManager::vibrate(int controllerNum, int leftVal, int rightVal)
{
	if (!controllerIsValid(controllerNum))
		return;

    // Create a Vibraton State
    XINPUT_VIBRATION Vibration;

    // Zeroise the Vibration
    ZeroMemory(&Vibration, sizeof(XINPUT_VIBRATION));

    // Set the Vibration Values
    Vibration.wLeftMotorSpeed = leftVal;
    Vibration.wRightMotorSpeed = rightVal;

    // Vibrate the controller
    XInputSetState(controllerNum, &Vibration);
}