aboutsummaryrefslogtreecommitdiff
path: root/core/sys
diff options
context:
space:
mode:
authorLucas Perlind <perlindluca@gmail.com>2023-12-12 11:51:54 +1100
committerLucas Perlind <perlindluca@gmail.com>2023-12-12 12:14:18 +1100
commite410908ce8b7db080abe78474d623df2513a434d (patch)
tree23fc21e5af7a0b0611401de8bc69f916c18b8d5a /core/sys
parentabe896a7beb5772e6a73697ec3add4f5afae4870 (diff)
Add Hidpi to Windows
Diffstat (limited to 'core/sys')
-rw-r--r--core/sys/windows/hidpi.odin134
-rw-r--r--core/sys/windows/types.odin2
2 files changed, 136 insertions, 0 deletions
diff --git a/core/sys/windows/hidpi.odin b/core/sys/windows/hidpi.odin
new file mode 100644
index 000000000..f1724ff0f
--- /dev/null
+++ b/core/sys/windows/hidpi.odin
@@ -0,0 +1,134 @@
+// +build windows
+package sys_windows
+import "core:c"
+
+USAGE :: distinct USHORT
+PUSAGE :: ^USAGE
+
+HIDP_CAPS :: struct {
+ Usage: USAGE,
+ UsagePage: USAGE,
+ InputReportByteLength: USHORT,
+ OutputReportByteLength: USHORT,
+ FeatureReportByteLength: USHORT,
+ Reserved: [17]USHORT,
+ NumberLinkCollectionNodes: USHORT,
+ NumberInputButtonCaps: USHORT,
+ NumberInputValueCaps: USHORT,
+ NumberInputDataIndices: USHORT,
+ NumberOutputButtonCaps: USHORT,
+ NumberOutputValueCaps: USHORT,
+ NumberOutputDataIndices: USHORT,
+ NumberFeatureButtonCaps: USHORT,
+ NumberFeatureValueCaps: USHORT,
+ NumberFeatureDataIndices: USHORT,
+}
+PHIDP_CAPS :: ^HIDP_CAPS
+
+HIDP_BUTTON_CAPS :: struct {
+ UsagePage: USAGE,
+ ReportID: UCHAR,
+ IsAlias: BOOLEAN,
+ BitField: USHORT,
+ LinkCollection: USHORT,
+ LinkUsage: USAGE,
+ LinkUsagePage: USAGE,
+ IsRange: BOOLEAN,
+ IsStringRange: BOOLEAN,
+ IsDesignatorRange: BOOLEAN,
+ IsAbsolute: BOOLEAN,
+ ReportCount: USHORT,
+ Reserved2: USHORT,
+ Reserved: [9]ULONG,
+ using _: struct #raw_union {
+ Range: struct {
+ UsageMin: USAGE,
+ UsageMax: USAGE,
+ StringMin: USHORT,
+ StringMax: USHORT,
+ DesignatorMin: USHORT,
+ DesignatorMax: USHORT,
+ DataIndexMin: USHORT,
+ DataIndexMax: USHORT,
+ },
+ NotRange: struct {
+ Usage: USAGE,
+ Reserved1: USAGE,
+ StringIndex: USHORT,
+ Reserved2: USHORT,
+ DesignatorIndex: USHORT,
+ Reserved3: USHORT,
+ DataIndex: USHORT,
+ Reserved4: USHORT,
+ },
+ },
+}
+PHIDP_BUTTON_CAPS :: ^HIDP_BUTTON_CAPS
+
+HIDP_VALUE_CAPS :: struct {
+ UsagePage: USAGE,
+ ReportID: UCHAR,
+ IsAlias: BOOLEAN,
+ BitField: USHORT,
+ LinkCollection: USHORT,
+ LinkUsage: USAGE,
+ LinkUsagePage: USAGE,
+ IsRange: BOOLEAN,
+ IsStringRange: BOOLEAN,
+ IsDesignatorRange: BOOLEAN,
+ IsAbsolute: BOOLEAN,
+ HasNull: BOOLEAN,
+ Reserved: UCHAR,
+ BitSize: USHORT,
+ ReportCount: USHORT,
+ Reserved2: [5]USHORT,
+ UnitsExp: ULONG,
+ Units: ULONG,
+ LogicalMin: LONG,
+ LogicalMax: LONG,
+ PhysicalMin: LONG,
+ PhysicalMax: LONG,
+ using _: struct #raw_union {
+ Range: struct {
+ UsageMin: USAGE,
+ UsageMax: USAGE,
+ StringMin: USHORT,
+ StringMax: USHORT,
+ DesignatorMin: USHORT,
+ DesignatorMax: USHORT,
+ DataIndexMin: USHORT,
+ DataIndexMax: USHORT,
+ },
+ NotRange: struct {
+ Usage: USAGE,
+ Reserved1: USAGE,
+ StringIndex: USHORT,
+ Reserved2: USHORT,
+ DesignatorIndex: USHORT,
+ Reserved3: USHORT,
+ DataIndex: USHORT,
+ Reserved4: USHORT,
+ },
+ },
+}
+PHIDP_VALUE_CAPS :: ^HIDP_VALUE_CAPS
+
+PHIDP_PREPARSED_DATA :: rawptr
+
+HIDP_REPORT_TYPE :: enum c.int {
+ Input,
+ Output,
+ Feature,
+}
+
+HIDP_STATUS_SUCCESS : NTSTATUS : 0x110000
+
+foreign import hid "system:hid.lib"
+@(default_calling_convention="stdcall")
+foreign hid {
+ HidP_GetCaps :: proc(PreparsedData: PHIDP_PREPARSED_DATA, Capabilities: PHIDP_CAPS) -> NTSTATUS ---
+ HidP_GetButtonCaps :: proc(ReportType: HIDP_REPORT_TYPE, ButtonCaps: PHIDP_BUTTON_CAPS, ButtonCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS ---
+ HidP_GetValueCaps :: proc(ReportType: HIDP_REPORT_TYPE, ValueCaps: PHIDP_VALUE_CAPS, ValueCapsLength: PUSHORT, PreparsedData: PHIDP_PREPARSED_DATA) -> NTSTATUS ---
+ HidP_GetUsages :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, UsageList: PUSAGE, UsageLength: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS ---
+ HidP_GetUsageValue :: proc(ReportType: HIDP_REPORT_TYPE, UsagePage: USAGE, LinkCollection: USHORT, Usage: USAGE, UsageValue: PULONG, PreparsedData: PHIDP_PREPARSED_DATA, Report: PCHAR, ReportLength: ULONG) -> NTSTATUS ---
+}
diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin
index 360cab738..10b474866 100644
--- a/core/sys/windows/types.odin
+++ b/core/sys/windows/types.odin
@@ -75,6 +75,8 @@ LPRECT :: ^RECT
LPPOINT :: ^POINT
LSTATUS :: LONG
PHKEY :: ^HKEY
+PUSHORT :: ^USHORT
+PCHAR :: ^CHAR
UINT8 :: u8
UINT16 :: u16