Mitchell Stokes BGE MouseWarp patch + warning fix

[#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.
This commit is contained in:
Campbell Barton
2009-11-11 08:32:29 +00:00
parent 1dfc7942d3
commit b2bb9ca39a
7 changed files with 39 additions and 25 deletions

View 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) {

View 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);

View 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;
}
}

View 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));
}

View 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

View 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

View 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);