1 module ws.wm.win32.api;
2 
3 public import
4 	derelict.opengl3.gl3,
5 	core.sys.windows.windows;
6 
7 __gshared:
8 
9 version(Windows):
10 
11 
12 extern(Windows){
13 
14 	alias WindowHandle = HWND;
15 	
16 	alias Context = HGLRC;
17 	
18 	struct Event {
19 		UINT msg;
20 		WPARAM wpar;
21 		LPARAM lpar;
22 	}
23 
24 	struct RAWMOUSE {
25 		USHORT usFlags;
26 		union {
27 			ULONG  ulButtons;
28 			struct {
29 				USHORT usButtonFlags;
30 				USHORT usButtonData;
31 			};
32 		};
33 		ULONG  ulRawButtons;
34 		LONG   lLastX;
35 		LONG   lLastY;
36 		ULONG  ulExtraInformation;
37 	}
38 
39 	struct RAWKEYBOARD {
40 		USHORT MakeCode;
41 		USHORT Flags;
42 		USHORT Reserved;
43 		USHORT VKey;
44 		UINT   Message;
45 		ULONG  ExtraInformation;
46 	}
47 
48 	struct RAWHID {
49 		DWORD dwSizeHid;
50 		DWORD dwCount;
51 		BYTE[1]  bRawData;
52 	}
53 
54 	struct RAWINPUTHEADER {
55 		DWORD  dwType;
56 		DWORD  dwSize;
57 		HANDLE hDevice;
58 		WPARAM wParam;
59 	}
60 
61 	struct RAWINPUT {
62 		RAWINPUTHEADER header;
63 		union {
64 			RAWMOUSE    mouse;
65 			RAWKEYBOARD keyboard;
66 			RAWHID      hid;
67 		}
68 	}
69 
70 	alias RAWINPUT* HRAWINPUT;
71 
72 	UINT GetRawInputData(
73 		HRAWINPUT hRawInput,
74 		UINT uiCommand,
75 		LPVOID pData,
76 		PUINT pcbSize,
77 		UINT cbSizeHeader
78 	);
79 
80 	BOOL RegisterRawInputDevices(RAWINPUTDEVICE* pRawInputDevices, UINT uiNumDevices, UINT cbSize);
81 
82 
83 	const int WM_INPUT = 0x00FF;
84 	const int RID_INPUT = 0x10000003;
85 	const int RIM_TYPEMOUSE = 0;
86 	const int RIDEV_INPUTSINK = 0x00000100;
87 
88 	HWND GetTopWindow(void*);
89 	HWND GetWindow(void*, uint);
90 	
91 	int GetWindowTextW(HWND, LPWSTR, int);
92 	
93 	DWORD GetWindowThreadProcessId(HWND, DWORD*);
94 	void SwitchToThisWindow(HWND, BOOL);
95 
96 	alias nothrow BOOL function(HDC, const(int)*, const(FLOAT)*, UINT, int*, UINT*) T_wglChoosePixelFormatARB;
97 	alias nothrow HGLRC function(HDC, HGLRC, const(int)*) T_wglCreateContextAttribsARB;
98 	
99 	nothrow BOOL SetWindowTextW(HWND,LPCWSTR);  
100 	nothrow HANDLE CreateWindowExW(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID);
101 	nothrow LRESULT DefWindowProcW(HWND,UINT,WPARAM,LPARAM);
102 	DWORD SetClassLongW(HWND,int,LONG);
103 
104 	int ChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR*);
105 	int DestroyWindow(void*);
106 	uint glewInit();
107 
108 	BOOL SwapBuffers(HDC);
109 
110 	ATOM RegisterClassW(const(WNDCLASSW)*);
111 	struct WNDCLASSW {
112 		uint style;
113 		WNDPROC lpfnWndProc;
114 		int cbClsExtra;
115 		int cbWndExtra;
116 		HINSTANCE hInstance;
117 		HICON hIcon;
118 		HCURSOR hCursor;
119 		HBRUSH hbrBackground;
120 		LPCWSTR lpszMenuName;
121 		LPCWSTR lpszClassName;
122 	}
123 	
124 	BOOL SendNotifyMessageA(HWND,UINT,WPARAM,LPARAM);
125 	
126 	struct TRACKMOUSEEVENT {
127 		DWORD cbSize;
128 		DWORD dwFlags;
129 		HWND  hwndTrack;
130 		DWORD dwHoverTime;
131 	};
132 
133 	struct RAWINPUTDEVICE {
134 		USHORT usUsagePage;
135 		USHORT usUsage;
136 		DWORD	dwFlags;
137 		HWND   hwndTarget;
138 	}
139 
140 	BOOL TrackMouseEvent(TRACKMOUSEEVENT*);
141 	const int WM_MOUSELEAVE = 0x2A3;
142 	const int WM_MOUSEWHEEL = 522;
143 	
144 	int GET_WHEEL_DELTA_WPARAM(WPARAM w){
145 		return (cast(WORD)(((cast(DWORD)w)>>16)&0xFFFF));
146 	}
147 	int GET_X_LPARAM(LPARAM l){
148 		return (cast(int)cast(short)(cast(WORD)(cast(DWORD)l)));
149 	}
150 	int GET_Y_LPARAM(LPARAM l){
151 		return (cast(int)(cast(WORD)((cast(DWORD)l>>16)&0xFFFF)));
152 	}
153 
154 		short GetKeyState(int nVirtKey);
155 
156 
157 	HWND FindWindowW(LPCWSTR lpClassName, LPCWSTR lpWindowName);
158 
159 	BOOL PostMessageA(
160 		HWND hWnd,
161 		UINT Msg,
162 		WPARAM wParam,
163 		LPARAM lParam
164 	);
165 
166 
167 }