openDecal/Native/DecalInput/MouseMoveAction.cpp
erik d1442e3747 Initial commit: Complete open-source Decal rebuild
All 5 phases of the open-source Decal rebuild:

Phase 1: 14 decompiled .NET projects (Interop.*, Adapter, FileService, DecalUtil)
Phase 2: 10 native DLLs rewritten as C# COM servers with matching GUIDs
  - DecalDat, DHS, SpellFilter, DecalInput, DecalNet, DecalFilters
  - Decal.Core, DecalControls, DecalRender, D3DService
Phase 3: C++ shims for Inject.DLL (D3D9 hooking) and LauncherHook.DLL
Phase 4: DenAgent WinForms tray application
Phase 5: WiX installer and build script

25 C# projects building with 0 errors.
Native C++ projects require VS 2022 + Windows SDK (x86).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:27:56 +01:00

81 lines
2 KiB
C++

// MouseMoveAction.cpp : Implementation of cMouseMoveAction
#include "stdafx.h"
#include "DecalInput.h"
#include "MouseMoveAction.h"
/////////////////////////////////////////////////////////////////////////////
// cMouseMoveAction
HRESULT cMouseMoveAction::onLoad( LPTSTR szData )
{
int nSep = ::_tcscspn( szData, _T( "," ) );
if( nSep == -1 )
return E_INVALIDARG;
szData[ nSep ] = _T( '\0' );
HRESULT hRes = loadValue( szData, m_x );
if( FAILED( hRes ) )
return hRes;
return loadValue( szData + nSep + 1, m_y );
}
HRESULT cMouseMoveAction::loadValue( LPTSTR szData, cValue &val )
{
if( *szData == _T( '-' ) )
{
// This is from right/bottom
if( ::_stscanf( szData + 1, _T( "%i" ), &val.m_nMagnitude ) != 1 )
return E_INVALIDARG;
if( val.m_nMagnitude < 0 || val.m_nMagnitude > 2000 )
return E_INVALIDARG;
val.m_eDir = eRightBottom;
return S_OK;
}
int nLength = ::_tcslen( szData );
if( szData[ nLength - 1 ] == _T( '%' ) )
{
szData[ nLength - 1 ] = _T( '\0' );
// This is from right/bottom
if( ::_stscanf( szData, _T( "%i" ), &val.m_nMagnitude ) != 1 )
return E_INVALIDARG;
if( val.m_nMagnitude < 0 || val.m_nMagnitude > 100 )
return E_INVALIDARG;
val.m_eDir = ePercent;
return S_OK;
}
if( ::_stscanf( szData, _T( "%i" ), &val.m_nMagnitude ) != 1 )
return E_INVALIDARG;
if( val.m_nMagnitude < 0 || val.m_nMagnitude > 2000 )
return E_INVALIDARG;
val.m_eDir = eLeftTop;
return S_OK;
}
STDMETHODIMP cMouseMoveAction::Execute()
{
CComPtr< IInputService > pService;
HRESULT hRes = m_pSite->get_Service( &pService );
if( FAILED( hRes ) )
return hRes;
CComPtr< IDecal > pDecal;
hRes = pService->get_Decal( &pDecal );
if( FAILED( hRes ) )
return hRes;
long nWidth, nHeight;
pDecal->get_ScreenSize( &nWidth, &nHeight );
return m_pSite->MoveMouse( m_x.value( nWidth ), m_y.value( nHeight ) );
}