Ohjurot / DualSense-Windows

Windows API for the PS5 DualSense controller
Other
342 stars 38 forks source link

TouchPad : touch up / touch down? #21

Closed elliotwoods closed 3 years ago

elliotwoods commented 3 years ago

Hi there!

Lovely implementation. I wrapped it here for openFrameworks: https://github.com/elliotwoods/ofxdualsense

One thing i was curious about was for the touchpad, there doesn't seem to be a way to know if the touches are currently active. Is this data available in the incoming hidInBuffer?

Ohjurot commented 3 years ago

Hi,

Nice work! Looks awesome and is also a nice visualization for testing.

There should be a Finger-Down-Bit in the HID Report, but it did not work reliable for me, but I have plans to work on that again as soon as I have time.

Did you notice anything strange with any of the Gyroscope axis? Because someone was reporting an issue there.

elliotwoods commented 3 years ago

I'm actually using the gyroscope for my application and so far seems stable. Interestingly, the gyroscope seems to be a type of sensor fusion value between then accel and gyro (it consistently knows which direction is down)

elliotwoods commented 3 years ago

Is there a reference out there of the HID data struct?

Ohjurot commented 3 years ago

Yes there are some: https://www.reddit.com/r/gamedev/comments/jumvi5/dualsense_haptics_leds_and_more_hid_output_report/ (Ok bad news... this is gone by now...) https://gist.github.com/Ryochan7/ef8fabae34c0d8b30e2ab057f3e6e039 https://gist.github.com/Ryochan7/91a9759deb5dff3096fc5afd50ba19e2 https://gist.github.com/dogtopus/894da226d73afb3bdd195df41b3a26aa

Ohjurot commented 3 years ago

https://web.archive.org/web/20201228212942/https://www.reddit.com/r/gamedev/comments/jumvi5/dualsense_haptics_leds_and_more_hid_output_report/

Ohjurot commented 3 years ago

ps_controller.txt These are my notes. The touch packed shoud have a released bit 'r' (Touch packed 1 (?? yyyyyyyyyyyyxxxxxxxxxxxxrsssssss) ) but it didn't work stabel for me

elliotwoods commented 3 years ago

Thanks for these responses! The 32bit timestamp didn't work for me. Having a go at the touch pad release now

elliotwoods commented 3 years ago

This works for me:

    // Evaluate touch state 1
    UINT32 touchpad1Raw = *(UINT32*)(&hidInBuffer[0x20]);
    ptrInputState->touchPoint1.y = (touchpad1Raw & 0xFFF00000) >> 20;
    ptrInputState->touchPoint1.x = (touchpad1Raw & 0x000FFF00) >> 8;
    ptrInputState->touchPoint1.down = (touchpad1Raw & (1 << 7)) == 0;
    ptrInputState->touchPoint1.id = (touchpad1Raw & 127);

    // Evaluate touch state 2
    UINT32 touchpad2Raw = *(UINT32*)(&hidInBuffer[0x24]);
    ptrInputState->touchPoint2.y = (touchpad2Raw & 0xFFF00000) >> 20;
    ptrInputState->touchPoint2.x = (touchpad2Raw & 0x000FFF00) >> 8;
    ptrInputState->touchPoint2.down = (touchpad2Raw & (1 << 7)) == 0;
    ptrInputState->touchPoint2.id = (touchpad2Raw & 127);
    /// <summary>
    /// Touchpad state
    /// </summary>
    typedef struct _Touch {
        /// <summary>
        /// X positon of finger (~ 0 - 2000)
        /// </summary>
        unsigned int x;

        /// <summary>
        /// Y position of finger (~ 0 - 2048)
        /// </summary>
        unsigned int y;

        /// <summary>
        /// Touch is down
        /// </summary>
        bool down;

        /// <summary>
        /// 7-bit ID for touch
        /// </summary>
        uint8_t id;
    } Touch;
Ohjurot commented 3 years ago

Fixed in PR #22 merged 0b869f4e34e4a6b608023a2f1e19bc28c037b64f Closing this issue now. Thx for your effort @elliotwoods