Rémi Bernon : dinput: Move mouse (Un)Acquire functions around.
Alexandre Julliard
julliard at winehq.org
Wed Oct 13 15:59:25 CDT 2021
Module: wine
Branch: master
Commit: 7908d25f235a968ff968f7187586d2fa3a8a143c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7908d25f235a968ff968f7187586d2fa3a8a143c
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Wed Oct 13 09:21:16 2021 +0200
dinput: Move mouse (Un)Acquire functions around.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/mouse.c | 152 +++++++++++++++++++++++++---------------------------
1 file changed, 74 insertions(+), 78 deletions(-)
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index e94cd4e7c50..c1992a8557f 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -463,84 +463,6 @@ static void warp_check( SysMouseImpl* This, BOOL force )
}
-/******************************************************************************
- * Acquire : gets exclusive control of the mouse
- */
-static HRESULT WINAPI SysMouseWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
-{
- SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
- POINT point;
- HRESULT res;
-
- TRACE("(this=%p)\n",This);
-
- if ((res = IDirectInputDevice2WImpl_Acquire(iface)) != DI_OK) return res;
-
- /* Init the mouse state */
- GetCursorPos( &point );
- if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
- {
- This->m_state.lX = point.x;
- This->m_state.lY = point.y;
- } else {
- This->m_state.lX = 0;
- This->m_state.lY = 0;
- This->org_coords = point;
- }
- This->m_state.lZ = 0;
- This->m_state.rgbButtons[0] = GetKeyState(VK_LBUTTON) & 0x80;
- This->m_state.rgbButtons[1] = GetKeyState(VK_RBUTTON) & 0x80;
- This->m_state.rgbButtons[2] = GetKeyState(VK_MBUTTON) & 0x80;
-
- if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
- {
- ShowCursor(FALSE); /* hide cursor */
- warp_check( This, TRUE );
- }
- else if (This->warp_override == WARP_FORCE_ON)
- {
- /* Need a window to warp mouse in. */
- if (!This->base.win) This->base.win = GetDesktopWindow();
- warp_check( This, TRUE );
- }
- else if (This->clipped)
- {
- ClipCursor( NULL );
- This->clipped = FALSE;
- }
-
- return DI_OK;
-}
-
-/******************************************************************************
- * Unacquire : frees the mouse
- */
-static HRESULT WINAPI SysMouseWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
-{
- SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface);
- HRESULT res;
-
- TRACE("(this=%p)\n",This);
-
- if ((res = IDirectInputDevice2WImpl_Unacquire(iface)) != DI_OK) return res;
-
- if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
- {
- ClipCursor(NULL);
- ShowCursor(TRUE); /* show cursor */
- This->clipped = FALSE;
- }
-
- /* And put the mouse cursor back where it was at acquire time */
- if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON)
- {
- TRACE("warping mouse back to %s\n", wine_dbgstr_point(&This->org_coords));
- SetCursorPos(This->org_coords.x, This->org_coords.y);
- }
-
- return DI_OK;
-}
-
/******************************************************************************
* GetDeviceState : returns the "state" of the mouse.
*
@@ -676,6 +598,80 @@ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
return res;
}
+static HRESULT WINAPI SysMouseWImpl_Acquire( IDirectInputDevice8W *iface )
+{
+ SysMouseImpl *impl = impl_from_IDirectInputDevice8W( iface );
+ POINT point;
+ HRESULT res;
+
+ TRACE( "iface %p\n", iface );
+
+ if ((res = IDirectInputDevice2WImpl_Acquire( iface )) != DI_OK) return res;
+
+ /* Init the mouse state */
+ GetCursorPos( &point );
+ if (impl->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
+ {
+ impl->m_state.lX = point.x;
+ impl->m_state.lY = point.y;
+ }
+ else
+ {
+ impl->m_state.lX = 0;
+ impl->m_state.lY = 0;
+ impl->org_coords = point;
+ }
+ impl->m_state.lZ = 0;
+ impl->m_state.rgbButtons[0] = GetKeyState( VK_LBUTTON ) & 0x80;
+ impl->m_state.rgbButtons[1] = GetKeyState( VK_RBUTTON ) & 0x80;
+ impl->m_state.rgbButtons[2] = GetKeyState( VK_MBUTTON ) & 0x80;
+
+ if (impl->base.dwCoopLevel & DISCL_EXCLUSIVE)
+ {
+ ShowCursor( FALSE ); /* hide cursor */
+ warp_check( impl, TRUE );
+ }
+ else if (impl->warp_override == WARP_FORCE_ON)
+ {
+ /* Need a window to warp mouse in. */
+ if (!impl->base.win) impl->base.win = GetDesktopWindow();
+ warp_check( impl, TRUE );
+ }
+ else if (impl->clipped)
+ {
+ ClipCursor( NULL );
+ impl->clipped = FALSE;
+ }
+
+ return DI_OK;
+}
+
+static HRESULT WINAPI SysMouseWImpl_Unacquire( IDirectInputDevice8W *iface )
+{
+ SysMouseImpl *impl = impl_from_IDirectInputDevice8W( iface );
+ HRESULT res;
+
+ TRACE( "iface %p\n", iface );
+
+ if ((res = IDirectInputDevice2WImpl_Unacquire( iface )) != DI_OK) return res;
+
+ if (impl->base.dwCoopLevel & DISCL_EXCLUSIVE)
+ {
+ ClipCursor( NULL );
+ ShowCursor( TRUE ); /* show cursor */
+ impl->clipped = FALSE;
+ }
+
+ /* And put the mouse cursor back where it was at acquire time */
+ if (impl->base.dwCoopLevel & DISCL_EXCLUSIVE || impl->warp_override == WARP_FORCE_ON)
+ {
+ TRACE( "warping mouse back to %s\n", wine_dbgstr_point( &impl->org_coords ) );
+ SetCursorPos( impl->org_coords.x, impl->org_coords.y );
+ }
+
+ return DI_OK;
+}
+
static const IDirectInputDevice8WVtbl SysMouseWvt =
{
IDirectInputDevice2WImpl_QueryInterface,
More information about the wine-cvs
mailing list