Skip to content

Instantly share code, notes, and snippets.

@spytheman
Created March 19, 2023 16:39
Show Gist options
  • Save spytheman/c96ae087e83207d110561299ddec73e8 to your computer and use it in GitHub Desktop.
Save spytheman/c96ae087e83207d110561299ddec73e8 to your computer and use it in GitHub Desktop.
Example of declaring C.INPUT that uses an anonymous union inside, by just ignoring it.
#include <windows.h>
[typedef]
struct C.MOUSEINPUT {
dx i64
dy i64
mouseData u32
dwFlags u32
time u32
dwExtraInfo &u64 = unsafe { nil }
}
[typedef]
struct C.KEYBDINPUT {
wVk u16
wScam u16
dwFlags u32
time u32
dwExtraInfo &u64 = unsafe { nil }
}
[typedef]
struct C.HARDWAREINPUT {
uMsg u32
wParamL u16
wParamH u16
}
[typedef]
struct C.INPUT {
@type u32
mi C.MOUSEINPUT
ki C.KEYBDINPUT
hi C.HARDWAREINPUT
}
fn main() {
a := unsafe { C.INPUT{} }
unsafe { dump(a.mi.dx) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment