mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 01:57:47 +01:00
ignore dinput keypresses if window not in foreground
This commit is contained in:
parent
e3e7dc22e1
commit
a1864d612a
@ -6,6 +6,7 @@
|
|||||||
#include "dd.h"
|
#include "dd.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include "detours.h"
|
#include "detours.h"
|
||||||
@ -86,13 +87,16 @@ static HRESULT WINAPI fake_did_GetDeviceData(
|
|||||||
pdwInOut,
|
pdwInOut,
|
||||||
dwFlags,
|
dwFlags,
|
||||||
_ReturnAddress());
|
_ReturnAddress());
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
BOOL block_mouse = This == g_mouse_device && !g_mouse_locked && !g_config.devmode;
|
||||||
|
BOOL in_background = FALSE;//g_ddraw.ref && g_ddraw.hwnd && !util_in_foreground(g_ddraw.hwnd);
|
||||||
|
|
||||||
HRESULT result = real_did_GetDeviceData(This, cbObjectData, rgdod, pdwInOut, dwFlags);
|
HRESULT result = real_did_GetDeviceData(This, cbObjectData, rgdod, pdwInOut, dwFlags);
|
||||||
|
|
||||||
if (SUCCEEDED(result) && This == g_mouse_device && !g_mouse_locked && !g_config.devmode)
|
if (SUCCEEDED(result))
|
||||||
{
|
{
|
||||||
if (pdwInOut)
|
if ((block_mouse || in_background) && pdwInOut)
|
||||||
{
|
{
|
||||||
if (rgdod && *pdwInOut > 0 && cbObjectData > 0)
|
if (rgdod && *pdwInOut > 0 && cbObjectData > 0)
|
||||||
{
|
{
|
||||||
@ -110,11 +114,14 @@ static HRESULT WINAPI fake_did_GetDeviceState(IDirectInputDeviceA* This, DWORD c
|
|||||||
{
|
{
|
||||||
//TRACE("DirectInput GetDeviceState(This=%p, cbData=%lu, lpvData=%p) [%p]\n", This, cbData, lpvData, _ReturnAddress());
|
//TRACE("DirectInput GetDeviceState(This=%p, cbData=%lu, lpvData=%p) [%p]\n", This, cbData, lpvData, _ReturnAddress());
|
||||||
|
|
||||||
|
BOOL block_mouse = This == g_mouse_device && !g_mouse_locked && !g_config.devmode;
|
||||||
|
BOOL in_background = g_ddraw.ref && g_ddraw.hwnd && !util_in_foreground(g_ddraw.hwnd);
|
||||||
|
|
||||||
HRESULT result = real_did_GetDeviceState(This, cbData, lpvData);
|
HRESULT result = real_did_GetDeviceState(This, cbData, lpvData);
|
||||||
|
|
||||||
if (SUCCEEDED(result) && This == g_mouse_device && !g_mouse_locked && !g_config.devmode)
|
if (SUCCEEDED(result))
|
||||||
{
|
{
|
||||||
if (cbData > 0 && lpvData)
|
if ((block_mouse || in_background) && cbData > 0 && lpvData)
|
||||||
{
|
{
|
||||||
memset(lpvData, 0, cbData);
|
memset(lpvData, 0, cbData);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user