kenshaw / motionserver

DualShock4 motion server for Cemu on Linux
MIT License
2 stars 2 forks source link

Investigations to support Nintendo's Joycons #6

Open toccata10 opened 3 years ago

toccata10 commented 3 years ago

After playing a bit with motionserver, I wondered if it was possible to also support nintendo's joycons. I was unable to go very far, but, this should start it:

    nintendoCorp = 1406
    leftJoy = 8198
    rightJoy = 8199
    combinedJoy= 8200

In func openDev

    if id.Vendor == nintendoCorp && strings.Contains(strings.ToLower(d.Name()), "imu") {
        if id.Product == leftJoy {
            pad = 5
        }
    }

The part I wasn't able to do is that in the poll function:

report.Gyro.Y =float32(event.Value) / float32(axes[evdev.AbsoluteRZ].Res)

doesn't work at all. Looking at the code from joycond-cemuhook (which works fine in yuzu), I see that it's a += and not =:

 sensors = [
            device_state.get('accel_y'),
            - device_state.get('accel_z'),
            device_state.get('accel_x'),
        ]

        # Gyro rotation in deg/s
        if report_motion:
            sensors.extend([
                - device_state.get('motion_y'),
                - device_state.get('motion_z'),
                device_state.get('motion_x')
                ])

                    if event.code == evdev.ecodes.ABS_RX:
                        self.motion_x += event.value / axis.resolution
                    if event.code == evdev.ecodes.ABS_RY:
                        self.motion_y += event.value / axis.resolution
                    if event.code == evdev.ecodes.ABS_RZ:
                        self.motion_z += event.value / axis.resolution
                    if event.code == evdev.ecodes.ABS_X:
                        self.accel_x = event.value / axis.resolution
                    if event.code == evdev.ecodes.ABS_Y:
                        self.accel_y = event.value / axis.resolution
                    if event.code == evdev.ecodes.ABS_Z:
                        self.accel_z = event.value / axis.resolution

I know too little of golang to be able to add this by myself, but maybe someone could be interested. The motivation for this, is to be able to start just motionserver and have motion support for both ds4 and joycons in yuzu.