Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -ur wine-1.3.14/dlls/user32/input.c wine-1.3.14-p/dlls/user32/input.c
- --- wine-1.3.14/dlls/user32/input.c 2011-02-18 20:28:55.000000000 +0200
- +++ wine-1.3.14-p/dlls/user32/input.c 2011-03-02 21:54:34.000000000 +0200
- @@ -22,6 +22,14 @@
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
- +/*
- + * Modififed by Reco 2009
- + * patch is based on
- + * http://win2kgaming.site90.com/phpBB2/viewtopic.php?f=6&t=7
- + * OldCigarettes Windows 2000 XP API Wrapper Pack
- + * Released under LGPL
- + */
- +
- #include "config.h"
- #include "wine/port.h"
- @@ -46,10 +54,45 @@
- #include "wine/server.h"
- #include "wine/debug.h"
- #include "wine/unicode.h"
- +#include "dinput.h"
- +DWORD WINAPI __pollInput(HWND) ;
- WINE_DEFAULT_DEBUG_CHANNEL(win);
- WINE_DECLARE_DEBUG_CHANNEL(keyboard);
- +BOOL mouse_init = FALSE;
- +LPDIRECTINPUT8A lpdi;
- +LPDIRECTINPUTDEVICE8A m_mouse;
- +
- +static DIMOUSESTATE2 mouse_state;
- +static DIMOUSESTATE2 mouse_state_prev;
- +
- +DWORD winCenterX, winCenterY;
- +
- +#define MOUSE_INPUT 0xABC123
- +#define RIM_TYPEMOUSE 0
- +#define RIM_INPUT 0x00000000
- +#define MOUSE_MOVE_RELATIVE 0x00000000
- +#define MOUSE_MOVE_ABSOLUTE 0x00000001
- +#define RI_MOUSE_LEFT_BUTTON_DOWN 0x0001
- +#define RI_MOUSE_LEFT_BUTTON_UP 0x0002
- +#define RI_MOUSE_RIGHT_BUTTON_DOWN 0x0004
- +#define RI_MOUSE_RIGHT_BUTTON_UP 0x0008
- +#define RI_MOUSE_MIDDLE_BUTTON_DOWN 0x0010
- +#define RI_MOUSE_MIDDLE_BUTTON_UP 0x0020
- +#define RI_MOUSE_BUTTON_1_DOWN RI_MOUSE_LEFT_BUTTON_DOWN
- +#define RI_MOUSE_BUTTON_1_UP RI_MOUSE_LEFT_BUTTON_UP
- +#define RI_MOUSE_BUTTON_2_DOWN RI_MOUSE_RIGHT_BUTTON_DOWN
- +#define RI_MOUSE_BUTTON_2_UP RI_MOUSE_RIGHT_BUTTON_UP
- +#define RI_MOUSE_BUTTON_3_DOWN RI_MOUSE_MIDDLE_BUTTON_DOWN
- +#define RI_MOUSE_BUTTON_3_UP RI_MOUSE_MIDDLE_BUTTON_UP
- +#define RI_MOUSE_BUTTON_4_DOWN 0x0040
- +#define RI_MOUSE_BUTTON_4_UP 0x0080
- +#define RI_MOUSE_BUTTON_5_DOWN 0x0100
- +#define RI_MOUSE_BUTTON_5_UP 0x0200
- +#define RI_MOUSE_WHEEL 0x0400
- +#define RIDEV_INPUTSINK 0x00000100
- +#define MOUSE_DEVICE_HANDLE 0x1337
- /***********************************************************************
- * get_key_state
- @@ -384,10 +427,74 @@
- /******************************************************************
- * RegisterRawInputDevices (USER32.@)
- */
- -BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(PRAWINPUTDEVICE pRawInputDevices, UINT uiNumDevices, UINT cbSize)
- +BOOL WINAPI RegisterRawInputDevices(PRAWINPUTDEVICE pRawInputDevices, UINT uiNumDevices, UINT cbSize)
- {
- - FIXME("(pRawInputDevices=%p, uiNumDevices=%d, cbSize=%d) stub!\n", pRawInputDevices, uiNumDevices, cbSize);
- + DWORD flags;
- + HWND hWnd;
- +
- + RECT rect;
- +
- + if(mouse_init) return FALSE;
- +
- + WARN("Only mouse is supported.\n");
- + if(uiNumDevices != 1)
- + return FALSE;
- + if(pRawInputDevices->usUsagePage != 0x01 || pRawInputDevices->usUsage != 0x02)
- + return FALSE;
- +
- + TRACE("Get the window handle if we need to...\n");
- + hWnd = pRawInputDevices->hwndTarget;
- + if(!hWnd) hWnd = GetActiveWindow();
- + if(!hWnd) return FALSE;
- +
- + if(!GetWindowRect(hWnd, &rect))
- + return FALSE;
- + winCenterX = (rect.right - rect.left) / 2;
- + winCenterY = (rect.bottom - rect.top ) / 2;
- +
- + TRACE("Trying to map flags to DirectX...\n");
- + flags = 0;
- + if(pRawInputDevices->dwFlags & RIDEV_INPUTSINK)
- + flags |= DISCL_BACKGROUND;
- + else
- + flags |= DISCL_FOREGROUND;
- + flags |= DISCL_NONEXCLUSIVE;
- +
- + TRACE("Init mouse\n");
- + if (FAILED(DirectInput8Create(GetModuleHandleW(NULL),
- + DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void**)&lpdi, NULL)))
- + {
- + ERR("DirectInput8Create failed.\n");
- + return FALSE;
- + }
- +
- + if (FAILED(lpdi->lpVtbl->CreateDevice(lpdi, &GUID_SysMouse, &m_mouse, NULL)))
- + {
- + ERR("CreateDevice failed.\n");
- + return FALSE;
- + }
- +
- + if (FAILED(m_mouse->lpVtbl->SetCooperativeLevel(m_mouse, hWnd, flags)))
- + {
- + ERR("SetCooperativeLevel failed.\n");
- + return FALSE;
- + }
- +
- + if (FAILED(m_mouse->lpVtbl->SetDataFormat(m_mouse, &c_dfDIMouse2)))
- + {
- + ERR("SetDataFormat failed.\n");
- + return FALSE;
- + }
- +
- + m_mouse->lpVtbl->Acquire(m_mouse); //OK if we don't acquire now
- + if(!CreateThread(NULL, 0, __pollInput, hWnd, 0, NULL))
- + {
- + ERR("Failed to CreateThread for __pollInput.\n");
- + return FALSE;
- + }
- +
- + mouse_init = TRUE;
- return TRUE;
- }
- @@ -397,12 +504,89 @@
- */
- UINT WINAPI GetRawInputData(HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader)
- {
- - FIXME("(hRawInput=%p, uiCommand=%d, pData=%p, pcbSize=%p, cbSizeHeader=%d) stub!\n",
- - hRawInput, uiCommand, pData, pcbSize, cbSizeHeader);
- + HRESULT hr;
- + RAWINPUT *raw;
- + POINT pos;
- + int i;
- - return 0;
- -}
- + if(!mouse_init) return FALSE;
- +
- + if(pData == NULL)
- + {
- + *pcbSize = sizeof(RAWINPUT);
- + return 0;
- + }
- +
- + raw = pData;
- + raw->header.dwType = RIM_TYPEMOUSE;
- + raw->header.dwSize = sizeof(RAWINPUT);
- + raw->header.hDevice = MOUSE_DEVICE_HANDLE;
- + raw->header.wParam = RIM_INPUT;
- +
- + hr = m_mouse->lpVtbl->GetDeviceState(m_mouse, sizeof(DIMOUSESTATE2), (LPVOID)&mouse_state);
- + if(FAILED(hr))
- + {
- + TRACE("Re-acquiring input.\n");
- + m_mouse->lpVtbl->Acquire(m_mouse);
- + while(hr == DIERR_INPUTLOST)
- + {
- + hr = m_mouse->lpVtbl->Acquire(m_mouse);
- + }
- + if(FAILED(hr))
- + {
- + TRACE("Mouse re-acquire failed.\n");
- + return NULL;
- + }
- + m_mouse->lpVtbl->GetDeviceState(m_mouse, sizeof(DIMOUSESTATE2), (LPVOID)&mouse_state);
- + }
- +
- + GetCursorPos(&pos);
- +
- + raw->data.mouse.usFlags = MOUSE_MOVE_ABSOLUTE;
- + raw->data.mouse.lLastX = pos.x;
- + raw->data.mouse.lLastY = pos.y;
- + raw->data.mouse.usButtonData = mouse_state.lZ & 0xffff;
- + raw->data.mouse.usButtonFlags = 0;
- + raw->data.mouse.ulRawButtons = 0;
- +
- + if(raw->data.mouse.usButtonData != 0) raw->data.mouse.usButtonFlags |= RI_MOUSE_WHEEL;
- +
- + for(i = 0; i < 8; i++)
- + if(mouse_state.rgbButtons[i] & 0x80)
- + raw->data.mouse.ulRawButtons |= 1<<i;
- +
- + if(mouse_state.rgbButtons[0] & 0x80 && !(mouse_state_prev.rgbButtons[0] & 0x80))
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_LEFT_BUTTON_DOWN;
- + if(!(mouse_state.rgbButtons[0] & 0x80) && mouse_state_prev.rgbButtons[0] & 0x80)
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_LEFT_BUTTON_UP;
- +
- + if(mouse_state.rgbButtons[1] & 0x80 && !(mouse_state_prev.rgbButtons[1] & 0x80))
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_RIGHT_BUTTON_DOWN;
- +
- + if(!(mouse_state.rgbButtons[1] & 0x80) && mouse_state_prev.rgbButtons[1] & 0x80)
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_RIGHT_BUTTON_UP;
- +
- + if(!(mouse_state.rgbButtons[2] & 0x80) && mouse_state_prev.rgbButtons[2] & 0x80)
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_MIDDLE_BUTTON_UP;
- +
- + if(mouse_state.rgbButtons[3] & 0x80 && !(mouse_state_prev.rgbButtons[3] & 0x80))
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_DOWN;
- +
- + if(!(mouse_state.rgbButtons[3] & 0x80) && mouse_state_prev.rgbButtons[3] & 0x80)
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_UP;
- +
- + if(mouse_state.rgbButtons[4] & 0x80 && !(mouse_state_prev.rgbButtons[4] & 0x80))
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_DOWN;
- +
- + if(!(mouse_state.rgbButtons[4] & 0x80) && mouse_state_prev.rgbButtons[4] & 0x80)
- + raw->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_UP;
- +
- + memcpy(&mouse_state_prev, &mouse_state, sizeof(DIMOUSESTATE2));
- +
- + return sizeof(RAWINPUT);
- +
- +}
- /******************************************************************
- * GetRawInputBuffer (USER32.@)
- @@ -436,15 +620,91 @@
- return 0;
- }
- -
- +DWORD WINAPI __pollInput(HWND hWnd)
- +{
- + for(;;)
- + {
- + Sleep(1000/60);
- + TRACE("SendMessageW(%p,%p,%p,%p)\n", hWnd, WM_INPUT, RIM_INPUT, MOUSE_INPUT);
- + SendMessageW(hWnd, WM_INPUT, RIM_INPUT, MOUSE_INPUT);
- + }
- + return 0;
- +}
- /******************************************************************
- * GetRegisteredRawInputDevices (USER32.@)
- */
- UINT WINAPI GetRegisteredRawInputDevices(PRAWINPUTDEVICE pRawInputDevices, PUINT puiNumDevices, UINT cbSize)
- {
- - FIXME("(pRawInputDevices=%p, puiNumDevices=%p, cbSize=%d) stub!\n", pRawInputDevices, puiNumDevices, cbSize);
- + HRESULT hr;
- + RAWINPUT *raw;
- + POINT pos;
- + int i;
- + DWORD flags;
- + HWND hWnd;
- +
- + RECT rect;
- +
- + if(mouse_init) return FALSE;
- +
- + WARN("Only mouse is supported.\n");
- + if(puiNumDevices != 1)
- + return FALSE;
- + if(pRawInputDevices->usUsagePage != 0x01 || pRawInputDevices->usUsage != 0x02)
- + return FALSE;
- +
- + TRACE("Get the window handle if we need to...\n");
- + hWnd = pRawInputDevices->hwndTarget;
- + if(!hWnd) hWnd = GetActiveWindow();
- + if(!hWnd) return FALSE;
- +
- + if(!GetWindowRect(hWnd, &rect))
- + return FALSE;
- + winCenterX = (rect.right - rect.left) / 2;
- + winCenterY = (rect.bottom - rect.top ) / 2;
- +
- + TRACE("Trying to map flags to DirectX...\n");
- + flags = 0;
- + if(pRawInputDevices->dwFlags & RIDEV_INPUTSINK)
- + flags |= DISCL_BACKGROUND;
- + else
- + flags |= DISCL_FOREGROUND;
- + flags |= DISCL_NONEXCLUSIVE;
- - return 0;
- + TRACE("Init mouse\n");
- + if (FAILED(DirectInput8Create(GetModuleHandleW(NULL),
- + DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void**)&lpdi, NULL)))
- + {
- + ERR("DirectInput8Create failed.\n");
- + return FALSE;
- + }
- +
- + if (FAILED(lpdi->lpVtbl->CreateDevice(lpdi, &GUID_SysMouse, &m_mouse, NULL)))
- + {
- + ERR("CreateDevice failed.\n");
- + return FALSE;
- + }
- +
- + if (FAILED(m_mouse->lpVtbl->SetCooperativeLevel(m_mouse, hWnd, flags)))
- + {
- + ERR("SetCooperativeLevel failed.\n");
- + return FALSE;
- + }
- +
- + if (FAILED(m_mouse->lpVtbl->SetDataFormat(m_mouse, &c_dfDIMouse2)))
- + {
- + ERR("SetDataFormat failed.\n");
- + return FALSE;
- + }
- +
- + m_mouse->lpVtbl->Acquire(m_mouse); //OK if we don't acquire now
- +
- + if(!CreateThread(NULL, 0, __pollInput, hWnd, 0, NULL))
- + {
- + ERR("Failed to CreateThread for __pollInput.\n");
- + return FALSE;
- + }
- +
- + mouse_init = TRUE;
- }
- Только в wine-1.3.14-p/dlls/user32: input.c.orig
- diff -ur wine-1.3.14/dlls/user32/Makefile.in wine-1.3.14-p/dlls/user32/Makefile.in
- --- wine-1.3.14/dlls/user32/Makefile.in 2011-02-18 20:28:55.000000000 +0200
- +++ wine-1.3.14-p/dlls/user32/Makefile.in 2011-03-02 21:55:14.000000000 +0200
- @@ -1,7 +1,7 @@
- EXTRADEFS = -D_USER32_ -D_WINABLE_
- MODULE = user32.dll
- IMPORTLIB = user32
- -IMPORTS = gdi32 version advapi32
- +IMPORTS = gdi32 version advapi32 dinput8 dinput dxguid
- DELAYIMPORTS = imm32
- C_SRCS = \
- Только в wine-1.3.14-p/dlls/user32: Makefile.in.orig
- diff -ur wine-1.3.14/include/winuser.h wine-1.3.14-p/include/winuser.h
- --- wine-1.3.14/include/winuser.h 2011-02-18 20:28:55.000000000 +0200
- +++ wine-1.3.14-p/include/winuser.h 2011-03-02 21:54:34.000000000 +0200
- @@ -491,8 +491,8 @@
- struct {
- USHORT usButtonFlags;
- USHORT usButtonData;
- - } DUMMYSTRUCTNAME;
- - } DUMMYUNIONNAME;
- + };
- + };
- ULONG ulRawButtons;
- LONG lLastX;
- LONG lLastY;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement