Ignore K/M input when the cursor is outside of the rendering window
This commit is contained in:
parent
4c47d5a6d9
commit
dd24225477
|
@ -152,6 +152,11 @@ namespace DInput
|
||||||
|
|
||||||
bool KeyboardMouse::UpdateInput()
|
bool KeyboardMouse::UpdateInput()
|
||||||
{
|
{
|
||||||
|
if (mo_leave_wnd) {
|
||||||
|
std::memset(&m_state_in, 0, sizeof(m_state_in));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
DIMOUSESTATE2 tmp_mouse;
|
DIMOUSESTATE2 tmp_mouse;
|
||||||
|
|
||||||
HRESULT kb_hr = m_kb_device->GetDeviceState(sizeof(m_state_in.keyboard), &m_state_in.keyboard);
|
HRESULT kb_hr = m_kb_device->GetDeviceState(sizeof(m_state_in.keyboard), &m_state_in.keyboard);
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
namespace DInput
|
namespace DInput
|
||||||
{
|
{
|
||||||
inline bool bKbMoEnumerated = false;
|
inline bool bKbMoEnumerated = false;
|
||||||
|
inline bool mo_leave_wnd = false;
|
||||||
inline LONG mo_axis_range_pos = 0;
|
inline LONG mo_axis_range_pos = 0;
|
||||||
inline LONG mo_axis_range_neg = 0;
|
inline LONG mo_axis_range_neg = 0;
|
||||||
inline LONG mo_wheel_range_pos = 0;
|
inline LONG mo_wheel_range_pos = 0;
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#include "WalkIndexBuffer.h"
|
#include "WalkIndexBuffer.h"
|
||||||
#include "core\kernel\common\strings.hpp" // For uem_str
|
#include "core\kernel\common\strings.hpp" // For uem_str
|
||||||
#include "common\input\SdlJoystick.h"
|
#include "common\input\SdlJoystick.h"
|
||||||
|
#include "common\input\DInputKeyboardMouse.h"
|
||||||
#include "common/util/strConverter.hpp" // for utf8_to_utf16
|
#include "common/util/strConverter.hpp" // for utf8_to_utf16
|
||||||
#include "VertexShaderSource.h"
|
#include "VertexShaderSource.h"
|
||||||
|
|
||||||
|
@ -2030,11 +2031,33 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WM_MOUSELEAVE:
|
||||||
|
{
|
||||||
|
DInput::mo_leave_wnd = true;
|
||||||
|
g_bIsTrackingMoLeave = false;
|
||||||
|
g_bIsTrackingMoMove = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
{
|
{
|
||||||
if (g_bClipCursor) {
|
if (g_bClipCursor) {
|
||||||
CxbxClipCursor(hWnd);
|
CxbxClipCursor(hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!g_bIsTrackingMoLeave) {
|
||||||
|
TRACKMOUSEEVENT tme;
|
||||||
|
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
||||||
|
tme.hwndTrack = hWnd;
|
||||||
|
tme.dwFlags = TME_LEAVE;
|
||||||
|
TrackMouseEvent(&tme);
|
||||||
|
g_bIsTrackingMoLeave = true;
|
||||||
|
|
||||||
|
if (g_bIsTrackingMoMove) {
|
||||||
|
DInput::mo_leave_wnd = false;
|
||||||
|
g_bIsTrackingMoMove = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,8 @@ bool g_bIsWine = false;
|
||||||
bool g_bClipCursor = false;
|
bool g_bClipCursor = false;
|
||||||
bool g_CxbxPrintUEM = false;
|
bool g_CxbxPrintUEM = false;
|
||||||
ULONG g_CxbxFatalErrorCode = FATAL_ERROR_NONE;
|
ULONG g_CxbxFatalErrorCode = FATAL_ERROR_NONE;
|
||||||
|
bool g_bIsTrackingMoLeave = false;
|
||||||
|
bool g_bIsTrackingMoMove = false;
|
||||||
|
|
||||||
// Define function located in EmuXApi so we can call it from here
|
// Define function located in EmuXApi so we can call it from here
|
||||||
void SetupXboxDeviceTypes();
|
void SetupXboxDeviceTypes();
|
||||||
|
|
|
@ -203,6 +203,8 @@ extern bool g_bIsWine;
|
||||||
extern bool g_bClipCursor;
|
extern bool g_bClipCursor;
|
||||||
extern bool g_CxbxPrintUEM;
|
extern bool g_CxbxPrintUEM;
|
||||||
extern ULONG g_CxbxFatalErrorCode;
|
extern ULONG g_CxbxFatalErrorCode;
|
||||||
|
extern bool g_bIsTrackingMoLeave;
|
||||||
|
extern bool g_bIsTrackingMoMove;
|
||||||
|
|
||||||
extern size_t g_SystemMaxMemory;
|
extern size_t g_SystemMaxMemory;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue