more struct changes

db4
Doug Coleman 2009-08-27 21:43:29 -05:00
parent ae001ce75c
commit 111c0f6b89
4 changed files with 48 additions and 48 deletions

View File

@ -6,7 +6,7 @@ math.rectangles namespaces parser sequences shuffle
struct-arrays ui.backend.windows vectors windows.com
windows.dinput windows.dinput.constants windows.errors
windows.kernel32 windows.messages windows.ole32
windows.user32 ;
windows.user32 classes.struct ;
IN: game-input.dinput
CONSTANT: MOUSE-BUFFER-SIZE 16
@ -162,7 +162,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+
[ remove-controller ] each ;
: device-interface? ( dbt-broadcast-hdr -- ? )
DEV_BROADCAST_HDR-dbch_devicetype DBT_DEVTYP_DEVICEINTERFACE = ;
dbch_devicetype>> DBT_DEVTYP_DEVICEINTERFACE = ;
: device-arrived ( dbt-broadcast-hdr -- )
device-interface? [ find-controllers ] when ;
@ -185,9 +185,9 @@ TUPLE: window-rect < rect window-loc ;
{ 0 0 } >>dim ;
: (device-notification-filter) ( -- DEV_BROADCAST_DEVICEW )
"DEV_BROADCAST_DEVICEW" <c-object>
"DEV_BROADCAST_DEVICEW" heap-size over set-DEV_BROADCAST_DEVICEW-dbcc_size
DBT_DEVTYP_DEVICEINTERFACE over set-DEV_BROADCAST_DEVICEW-dbcc_devicetype ;
DEV_BROADCAST_DEVICEW <struct>
DEV_BROADCAST_DEVICEW heap-size >>dbcc_size
DBT_DEVTYP_DEVICEINTERFACE >>dbcc_devicetype ;
: create-device-change-window ( -- )
<zero-window-rect> WS_OVERLAPPEDWINDOW 0 create-window
@ -239,11 +239,13 @@ M: dinput-game-input-backend (close-game-input)
delete-dinput ;
M: dinput-game-input-backend (reset-game-input)
{
+dinput+ +keyboard-device+ +keyboard-state+
+controller-devices+ +controller-guids+
+device-change-window+ +device-change-handle+
} [ f swap set-global ] each ;
global [
{
+dinput+ +keyboard-device+ +keyboard-state+
+controller-devices+ +controller-guids+
+device-change-window+ +device-change-handle+
} [ off ] each
] bind ;
M: dinput-game-input-backend get-controllers
+controller-devices+ get

View File

@ -751,17 +751,18 @@ M: windows-ui-backend beep ( -- )
: fullscreen-RECT ( hwnd -- RECT )
MONITOR_DEFAULTTONEAREST MonitorFromWindow
"MONITORINFOEX" <c-object> dup length over set-MONITORINFOEX-cbSize
[ GetMonitorInfo win32-error=0/f ] keep MONITORINFOEX-rcMonitor ;
MONITORINFOEX <struct>
MONITORINFOEX heap-size >>cbSize
[ GetMonitorInfo win32-error=0/f ] keep rcMonitor>> ;
: client-area>RECT ( hwnd -- RECT )
"RECT" <c-object>
RECT <struct>
[ GetClientRect win32-error=0/f ]
[ "POINT" byte-array>struct-array [ ClientToScreen drop ] with each ]
[ nip ] 2tri ;
: hwnd>RECT ( hwnd -- RECT )
"RECT" <c-object> [ GetWindowRect win32-error=0/f ] keep ;
RECT <struct> [ GetWindowRect win32-error=0/f ] keep ;
M: windows-ui-backend (grab-input) ( handle -- )
0 ShowCursor drop

View File

