mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
In linux only read keyboard and mouse input when the emulator window has focus.
Also other code clean up. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5053 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -42,12 +42,11 @@
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
||||
*/
|
||||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "StringUtil.h" // for ArrayToString
|
||||
|
||||
#include "wiimote_hid.h" // Local
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "Common.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "wiimote_hid.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Encryption.h"
|
||||
|
@ -196,6 +196,17 @@ void LoadRecordedMovements()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
bool HaveFocus (void)
|
||||
{
|
||||
Window GLWin = *(Window *)g_WiimoteInitialize.pXWindow;
|
||||
Window FocusWin;
|
||||
int Revert;
|
||||
XGetInputFocus(WMdisplay, &FocusWin, &Revert);
|
||||
return (GLWin != 0 && GLWin == FocusWin);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */
|
||||
void GetMousePos(float& x, float& y)
|
||||
{
|
||||
@ -216,12 +227,13 @@ void GetMousePos(float& x, float& y)
|
||||
float PictureWidth = WinWidth, PictureHeight = WinHeight;
|
||||
#else
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Window GLWin = *(Window *)g_WiimoteInitialize.pXWindow;
|
||||
float WinWidth = 0, WinHeight = 0;
|
||||
float XOffset = 0, YOffset = 0;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
Window GLWin = *(Window *)g_WiimoteInitialize.pXWindow;
|
||||
if (GLWin != 0)
|
||||
if (HaveFocus())
|
||||
{
|
||||
Window GLWin = *(Window *)g_WiimoteInitialize.pXWindow;
|
||||
XWindowAttributes WinAttribs;
|
||||
XGetWindowAttributes (WMdisplay, GLWin, &WinAttribs);
|
||||
WinWidth = (float)WinAttribs.width;
|
||||
|
@ -42,9 +42,12 @@ void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size
|
||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) ;
|
||||
void Update(int _number);
|
||||
void DoState(PointerWrap &p);
|
||||
//void ReadLinuxKeyboard();
|
||||
bool IsKey(int Key);
|
||||
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
bool HaveFocus (void);
|
||||
#endif
|
||||
|
||||
// Recordings
|
||||
void LoadRecordedMovements();
|
||||
void GetMousePos(float& x, float& y);
|
||||
|
@ -17,8 +17,8 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "Common.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "Encryption.h"
|
||||
|
||||
|
||||
|
@ -310,7 +310,7 @@ bool IsKey(int Key)
|
||||
}
|
||||
else if (MapKey < 0x1100)
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
if (MapKey < 256 || MapKey >= 0xf000)
|
||||
if (HaveFocus() && (MapKey < 256 || MapKey >= 0xf000))
|
||||
{
|
||||
char keys[32];
|
||||
KeyCode keyCode;
|
||||
@ -346,23 +346,20 @@ bool IsKey(int Key)
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
if ((Key == EWM_SHAKE) || (Key == EWM_A) || (Key == EWM_B))
|
||||
if ((Key == EWM_SHAKE || Key == EWM_A || Key == EWM_B) && HaveFocus())
|
||||
{
|
||||
Window GLWin = *(Window *)g_WiimoteInitialize.pXWindow;
|
||||
if (GLWin != 0)
|
||||
int root_x, root_y, win_x, win_y;
|
||||
Window rootDummy, childWin;
|
||||
unsigned int mask;
|
||||
XQueryPointer(WMdisplay, GLWin, &rootDummy, &childWin, &root_x, &root_y, &win_x, &win_y, &mask);
|
||||
if (((Key == EWM_A) && (mask & Button1Mask))
|
||||
|| ((Key == EWM_B) && (mask & Button3Mask))
|
||||
|| ((Key == EWM_SHAKE) && (mask & Button3Mask)))
|
||||
{
|
||||
int root_x, root_y, win_x, win_y;
|
||||
Window rootDummy, childWin;
|
||||
unsigned int mask;
|
||||
XQueryPointer(WMdisplay, GLWin, &rootDummy, &childWin, &root_x, &root_y, &win_x, &win_y, &mask);
|
||||
if (((Key == EWM_A) && (mask & Button1Mask))
|
||||
|| ((Key == EWM_B) && (mask & Button3Mask))
|
||||
|| ((Key == EWM_SHAKE) && (mask & Button3Mask)))
|
||||
{
|
||||
float x, y;
|
||||
GetMousePos(x, y);
|
||||
Ret = !(x < 0 || x > 1 || y < 0 || y > 1);
|
||||
}
|
||||
float x, y;
|
||||
GetMousePos(x, y);
|
||||
Ret = !(x < 0 || x > 1 || y < 0 || y > 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user