Skip to content

Commit

Permalink
Simplify direction checking
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jun 26, 2024
1 parent 86fd6fa commit a801c09
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dinput8/IDirectInputDevice8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "dinput8.h"

constexpr DWORD SignBit = 0x80000000;

HRESULT m_IDirectInputDevice8::QueryInterface(REFIID riid, LPVOID* ppvObj)
{
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";
Expand Down Expand Up @@ -183,7 +185,7 @@ HRESULT m_IDirectInputDevice8::GetMouseDeviceData(DWORD cbObjectData, LPDIDEVICE
lpdod->dwOfs == DIMOFS_Z ? 2 : 0;

// Check if record should be merged, if there is an existing record and the movement direction has not changed
if (isSet[v] && !((dod[Loc[v]].lData < 0 && (LONG)lpdod->dwData > 0) || (dod[Loc[v]].lData > 0 && (LONG)lpdod->dwData < 0)))
if (isSet[v] && (dod[Loc[v]].lData & SignBit) == (lpdod->dwData & SignBit))
{
// Updating movement data (merging records)
dod[Loc[v]].lData += (LONG)lpdod->dwData;
Expand Down

0 comments on commit a801c09

Please sign in to comment.