@ -216,17 +216,17 @@ CONSTANT: TRUE 1
! typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
C-STRUCT: WNDCLASS
{ "UINT" "style" }
{ "WNDPROC" "lpfnWndProc" }
{ "int" "cbClsExtra" }
{ "int" "cbWndExtra" }
{ "HINSTANCE" "hInstance" }
{ "HICON" "hIcon" }
{ "HCURSOR" "hCursor" }
{ "HBRUSH" "hbrBackground" }
{ "LPCTSTR" "lpszMenuName" }
{ "LPCTSTR" "lpszClassName" } ;
STRUCT: WNDCLASS
{ style UINT }
{ lpfnWndProc WNDPROC }
{ cbClsExtra int }
{ cbWndExtra int }
{ hInstance HINSTANCE }
{ hIcon HICON }
{ hCursor HCURSOR }
{ hbrBackground HBRUSH }
{ lpszMenuName LPCTSTR }
{ lpszClassName LPCTSTR } ;
STRUCT: WNDCLASSEX
{ cbSize UINT }
@ -329,12 +329,6 @@ STRUCT: PIXELFORMATDESCRIPTOR
{ dwVisibleMask DWORD }
{ dwDamageMask DWORD } ;
C-STRUCT: RECT
{ "LONG" "left" }
{ "LONG" "top" }
{ "LONG" "right" }
{ "LONG" "bottom" } ;
: <RECT> ( loc dim -- RECT )
[ RECT <struct> ] 2dip
[ drop [ first >>left ] [ second >>top ] bi ]

View File

@ -1,7 +1,8 @@
! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.syntax parser namespaces kernel math
windows.types generalizations math.bitwise classes.struct ;
windows.types generalizations math.bitwise classes.struct
literals ;
IN: windows.user32
! HKL for ActivateKeyboardLayout
@ -74,8 +75,10 @@ CONSTANT: WS_EX_RIGHTSCROLLBAR HEX: 00000000
CONSTANT: WS_EX_CONTROLPARENT HEX: 00010000
CONSTANT: WS_EX_STATICEDGE HEX: 00020000
CONSTANT: WS_EX_APPWINDOW HEX: 00040000
: WS_EX_OVERLAPPEDWINDOW ( -- n )
WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE bitor ; foldable
: WS_EX_PALETTEWINDOW ( -- n )
{ WS_EX_WINDOWEDGE WS_EX_TOOLWINDOW WS_EX_TOPMOST } flags ; foldable
@ -538,26 +541,26 @@ CONSTANT: DEVICE_NOTIFY_SERVICE_HANDLE 1
CONSTANT: DEVICE_NOTIFY_ALL_INTERFACE_CLASSES 4
C-STRUCT: DEV_BROADCAST_HDR
{ "DWORD" "dbch_size" }
{ "DWORD" "dbch_devicetype" }
{ "DWORD" "dbch_reserved" } ;
STRUCT: DEV_BROADCAST_HDR
{ dbch_size DWORD }
{ dbch_devicetype DWORD }
{ dbch_reserved DWORD } ;
C-STRUCT: DEV_BROADCAST_DEVICEW
{ "DWORD" "dbcc_size" }
{ "DWORD" "dbcc_devicetype" }
{ "DWORD" "dbcc_reserved" }
{ "GUID" "dbcc_classguid" }
{ { "WCHAR" 1 } "dbcc_name" } ;
STRUCT: DEV_BROADCAST_DEVICEW
{ dbcc_size DWORD }
{ dbcc_devicetype DWORD }
{ dbcc_reserved DWORD }
{ dbcc_classguid GUID }
{ dbcc_name WCHAR[1] } ;
CONSTANT: CCHDEVICENAME 32
C-STRUCT: MONITORINFOEX
{ "DWORD" "cbSize" }
{ "RECT" "rcMonitor" }
{ "RECT" "rcWork" }
{ "DWORD" "dwFlags" }
{ { "TCHAR" CCHDEVICENAME } "szDevice" } ;
STRUCT: MONITORINFOEX
{ cbSize DWORD }
{ rcMonitor RECT }
{ rcWork RECT }
{ dwFlags DWORD }
{ szDevice { "TCHAR" $ CCHDEVICENAME } } ;
TYPEDEF: MONITORINFOEX* LPMONITORINFOEX
TYPEDEF: MONITORINFOEX* LPMONITORINFO