Browse Source

Merge pull request #1826 from englerj/windows-bindings

Added additional Windows bindings.
gingerBill 3 years ago
parent
commit
c0d2359a91
2 changed files with 75 additions and 8 deletions
  1. 73 8
      core/sys/windows/types.odin
  2. 2 0
      core/sys/windows/user32.odin

+ 73 - 8
core/sys/windows/types.odin

@@ -196,15 +196,26 @@ OPEN_ALWAYS: DWORD : 4
 OPEN_EXISTING: DWORD : 3
 OPEN_EXISTING: DWORD : 3
 TRUNCATE_EXISTING: DWORD : 5
 TRUNCATE_EXISTING: DWORD : 5
 
 
+FILE_READ_DATA            : DWORD : 0x00000001
+FILE_LIST_DIRECTORY       : DWORD : 0x00000001
+FILE_WRITE_DATA           : DWORD : 0x00000002
+FILE_ADD_FILE             : DWORD : 0x00000002
+FILE_APPEND_DATA          : DWORD : 0x00000004
+FILE_ADD_SUBDIRECTORY     : DWORD : 0x00000004
+FILE_CREATE_PIPE_INSTANCE : DWORD : 0x00000004
+FILE_READ_EA              : DWORD : 0x00000008
+FILE_WRITE_EA             : DWORD : 0x00000010
+FILE_EXECUTE              : DWORD : 0x00000020
+FILE_TRAVERSE             : DWORD : 0x00000020
+FILE_DELETE_CHILD         : DWORD : 0x00000040
+FILE_READ_ATTRIBUTES      : DWORD : 0x00000080
+FILE_WRITE_ATTRIBUTES     : DWORD : 0x00000100
+
+GENERIC_READ    : DWORD : 0x80000000
+GENERIC_WRITE   : DWORD : 0x40000000
+GENERIC_EXECUTE : DWORD : 0x20000000
+GENERIC_ALL     : DWORD : 0x10000000
 
 
-
-FILE_WRITE_DATA: DWORD : 0x00000002
-FILE_APPEND_DATA: DWORD : 0x00000004
-FILE_WRITE_EA: DWORD : 0x00000010
-FILE_WRITE_ATTRIBUTES: DWORD : 0x00000100
-FILE_READ_ATTRIBUTES: DWORD : 0x000000080
-GENERIC_READ: DWORD : 0x80000000
-GENERIC_WRITE: DWORD : 0x40000000
 FILE_GENERIC_WRITE: DWORD : STANDARD_RIGHTS_WRITE |
 FILE_GENERIC_WRITE: DWORD : STANDARD_RIGHTS_WRITE |
 	FILE_WRITE_DATA |
 	FILE_WRITE_DATA |
 	FILE_WRITE_ATTRIBUTES |
 	FILE_WRITE_ATTRIBUTES |
@@ -250,6 +261,9 @@ DIAGNOSTIC_REASON_SIMPLE_STRING   :: 0x00000001
 DIAGNOSTIC_REASON_DETAILED_STRING :: 0x00000002
 DIAGNOSTIC_REASON_DETAILED_STRING :: 0x00000002
 DIAGNOSTIC_REASON_NOT_SPECIFIED   :: 0x80000000
 DIAGNOSTIC_REASON_NOT_SPECIFIED   :: 0x80000000
 
 
+ENUM_CURRENT_SETTINGS  : DWORD : 4294967295 // (DWORD)-1
+ENUM_REGISTRY_SETTINGS : DWORD : 4294967294 // (DWORD)-2
+
 // Defines for power request APIs
 // Defines for power request APIs
 
 
 POWER_REQUEST_CONTEXT_VERSION :: DIAGNOSTIC_REASON_VERSION
 POWER_REQUEST_CONTEXT_VERSION :: DIAGNOSTIC_REASON_VERSION
@@ -813,6 +827,57 @@ CREATESTRUCTW:: struct {
 	dwExStyle:      DWORD,
 	dwExStyle:      DWORD,
 }
 }
 
 
+DEVMODEW :: struct {
+	dmDeviceName:   [32]wchar_t,
+	dmSpecVersion:   WORD,
+	dmDriverVersion: WORD,
+	dmSize:          WORD,
+	dmDriverExtra:   WORD,
+	dmFields:        DWORD,
+	using _: struct #raw_union {
+		// Printer only fields.
+		using _: struct {
+			dmOrientation:   c_short,
+			dmPaperSize:     c_short,
+			dmPaperLength:   c_short,
+			dmPaperWidth:    c_short,
+			dmScale:         c_short,
+			dmCopies:        c_short,
+			dmDefaultSource: c_short,
+			dmPrintQuality:  c_short,
+		},
+		// Display only fields.
+		using _: struct {
+			dmPosition:           POINT,
+			dmDisplayOrientation: DWORD,
+			dmDisplayFixedOutput: DWORD,
+		},
+	},
+	dmColor:       c_short,
+	dmDuplex:      c_short,
+	dmYResolution: c_short,
+	dmTTOption:    c_short,
+	dmCollate:     c_short,
+	dmFormName:    [32]wchar_t,
+	dmLogPixels:   WORD,
+	dmBitsPerPel:  DWORD,
+	dmPelsWidth:   DWORD,
+	dmPelsHeight:  DWORD,
+	using _: struct #raw_union {
+		dmDisplayFlags: DWORD,
+		dmNup:          DWORD,
+	},
+	dmDisplayFrequency: DWORD,
+	dmICMMethod:        DWORD,
+	dmICMIntent:        DWORD,
+	dmMediaType:        DWORD,
+	dmDitherType:       DWORD,
+	dmReserved1:        DWORD,
+	dmReserved2:        DWORD,
+	dmPanningWidth:     DWORD,
+	dmPanningHeight:    DWORD,
+}
+
 // MessageBox() Flags
 // MessageBox() Flags
 MB_OK                :: 0x00000000
 MB_OK                :: 0x00000000
 MB_OKCANCEL          :: 0x00000001
 MB_OKCANCEL          :: 0x00000001

+ 2 - 0
core/sys/windows/user32.odin

@@ -135,6 +135,8 @@ foreign user32 {
 	SetCursorPos :: proc(X: c_int, Y: c_int) -> BOOL ---
 	SetCursorPos :: proc(X: c_int, Y: c_int) -> BOOL ---
 	SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR ---
 	SetCursor :: proc(hCursor: HCURSOR) -> HCURSOR ---
 
 
+	EnumDisplaySettingsW :: proc(lpszDeviceName: LPCWSTR, iModeNum: DWORD, lpDevMode: ^DEVMODEW) -> BOOL ---
+	
 	BroadcastSystemMessageW :: proc(
 	BroadcastSystemMessageW :: proc(
 		flags: DWORD,
 		flags: DWORD,
 		lpInfo: LPDWORD,
 		lpInfo: LPDWORD,