Created
March 20, 2011 23:01
-
-
Save winex/878773 to your computer and use it in GitHub Desktop.
world of tanks patches for wine (based on http://bugs.winehq.org/show_bug.cgi?id=20395)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: wine1.3-1.3.23/dlls/user32/input.c | |
=================================================================== | |
--- wine1.3-1.3.23.orig/dlls/user32/input.c 2011-06-25 02:29:32.000000000 +0400 | |
+++ wine1.3-1.3.23/dlls/user32/input.c 2011-07-01 19:29:32.965148133 +0400 | |
@@ -22,6 +22,14 @@ | |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA | |
*/ | |
+/* | |
+ * Modififed by Reco 2009, winex 2011 | |
+ * 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" | |
@@ -48,10 +56,48 @@ | |
#include "wine/server.h" | |
#include "wine/debug.h" | |
#include "wine/unicode.h" | |
+#include "dinput.h" | |
WINE_DEFAULT_DEBUG_CHANNEL(win); | |
WINE_DECLARE_DEBUG_CHANNEL(keyboard); | |
+DWORD WINAPI __pollInput(HWND); | |
+ | |
+BOOL mouse_init = FALSE; | |
+LPDIRECTINPUT8A lpdi; | |
+LPDIRECTINPUTDEVICE8A m_mouse; | |
+ | |
+static DIMOUSESTATE2 mouse_state; | |
+static DIMOUSESTATE2 mouse_state_prev; | |
+ | |
+#define MOUSE_INPUT 0xABC123 | |
+#define RIM_TYPEMOUSE 0 | |
+#define RIM_INPUT 0x00000000 | |
+ | |
+#define MOUSE_MOVE_RELATIVE 0x00000000 | |
+#define MOUSE_MOVE_ABSOLUTE 0x00000001 | |
+#define MOUSE_VIRTUAL_DESKTOP 0x00000002 | |
+ | |
+#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 | |
@@ -488,10 +534,67 @@ | |
/****************************************************************** | |
* 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; | |
+ | |
+ 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; | |
+ | |
+ 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; | |
} | |
@@ -501,12 +604,87 @@ | |
*/ | |
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; | |
+ 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); | |
+ if (hr == DIERR_INPUTLOST) | |
+ hr = m_mouse->lpVtbl->Acquire(m_mouse); | |
+ if (FAILED(hr)) | |
+ { | |
+ TRACE("Mouse re-acquire failed.\n"); | |
+ return 0; | |
+ } | |
+ m_mouse->lpVtbl->GetDeviceState(m_mouse, sizeof(DIMOUSESTATE2), (LPVOID)&mouse_state); | |
+ } | |
+ | |
+ raw->data.mouse.usFlags = MOUSE_MOVE_RELATIVE; | |
+ raw->data.mouse.lLastX = mouse_state.lX; | |
+ raw->data.mouse.lLastY = mouse_state.lY; | |
+ 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_DOWN; | |
+ | |
+ 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.@) | |
@@ -540,15 +718,80 @@ | |
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); | |
+ DWORD flags; | |
+ HWND hWnd; | |
- return 0; | |
+ 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; | |
+ | |
+ 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; | |
} | |
Index: wine1.3-1.3.23/dlls/user32/Makefile.in | |
=================================================================== | |
--- wine1.3-1.3.23.orig/dlls/user32/Makefile.in 2011-06-25 02:29:32.000000000 +0400 | |
+++ wine1.3-1.3.23/dlls/user32/Makefile.in 2011-07-01 19:29:32.965148133 +0400 | |
@@ -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 = \ | |
Index: wine1.3-1.3.23/include/winuser.h | |
=================================================================== | |
--- wine1.3-1.3.23.orig/include/winuser.h 2011-06-25 02:29:32.000000000 +0400 | |
+++ wine1.3-1.3.23/include/winuser.h 2011-07-01 19:29:32.969148159 +0400 | |
@@ -491,8 +491,8 @@ | |
struct { | |
USHORT usButtonFlags; | |
USHORT usButtonData; | |
- } DUMMYSTRUCTNAME; | |
- } DUMMYUNIONNAME; | |
+ }; | |
+ }; | |
ULONG ulRawButtons; | |
LONG lLastX; | |
LONG lLastY; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: wine1.3-1.3.23/dlls/user32/input.c | |
=================================================================== | |
--- wine1.3-1.3.23.orig/dlls/user32/input.c 2011-07-01 19:29:32.965148133 +0400 | |
+++ wine1.3-1.3.23/dlls/user32/input.c 2011-07-01 19:29:33.397150275 +0400 | |
@@ -544,6 +544,11 @@ | |
WARN("Only mouse is supported.\n"); | |
if(uiNumDevices != 1) | |
return FALSE; | |
+ if ((pRawInputDevices->usUsagePage == 0x01) && (pRawInputDevices->usUsage == 0x06)) | |
+ { | |
+ FIXME("Returning TRUE for keyboard!!!\n"); | |
+ return TRUE; | |
+ } | |
if(pRawInputDevices->usUsagePage != 0x01 || pRawInputDevices->usUsage != 0x02) | |
return FALSE; | |
@@ -741,6 +746,11 @@ | |
WARN("Only mouse is supported.\n"); | |
if(puiNumDevices != 1) | |
return FALSE; | |
+ if ((pRawInputDevices->usUsagePage == 0x01) && (pRawInputDevices->usUsage == 0x06)) | |
+ { | |
+ FIXME("Returning TRUE for keyboard!!!\n"); | |
+ return TRUE; | |
+ } | |
if(pRawInputDevices->usUsagePage != 0x01 || pRawInputDevices->usUsage != 0x02) | |
return FALSE; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: wine1.3-1.3.23/dlls/winex11.drv/mouse.c | |
=================================================================== | |
--- wine1.3-1.3.23.orig/dlls/winex11.drv/mouse.c 2011-06-25 02:29:32.000000000 +0400 | |
+++ wine1.3-1.3.23/dlls/winex11.drv/mouse.c 2011-07-01 19:29:33.765152106 +0400 | |
@@ -200,14 +200,30 @@ | |
void set_window_cursor( Window window, HCURSOR handle ) | |
{ | |
Cursor cursor, prev; | |
+ char* hwgl; | |
+ hwgl = getenv("WINE_CURSOR"); | |
wine_tsx11_lock(); | |
if (!handle) cursor = get_empty_cursor(); | |
else if (!cursor_context || XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor )) | |
{ | |
/* try to create it */ | |
wine_tsx11_unlock(); | |
- if (!(cursor = create_cursor( handle ))) return; | |
+ if (hwgl && (strcmp(hwgl, "X") == 0 || strcmp(hwgl, "XNOJIG") == 0) ) | |
+ { | |
+ if (!(cursor = XCreateFontCursor(gdi_display, XC_left_ptr))) | |
+ return; | |
+ } | |
+ else if (hwgl != NULL) | |
+ { | |
+ if (!(cursor = XCreateFontCursor(gdi_display, XC_dotbox))) | |
+ return; | |
+ } | |
+ else | |
+ { | |
+ if (!(cursor = create_cursor( handle ))) | |
+ return; | |
+ } | |
wine_tsx11_lock(); | |
if (!cursor_context) cursor_context = XUniqueContext(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment