Advertisement Jump to content
Sign in to follow this  

XInput rumble not stopping...

This topic is 631 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I've started to play around with a XBone controller using the XInput API.
​So far I've managed to retrieve all buttons and sticks input without a problem.

The only thing I don't understand, is how the rumble function works.
​I know how to enable it with XINPUT_VIBRATION and the motor speeds (0 to 65xxx).
​But if I try to disable rumbling by setting the motor speeds to 0, the rumbling doesn't stop.

Do you have any idea what I'm doing wrong?
​Below is the code of the simple test application.

Any input is appreciated.

		ZeroMemory(&state, sizeof(XINPUT_STATE));
		dwResult = XInputGetState(controllerId, &state);

		if(dwResult != ERROR_SUCCESS)		// controller NOT connected?
			MessageBox(NULL, L"XBox controller error - state not retrieved", L"Whoops...", MB_ICONERROR);

		if(((state.Gamepad.wButtons & XINPUT_GAMEPAD_A) != 0))				MessageBox(NULL, L"A", L"XBone", MB_OK);			// A button
		if(((state.Gamepad.wButtons & XINPUT_GAMEPAD_B) != 0))				MessageBox(NULL, L"B", L"XBone", MB_OK);			// B button
		if(((state.Gamepad.wButtons & XINPUT_GAMEPAD_X) != 0))																	// X button + RUMBLE
			rumbler.wLeftMotorSpeed = 25000;
			rumbler.wRightMotorSpeed = 25000;
			XInputSetState(controllerId, &rumbler);
			//MessageBox(NULL, L"X - rumble ON", L"XBone", MB_OK);			
		if(((state.Gamepad.wButtons & XINPUT_GAMEPAD_Y) != 0))																	// Y button + RUMBLE OFF
			rumblerOff.wLeftMotorSpeed = 0;
			rumblerOff.wRightMotorSpeed = 0;
			XInputSetState(controllerId, &rumblerOff);
			//MessageBox(NULL, L"Y - rumble OFF", L"XBone", MB_OK);

		// Escape
		if(GetAsyncKeyState(VkKeyScan(VK_ESCAPE)) & 0x8000) done = true;

Another question, do I need to use XInputEnable(true/false) when my application goes in/ out of scope?
​It doesn't seem to work with all XInput versions.

I'm currently including <xinput.h> and linking Xinput9_1_0.lib

Share this post

Link to post
Share on other sites

Thanks, I gave it a shot right away:

XInputSetState(controllerId, FALSE);

Unfortunately the same result.
I'll try to check the result that XInputSetState returns, maybe it's something else that's going wrong. I assume 'false' should give the same result as 0 and 0 for the left and right motor speeds.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!