Mitchell Stokes BGE MouseWarp patch + warning fix
authorCampbell Barton <ideasman42@gmail.com>
Wed, 11 Nov 2009 08:32:29 +0000 (08:32 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 11 Nov 2009 08:32:29 +0000 (08:32 +0000)
[#19854] [bugfix] Fix for broken Rasterizer mouse functions
---
This patch fixes the embedded player's ability to control the mouse. For example, hiding and unhiding the mouse cursor
did not work in 2.5, nor could the mouse's position be controlled. This was because these parts still needed to be ported
to 2.5 window manager code.

source/blender/editors/transform/transform_manipulator.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_window.c
source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
source/gameengine/BlenderRoutines/KX_BlenderGL.h

index a4e093644c35349c05acd169b37d51611888975a..fe79e9b428520e2abbf027048a22d4c0b21c389d 100644 (file)
@@ -1563,7 +1563,7 @@ void BIF_draw_manipulator(const bContext *C)
                        break;
                }
 
-               mul_mat3_m4_fl((float *)rv3d->twmat, get_manipulator_drawsize(ar));
+               mul_mat3_m4_fl(rv3d->twmat, get_manipulator_drawsize(ar));
        }
 
        if(v3d->twflag & V3D_DRAW_MANIPULATOR) {
index a784a1d560aa1117543931939649c90b461d1bde..554418e6483b1d1f9db6c0d87bc10928b32ee5e3 100644 (file)
@@ -86,6 +86,8 @@ void          WM_timecursor           (struct wmWindow *win, int nr);
 void           *WM_paint_cursor_activate(struct wmWindowManager *wm, int (*poll)(struct bContext *C), void (*draw)(struct bContext *C, int, int, void *customdata), void *customdata);
 void           WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
 
+void           WM_cursor_warp          (struct wmWindow *win, int x, int y);
+
                        /* keyconfig and keymap */
 wmKeyConfig *WM_keyconfig_add  (struct wmWindowManager *wm, char *idname);
 void           WM_keyconfig_free       (struct wmKeyConfig *keyconf);
index ae6d9ddb4255138b6bccc3c8dfb34576d23c7230..a4a22f347b78320720dd070127071aa9c0c7bbf6 100644 (file)
@@ -972,3 +972,17 @@ void WM_setprefsize(int stax, int stay, int sizx, int sizy)
        prefsizy= sizy;
 }
 
+/* This function requires access to the GHOST_SystemHandle (g_system) */
+void WM_cursor_warp(wmWindow *win, int x, int y)
+{
+       if (win && win->ghostwin) {
+               int oldx=x, oldy=y;
+
+               y= win->sizey -y - 1;
+               GHOST_ClientToScreen(win->ghostwin, x, y, &x, &y);
+               GHOST_SetCursorPosition(g_system, x, y);
+
+               win->eventstate->prevx= oldx;
+               win->eventstate->prevy= oldy;
+       }
+}
\ No newline at end of file
index 73803846d70f660e7a111adfbc776c15f5fe3744..e53a96ad9f69cd70cd2ce4b9c243ae0b257e8f6d 100644 (file)
@@ -138,17 +138,17 @@ void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate)
        {
        case MOUSE_INVISIBLE:
                {
-                       BL_HideMouse();
+                       BL_HideMouse(m_win);
                        break;
                }
        case MOUSE_WAIT:
                {
-                       BL_WaitMouse();
+                       BL_WaitMouse(m_win);
                        break;
                }
        case MOUSE_NORMAL:
                {
-                       BL_NormalMouse();
+                       BL_NormalMouse(m_win);
                        break;
                }
        default:
@@ -166,7 +166,7 @@ void KX_BlenderCanvas::SetMousePosition(int x,int y)
        int winY = m_frame_rect.GetBottom();
        int winH = m_frame_rect.GetHeight();
        
-       BL_warp_pointer(winX + x, winY + (winH-y-1));
+       BL_warp_pointer(m_win, winX + x, winY + (winH-y-1));
 }
 
 
index 5967ce78b4696f0d099d28769b978872da181b2d..2c6962b5863835bb68b84cc1894f566bdfe245ef 100644 (file)
@@ -64,7 +64,7 @@ public:
         * 
         * @param area The Blender ARegion to run the game within.
         */
-       KX_BlenderCanvas(struct wmWindow* win, struct RAS_Rect &rect);
+       KX_BlenderCanvas(struct wmWindow* win, class RAS_Rect &rect);
        ~KX_BlenderCanvas();
 
                void 
index bb02f3b372eae303d4ccce13e6f0d6ba61ea78f5..b718dfc1acd642d5b93cde891b16dec9045e0125 100644 (file)
@@ -73,11 +73,11 @@ extern "C" {
 #include "BKE_image.h"
 
 extern "C" {
-//XXX #include "BDR_drawmesh.h"
-//XXX #include "BIF_mywindow.h"
-//XXX #include "BIF_toolbox.h"
-//XXX #include "BIF_graphics.h" /* For CURSOR_NONE CURSOR_WAIT CURSOR_STD */
-void wm_window_swap_buffers(wmWindow *win); // wm_window.h
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm_event_system.h"
+#include "wm_cursors.h"
+#include "wm_window.h"
 }
 
 /* end of blender block */
@@ -90,16 +90,14 @@ void spack(unsigned int ucol)
        glColor3ub(cp[3], cp[2], cp[1]);
 }
 
-void BL_warp_pointer(int x,int y)
+void BL_warp_pointer(wmWindow *win, int x,int y)
 {
-       //XXX warp_pointer(x,y);
+       WM_cursor_warp(win, x, y);
 }
 
 void BL_SwapBuffers(wmWindow *win)
 {
-       //wmWindow *window= CTX_wm_window(C);
        wm_window_swap_buffers(win);
-       //XXX myswapbuffers();
 }
 
 void DisableForText()
@@ -194,21 +192,21 @@ void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int widt
        glEnable(GL_DEPTH_TEST);
 }
 
-void BL_HideMouse()
+void BL_HideMouse(wmWindow *win)
 {
-       //XXX set_cursor(CURSOR_NONE);
+       WM_cursor_set(win, CURSOR_NONE);
 }
 
 
-void BL_WaitMouse()
+void BL_WaitMouse(wmWindow *win)
 {
-       //XXX set_cursor(CURSOR_WAIT);
+       WM_cursor_set(win, CURSOR_WAIT);
 }
 
 
-void BL_NormalMouse()
+void BL_NormalMouse(wmWindow *win)
 {
-       //XXX set_cursor(CURSOR_STD);
+       WM_cursor_set(win, CURSOR_STD);
 }
 #define MAX_FILE_LENGTH 512
 
index 5c947ff630e8d76ce737f1ef3ef5b2f57418f3c9..d93b5eeabc57dc890862f1eb56c023fae344d88c 100644 (file)
@@ -39,13 +39,13 @@ struct ARegion;
 // special swapbuffers, that takes care of which area (viewport) needs to be swapped
 void   BL_SwapBuffers(struct wmWindow *win);
 
-void   BL_warp_pointer(int x,int y);
+void   BL_warp_pointer(struct wmWindow *win,int x,int y);
 
 void   BL_MakeScreenShot(struct ARegion *ar, const char* filename);
 
-void   BL_HideMouse();
-void   BL_NormalMouse();
-void   BL_WaitMouse();
+void   BL_HideMouse(struct wmWindow *win);
+void   BL_NormalMouse(struct wmWindow *win);
+void   BL_WaitMouse(struct wmWindow *win);
 
 void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height);
 void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height);