Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dualshock vibration feature works only on motor1 while motor2 stands still (possible bug) #25

Open
maxbambucha opened this issue Jan 21, 2020 · 1 comment

Comments

@maxbambucha
Copy link

Hello community!
First of all, thank you all for this super library, I love it! Using this lib I've built an RC monster truck controlled by a wireless Dualshock 2 (not original copy). Now I want to add a feedback from RC model to controller, so I equipped my truck's receiver with a vibration sensor in order to make PS2 controller vibrate as strong as shaky the road surface is!

And it actually works however I noticed that controller vibrates only with motor1 while motor2 stands still. After a short research I found a suggestion to replace ps2x.read_gamepad(false, vibrate); with ps2x.read_gamepad(true, vibrate); to enable motor2. When I do so, motor2 keeps spinning at a constant speed indefinitely and I'm unable to control it by vibrate variable.

Digging deeper in PS2X_lib.cpp, it felt a bit strange that motor1 is controlled by a number 0..255 and motor2 is controlled by boolean true/false value.

Playing around with PS2X::read_gamepad(boolean motor1, byte motor2) function in PS2X_lib.cpp, I've replaced the string byte dword[9] = {0x01,0x42,0,motor1,motor2,0,0,0,0}; with byte dword[9] = {0x01,0x42,0,motor2,motor2,0,0,0,0};. So that boolean motor1 is ignored and byte motor2 value is sent to the controller as a "vibration strength" value for both motors. To my surprise, it worked and now my controller rumbles with both motors as strong as byte motor2 value is.

This is my first Arduino and GitHub experience, so I decided just to share my thoughts and result and may be contribute a bit to this cool library! Thanks for reading!

@Oakshen
Copy link

Oakshen commented May 13, 2021

Thanks for your sharing. I also encounter this problem recently.It helps me a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants