rdepena / node-dualshock-controller

Eventing API layer over HID for the Sony DualShock 3 and DualShock 4 controllers
208 stars 46 forks source link

DS4: r2Analog stick not working #67

Closed tobiasmuecksch closed 7 years ago

tobiasmuecksch commented 7 years ago

Hey there,

I'm using the example from the readme and I've set the config value to config: 'dualShock4',. Additionally I've added the following line:

controller.on('l2Analog:move', data => console.log('L2 Moved: ' + data.x));

When I move the L2 button nothing happens. It works for the two main sticks without a problem.

I've debugged thesrc/analogs.js file by adding the following to line 26:

        if (analogStick.name === 'r2Analog') {
            console.log('ANALOG', analogStick);

        }

With that console output I found out that x always has the value 101. Even while moving it.

ANALOG { name: 'r2Analog', x: 101, joystickXNumber: 4 }
ANALOG { name: 'r2Analog', x: 101, joystickXNumber: 4 }
ANALOG { name: 'r2Analog', x: 101, joystickXNumber: 4 }
ANALOG { name: 'r2Analog', x: 101, joystickXNumber: 4 }
ANALOG { name: 'r2Analog', x: 101, joystickXNumber: 4 }
ANALOG { name: 'r2Analog', x: 101, joystickXNumber: 4 }

How can I debug that problem further?

rdepena commented 7 years ago

Hey @tobiasmuecksch , try running the console print dualshock 4 example, if you don't get any results with that you can try printing the raw hid output for that specific controller:

Use the config json file as a reference: [Button block is the index on the data buffer] (https://github.com/rdepena/node-dualshock-controller/blob/master/controllerConfigurations/dualShock4.json#L46)

Vendor and device id

And modify The device discovery help example to connect to that specific vendor/deviceId combo and print the specific index.

Also, do you get the same results if you are connected via USB?

tobiasmuecksch commented 7 years ago

With the console print dualshock 4 example you've mentioned, the L1 and R1 buttons work. Why - what is different in this example?

tobiasmuecksch commented 7 years ago

This is my source code: https://gist.github.com/tobiasmuecksch/36962177b65ec8df39fc56fe44d35e55

rdepena commented 7 years ago

I guess lines 42 and 43 from the gist are the lines of interest:


controller.on('l2:move', data => console.log('L2 moved'));
controller.on('R2:move', data => console.log('R1 moved'));

I changed them to (capturing the 'analog' event):

controller.on('l2:analog', data => console.log(data));
controller.on('r2:analog', data => console.log(data));

Let me know if that was not the issue.

tobiasmuecksch commented 7 years ago

@rdepena Thank you so much. Using r2:analog instead of r2:move solved the problem!

rdepena commented 7 years ago

@tobiasmuecksch cool, np.