From 4758cca22319f5c84a2ef623dde3e797fafd1a8b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 17 Sep 2009 14:22:49 -0500 Subject: [PATCH] fix dinput device hotplug support --- basis/game-input/dinput/dinput.factor | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/basis/game-input/dinput/dinput.factor b/basis/game-input/dinput/dinput.factor index ea3100f95f..a7489f26a2 100755 --- a/basis/game-input/dinput/dinput.factor +++ b/basis/game-input/dinput/dinput.factor @@ -160,19 +160,24 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ [ device-attached? not ] filter [ remove-controller ] each ; -: device-interface? ( dbt-broadcast-hdr -- ? ) - dbch_devicetype>> DBT_DEVTYP_DEVICEINTERFACE = ; +: ?device-interface ( dbt-broadcast-hdr -- ? ) + dup dbch_devicetype>> DBT_DEVTYP_DEVICEINTERFACE = + [ >c-ptr DEV_BROADCAST_DEVICEW memory>struct ] + [ drop f ] if ; inline : device-arrived ( dbt-broadcast-hdr -- ) - device-interface? [ find-controllers ] when ; + ?device-interface [ find-controllers ] when ; inline : device-removed ( dbt-broadcast-hdr -- ) - device-interface? [ find-and-remove-detached-devices ] when ; + ?device-interface [ find-and-remove-detached-devices ] when ; inline + +: ( wParam -- struct ) + DEV_BROADCAST_HDR memory>struct ; : handle-wm-devicechange ( hWnd uMsg wParam lParam -- ) [ 2drop ] 2dip swap { - { [ dup DBT_DEVICEARRIVAL = ] [ drop device-arrived ] } - { [ dup DBT_DEVICEREMOVECOMPLETE = ] [ drop device-removed ] } + { [ dup DBT_DEVICEARRIVAL = ] [ drop device-arrived ] } + { [ dup DBT_DEVICEREMOVECOMPLETE = ] [ drop device-removed ] } [ 2drop ] } cond ;