World Of Tanks - myszka zmienia swoje położenie dopiero po kliknięciu.

Gry, do uruchomienia których potrzebne są programy typu Wine/Cedega/CrossOver albo jakieś emulatory.
Grzegor1922
Piegowaty Guziec
Piegowaty Guziec
Posty: 1
Rejestracja: 28 sty 2012, 14:48
Wersja Ubuntu: 11.10
Środowisko graficzne: Unity

World Of Tanks - myszka zmienia swoje położenie dopiero po kliknięciu.

Post autor: Grzegor1922 »

Witam,
Jestem nowym forumowiczem i nie wiem czy dobrze umieściłem temat :]

A więc tak:
Zainstalowałem sobie world of tanks przez wine wszystko było cacy ale nie działało więc pobrałem WotFlix (jakoś tak ) i umieściłem gra ładnie się załącza tylko jest jeden problem... Myszka się nie rusza dopiero po kliknięciu zmienia swoje położenie.
Po wnikliwej analizie i poszukiwaniach w gogle odnalazłem kod aby myszka działała :

Kod: Zaznacz cały

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;
I jeszcze dwa pliczki wszystkie z zakończeniem .patch.
Teraz pytanie jak to wsadzić (zaimplementować do wine)
Proszę o pomoc :[
Ostatnio zmieniony 28 sty 2012, 15:37 przez Grzegor1922, łącznie zmieniany 1 raz.
ODPOWIEDZ

Wróć do „Z innych systemów”

Kto jest online

Użytkownicy przeglądający to forum: Obecnie na forum nie ma żadnego zarejestrowanego użytkownika i 9 gości