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

MOUSEINPUT is of the wrong type #1865

Closed
pentamassiv opened this issue Mar 4, 2024 · 8 comments
Closed

MOUSEINPUT is of the wrong type #1865

pentamassiv opened this issue Mar 4, 2024 · 8 comments
Labels
question Further information is requested

Comments

@pentamassiv
Copy link

Summary

It is the same issue as microsoft/windows-rs#2708. Even after updating the metadata in microsoft/windows-rs@b62b802, the issue still persists.

In version 0.51, windows::Win32::UI::Input::KeyboardAndMouse::MOUSEINPUT.mouseData was of type i32. Starting in version 0.52, it is of type u32. According to the documentation, the type is DWORD. However it also states:

If dwFlags contains MOUSEEVENTF_WHEEL, then mouseData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.

(source).

Crate manifest

No response

Crate code

No response

@pentamassiv pentamassiv added the bug Something isn't working label Mar 4, 2024
@kennykerr kennykerr added question Further information is requested and removed bug Something isn't working labels Mar 4, 2024
@kennykerr
Copy link
Contributor

MOUSEINPUT is originally defined as follows:

typedef struct tagMOUSEINPUT {
    LONG    dx;
    LONG    dy;
    DWORD   mouseData;
    DWORD   dwFlags;
    DWORD   time;
    ULONG_PTR dwExtraInfo;
} MOUSEINPUT, *PMOUSEINPUT, FAR* LPMOUSEINPUT;

The metadata defines it as follows:

public struct MOUSEINPUT
{
	public int dx;
	public int dy;
	public uint mouseData;
	public MOUSE_EVENT_FLAGS dwFlags;
	public uint time;
	public UIntPtr dwExtraInfo;
}

So mouseData looks correct to me.

@pentamassiv
Copy link
Author

It looks like there is a lot of going back and forth between the two types (https://github.com/microsoft/win32metadata/issues?q=is%3Aissue+mouseinput+is%3Aclosed). It was changed to i32 because you have to be able to use negative values to scroll up (#933) and a special case was added to the metadata. Later that seems to have been reverted.

@kennykerr
Copy link
Contributor

Yes, it seems that way. I haven't been tracking that, but I believe the value is correct as of now. I'll transfer to the Win32 metadata repo for their input.

@kennykerr kennykerr transferred this issue from microsoft/windows-rs Mar 4, 2024
@mikebattista
Copy link
Collaborator

As long as we're ok deviating from the headers, we can change it back to int.

@kennykerr
Copy link
Contributor

The type is clearly uint - I don't see a compelling reason to change it - the caller is clearly expected to cast a negative value.

@riverar
Copy link
Collaborator

riverar commented Mar 4, 2024

I originally marked it as int long before we had ABI and codegen compatibility concerns/discussions (#889). I now agree this should remain uint and the user should cast.

Metadata currently has this listed as uint, but then we have this in the emitter rsp... 🤔 https://github.com/riverar/win32metadata/blob/master/generation/WinSDK/emitter.settings.rsp#L464. Looks like something we need to clean up.

@mikebattista
Copy link
Collaborator

Everything looks correct to me in the latest builds.

@mikebattista mikebattista closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
@pentamassiv
Copy link
Author

Okay, thank you for the quick response. I will cast the values.

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

No branches or pull requests

4 participants