From: Joe Groff Date: Mon, 31 Aug 2009 17:45:39 +0000 (-0500) Subject: fix some things that broke in the windows UI/game-input backends X-Git-Tag: 0.97~5644 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=9bd7471696a55e75d71db1d88f136cf264388f8f fix some things that broke in the windows UI/game-input backends --- diff --git a/basis/game-input/dinput/dinput.factor b/basis/game-input/dinput/dinput.factor index 0fed15931d..6c72dc05cc 100755 --- a/basis/game-input/dinput/dinput.factor +++ b/basis/game-input/dinput/dinput.factor @@ -95,6 +95,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ : find-device-axes-callback ( -- alien ) [ ! ( lpddoi pvRef -- BOOL ) + [ DIDEVICEOBJECTINSTANCEW memory>struct ] dip +controller-devices+ get at swap guidType>> { { [ dup GUID_XAxis = ] [ drop 0.0 >>x ] } @@ -142,7 +143,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ : find-controller-callback ( -- alien ) [ ! ( lpddi pvRef -- BOOL ) - drop guidInstance>> add-controller + drop DIDEVICEINSTANCEW memory>struct guidInstance>> add-controller DIENUM_CONTINUE ] LPDIENUMDEVICESCALLBACKW ; inline @@ -255,7 +256,7 @@ M: dinput-game-input-backend product-string utf16n alien>string ; M: dinput-game-input-backend product-id - handle>> device-info guidProduct>> ; + handle>> device-info guidProduct>> ; M: dinput-game-input-backend instance-id handle>> device-guid ; @@ -311,9 +312,9 @@ CONSTANT: pov-values : fill-mouse-state ( buffer count -- state ) [ +mouse-state+ get ] 2dip swap [ nth (fill-mouse-state) ] curry each ; -: get-device-state ( device byte-array -- ) +: get-device-state ( device DIJOYSTATE2 -- ) [ dup IDirectInputDevice8W::Poll ole32-error ] dip - [ length ] keep + [ byte-length ] keep IDirectInputDevice8W::GetDeviceState ole32-error ; : (read-controller) ( handle template -- state ) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index cf4966b756..fd06b2cb76 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -614,8 +614,8 @@ M: windows-ui-backend do-events : default-position-RECT ( RECT -- RECT' ) dup get-RECT-width/height - [ CW_USEDEFAULT + >>bottom ] dip - CW_USEDEFAULT + >>right + [ CW_USEDEFAULT + >>right ] dip + CW_USEDEFAULT + >>bottom CW_USEDEFAULT >>left CW_USEDEFAULT >>top ; @@ -758,7 +758,7 @@ M: windows-ui-backend beep ( -- ) : client-area>RECT ( hwnd -- RECT ) RECT [ GetClientRect win32-error=0/f ] - [ "POINT" byte-array>struct-array [ ClientToScreen drop ] with each ] + [ >c-ptr "POINT" byte-array>struct-array [ ClientToScreen drop ] with each ] [ nip ] 2tri ; : hwnd>RECT ( hwnd -- RECT ) diff --git a/basis/windows/dinput/constants/constants.factor b/basis/windows/dinput/constants/constants.factor index ccc28c00e9..ec70a3cdd6 100755 --- a/basis/windows/dinput/constants/constants.factor +++ b/basis/windows/dinput/constants/constants.factor @@ -2,7 +2,7 @@ USING: windows.dinput windows.kernel32 windows.ole32 windows.com windows.com.syntax alien alien.c-types alien.syntax kernel system namespaces combinators sequences fry math accessors macros words quotations libc continuations generalizations splitting locals assocs init -struct-arrays memoize ; +struct-arrays memoize classes.struct ; IN: windows.dinput.constants ! Some global variables aren't provided by the DirectInput DLL (they're in the @@ -38,14 +38,6 @@ MEMO: heap-size* ( c-type -- n ) heap-size ; : (flags) ( array -- n ) 0 [ (flag) bitor ] reduce ; -: (DIOBJECTDATAFORMAT) ( pguid dwOfs dwType dwFlags alien -- alien ) - [ { - [ set-DIOBJECTDATAFORMAT-dwFlags ] - [ set-DIOBJECTDATAFORMAT-dwType ] - [ set-DIOBJECTDATAFORMAT-dwOfs ] - [ set-DIOBJECTDATAFORMAT-pguid ] - } cleave ] keep ; - : ( struct {pguid-var,field,index,dwType-flags,dwFlags} -- alien ) { [ first dup word? [ get ] when ] @@ -54,10 +46,10 @@ MEMO: heap-size* ( c-type -- n ) heap-size ; [ fourth (flags) ] [ 4 swap nth (flag) ] } cleave - "DIOBJECTDATAFORMAT" (DIOBJECTDATAFORMAT) ; + DIOBJECTDATAFORMAT ; :: malloc-DIOBJECTDATAFORMAT-array ( struct array -- alien ) - [let | alien [ array length "DIOBJECTDATAFORMAT" malloc-struct-array ] | + [let | alien [ array length DIOBJECTDATAFORMAT malloc-struct-array ] | array [| args i | struct args i alien set-nth @@ -65,22 +57,10 @@ MEMO: heap-size* ( c-type -- n ) heap-size ; alien ] ; -: (DIDATAFORMAT) ( dwSize dwObjSize dwFlags dwDataSize dwNumObjs rgodf alien -- alien ) - [ - { - [ set-DIDATAFORMAT-rgodf ] - [ set-DIDATAFORMAT-dwNumObjs ] - [ set-DIDATAFORMAT-dwDataSize ] - [ set-DIDATAFORMAT-dwFlags ] - [ set-DIDATAFORMAT-dwObjSize ] - [ set-DIDATAFORMAT-dwSize ] - } cleave - ] keep ; - : ( dwFlags dwDataSize struct rgodf-array -- alien ) - [ "DIDATAFORMAT" heap-size "DIOBJECTDATAFORMAT" heap-size ] 4 ndip + [ DIDATAFORMAT heap-size DIOBJECTDATAFORMAT heap-size ] 4 ndip [ nip length ] [ malloc-DIOBJECTDATAFORMAT-array ] 2bi - "DIDATAFORMAT" (DIDATAFORMAT) ; + DIDATAFORMAT ; : initialize ( symbol quot -- ) call swap set-global ; inline @@ -861,7 +841,7 @@ MEMO: heap-size* ( c-type -- n ) heap-size ; { c_dfDIKeyboard c_dfDIKeyboard_HID c_dfDIMouse2 c_dfDIJoystick2 - } [ [ DIDATAFORMAT-rgodf free ] uninitialize ] each ; + } [ [ rgodf>> free ] uninitialize ] each ; PRIVATE> diff --git a/basis/windows/types/types.factor b/basis/windows/types/types.factor index 8a5c963de0..c882ba2e7f 100755 --- a/basis/windows/types/types.factor +++ b/basis/windows/types/types.factor @@ -330,9 +330,7 @@ STRUCT: PIXELFORMATDESCRIPTOR { dwDamageMask DWORD } ; : ( loc dim -- RECT ) - [ RECT ] 2dip - [ drop [ first >>left ] [ second >>top ] bi ] - [ v+ [ first >>right ] [ second >>bottom ] bi ] 2bi ; + dupd v+ [ first2 ] bi@ RECT ; TYPEDEF: RECT* PRECT TYPEDEF: RECT* LPRECT