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

TOUCH_STATE returning methods yield incorrect sequence of values [C#] #37

Open
salty-sweet opened this issue Jun 9, 2021 · 0 comments

Comments

@salty-sweet
Copy link

salty-sweet commented Jun 9, 2021

VERSION: Release v2.2.0

ISSUE

The TOUCH_STATE struct I used and added into JoyShockLibrary.cs was in a wrong form despite the fact that I directly copied it from JoyShockLibrary.h @ Line 111. Here's TOUCH_STATE struct declared on that said file:

typedef struct TOUCH_STATE {
	int t0Id;
	int t1Id;
	bool t0Down;
	bool t1Down;
	float t0X;
	float t0Y;
	float t1X;
	float t1Y;
} TOUCH_STATE;

...and here's that same struct I converted to C# initially:

    [StructLayout(LayoutKind.Sequential)]
    public struct TOUCH_STATE {
        public int t0Id;
        public int t1Id;
        public bool t0Down;
        public bool t1Down;
        public float t0X;
        public float t0Y;
        public float t1X;
        public float t1Y;
    }

It is already identical, and yet it yields data in a different sequence. I found out later on that the methods that return TOUCH_STATE structs do not contain any values that should be for t1Down.

WORKAROUND SOLUTION

Putting the public bool t1Down; or public float t1Down; at the very bottom of the struct returns proper values for both touches. This is how the C# struct looks now:

    [StructLayout(LayoutKind.Sequential)]
    public struct MODIFIED_TOUCH_STATE
    {
        public int t0Id;
        public int t1Id;
        public bool t0Down;
        public float t0X;
        public float t0Y;
        public float t1X;
        public float t1Y;
        public float t1Down;   // still nothing
    }

My tests still don't show any change in value on t1Down after moving it downwards, so I'm thinking there's no value for checking if there's a second touch? I wish to help look into your source code to pinpoint where this problem stems from, but I don't know much about C++. I'm just going to bet that it's within the InputHelpers.cpp of yours.

I'm willing to answer further questions that may help you!

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

1 participant