• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows [Solved] Gamemaker Studio 2 DS4 Vibration not working

S

Seraph

Guest
Hello,
I am struggling to get my ds4 controller to rumble with the gampad_set_vibration function.
Code:
 gamepad_set_vibration(device, left_motor, right_motor)
So I am doing the following when I enter a character attack area
Code:
 gamepad_set_vibration(obj_player.gamepadSlot, 0.5, 0.5);
 alarm[11] = room_speed / 2; // Turns off vibration
My obj_player.gamepadSlot does hold the correct slot, since I use if for other gamepad functions that work fine.
Any help or ideas would be greatly appreciated.

Thanks
 
Try playing with the first argument till it works (instead of obj_player.gamepadSlot use 0, 1, 2, etc.)
If it doesn't work maybe your code never executes? put a show_debug_message above it and see if it triggers whenever the vibration is supposed to happen.
 
Have you tried setting the rumble to last for more than 0.5 seconds? Your alarm is going to trigger in 0.5 second and stop the rumble, and with only half power being applied to the rumble initially is that enough time to feel it. What if you increase your alarm to room_speed * 2, and set the left_motor and right_motor to 1 for full power?
 
S

Seraph

Guest
Try playing with the first argument till it works (instead of obj_player.gamepadSlot use 0, 1, 2, etc.)
If it doesn't work maybe your code never executes? put a show_debug_message above it and see if it triggers whenever the vibration is supposed to happen.
I cycled through all the gamepad slots and none of those worked. I also placed the debug right above the function, and the message did appear in the console.
 
S

Seraph

Guest
Have you tried setting the rumble to last for more than 0.5 seconds? Your alarm is going to trigger in 0.5 second and stop the rumble, and with only half power being applied to the rumble initially is that enough time to feel it. What if you increase your alarm to room_speed * 2, and set the left_motor and right_motor to 1 for full power?
I though that might have been the issue at first, so I set the rumble amount to one. I hadn't though of increasing the alarm time, but I tried it to no avail unfortunately.
 
S

Seraph

Guest
Are you able to see whether the controller is using DirectInput in Windows? I see in another thread that vibration did not work for DirectInput controllers in GMS1.4, so not sure if it is the same in GMS2.
https://forum.yoyogames.com/index.php?threads/dualshock-4-controller-wont-vibrate.34747/#post-214775
My controller works in slot 4, which from my research is the directInput controllers. I've found the article you've linked, however, I have not been able to find anything that explicitly states that directInput vibration does not work in GMS2.
 
S

Sabrina Stoakes

Guest
To my knowledge, isn't the DS4 controller using Dinput? That would mean you would need to set the device to 4 (unless this has changed.) Also, it's dependant on what you're using for the DS4 controller. If you're using DS4 Tool then I know that it emulates an Xbox controller and may not support rumble while emulating Xinput.

Try setting a local variable (to 0,) that you can add += 1 to using a key press. Then set the vibration code in the step event with that local variable in place of the device. Now add to the variable with your key press until you feel the vibration. If you don't then you know it's the controller/controller emulation.
 

O.Stogden

Member
If you use DS4 Windows to emulate it as Xinput then vibration will work.

However I don't know of a way to get Dinput controllers to work with vibration.

Just tested with an Xbox 360 and a PS4 controller, first without DS4 Windows, in which the 360 controller worked immediately, but the PS4 controller did nothing, then with DS4 Windows, where both the Xbox 360 and PS4 controller started to rumble.

You'll probably just have to skip rumble support for PS4 controllers, or leave a note saying to use DS4 Windows. This is quite common really, the PS4 controller didn't really start getting support on the PC until recently, and many games from 2017 and earlier don't really work with it. I've played a couple of games from 2018 that haven't worked with it without using DS4 Windows too, and they weren't indie games. :D
 
S

Seraph

Guest
If you use DS4 Windows to emulate it as Xinput then vibration will work.

However I don't know of a way to get Dinput controllers to work with vibration.

Just tested with an Xbox 360 and a PS4 controller, first without DS4 Windows, in which the 360 controller worked immediately, but the PS4 controller did nothing, then with DS4 Windows, where both the Xbox 360 and PS4 controller started to rumble.

You'll probably just have to skip rumble support for PS4 controllers, or leave a note saying to use DS4 Windows. This is quite common really, the PS4 controller didn't really start getting support on the PC until recently, and many games from 2017 and earlier don't really work with it. I've played a couple of games from 2018 that haven't worked with it without using DS4 Windows too, and they weren't indie games. :D
Thank you this has solved my issue. Not exactly the answer I wanted, but oh darn, I'll have to make do. I was able to get the ds4 to rumble when I had ds4 for windows running, so I can use this to test what feels like good rumble for my players using xbox controllers.
 
Top