Implement wiimote IR emulation with the mouse without using the pointer motion events. Hopefully this removes some of the overhead from the X event loops. One downside is that the IR emulation will not work until another event on the window has occured. Although this is minor, usually an event happens before you need the IR pointer.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5040 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-02-12 02:53:45 +00:00
parent e4dcdf796f
commit 78f8fe2e85
3 changed files with 18 additions and 26 deletions

View File

@ -476,7 +476,7 @@ bool OpenGL_MakeCurrent()
// better for pad plugin key input (thc)
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | ButtonPressMask | KeyReleaseMask | ButtonReleaseMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
FocusChangeMask | PointerMotionMask );
FocusChangeMask );
#endif
return true;
}
@ -651,7 +651,7 @@ void OpenGL_Shutdown()
/* switch back to original desktop resolution if we were in fs */
if ((GLWin.dpy != NULL) && GLWin.fs) {
XUngrabKeyboard (GLWin.dpy, CurrentTime);
XUngrabButton (GLWin.dpy, AnyButton, AnyModifier, GLWin.win);
XUngrabPointer (GLWin.dpy, CurrentTime);
XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, &GLWin.deskMode);
XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0);
}

View File

@ -197,7 +197,7 @@ void LoadRecordedMovements()
}
#if defined(HAVE_X11) && HAVE_X11
MousePosition MousePos;
Window GLWin;
#endif
/* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */
@ -220,9 +220,19 @@ void GetMousePos(float& x, float& y)
float PictureWidth = WinWidth, PictureHeight = WinHeight;
#else
#if defined(HAVE_X11) && HAVE_X11
float WinWidth = (float)MousePos.WinWidth;
float WinHeight = (float)MousePos.WinHeight;
float WinWidth = 0, WinHeight = 0;
float XOffset = 0, YOffset = 0;
int root_x, root_y, win_x, win_y;
if (GLWin != 0)
{
XWindowAttributes WinAttribs;
XGetWindowAttributes (WMdisplay, GLWin, &WinAttribs);
WinWidth = (float)WinAttribs.width;
WinHeight = (float)WinAttribs.height;
Window rootDummy, childWin;
unsigned int mask;
XQueryPointer(WMdisplay, GLWin, &rootDummy, &childWin, &root_x, &root_y, &win_x, &win_y, &mask);
}
float PictureWidth = WinWidth, PictureHeight = WinHeight;
#endif
#endif
@ -305,8 +315,8 @@ void GetMousePos(float& x, float& y)
*/
#else
#if defined(HAVE_X11) && HAVE_X11
x = ((float)MousePos.x - XOffset) / PictureWidth;
y = ((float)MousePos.y - YOffset) / PictureHeight;
x = ((float)win_x - XOffset) / PictureWidth;
y = ((float)win_y - YOffset) / PictureHeight;
#endif
#endif
}
@ -674,6 +684,7 @@ void ReadLinuxKeyboard()
for (num_events = XPending(WMdisplay); num_events > 0; num_events--)
{
XNextEvent(WMdisplay, &E);
GLWin = E.xany.window;
switch (E.type)
{
case KeyPress:
@ -735,16 +746,6 @@ void ReadLinuxKeyboard()
XPutBackEvent(WMdisplay, &E);
break;
}
case MotionNotify:
{
MousePos.x = E.xmotion.x;
MousePos.y = E.xmotion.y;
XWindowAttributes WinAttribs;
XGetWindowAttributes (E.xmotion.display, E.xmotion.window, &WinAttribs);
MousePos.WinWidth = WinAttribs.width;
MousePos.WinHeight = WinAttribs.height;
break;
}
case ConfigureNotify:
case ClientMessage:
XPutBackEvent(WMdisplay, &E);

View File

@ -62,15 +62,6 @@ void TiltToAccelerometer(int &_x, int &_y, int &_z, STiltData &_TiltData);
void AdjustAngles(int &Roll, int &Pitch);
void RotateIRDot(int &_x, int &_y, STiltData &_TiltData);
#if defined(HAVE_X11) && HAVE_X11
struct MousePosition
{
int x, y;
int WinWidth, WinHeight;
};
extern MousePosition MousePos;
#endif
// Accelerometer
//void PitchAccelerometerToDegree(u8 _x, u8 _y, u8 _z, int &_Roll, int &_Pitch, int&, int&);
//float AccelerometerToG(float Current, float Neutral, float G);