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>
This commit is contained in:
erik 2026-02-08 18:27:56 +01:00
commit d1442e3747
1382 changed files with 170725 additions and 0 deletions

View file

@ -0,0 +1,91 @@
// DecalInput.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f DecalInputps.mk in the project directory.
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "DecalInput.h"
#include "DecalInput_i.c"
#include "InputService.h"
#include "Timer.h"
#include "Hotkey.h"
#include "WinMsgHook.h"
#include "InputBuffer.h"
#include "TypeAction.h"
#include "MouseMoveAction.h"
#include "DelayAction.h"
#include "EventAction.h"
#include "PolledDelayAction.h"
#include "RestoreAction.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_InputService, cInputService)
OBJECT_ENTRY(CLSID_Timer, cTimer)
OBJECT_ENTRY(CLSID_Hotkey, cHotkey)
OBJECT_ENTRY(CLSID_WinMsgHook, cWinMsgHook)
OBJECT_ENTRY(CLSID_InputBuffer, cInputBuffer)
OBJECT_ENTRY(CLSID_TypeAction, cTypeAction)
OBJECT_ENTRY(CLSID_MouseMoveAction, cMouseMoveAction)
OBJECT_ENTRY(CLSID_DelayAction, cDelayAction)
OBJECT_ENTRY(CLSID_EventAction, cEventAction)
OBJECT_ENTRY(CLSID_PolledDelayAction, cPolledDelayAction)
OBJECT_ENTRY(CLSID_RestoreAction, cRestoreAction)
END_OBJECT_MAP()
/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance, &LIBID_DecalInput);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE; // ok
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
return _Module.UnregisterServer(TRUE);
}

View file

@ -0,0 +1,9 @@
; DecalInput.def : Declares the module parameters.
LIBRARY "DecalInput.DLL"
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

View file

@ -0,0 +1,393 @@
# Microsoft Developer Studio Project File - Name="DecalInput" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=DecalInput - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "DecalInput.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "DecalInput.mak" CFG="DecalInput - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "DecalInput - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "DecalInput - Win32 Unicode Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "DecalInput - Win32 Release MinSize" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "DecalInput - Win32 Unicode Release MinSize" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "DecalInput - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /Ob0 /I "..\Include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD MTL /nologo /I "..\Include" /Oicf
# ADD BASE RSC /l 0x1009 /d "_DEBUG"
# ADD RSC /l 0x1009 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# Begin Custom Build - Performing registration
OutDir=.\..\Debug
TargetPath=\sb\source\Debug\DecalInput.dll
InputPath=\sb\source\Debug\DecalInput.dll
SOURCE="$(InputPath)"
"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
regsvr32 /s /c "$(TargetPath)"
echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
# End Custom Build
!ELSEIF "$(CFG)" == "DecalInput - Win32 Unicode Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "DebugU"
# PROP BASE Intermediate_Dir "DebugU"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugU"
# PROP Intermediate_Dir "DebugU"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\Include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c
# ADD MTL /nologo /I "..\Include" /Oicf
# ADD BASE RSC /l 0x1009 /d "_DEBUG"
# ADD RSC /l 0x1009 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# Begin Custom Build - Performing registration
OutDir=.\DebugU
TargetPath=.\DebugU\DecalInput.dll
InputPath=.\DebugU\DecalInput.dll
SOURCE="$(InputPath)"
"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
if "%OS%"=="" goto NOTNT
if not "%OS%"=="Windows_NT" goto NOTNT
regsvr32 /s /c "$(TargetPath)"
echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
goto end
:NOTNT
echo Warning : Cannot register Unicode DLL on Windows 95
:end
# End Custom Build
!ELSEIF "$(CFG)" == "DecalInput - Win32 Release MinSize"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "ReleaseMinSize"
# PROP BASE Intermediate_Dir "ReleaseMinSize"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\Release"
# PROP Intermediate_Dir "ReleaseMinSize"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /Zi /Oa /Og /Oi /Os /Oy /Ob1 /Gf /Gy /I "..\Include" /D "_MBCS" /D "_ATL_DLL" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /Yu"stdafx.h" /FD /c
# ADD MTL /nologo /I "..\Include" /Oicf
# ADD BASE RSC /l 0x1009 /d "NDEBUG"
# ADD RSC /l 0x1009 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\Release"
# Begin Custom Build - Performing registration
OutDir=.\..\Release
TargetPath=\sb\source\Release\DecalInput.dll
InputPath=\sb\source\Release\DecalInput.dll
SOURCE="$(InputPath)"
"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
regsvr32 /s /c "$(TargetPath)"
echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
# End Custom Build
!ELSEIF "$(CFG)" == "DecalInput - Win32 Unicode Release MinSize"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "ReleaseUMinSize"
# PROP BASE Intermediate_Dir "ReleaseUMinSize"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "ReleaseUMinSize"
# PROP Intermediate_Dir "ReleaseUMinSize"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O1 /I "..\Include" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /Yu"stdafx.h" /FD /c
# ADD MTL /nologo /I "..\Include" /Oicf
# ADD BASE RSC /l 0x1009 /d "NDEBUG"
# ADD RSC /l 0x1009 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib winmm.lib libctiny.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\Release"
# Begin Custom Build - Performing registration
OutDir=.\ReleaseUMinSize
TargetPath=.\ReleaseUMinSize\DecalInput.dll
InputPath=.\ReleaseUMinSize\DecalInput.dll
SOURCE="$(InputPath)"
"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
if "%OS%"=="" goto NOTNT
if not "%OS%"=="Windows_NT" goto NOTNT
regsvr32 /s /c "$(TargetPath)"
echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
goto end
:NOTNT
echo Warning : Cannot register Unicode DLL on Windows 95
:end
# End Custom Build
!ENDIF
# Begin Target
# Name "DecalInput - Win32 Debug"
# Name "DecalInput - Win32 Unicode Debug"
# Name "DecalInput - Win32 Release MinSize"
# Name "DecalInput - Win32 Unicode Release MinSize"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\DecalInput.cpp
# End Source File
# Begin Source File
SOURCE=.\DecalInput.def
# End Source File
# Begin Source File
SOURCE=..\Include\DecalInput.idl
# ADD MTL /tlb "DecalInput.tlb" /h "..\Include\DecalInput.h" /iid "..\Include\DecalInput_i.c"
# End Source File
# Begin Source File
SOURCE=.\DecalInput.rc
# End Source File
# Begin Source File
SOURCE=.\DelayAction.cpp
# End Source File
# Begin Source File
SOURCE=.\EventAction.cpp
# End Source File
# Begin Source File
SOURCE=.\Hotkey.cpp
# End Source File
# Begin Source File
SOURCE=.\InputBuffer.cpp
# End Source File
# Begin Source File
SOURCE=.\InputService.cpp
# End Source File
# Begin Source File
SOURCE=.\MouseMoveAction.cpp
# End Source File
# Begin Source File
SOURCE=.\PolledDelayAction.cpp
# End Source File
# Begin Source File
SOURCE=.\RestoreAction.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\Timer.cpp
# End Source File
# Begin Source File
SOURCE=.\TypeAction.cpp
# End Source File
# Begin Source File
SOURCE=.\WinMsgHook.cpp
# End Source File
# Begin Source File
SOURCE=.\WndMsg.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\DecalInputCP.h
# End Source File
# Begin Source File
SOURCE=..\Include\DecalInputImpl.h
# End Source File
# Begin Source File
SOURCE=.\DelayAction.h
# End Source File
# Begin Source File
SOURCE=.\EventAction.h
# End Source File
# Begin Source File
SOURCE=.\Hotkey.h
# End Source File
# Begin Source File
SOURCE=.\InputBuffer.h
# End Source File
# Begin Source File
SOURCE=.\InputService.h
# End Source File
# Begin Source File
SOURCE=.\MouseMoveAction.h
# End Source File
# Begin Source File
SOURCE=.\PolledDelayAction.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\RestoreAction.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\Timer.h
# End Source File
# Begin Source File
SOURCE=.\TypeAction.h
# End Source File
# Begin Source File
SOURCE=.\WinMsgHook.h
# End Source File
# Begin Source File
SOURCE=.\WndMsg.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\DelayAction.rgs
# End Source File
# Begin Source File
SOURCE=.\EventAction.rgs
# End Source File
# Begin Source File
SOURCE=.\Hotkey.rgs
# End Source File
# Begin Source File
SOURCE=.\InputBuffer.rgs
# End Source File
# Begin Source File
SOURCE=.\InputService.rgs
# End Source File
# Begin Source File
SOURCE=.\MouseMoveAction.rgs
# End Source File
# Begin Source File
SOURCE=.\PolledDelayAction.rgs
# End Source File
# Begin Source File
SOURCE=.\RestoreAction.rgs
# End Source File
# Begin Source File
SOURCE=.\Timer.rgs
# End Source File
# Begin Source File
SOURCE=.\TypeAction.rgs
# End Source File
# Begin Source File
SOURCE=.\WinMsgHook.rgs
# End Source File
# Begin Source File
SOURCE=.\WndMsg.rgs
# End Source File
# End Group
# End Target
# End Project

View file

@ -0,0 +1,143 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "..\Include\DecalVersion.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"1 TYPELIB ""DecalInput.tlb""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION DECAL_MAJOR, DECAL_MINOR, DECAL_BUGFIX, DECAL_RELEASE
PRODUCTVERSION DECAL_MAJOR, DECAL_MINOR, DECAL_BUGFIX, DECAL_RELEASE
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "DecalInput Module"
VALUE "FileVersion", DECAL_VERSION_STRING
VALUE "InternalName", "DecalInput"
VALUE "LegalCopyright", "Copyright 2001"
VALUE "OriginalFilename", "DecalInput.DLL"
VALUE "ProductName", "DecalInput Module"
VALUE "ProductVersion", DECAL_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "DecalInput"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (Canada) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENC)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_INPUTSERVICE REGISTRY "InputService.rgs"
IDR_TIMER REGISTRY "Timer.rgs"
IDR_HOTKEY REGISTRY "Hotkey.rgs"
IDR_WINMSGHOOK REGISTRY "WinMsgHook.rgs"
IDR_WNDMSG REGISTRY "WndMsg.rgs"
IDR_INPUTBUFFER REGISTRY "InputBuffer.rgs"
IDR_TYPEACTION REGISTRY "TypeAction.rgs"
IDR_MOUSEMOVEACTION REGISTRY "MouseMoveAction.rgs"
IDR_DELAYACTION REGISTRY "DelayAction.rgs"
IDR_EVENTACTION REGISTRY "EventAction.rgs"
IDR_POLLEDDELAYACTION REGISTRY "PolledDelayAction.rgs"
IDR_RESTOREACTION REGISTRY "RestoreAction.rgs"
#endif // English (Canada) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "DecalInput.tlb"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,191 @@
#ifndef _DECALINPUTCP_H_
#define _DECALINPUTCP_H_
template <class T>
class CProxyIHotkeyEvents : public IConnectionPointImpl<T, &DIID_IHotkeyEvents, CComDynamicUnkArray>
{
//Warning this class may be recreated by the wizard.
public:
HRESULT Fire_Hotkey(IHotkey * Source)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = Source;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
};
template <class T>
class CProxyITimerEvents : public IConnectionPointImpl<T, &DIID_ITimerEvents, CComDynamicUnkArray>
{
//Warning this class may be recreated by the wizard.
public:
HRESULT Fire_Timeout(IDecalTimer * Source)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = Source;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
};
template <class T>
class CProxyIWinMsgHookEvents : public IConnectionPointImpl<T, &DIID_IWinMsgHookEvents, CComDynamicUnkArray>
{
//Warning this class may be recreated by the wizard.
public:
HRESULT Fire_Message(IWinMsgHook * Hook, IWndMsg * Message)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[2];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[1] = Hook;
pvars[0] = Message;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
};
template <class T>
class CProxyIInputBufferEvents : public IConnectionPointImpl<T, &DIID_IInputBufferEvents, CComDynamicUnkArray>
{
//Warning this class may be recreated by the wizard.
public:
HRESULT Fire_Begin(IInputBuffer * Buffer)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = Buffer;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
HRESULT Fire_End(IInputBuffer * Buffer)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = Buffer;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
HRESULT Fire_Event(IInputBuffer * Buffer, LONG EventID, VARIANT Param)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[3];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[2] = Buffer;
pvars[1] = EventID;
pvars[0].Copy( &Param );
DISPPARAMS disp = { pvars, NULL, 3, 0 };
pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
};
#endif

View file

@ -0,0 +1,11 @@
LIBRARY "DecalInputPS"
DESCRIPTION 'Proxy/Stub DLL'
EXPORTS
DllGetClassObject @1 PRIVATE
DllCanUnloadNow @2 PRIVATE
GetProxyDllInfo @3 PRIVATE
DllRegisterServer @4 PRIVATE
DllUnregisterServer @5 PRIVATE

View file

@ -0,0 +1,16 @@
DecalInputps.dll: dlldata.obj DecalInput_p.obj DecalInput_i.obj
link /dll /out:DecalInputps.dll /def:DecalInputps.def /entry:DllMain dlldata.obj DecalInput_p.obj DecalInput_i.obj \
kernel32.lib rpcndr.lib rpcns4.lib rpcrt4.lib oleaut32.lib uuid.lib \
.c.obj:
cl /c /Ox /DWIN32 /D_WIN32_WINNT=0x0400 /DREGISTER_PROXY_DLL \
$<
clean:
@del DecalInputps.dll
@del DecalInputps.lib
@del DecalInputps.exp
@del dlldata.obj
@del DecalInput_p.obj
@del DecalInput_i.obj

View file

@ -0,0 +1,8 @@
// DelayAction.cpp : Implementation of cDelayAction
#include "stdafx.h"
#include "DecalInput.h"
#include "DelayAction.h"
/////////////////////////////////////////////////////////////////////////////
// cDelayAction

View file

@ -0,0 +1,46 @@
// DelayAction.h : Declaration of the cDelayAction
#ifndef __DELAYACTION_H_
#define __DELAYACTION_H_
#include "resource.h" // main symbols
#include <DecalInputImpl.h>
/////////////////////////////////////////////////////////////////////////////
// cDelayAction
class ATL_NO_VTABLE cDelayAction :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cDelayAction, &CLSID_DelayAction>,
public IInputActionImpl< cDelayAction >
{
public:
cDelayAction()
{
}
long m_nTime;
HRESULT onLoad( LPTSTR szData )
{
// Attempt to convert it to a number
return ( ::_stscanf( szData, _T( "%i" ), &m_nTime ) == 1 ) ? S_OK : E_INVALIDARG;
}
DECLARE_REGISTRY_RESOURCEID(IDR_DELAYACTION)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cDelayAction)
COM_INTERFACE_ENTRY(IInputAction)
END_COM_MAP()
// IInputAction
public:
STDMETHOD(Execute)()
{
m_pSite->Delay( m_nTime, VARIANT_TRUE );
return S_OK;
}
};
#endif //__DELAYACTION_H_

View file

@ -0,0 +1,43 @@
HKCR
{
DecalInput.DelayAction.1 = s 'DelayAction Class'
{
CLSID = s '{324D76B8-D8C7-4A81-B867-E4E1F874E488}'
}
DecalInput.DelayAction = s 'DelayAction Class'
{
CLSID = s '{324D76B8-D8C7-4A81-B867-E4E1F874E488}'
CurVer = s 'DecalInput.DelayAction.1'
}
NoRemove CLSID
{
ForceRemove {324D76B8-D8C7-4A81-B867-E4E1F874E488} = s 'DelayAction Class'
{
ProgID = s 'DecalInput.DelayAction.1'
VersionIndependentProgID = s 'DecalInput.DelayAction'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}
HKLM
{
NoRemove SOFTWARE
{
NoRemove Decal
{
NoRemove InputActions
{
ForceRemove {324D76B8-D8C7-4A81-B867-E4E1F874E488} = s 'Delay Input Action'
{
val Enabled = d '1'
val Prefix = s 'delay'
}
}
}
}
}

View file

@ -0,0 +1,8 @@
// EventAction.cpp : Implementation of cEventAction
#include "stdafx.h"
#include "DecalInput.h"
#include "EventAction.h"
/////////////////////////////////////////////////////////////////////////////
// cEventAction

View file

@ -0,0 +1,48 @@
// EventAction.h : Declaration of the cEventAction
#ifndef __EVENTACTION_H_
#define __EVENTACTION_H_
#include "resource.h" // main symbols
#include <DecalInputImpl.h>
/////////////////////////////////////////////////////////////////////////////
// cEventAction
class ATL_NO_VTABLE cEventAction :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cEventAction, &CLSID_EventAction>,
public IInputActionImpl< cEventAction >
{
public:
cEventAction()
{
}
long m_nEvent;
HRESULT onLoad( LPTSTR szData )
{
// Attempt to convert it to a number
return ( ::_stscanf( szData, _T( "%i" ), &m_nEvent ) == 1 ) ? S_OK : E_INVALIDARG;
}
DECLARE_REGISTRY_RESOURCEID(IDR_EVENTACTION)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cEventAction)
COM_INTERFACE_ENTRY(IInputAction)
END_COM_MAP()
// IEventAction
public:
STDMETHOD(Execute)()
{
CComVariant v;
m_pSite->FireEvent( m_nEvent, v );
return S_OK;
}
};
#endif //__EVENTACTION_H_

View file

@ -0,0 +1,43 @@
HKCR
{
DecalInput.EventAction.1 = s 'EventAction Class'
{
CLSID = s '{D6E4BD19-4900-4515-BCE2-A9EA4AAE2699}'
}
DecalInput.EventAction = s 'EventAction Class'
{
CLSID = s '{D6E4BD19-4900-4515-BCE2-A9EA4AAE2699}'
CurVer = s 'DecalInput.EventAction.1'
}
NoRemove CLSID
{
ForceRemove {D6E4BD19-4900-4515-BCE2-A9EA4AAE2699} = s 'EventAction Class'
{
ProgID = s 'DecalInput.EventAction.1'
VersionIndependentProgID = s 'DecalInput.EventAction'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}
HKLM
{
NoRemove SOFTWARE
{
NoRemove Decal
{
NoRemove InputActions
{
ForceRemove {D6E4BD19-4900-4515-BCE2-A9EA4AAE2699} = s 'Event Input Action'
{
val Enabled = d '1'
val Prefix = s 'event'
}
}
}
}
}

View file

@ -0,0 +1,159 @@
// Hotkey.cpp : Implementation of cHotkey
#include "stdafx.h"
#include "DecalInput.h"
#include "Hotkey.h"
#include "InputService.h"
/////////////////////////////////////////////////////////////////////////////
// cHotkey
STDMETHODIMP cHotkey::get_Tag(VARIANT *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
return ::VariantCopy( pVal, &m_tag );
}
STDMETHODIMP cHotkey::put_Tag(VARIANT newVal)
{
m_tag = newVal;
return S_OK;
}
STDMETHODIMP cHotkey::get_Key(BSTR *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
USES_CONVERSION;
if( m_nVK == -1 )
{
// Key must be set before it's retreived
_ASSERT( FALSE );
return E_FAIL;
}
// Try and convert it to a special char
cInputService::cCharNames *i_char = cInputService::charFromVK( m_nVK );
if( i_char != cInputService::end_chars() )
{
TCHAR szKey[ 12 ];
::_stprintf( szKey, _T( "{%s}" ), i_char->szName );
*pVal = T2BSTR( szKey );
return S_OK;
}
TCHAR szKey[2] = { static_cast< TCHAR >( m_nVK ), _T( '\0' ) };
*pVal = T2BSTR( szKey );
return S_OK;
}
STDMETHODIMP cHotkey::put_Key(BSTR newVal)
{
USES_CONVERSION;
// Convert to upper case
LPTSTR szKey = OLE2T( newVal );
::_tcsupr( szKey );
if( szKey[ 0 ] == '{' )
{
for( LPTSTR szEndKey = szKey + 1; *szEndKey != '\0'; ++ szEndKey )
{
if( *szEndKey == _T( '}' ) )
{
cInputService::cCharNames *i_char = cInputService::charFromName( szKey + 1, szEndKey - ( szKey + 1 ) );
if( i_char == cInputService::end_chars() )
{
// Unknown special character name
_ASSERT( FALSE );
return E_INVALIDARG;
}
// We have our vkey
m_nVK = i_char->m_nVKey;
return S_OK;
}
}
// Malformed string
_ASSERT( FALSE );
return E_INVALIDARG;
}
if( szKey[ 1 ] != _T( '\0' ) )
{
// Malformed string - should only contain one character
_ASSERT( FALSE );
return E_INVALIDARG;
}
m_nVK = szKey[ 0 ];
return S_OK;
}
STDMETHODIMP cHotkey::get_Enabled(VARIANT_BOOL *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
*pVal = ( m_bEnabled ) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP cHotkey::put_Enabled(VARIANT_BOOL newVal)
{
if( !!newVal == m_bEnabled )
return S_FALSE;
if( cInputService::g_p == NULL )
{
// Input Service must be started to enable or disable a hotkey
_ASSERT( FALSE );
return E_FAIL;
}
m_bEnabled = !!newVal;
if( m_bEnabled )
{
#ifdef _DEBUG
for( cInputService::cHotkeyList::iterator i = cInputService::g_p->m_hotkeys.begin(); i != cInputService::g_p->m_hotkeys.end(); ++ i )
_ASSERTE( *i != this );
#endif
cInputService::g_p->m_hotkeys.push_back( this );
}
else
{
for( cInputService::cHotkeyList::iterator i = cInputService::g_p->m_hotkeys.begin(); i != cInputService::g_p->m_hotkeys.end(); ++ i )
{
if( *i == this )
{
cInputService::g_p->m_hotkeys.erase( i );
break;
}
}
_ASSERTE( i != cInputService::g_p->m_hotkeys.end() );
}
return S_OK;
}

View file

@ -0,0 +1,61 @@
// Hotkey.h : Declaration of the cHotkey
#ifndef __HOTKEY_H_
#define __HOTKEY_H_
#include "resource.h" // main symbols
#include "DecalInputCP.h"
/////////////////////////////////////////////////////////////////////////////
// cHotkey
class ATL_NO_VTABLE cHotkey :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cHotkey, &CLSID_Hotkey>,
public IProvideClassInfo2Impl< &CLSID_Hotkey, &DIID_IHotkeyEvents, &LIBID_DecalInput >,
public IConnectionPointContainerImpl<cHotkey>,
public IDispatchImpl<IHotkey, &IID_IHotkey, &LIBID_DecalInput>,
public CProxyIHotkeyEvents< cHotkey >
{
public:
cHotkey()
: m_bEnabled( false ),
m_nVK( -1 )
{
}
void FinalRelease()
{
if( m_bEnabled )
put_Enabled( VARIANT_FALSE );
}
bool m_bEnabled;
_variant_t m_tag;
long m_nVK;
DECLARE_REGISTRY_RESOURCEID(IDR_HOTKEY)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cHotkey)
COM_INTERFACE_ENTRY(IHotkey)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(cHotkey)
CONNECTION_POINT_ENTRY(DIID_IHotkeyEvents)
END_CONNECTION_POINT_MAP()
// IHotkey
public:
STDMETHOD(get_Enabled)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Enabled)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Key)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Key)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Tag)(/*[out, retval]*/ VARIANT *pVal);
STDMETHOD(put_Tag)(/*[in]*/ VARIANT newVal);
};
#endif //__HOTKEY_H_

View file

@ -0,0 +1,26 @@
HKCR
{
DecalInput.Hotkey.1 = s 'Hotkey Class'
{
CLSID = s '{F183506A-3664-49D6-8CA4-CFD295F2811D}'
}
DecalInput.Hotkey = s 'Hotkey Class'
{
CLSID = s '{F183506A-3664-49D6-8CA4-CFD295F2811D}'
CurVer = s 'DecalInput.Hotkey.1'
}
NoRemove CLSID
{
ForceRemove {F183506A-3664-49D6-8CA4-CFD295F2811D} = s 'Hotkey Class'
{
ProgID = s 'DecalInput.Hotkey.1'
VersionIndependentProgID = s 'DecalInput.Hotkey'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}

View file

@ -0,0 +1,351 @@
// InputBuffer.cpp : Implementation of cInputBuffer
#include "stdafx.h"
#include "DecalInput.h"
#include "InputBuffer.h"
#include "InputService.h"
/////////////////////////////////////////////////////////////////////////////
// cInputBuffer
void cInputBuffer::FinalRelease()
{
if( cInputService::g_p != NULL && cInputService::g_p->m_pActive == this )
Stop();
}
bool cInputBuffer::checkState()
{
if( cInputService::g_p == NULL || cInputService::g_p->m_pActive == this )
{
// There must be an input service and it must be inactive
_ASSERT( FALSE );
return false;
}
return true;
}
HRESULT cInputBuffer::addItem( BSTR strInit, IInputAction **ppAction )
{
USES_CONVERSION;
LPTSTR szType = OLE2T( strInit );
size_t iInitData = ::_tcscspn( szType, _T( ":" ) );
if( iInitData == -1 )
return E_INVALIDARG;
szType[ iInitData ] = _T( '\0' );
LPCTSTR szInitData = szType + iInitData + 1;
::_tcslwr( szType );
for( cInputService::cActionTypeList::iterator i = cInputService::g_p->m_actiontypes.begin(); i != cInputService::g_p->m_actiontypes.end(); ++ i )
{
if( ::_tcscmp( szType, i->szAction ) == 0 )
break;
}
if( i == cInputService::g_p->m_actiontypes.end() )
return E_INVALIDARG;
// Get the configuration object for this inputaction
static _bstr_t _strActions( _T( "InputActions" ) );
CComPtr< IDecalEnum > pInputEnum;
if( cInputService::g_p->m_pDecal->get_Configuration( _strActions, i->m_clsid, &pInputEnum ) != S_OK )
// What used to be there is gone
return E_FAIL;
HRESULT hRes = pInputEnum->CreateInstance( __uuidof( IInputAction ), reinterpret_cast< void ** >( ppAction ) );
if( FAILED( hRes ) )
// Could not create our object
return hRes;
return ( *ppAction )->Initialize( this, _bstr_t( szInitData ) );
}
void cInputBuffer::runActions()
{
m_bWaiting = false;
while( m_play != m_entries.end() )
{
HRESULT hRes;
switch( m_play->m_eType )
{
case eExecute:
hRes = m_play->m_pAction->Execute();
break;
case ePush:
m_playstack.push( &*m_play );
hRes = m_play->m_pAction->Push();
break;
case ePop:
m_playstack.pop();
hRes = m_play->m_pAction->Pop();
break;
default:
hRes = E_FAIL;
}
if( FAILED( hRes ) )
{
_ASSERT( FALSE );
Stop();
return;
}
if( m_bWaiting || cInputService::g_p->m_pActive != this )
// If we're now waiting, return from our actions and continue
return;
++ m_play;
}
// We're done here
Stop();
}
STDMETHODIMP cInputBuffer::get_Tag(VARIANT *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
return ::VariantCopy( pVal, &m_tag );
}
STDMETHODIMP cInputBuffer::put_Tag(VARIANT newVal)
{
m_tag = newVal;
return S_OK;
}
STDMETHODIMP cInputBuffer::Add(BSTR strCommand)
{
if( !checkState() )
return E_FAIL;
cEntry e;
HRESULT hRes = addItem( strCommand, &e.m_pAction );
if( FAILED( hRes ) )
return hRes;
e.m_eType = eExecute;
m_entries.push_back( e );
return S_OK;
}
STDMETHODIMP cInputBuffer::Push(BSTR Command)
{
if( !checkState() )
return E_FAIL;
cEntry e;
HRESULT hRes = addItem( Command, &e.m_pAction );
if( FAILED( hRes ) )
return hRes;
VARIANT_BOOL bStackable;
e.m_pAction->get_Stackable( &bStackable );
if( !bStackable )
return E_INVALIDARG;
e.m_eType = ePush;
m_entries.push_back( e );
m_insertstack.push( &m_entries.back() );
return S_OK;
}
STDMETHODIMP cInputBuffer::Pop()
{
if( !checkState() )
return E_FAIL;
if( m_insertstack.size() == 0 )
{
_ASSERT( FALSE );
return E_FAIL;
}
cEntry e;
e.m_eType = ePop;
e.m_pAction = m_insertstack.top()->m_pAction;
m_entries.push_back( e );
m_insertstack.pop();
return S_OK;
}
STDMETHODIMP cInputBuffer::get_CanRun(VARIANT_BOOL *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
if( cInputService::g_p == NULL )
{
// There must be an input service
_ASSERT( FALSE );
return E_FAIL;
}
*pVal = ( cInputService::g_p->m_pActive == NULL ) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP cInputBuffer::Run()
{
if( cInputService::g_p == NULL || cInputService::g_p->m_pActive != NULL )
{
// There must be an input service and it must be inactive
_ASSERT( FALSE );
return E_FAIL;
}
// First check if the insert stack is incomplete
while( m_insertstack.size() > 0 )
Pop();
// Reset the cursors
while( m_playstack.size() > 0 )
m_playstack.pop();
m_play = m_entries.begin();
cInputService::g_p->m_pActive = this;
// Reset the actions
for( cEntryList::iterator i = m_entries.begin(); i != m_entries.end(); ++ i )
i->m_pAction->Reset();
Fire_Begin( this );
// Lock down the user input
::BlockInput( TRUE );
runActions();
return S_OK;
}
STDMETHODIMP cInputBuffer::Stop()
{
if( cInputService::g_p == NULL )
{
// There must be an input service
_ASSERT( FALSE );
return E_FAIL;
}
if( cInputService::g_p->m_pActive == NULL )
return S_FALSE;
if( cInputService::g_p->m_pActive != this )
return E_FAIL;
// Stop immediately, flush all entries in the stack
while( m_playstack.size() > 0 )
{
m_playstack.top()->m_pAction->Pop();
m_playstack.pop();
}
cInputService::g_p->m_pActive = NULL;
::BlockInput( FALSE );
Fire_End( this );
return S_OK;
}
STDMETHODIMP cInputBuffer::Delay(long Time, VARIANT_BOOL Advance)
{
if( Advance )
++ m_play;
m_bWaiting = true;
m_nUntilTime = ::timeGetTime() + Time;
return S_OK;
}
STDMETHODIMP cInputBuffer::FireEvent(long nEventID, VARIANT vParam)
{
Fire_Event( this, nEventID, vParam );
return S_OK;
}
STDMETHODIMP cInputBuffer::MoveMouse(long X, long Y)
{
if( cInputService::g_p == NULL )
{
// There must be an input service
_ASSERT( FALSE );
return E_FAIL;
}
// These are already traslated to screen coords
cInputService *pis = cInputService::g_p;
if( pis->m_eWindows == cInputService::eWindows98NoMemLocs )
return E_FAIL;
// Otherwise, get the window proc and send some info to move the mouse
WNDPROC wndProc = reinterpret_cast< WNDPROC >( ::GetWindowLong( pis->m_hWndHook, GWL_WNDPROC ) );
POINT ptScreen = { X, Y };
::ClientToScreen( pis->m_hWndHook, &ptScreen );
::SetCursorPos( ptScreen.x, ptScreen.y );
POINTS pts = { X, Y };
wndProc( pis->m_hWndHook, WM_MOUSEMOVE, 0, *reinterpret_cast< DWORD * >( &pts ) );
// Special additional functionality for win98
if( pis->m_eWindows == cInputService::eWindows98WithMemLocs )
{
pis->m_pnOffset1[ 0 ] = X;
pis->m_pnOffset1[ 1 ] = Y;
pis->m_pnOffset2[ 0 ] = X;
pis->m_pnOffset2[ 1 ] = Y;
pis->m_pnOffset2[ 2 ] = X;
pis->m_pnOffset2[ 3 ] = Y;
pis->m_pnOffset2[ 4 ] = X;
pis->m_pnOffset2[ 5 ] = Y;
// Delay a couple frames to be sure it's taken effect
Delay( 100, VARIANT_TRUE );
}
return S_OK;
}
STDMETHODIMP cInputBuffer::get_Service(IInputService **pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
if( cInputService::g_p == NULL )
{
// There must be an input service
_ASSERT( FALSE );
return E_FAIL;
}
return static_cast< IInputService * >( cInputService::g_p )->QueryInterface( pVal );
}

View file

@ -0,0 +1,93 @@
// InputBuffer.h : Declaration of the cInputBuffer
#ifndef __INPUTBUFFER_H_
#define __INPUTBUFFER_H_
#include "resource.h" // main symbols
#include "DecalInputCP.h"
/////////////////////////////////////////////////////////////////////////////
// cInputBuffer
class ATL_NO_VTABLE cInputBuffer :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cInputBuffer, &CLSID_InputBuffer>,
public IConnectionPointContainerImpl<cInputBuffer>,
public IProvideClassInfo2Impl< &CLSID_InputBuffer, &DIID_IInputBufferEvents, &LIBID_DecalInput >,
public IDispatchImpl<IInputBuffer, &IID_IInputBuffer, &LIBID_DecalInput>,
public IInputActionSite,
public CProxyIInputBufferEvents< cInputBuffer >
{
public:
cInputBuffer()
: m_bWaiting( false ),
m_nUntilTime( 0 )
{
}
void FinalRelease();
_variant_t m_tag;
enum eEntryType
{
eExecute,
ePush,
ePop
};
struct cEntry
{
eEntryType m_eType;
CComPtr< IInputAction > m_pAction;
};
typedef std::list< cEntry > cEntryList;
cEntryList m_entries;
typedef std::stack< cEntry * > cEntryStack;
cEntryStack m_insertstack, m_playstack;
cEntryList::iterator m_play;
bool checkState();
HRESULT addItem( BSTR strInit, IInputAction **ppAction );
void runActions();
// Delay information
bool m_bWaiting;
long m_nUntilTime;
DECLARE_REGISTRY_RESOURCEID(IDR_INPUTBUFFER)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cInputBuffer)
COM_INTERFACE_ENTRY(IInputActionSite)
COM_INTERFACE_ENTRY(IInputBuffer)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(cInputBuffer)
CONNECTION_POINT_ENTRY(DIID_IInputBufferEvents)
END_CONNECTION_POINT_MAP()
public:
// IInputActionSite
STDMETHOD(Delay)(long Time, VARIANT_BOOL Advance);
STDMETHOD(FireEvent)(long nEventID, VARIANT vParam);
STDMETHOD(MoveMouse)(long X, long Y);
STDMETHOD(get_Service)(/*[out, retval]*/ IInputService * *pVal);
// IInputBuffer
STDMETHOD(Stop)();
STDMETHOD(Run)();
STDMETHOD(get_CanRun)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(Pop)();
STDMETHOD(Push)(BSTR Command);
STDMETHOD(Add)(BSTR Command);
STDMETHOD(get_Tag)(/*[out, retval]*/ VARIANT *pVal);
STDMETHOD(put_Tag)(/*[in]*/ VARIANT newVal);
};
#endif //__INPUTBUFFER_H_

View file

@ -0,0 +1,26 @@
HKCR
{
DecalInput.InputBuffer.1 = s 'InputBuffer Class'
{
CLSID = s '{F0A17A04-7F8F-4A17-A41D-8C297A1E929B}'
}
DecalInput.InputBuffer = s 'InputBuffer Class'
{
CLSID = s '{F0A17A04-7F8F-4A17-A41D-8C297A1E929B}'
CurVer = s 'DecalInput.InputBuffer.1'
}
NoRemove CLSID
{
ForceRemove {F0A17A04-7F8F-4A17-A41D-8C297A1E929B} = s 'InputBuffer Class'
{
ProgID = s 'DecalInput.InputBuffer.1'
VersionIndependentProgID = s 'DecalInput.InputBuffer'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}

View file

@ -0,0 +1,408 @@
// InputService.cpp : Implementation of cInputService
#include "stdafx.h"
#include "DecalInput.h"
#include "InputService.h"
#include "Timer.h"
#include "Hotkey.h"
#include "WinMsgHook.h"
#include "InputBuffer.h"
using cInputService::cCharNames;
static cCharNames _charnames[] = {
{ _T( "BACKSPACE" ), VK_BACK },
{ _T( "BS" ), VK_BACK },
{ _T( "BKSP" ), VK_BACK },
{ _T( "CAPSLOCK" ), VK_CAPITAL },
{ _T( "DELETE" ), VK_DELETE },
{ _T( "DEL" ), VK_DELETE },
{ _T( "DOWN" ), VK_DOWN },
{ _T( "END" ), VK_END },
{ _T( "ENTER" ), VK_RETURN },
{ _T( "ESC" ), VK_ESCAPE },
{ _T( "HELP" ), VK_HELP },
{ _T( "HOME" ), VK_HOME },
{ _T( "INS" ), VK_INSERT },
{ _T( "INSERT" ), VK_INSERT },
{ _T( "LEFT" ), VK_LEFT },
{ _T( "NUMLOCK" ), VK_NUMLOCK },
{ _T( "PGDN" ), VK_NEXT },
{ _T( "PGUP" ), VK_PRIOR },
{ _T( "PRTSC" ), VK_SNAPSHOT },
{ _T( "RIGHT" ), VK_RIGHT },
{ _T( "SCROLLLOCK" ), VK_SCROLL },
{ _T( "TAB" ), VK_TAB },
{ _T( "UP" ), VK_UP },
{ _T( "F1" ), VK_F1 },
{ _T( "F2" ), VK_F2 },
{ _T( "F3" ), VK_F3 },
{ _T( "F4" ), VK_F4 },
{ _T( "F5" ), VK_F5 },
{ _T( "F6" ), VK_F6 },
{ _T( "F7" ), VK_F7 },
{ _T( "F8" ), VK_F8 },
{ _T( "F9" ), VK_F9 },
{ _T( "F10" ), VK_F10 },
{ _T( "F11" ), VK_F11 },
{ _T( "F12" ), VK_F12 },
{ _T( "F13" ), VK_F13 },
{ _T( "F14" ), VK_F14 },
{ _T( "F15" ), VK_F15 },
{ _T( "F16" ), VK_F16 },
{ _T( "+" ), VK_ADD },
{ _T( "SHIFT" ), VK_SHIFT },
{ _T( "CTRL" ), VK_CONTROL },
{ _T( "ALT" ), VK_MENU },
{ _T( "LBUTTON" ), VK_LBUTTON },
{ _T( "RBUTTON" ), VK_RBUTTON } },
*_end_charnames = _charnames + ( sizeof(_charnames ) / sizeof( cCharNames ) );
/////////////////////////////////////////////////////////////////////////////
// cInputService
LRESULT cInputService::wndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
{
if( g_p == NULL || g_p->m_hWndHook != hWnd )
{
// We have no idea how to continue - this hook has been orphaned
_ASSERT( FALSE );
return 0;
}
if( g_p->m_msghooks.size() > 0 )
{
// Fill out the message
g_p->m_pMessage->loadMessage( hWnd, nMsg, wParam, lParam );
for( cWinMsgHookList::iterator i = g_p->m_msghooks.begin(); i != g_p->m_msghooks.end(); ++ i )
{
( *i )->Fire_Message( *i, g_p->m_pMessage );
if( g_p->m_pMessage->m_bEaten )
// This message was eaten, yummy
return 0;
}
}
// NOTE: The hotkeys are not dispatched while an input buffer is running - tough luck
if( nMsg == WM_KEYUP && g_p->m_pActive == NULL )
{
int nVK = static_cast< int >( wParam );
// Check if there's a matching hotkey
for( cHotkeyList::iterator i = g_p->m_hotkeys.begin(); i != g_p->m_hotkeys.end(); ++ i )
{
if( ( *i )->m_nVK == nVK )
{
// Found a hotkey - fire the event and eat it
( *i )->Fire_Hotkey( *i );
break;
}
}
}
return g_p->m_pfnHook( hWnd, nMsg, wParam, lParam );
}
cInputService *cInputService::g_p = NULL;
HRESULT cInputService::onInitialize()
{
// ::DebugBreak();
USES_CONVERSION;
if( g_p == NULL )
g_p = this;
// Create the message object
CComObject< cWndMsg >::CreateInstance( &m_pMessage );
m_pMessage->AddRef();
// Load the list of action types from the configuration data
{
static _bstr_t _strPrefix( _T( "Prefix" ) );
CComPtr< IDecalEnum > pActions;
m_pDecal->get_Configuration( _bstr_t( _T( "InputActions" ) ), GUID_NULL, &pActions );
while( pActions->Next() == S_OK )
{
VARIANT_BOOL bEnabled;
HRESULT hRes = pActions->get_Enabled ( &bEnabled );
_ASSERTE ( SUCCEEDED ( hRes ) );
if ( !bEnabled )
continue;
cActionType at;
pActions->get_ComClass( &at.m_clsid );
CComVariant v;
if( FAILED( pActions->get_Property( _strPrefix, &v ) ) )
continue;
::_tcscpy( at.szAction, OLE2T( v.bstrVal ) );
::_tcslwr( at.szAction );
m_actiontypes.push_back( at );
}
}
// Get the OS version
OSVERSIONINFO ovi;
ovi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
::GetVersionEx( &ovi );
if( ovi.dwPlatformId == VER_PLATFORM_WIN32_NT )
{
m_eWindows = eWindowsNT;
return S_OK;
}
// First check if there's version info in the registry
RegKey key;
key.Open( HKEY_LOCAL_MACHINE, _T( "Software\\Decal" ) );
DWORD dwRegMajor, dwRegMinor;
if( key.QueryDWORDValue( _T( "ACMajorVersion" ), dwRegMajor ) != ERROR_SUCCESS ||
key.QueryDWORDValue( _T( "ACMinorVersion" ), dwRegMinor ) != ERROR_SUCCESS )
{
m_eWindows = eWindows98NoMemLocs;
return S_OK;
}
TCHAR szFilename[ MAX_PATH ];
DWORD dwVerSize;
::GetModuleFileName( NULL, szFilename, MAX_PATH );
if( ::GetFileVersionInfoSize( szFilename, &dwVerSize ) )
{
m_eWindows = eWindows98NoMemLocs;
return S_OK;
}
BYTE *pbVersionInfo = reinterpret_cast< BYTE * >( ::_alloca( dwVerSize ) );
::GetFileVersionInfo( szFilename, 0, dwVerSize, pbVersionInfo );
VS_FIXEDFILEINFO *vffi;
UINT nLength = sizeof( VS_FIXEDFILEINFO );
if( ::VerQueryValue( pbVersionInfo, _T( "\\" ), reinterpret_cast< LPVOID * >( &vffi ), &nLength ) )
{
if( dwRegMajor == vffi->dwFileVersionMS && dwRegMinor == vffi->dwFileVersionLS )
{
DWORD dwOffset1, dwOffset2;
if( key.QueryDWORDValue( _T( "MouseOffset1" ), dwOffset1 ) == ERROR_SUCCESS &&
key.QueryDWORDValue( _T( "MouseOffset2" ), dwOffset2 ) == ERROR_SUCCESS )
{
m_eWindows = eWindows98WithMemLocs;
m_pnOffset1 = reinterpret_cast< long * >( dwOffset1 );
m_pnOffset2 = reinterpret_cast< long * >( dwOffset2 );
return S_OK;
}
}
}
m_eWindows = eWindows98NoMemLocs;
return S_OK;
}
void cInputService::onTerminate()
{
// Create the message object
m_pMessage->Release();
m_pMessage = NULL;
if( g_p == this )
g_p = NULL;
}
cCharNames *cInputService::begin_chars()
{
return _charnames;
}
cCharNames *cInputService::end_chars()
{
return _end_charnames;
}
cCharNames *cInputService::charFromVK( int nVK )
{
for( cCharNames *i_chars = _charnames; i_chars != _end_charnames; ++ i_chars )
{
if( i_chars->m_nVKey == nVK )
break;
}
return i_chars;
}
cCharNames *cInputService::charFromName( LPCTSTR szName, int nLength )
{
for( cCharNames *i_chars = _charnames; i_chars != _end_charnames; ++ i_chars )
{
if( ::strlen( i_chars->szName ) == nLength && std::equal( szName, szName + nLength, i_chars->szName ) )
break;
}
return i_chars;
}
STDMETHODIMP cInputService::BeforePlugins()
{
// Hook the main plugin window
long nWnd;
m_pDecal->get_HWND( &nWnd );
if( nWnd != 0 )
{
m_hWndHook = reinterpret_cast< HWND >( nWnd );
m_pfnHook = reinterpret_cast< WNDPROC >( ::SetWindowLong( m_hWndHook, GWL_WNDPROC, reinterpret_cast< LONG >( wndProc ) ) );
}
// Load the keymap
RegKey key;
if(key.Open( HKEY_LOCAL_MACHINE, _T( "SOFTWARE\\Microsoft\\Microsoft Games\\Asheron's Call\\1.00" ), KEY_READ ) != ERROR_SUCCESS)
return E_FAIL;
TCHAR szFilename[ MAX_PATH ];
TCHAR *pszInsert = szFilename;
DWORD dwSize = MAX_PATH;
key.QueryStringValue( _T("Path"), szFilename, &dwSize );
pszInsert = &szFilename[dwSize-1];
//pszInsert += dwSize;
::_tcscat( pszInsert, _T( "\\" ) );
++ pszInsert;
dwSize = MAX_PATH - ( dwSize + 1 );
key.QueryStringValue( _T( "CurrentInputMap" ), pszInsert, &dwSize );
// Looking good, open up the file and load the keys
std::ifstream is( szFilename );
if( is.bad() )
// Could not load the file
return E_FAIL;
int nCount = 0;
is >> nCount;
for( ; nCount > 0; -- nCount )
{
int nInputType, nVK, nChording, nCommandType, nAnalogType;
TCHAR szCommandName[ 64 ];
is >> nInputType >> nVK >> nChording >> szCommandName >> nCommandType >> nAnalogType;
m_commands.insert( cCommandMap::value_type( szCommandName, static_cast< WORD >( nVK ) ) );
}
return S_OK;
}
STDMETHODIMP cInputService::AfterPlugins()
{
m_commands.clear();
if( m_hWndHook != NULL )
{
_ASSERTE( reinterpret_cast< LONG >( wndProc ) == ::GetWindowLong( m_hWndHook, GWL_WNDPROC ) );
::SetWindowLong( m_hWndHook, GWL_WNDPROC, reinterpret_cast< LONG >( m_pfnHook ) );
}
return S_OK;
}
STDMETHODIMP cInputService::get_Command(BSTR strCommandName, BSTR *pVal)
{
USES_CONVERSION;
// First try to find the command in the list
_bstr_t strCommand( strCommandName );
cCommandMap::iterator i = m_commands.find( strCommand );
if( i == m_commands.end() )
{
*pVal = T2BSTR( _T( "" ) );
return S_FALSE;
}
WORD nCommand = i->second;
// Scan to see if this command has a special name
cCharNames *i_chars = charFromVK( nCommand );
if( i_chars != end_chars() )
{
TCHAR szFormat[ 12 ];
::_stprintf( szFormat, _T( "{%s}" ), i_chars->szName );
*pVal = T2BSTR( szFormat );
return S_OK;
}
// Ok, we'll assume the char is printable
TCHAR szString[ 2 ] = { nCommand, _T( '\0' ) };
*pVal = T2BSTR( szString );
return S_OK;
}
STDMETHODIMP cInputService::Render2D()
{
long nTime = static_cast< long >( ::timeGetTime() );
cTimerList::iterator i = m_timers.begin();
while( i != m_timers.end() )
{
cTimerList::iterator j = i++; // Make a copy of the iterator, increment it, then call the timeout.
if( ( ( *j )->m_nStart + ( *j )->m_nInterval ) <= nTime )
{
( *j )->m_nStart = nTime;
( *j )->Fire_Timeout( *j );
}
}
// Check to see if there's a delay paused
if( m_pActive != NULL && m_pActive->m_bWaiting && m_pActive->m_nUntilTime <= nTime )
// We've passed the timeout, continue processing actions
m_pActive->runActions();
return S_OK;
}
STDMETHODIMP cInputService::ChangeHWND()
{
return S_OK;
}
STDMETHODIMP cInputService::get_Decal(IDecal **pVal)
{
return m_pDecal->QueryInterface( pVal );
}
STDMETHODIMP cInputService::get_KeyByName(BSTR strName, long *pVal)
{
USES_CONVERSION;
LPTSTR szName = OLE2T( strName );
cCharNames *i_c = charFromName( szName, ::_tcslen( szName ) );
if( i_c == end_chars() )
return E_INVALIDARG;
*pVal = i_c->m_nVKey;
return S_OK;
}
STDMETHODIMP cInputService::get_CommandKey(BSTR strCommandName, long *pVal)
{
_bstr_t strCommand( strCommandName );
cCommandMap::iterator i = m_commands.find( strCommand );
if( i == m_commands.end() )
return E_FAIL;
*pVal = i->second;
return S_OK;
}

View file

@ -0,0 +1,121 @@
// InputService.h : Declaration of the cInputService
#ifndef __INPUTSERVICE_H_
#define __INPUTSERVICE_H_
#include "resource.h" // main symbols
#include <DecalImpl.h>
#include "WndMsg.h"
class cTimer;
class cHotkey;
class cWinMsgHook;
class cInputBuffer;
/////////////////////////////////////////////////////////////////////////////
// cInputService
class ATL_NO_VTABLE cInputService :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cInputService, &CLSID_InputService>,
public IDecalServiceImpl< cInputService >,
public IDecalRenderImpl,
public IDispatchImpl<IInputService, &IID_IInputService, &LIBID_DecalInput>
{
public:
cInputService()
: m_hWndHook( NULL ),
m_pfnHook( NULL ),
m_pnOffset1( NULL ),
m_pnOffset2( NULL ),
m_pMessage( NULL ),
m_pActive( NULL )
{
}
typedef std::map< _bstr_t, WORD > cCommandMap;
cCommandMap m_commands;
typedef std::list< cTimer * > cTimerList;
cTimerList m_timers;
typedef std::list< cHotkey * > cHotkeyList;
cHotkeyList m_hotkeys;
typedef std::list< cWinMsgHook * > cWinMsgHookList;
cWinMsgHookList m_msghooks;
CComObject< cWndMsg > *m_pMessage;
HWND m_hWndHook;
WNDPROC m_pfnHook;
static LRESULT CALLBACK wndProc( HWND, UINT, WPARAM, LPARAM );
enum eWindowsType
{
eWindowsNT,
eWindows98WithMemLocs,
eWindows98NoMemLocs
};
eWindowsType m_eWindows;
long *m_pnOffset1,
*m_pnOffset2;
struct cActionType
{
TCHAR szAction[ 20 ];
CLSID m_clsid;
};
typedef std::vector< cActionType > cActionTypeList;
cActionTypeList m_actiontypes;
cInputBuffer *m_pActive;
static cInputService *g_p;
HRESULT onInitialize();
void onTerminate();
// Key-name mapping
struct cCharNames
{
LPCTSTR szName;
WORD m_nVKey;
};
static cCharNames *begin_chars();
static cCharNames *end_chars();
static cCharNames *charFromVK( int nVK );
static cCharNames *charFromName( LPCTSTR szName, int nLength );
DECLARE_REGISTRY_RESOURCEID(IDR_INPUTSERVICE)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cInputService)
COM_INTERFACE_ENTRY(IDecalRender)
COM_INTERFACE_ENTRY(IDecalService)
COM_INTERFACE_ENTRY(IInputService)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
// IInputService
public:
STDMETHOD(get_CommandKey)(BSTR strCommand, /*[out, retval]*/ long *pVal);
STDMETHOD(get_KeyByName)(BSTR strName, /*[out, retval]*/ long *pVal);
STDMETHOD(get_Decal)(/*[out, retval]*/ IDecal * *pVal);
STDMETHOD(get_Command)(BSTR strCommandName, /*[out, retval]*/ BSTR *pVal);
// IDecalService
STDMETHOD(BeforePlugins)();
STDMETHOD(AfterPlugins)();
// IDecalRender
STDMETHOD(Render2D)();
STDMETHOD(ChangeHWND)();
};
#endif //__INPUTSERVICE_H_

View file

@ -0,0 +1,43 @@
HKCR
{
DecalInput.InputService.1 = s 'InputService Class'
{
CLSID = s '{B33307BA-706D-474A-80B9-70BB8D13EF3E}'
}
DecalInput.InputService = s 'InputService Class'
{
CLSID = s '{B33307BA-706D-474A-80B9-70BB8D13EF3E}'
CurVer = s 'DecalInput.InputService.1'
}
NoRemove CLSID
{
ForceRemove {B33307BA-706D-474A-80B9-70BB8D13EF3E} = s 'InputService Class'
{
ProgID = s 'DecalInput.InputService.1'
VersionIndependentProgID = s 'DecalInput.InputService'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}
HKLM
{
NoRemove SOFTWARE
{
NoRemove Decal
{
NoRemove Services
{
ForceRemove {B33307BA-706D-474A-80B9-70BB8D13EF3E} = s 'Decal Input Service'
{
val Enabled = d '1'
}
}
}
}
}

View file

@ -0,0 +1,81 @@
// 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 ) );
}

View file

@ -0,0 +1,71 @@
// MouseMoveAction.h : Declaration of the cMouseMoveAction
#ifndef __MOUSEMOVEACTION_H_
#define __MOUSEMOVEACTION_H_
#include "resource.h" // main symbols
#include <DecalInputImpl.h>
/////////////////////////////////////////////////////////////////////////////
// cMouseMoveAction
class ATL_NO_VTABLE cMouseMoveAction :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cMouseMoveAction, &CLSID_MouseMoveAction>,
public IInputActionImpl< cMouseMoveAction >
{
public:
cMouseMoveAction()
{
}
enum eDirection
{
eLeftTop,
eRightBottom,
ePercent
};
struct cValue
{
eDirection m_eDir;
long m_nMagnitude;
long value( long nMax )
{
switch( m_eDir )
{
case eLeftTop:
return m_nMagnitude;
case ePercent:
return ( ( nMax * m_nMagnitude ) / 100 );
case eRightBottom:
return nMax - m_nMagnitude;
}
// Unknown type
_ASSERT( FALSE );
return 0;
}
};
cValue m_x, m_y;
HRESULT onLoad( LPTSTR szData );
HRESULT loadValue( LPTSTR szData, cValue &val );
DECLARE_REGISTRY_RESOURCEID(IDR_MOUSEMOVEACTION)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cMouseMoveAction)
COM_INTERFACE_ENTRY(IInputAction)
END_COM_MAP()
// IMouseMoveAction
public:
STDMETHOD(Execute)();
};
#endif //__MOUSEMOVEACTION_H_

View file

@ -0,0 +1,43 @@
HKCR
{
DecalInput.MouseMoveAction.1 = s 'MouseMoveAction Class'
{
CLSID = s '{57D18578-0BF0-4DE5-A0A9-E7CB531C0429}'
}
DecalInput.MouseMoveAction = s 'MouseMoveAction Class'
{
CLSID = s '{57D18578-0BF0-4DE5-A0A9-E7CB531C0429}'
CurVer = s 'DecalInput.MouseMoveAction.1'
}
NoRemove CLSID
{
ForceRemove {57D18578-0BF0-4DE5-A0A9-E7CB531C0429} = s 'MouseMoveAction Class'
{
ProgID = s 'DecalInput.MouseMoveAction.1'
VersionIndependentProgID = s 'DecalInput.MouseMoveAction'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}
HKLM
{
NoRemove SOFTWARE
{
NoRemove Decal
{
NoRemove InputActions
{
ForceRemove {57D18578-0BF0-4DE5-A0A9-E7CB531C0429} = s 'Mouse Move Input Action'
{
val Enabled = d '1'
val Prefix = s 'mousemove'
}
}
}
}
}

View file

@ -0,0 +1,8 @@
// PolledDelayAction.cpp : Implementation of cPolledDelayAction
#include "stdafx.h"
#include "DecalInput.h"
#include "PolledDelayAction.h"
/////////////////////////////////////////////////////////////////////////////
// cPolledDelayAction

View file

@ -0,0 +1,84 @@
// PolledDelayAction.h : Declaration of the cPolledDelayAction
#ifndef __POLLEDDELAYACTION_H_
#define __POLLEDDELAYACTION_H_
#include "resource.h" // main symbols
#include <DecalInputImpl.h>
/////////////////////////////////////////////////////////////////////////////
// cPolledDelayAction
class ATL_NO_VTABLE cPolledDelayAction :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cPolledDelayAction, &CLSID_PolledDelayAction>,
public IInputActionImpl< cPolledDelayAction >
{
public:
cPolledDelayAction()
: m_bFirst( true )
{
}
bool m_bFirst;
long m_nTime,
m_nEvent;
HRESULT load( LPTSTR szBuffer )
{
int nSep = ::_tcscspn( szBuffer, _T( ";" ) );
if( nSep == -1 )
return E_INVALIDARG;
szBuffer[ nSep ] = _T( '\0' );
if( ::_stscanf( szBuffer, _T( "%i" ), &m_nTime ) != 1 )
return E_INVALIDARG;
if( ::_stscanf( szBuffer + nSep + 1, _T( "%i" ), &m_nEvent ) != 1 )
return E_INVALIDARG;
return S_OK;
}
DECLARE_REGISTRY_RESOURCEID(IDR_POLLEDDELAYACTION)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cPolledDelayAction)
COM_INTERFACE_ENTRY(IInputAction)
END_COM_MAP()
// IPolledDelayAction
public:
STDMETHOD(Reset)()
{
m_bFirst = true;
return S_OK;
}
STDMETHOD(Execute)()
{
if( !m_bFirst )
{
// Fire the event to figure out if we should continue
VARIANT_BOOL bContinue = VARIANT_FALSE;
VARIANT vParam;
vParam.vt = VT_BOOL | VT_BYREF;
vParam.pboolVal = &bContinue;
m_pSite->FireEvent( m_nEvent, vParam );
if( !bContinue )
// Abort and let it carry on
return S_OK;
}
else
// Clear the first flag
m_bFirst = false;
m_pSite->Delay( m_nTime, VARIANT_FALSE );
return S_OK;
}
};
#endif //__POLLEDDELAYACTION_H_

View file

@ -0,0 +1,43 @@
HKCR
{
DecalInput.PolledDelayAction.1 = s 'PolledDelayAction Class'
{
CLSID = s '{762335B2-2274-4BB4-8B1F-F7286C949FF7}'
}
DecalInput.PolledDelayAction = s 'PolledDelayAction Class'
{
CLSID = s '{762335B2-2274-4BB4-8B1F-F7286C949FF7}'
CurVer = s 'DecalInput.PolledDelayAction.1'
}
NoRemove CLSID
{
ForceRemove {762335B2-2274-4BB4-8B1F-F7286C949FF7} = s 'PolledDelayAction Class'
{
ProgID = s 'DecalInput.PolledDelayAction.1'
VersionIndependentProgID = s 'DecalInput.PolledDelayAction'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}
HKLM
{
NoRemove SOFTWARE
{
NoRemove Decal
{
NoRemove InputActions
{
ForceRemove {762335B2-2274-4BB4-8B1F-F7286C949FF7} = s 'Polled Delay Input Action'
{
val Enabled = d '1'
val Prefix = s 'polldelay'
}
}
}
}
}

View file

@ -0,0 +1,8 @@
// RestoreAction.cpp : Implementation of cRestoreAction
#include "stdafx.h"
#include "DecalInput.h"
#include "RestoreAction.h"
/////////////////////////////////////////////////////////////////////////////
// cRestoreAction

View file

@ -0,0 +1,54 @@
// RestoreAction.h : Declaration of the cRestoreAction
#ifndef __RESTOREACTION_H_
#define __RESTOREACTION_H_
#include "resource.h" // main symbols
#include <DecalInputImpl.h>
/////////////////////////////////////////////////////////////////////////////
// cRestoreAction
class ATL_NO_VTABLE cRestoreAction :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cRestoreAction, &CLSID_RestoreAction>,
public IInputActionImpl< cRestoreAction >
{
public:
cRestoreAction()
{
}
POINT m_pt;
// Nothing to load really
DECLARE_REGISTRY_RESOURCEID(IDR_RESTOREACTION)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cRestoreAction)
COM_INTERFACE_ENTRY(IInputAction)
END_COM_MAP()
// IRestoreAction
public:
STDMETHOD(get_Stackable)(VARIANT_BOOL *pVal)
{
*pVal = VARIANT_TRUE;
return S_OK;
}
STDMETHOD(Push)()
{
::GetCursorPos( &m_pt );
return S_OK;
}
STDMETHOD(Pop)()
{
m_pSite->MoveMouse( m_pt.x, m_pt.y );
return S_OK;
}
};
#endif //__RESTOREACTION_H_

View file

@ -0,0 +1,43 @@
HKCR
{
DecalInput.RestoreAction.1 = s 'RestoreAction Class'
{
CLSID = s '{6EE2F682-7129-44BE-84B9-787BAE35EC1C}'
}
DecalInput.RestoreAction = s 'RestoreAction Class'
{
CLSID = s '{6EE2F682-7129-44BE-84B9-787BAE35EC1C}'
CurVer = s 'DecalInput.RestoreAction.1'
}
NoRemove CLSID
{
ForceRemove {6EE2F682-7129-44BE-84B9-787BAE35EC1C} = s 'RestoreAction Class'
{
ProgID = s 'DecalInput.RestoreAction.1'
VersionIndependentProgID = s 'DecalInput.RestoreAction'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}
HKLM
{
NoRemove SOFTWARE
{
NoRemove Decal
{
NoRemove InputActions
{
ForceRemove {6EE2F682-7129-44BE-84B9-787BAE35EC1C} = s 'Restore Input Action'
{
val Enabled = d '1'
val Prefix = s 'restore'
}
}
}
}
}

View file

@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// stdafx.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View file

@ -0,0 +1,40 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#if !defined(AFX_STDAFX_H__F251EED2_D7E2_4CAB_B862_F92CB04AF3C6__INCLUDED_)
#define AFX_STDAFX_H__F251EED2_D7E2_4CAB_B862_F92CB04AF3C6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define STRICT
#define _WIN32_WINDOWS 0x0410
#define _ATL_APARTMENT_THREADED
#pragma warning(disable:4530)
#ifdef NDEBUG
#ifdef _ATL_DLL
#undef _ATL_DLL
#endif
#endif
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <winable.h>
#include <map>
#include <list>
#include <vector>
#include <stack>
#include <fstream>
#import <msxml.dll>
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__F251EED2_D7E2_4CAB_B862_F92CB04AF3C6__INCLUDED)

View file

@ -0,0 +1,96 @@
// Timer.cpp : Implementation of cTimer
#include "stdafx.h"
#include "DecalInput.h"
#include "Timer.h"
#include "InputService.h"
/////////////////////////////////////////////////////////////////////////////
// cTimer
STDMETHODIMP cTimer::Start(long Interval)
{
if( cInputService::g_p == NULL )
{
_ASSERT( FALSE );
return E_FAIL;
}
if( Interval <= 0 )
{
_ASSERT( FALSE );
return E_INVALIDARG;
}
if( m_bStarted )
Stop();
m_nStart = static_cast< long >( ::timeGetTime() );
m_nInterval = Interval;
static_cast< IDispatch * >( cInputService::g_p )->AddRef();
cInputService::g_p->m_timers.push_back( this );
m_bStarted = true;
return S_OK;
}
STDMETHODIMP cTimer::Stop()
{
if( cInputService::g_p == NULL )
{
_ASSERT( FALSE );
return E_FAIL;
}
if( !m_bStarted )
return S_FALSE;
m_bStarted = false;
// Remove from the input service
for( cInputService::cTimerList::iterator i = cInputService::g_p->m_timers.begin(); i != cInputService::g_p->m_timers.end(); ++ i )
{
if( *i == this )
{
cInputService::g_p->m_timers.erase( i );
static_cast< IDispatch * >( cInputService::g_p )->Release();
return S_OK;
}
}
_ASSERT( FALSE );
return E_FAIL;
}
STDMETHODIMP cTimer::get_Tag(VARIANT *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
return ::VariantCopy( pVal, &m_tag );
}
STDMETHODIMP cTimer::put_Tag(VARIANT newVal)
{
m_tag = newVal;
return S_OK;
}
STDMETHODIMP cTimer::get_Running(VARIANT_BOOL *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
*pVal = ( m_bStarted ) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}

60
Native/DecalInput/Timer.h Normal file
View file

@ -0,0 +1,60 @@
// Timer.h : Declaration of the cTimer
#ifndef __TIMER_H_
#define __TIMER_H_
#include "resource.h" // main symbols
#include "DecalInputCP.h"
/////////////////////////////////////////////////////////////////////////////
// cTimer
class ATL_NO_VTABLE cTimer :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<cTimer, &CLSID_Timer>,
public IConnectionPointContainerImpl<cTimer>,
public IProvideClassInfo2Impl< &CLSID_Timer, &DIID_ITimerEvents, &LIBID_DecalInput >,
public IDispatchImpl<IDecalTimer, &IID_IDecalTimer, &LIBID_DecalInput>,
public CProxyITimerEvents< cTimer >
{
public:
cTimer()
: m_bStarted( false )
{
}
void FinalRelease()
{
if( m_bStarted )
Stop();
}
_variant_t m_tag;
bool m_bStarted;
long m_nStart,
m_nInterval;
DECLARE_REGISTRY_RESOURCEID(IDR_TIMER)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cTimer)
COM_INTERFACE_ENTRY(IDecalTimer)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(cTimer)
CONNECTION_POINT_ENTRY(DIID_ITimerEvents)
END_CONNECTION_POINT_MAP()
// ITimer
public:
STDMETHOD(get_Running)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(get_Tag)(/*[out, retval]*/ VARIANT *pVal);
STDMETHOD(put_Tag)(/*[in]*/ VARIANT newVal);
STDMETHOD(Stop)();
STDMETHOD(Start)(long Interval);
};
#endif //__TIMER_H_

View file

@ -0,0 +1,26 @@
HKCR
{
DecalInput.Timer.1 = s 'Timer Class'
{
CLSID = s '{79497C87-92E1-416B-AE5C-9D6C4C59133C}'
}
DecalInput.Timer = s 'Timer Class'
{
CLSID = s '{79497C87-92E1-416B-AE5C-9D6C4C59133C}'
CurVer = s 'DecalInput.Timer.1'
}
NoRemove CLSID
{
ForceRemove {79497C87-92E1-416B-AE5C-9D6C4C59133C} = s 'Timer Class'
{
ProgID = s 'DecalInput.Timer.1'
VersionIndependentProgID = s 'DecalInput.Timer'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Both'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}

View file

@ -0,0 +1,231 @@
// TypeAction.cpp : Implementation of cTypeAction
#include "stdafx.h"
#include "DecalInput.h"
#include "TypeAction.h"
/////////////////////////////////////////////////////////////////////////////
// cTypeAction
HRESULT cTypeAction::extractKey( LPTSTR &szIter, long nShiftState, IInputService *pService )
{
HRESULT hRes;
switch( *szIter )
{
case _T( '\0' ):
return E_INVALIDARG;
case _T( '{' ):
// Make sure this is a good key
{
for( TCHAR *szChar = szIter + 1; *szChar != _T( '\0' ); ++ szChar )
{
if( *szChar == _T( '}' ) )
{
// Look up this character in the site table
std::string strspecial( szIter + 1, szChar - ( szIter + 1 ) );
long nVK;
hRes = pService->get_KeyByName( _bstr_t( strspecial.c_str() ), &nVK );
if( FAILED( hRes ) )
{
_ASSERTE( FALSE );
return E_INVALIDARG;
}
cKey key = { nShiftState, nVK };
m_keys.push_back( key );
szIter = szChar + 1;
break;
}
}
if( *szChar == _T( '\0' ) )
{
// Unterminated constant
return E_INVALIDARG;
}
}
break;
case _T( '<' ):
{
for( TCHAR *szChar = szIter + 1; *szChar != _T( '\0' ); ++ szChar )
{
if( *szChar == _T( '>' ) )
{
// Look up this character in the site table
std::string strspecial( szIter + 1, szChar - ( szIter + 1 ) );
long nVK;
hRes = pService->get_CommandKey( _bstr_t( strspecial.c_str() ), &nVK );
if( hRes != S_OK )
{
_ASSERTE( FALSE );
return E_INVALIDARG;
}
cKey key = { nShiftState, nVK };
m_keys.push_back( key );
szIter = szChar + 1;
break;
}
}
if( *szChar == _T( '\0' ) )
{
// Unterminated constant
return E_INVALIDARG;
}
}
break;
default:
{
// Convert the character
WORD wVkScan = VkKeyScan( *szIter );
cKey key = { nShiftState | ( wVkScan & SHIFT_MASK ),
wVkScan & VKEY_MASK };
m_keys.push_back( key );
++ szIter;
}
}
return S_OK;
}
HRESULT cTypeAction::onLoad( LPTSTR szData )
{
USES_CONVERSION;
typedef std::stack< long > cShiftStack;
cShiftStack shifts;
long nCurrentShift = 0;
CComPtr< IInputService > pService;
HRESULT hRes = m_pSite->get_Service( &pService );
if( FAILED( hRes ) )
return hRes;
for( TCHAR *szIter = szData; *szIter != _T( '\0' ); )
{
switch( *szIter )
{
case _T( '+' ):
if( szIter[ 1 ] == _T( '(' ) )
{
szIter += 2;
shifts.push( nCurrentShift );
nCurrentShift |= MASK_SHIFT;
}
else
{
++ szIter;
hRes = extractKey( szIter, nCurrentShift | MASK_SHIFT, pService );
if( FAILED( hRes ) )
return hRes;
}
break;
case _T( '^' ):
if( szIter[ 1 ] == _T( '(' ) )
{
szIter += 2;
shifts.push( nCurrentShift );
nCurrentShift |= MASK_CTRL;
}
else
{
++ szIter;
hRes = extractKey( szIter, nCurrentShift | MASK_SHIFT, pService );
if( FAILED( hRes ) )
return hRes;
}
break;
case _T( '%' ):
if( szIter[ 1 ] == _T( '(' ) )
{
szIter += 2;
shifts.push( nCurrentShift );
nCurrentShift |= MASK_ALT;
}
else
{
++ szIter;
hRes = extractKey( szIter, nCurrentShift | MASK_SHIFT, pService );
if( FAILED( hRes ) )
return hRes;
}
break;
case _T( ')' ):
{
if( shifts.size() == 0 )
{
// Misplaced ')'
_ASSERT( FALSE );
return E_INVALIDARG;
}
nCurrentShift = shifts.top();
shifts.pop();
++ szIter;
}
break;
default:
hRes = extractKey( szIter, nCurrentShift, pService );
if( FAILED( hRes ) )
return hRes;
break;
}
}
if( shifts.size() > 0 )
{
// Unterminated shift
_ASSERT( FALSE );
return E_INVALIDARG;
}
// Successful parsing WTG!
return S_OK;
}
STDMETHODIMP cTypeAction::Execute()
{
long nShift = 0;
for( cKeyList::iterator i = m_keys.begin(); i != m_keys.end(); ++ i )
{
transitionShift( nShift, i->m_nShiftState );
pressKey( i->m_nVK, true );
pressKey( i->m_nVK, false );
nShift = i->m_nShiftState;
}
// Make sure all shift keys are released
transitionShift( nShift, 0 );
flushInput();
return S_OK;
}
STDMETHODIMP cTypeAction::Push()
{
doInput( m_keys.begin(), m_keys.end(), true );
return S_OK;
}
STDMETHODIMP cTypeAction::Pop()
{
doInput( m_keys.rbegin(), m_keys.rend(), false );
return S_OK;
}

View file

@ -0,0 +1,140 @@
// TypeAction.h : Declaration of the cTypeAction
#ifndef __TYPEACTION_H_
#define __TYPEACTION_H_
#include "resource.h" // main symbols
#include <DecalInputImpl.h>
#define MASK_SHIFT 0x0100
#define MASK_CTRL 0x0200
#define MASK_ALT 0x0400
#define SHIFT_MASK 0x0700
#define VKEY_MASK 0x00FF
/////////////////////////////////////////////////////////////////////////////
// cTypeAction
class ATL_NO_VTABLE cTypeAction :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cTypeAction, &CLSID_TypeAction>,
public IInputActionImpl< cTypeAction >
{
public:
cTypeAction()
: i_input( m_pInput )
{
::memset( m_pInput, 0, sizeof( INPUT ) * 16 );
}
struct cKey
{
long m_nShiftState,
m_nVK;
};
typedef std::deque< cKey > cKeyList;
cKeyList m_keys;
INPUT m_pInput[ 32 ],
*i_input;
void nextInput()
{
++ i_input;
if( i_input == ( m_pInput + 32 ) )
flushInput();
}
void flushInput()
{
if( i_input != m_pInput )
{
::SendInput( ( i_input - m_pInput ), m_pInput, sizeof( INPUT ) );
i_input = m_pInput;
::memset( m_pInput, 0, sizeof( INPUT ) * 32 );
}
}
void pressKey(long nVK, bool bDown)
{
switch( nVK )
{
case VK_LBUTTON:
i_input->type = INPUT_MOUSE;
i_input->mi.dwFlags = ( bDown ) ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
break;
case VK_RBUTTON:
i_input->type = INPUT_MOUSE;
i_input->mi.dwFlags = ( bDown ) ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
break;
default:
i_input->type = INPUT_KEYBOARD;
i_input->ki.wVk = nVK;
i_input->ki.wScan = ::MapVirtualKey( nVK, 0 );
i_input->ki.dwFlags = ( bDown ) ? 0 : KEYEVENTF_KEYUP;
break;
}
nextInput();
}
void transitionShift(long nFrom, long nTo)
{
if( nFrom == nTo )
// Nothing to transition
return;
// Check for all 6 possible key presses
if( ( nFrom & MASK_SHIFT ) && !( nTo & MASK_SHIFT ) )
pressKey( VK_SHIFT, false );
else if( !( nFrom & MASK_SHIFT ) && ( nTo & MASK_SHIFT ) )
pressKey( VK_SHIFT, true );
if( ( nFrom & MASK_CTRL ) && !( nTo & MASK_CTRL ) )
pressKey( VK_CONTROL, false );
else if( !( nFrom & MASK_CTRL ) && ( nTo & MASK_CTRL ) )
pressKey( VK_CONTROL, true );
if( ( nFrom & MASK_ALT ) && !( nTo & MASK_ALT ) )
pressKey( VK_MENU, false );
else if( !( nFrom & MASK_ALT ) && ( nTo & MASK_ALT ) )
pressKey( VK_MENU, true );
}
HRESULT extractKey( LPTSTR &szIterator, long nShiftState, IInputService *pService );
HRESULT onLoad( LPTSTR szData );
template< class iterator_t >
void doInput( iterator_t begin, iterator_t end, bool bDown )
{
for( iterator_t i = begin; i != end; ++ i )
pressKey( i->m_nVK, bDown );
flushInput();
}
DECLARE_REGISTRY_RESOURCEID(IDR_TYPEACTION)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cTypeAction)
COM_INTERFACE_ENTRY(IInputAction)
END_COM_MAP()
// ITypeAction
public:
STDMETHOD(get_Stackable)(VARIANT_BOOL *pVal)
{
*pVal = VARIANT_TRUE;
return S_OK;
}
STDMETHOD(Execute)();
STDMETHOD(Push)();
STDMETHOD(Pop)();
};
#endif //__TYPEACTION_H_

View file

@ -0,0 +1,43 @@
HKCR
{
DecalInput.TypeAction.1 = s 'TypeAction Class'
{
CLSID = s '{9CDCEEDC-F8AC-42D5-9A05-52B9346D00A4}'
}
DecalInput.TypeAction = s 'TypeAction Class'
{
CLSID = s '{9CDCEEDC-F8AC-42D5-9A05-52B9346D00A4}'
CurVer = s 'DecalInput.TypeAction.1'
}
NoRemove CLSID
{
ForceRemove {9CDCEEDC-F8AC-42D5-9A05-52B9346D00A4} = s 'TypeAction Class'
{
ProgID = s 'DecalInput.TypeAction.1'
VersionIndependentProgID = s 'DecalInput.TypeAction'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}
HKLM
{
NoRemove SOFTWARE
{
NoRemove Decal
{
NoRemove InputActions
{
ForceRemove {9CDCEEDC-F8AC-42D5-9A05-52B9346D00A4} = s 'Typing Input Action'
{
val Enabled = d '1'
val Prefix = s 'type'
}
}
}
}
}

View file

@ -0,0 +1,81 @@
// WinMsgHook.cpp : Implementation of cWinMsgHook
#include "stdafx.h"
#include "DecalInput.h"
#include "WinMsgHook.h"
#include "InputService.h"
/////////////////////////////////////////////////////////////////////////////
// cWinMsgHook
STDMETHODIMP cWinMsgHook::get_Tag(VARIANT *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
return ::VariantCopy( pVal, &m_tag );
}
STDMETHODIMP cWinMsgHook::put_Tag(VARIANT newVal)
{
m_tag = newVal;
return S_OK;
}
STDMETHODIMP cWinMsgHook::get_Enabled(VARIANT_BOOL *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
*pVal = ( m_bEnabled ) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP cWinMsgHook::put_Enabled(VARIANT_BOOL newVal)
{
if( !!newVal == m_bEnabled )
return S_FALSE;
if( cInputService::g_p == NULL )
{
// Input Service must be started to enable or disable a hotkey
_ASSERT( FALSE );
return E_FAIL;
}
m_bEnabled = !!newVal;
if( m_bEnabled )
{
#ifdef _DEBUG
for( cInputService::cWinMsgHookList::iterator i = cInputService::g_p->m_msghooks.begin(); i != cInputService::g_p->m_msghooks.end(); ++ i )
_ASSERTE( *i != this );
#endif
cInputService::g_p->m_msghooks.push_back( this );
}
else
{
for( cInputService::cWinMsgHookList::iterator i = cInputService::g_p->m_msghooks.begin(); i != cInputService::g_p->m_msghooks.end(); ++ i )
{
if( *i == this )
{
cInputService::g_p->m_msghooks.erase( i );
break;
}
}
_ASSERTE( i != cInputService::g_p->m_msghooks.end() );
}
return S_OK;
}

View file

@ -0,0 +1,57 @@
// WinMsgHook.h : Declaration of the cWinMsgHook
#ifndef __WINMSGHOOK_H_
#define __WINMSGHOOK_H_
#include "resource.h" // main symbols
#include "DecalInputCP.h"
/////////////////////////////////////////////////////////////////////////////
// cWinMsgHook
class ATL_NO_VTABLE cWinMsgHook :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<cWinMsgHook, &CLSID_WinMsgHook>,
public IProvideClassInfo2Impl< &CLSID_WinMsgHook, &DIID_IWinMsgHookEvents, &LIBID_DecalInput >,
public IConnectionPointContainerImpl<cWinMsgHook>,
public IDispatchImpl<IWinMsgHook, &IID_IWinMsgHook, &LIBID_DecalInput>,
public CProxyIWinMsgHookEvents< cWinMsgHook >
{
public:
cWinMsgHook()
: m_bEnabled( false )
{
}
void FinalRelease()
{
if( m_bEnabled )
put_Enabled( VARIANT_FALSE );
}
_variant_t m_tag;
bool m_bEnabled;
DECLARE_REGISTRY_RESOURCEID(IDR_WINMSGHOOK)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cWinMsgHook)
COM_INTERFACE_ENTRY(IWinMsgHook)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(cWinMsgHook)
CONNECTION_POINT_ENTRY(DIID_IWinMsgHookEvents)
END_CONNECTION_POINT_MAP()
// IWinMsgHook
public:
STDMETHOD(get_Enabled)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Enabled)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Tag)(/*[out, retval]*/ VARIANT *pVal);
STDMETHOD(put_Tag)(/*[in]*/ VARIANT newVal);
};
#endif //__WINMSGHOOK_H_

View file

@ -0,0 +1,26 @@
HKCR
{
DecalInput.WinMsgHook.1 = s 'WinMsgHook Class'
{
CLSID = s '{F3170E85-517E-43A4-B7B4-6F006A7B1B85}'
}
DecalInput.WinMsgHook = s 'WinMsgHook Class'
{
CLSID = s '{F3170E85-517E-43A4-B7B4-6F006A7B1B85}'
CurVer = s 'DecalInput.WinMsgHook.1'
}
NoRemove CLSID
{
ForceRemove {F3170E85-517E-43A4-B7B4-6F006A7B1B85} = s 'WinMsgHook Class'
{
ProgID = s 'DecalInput.WinMsgHook.1'
VersionIndependentProgID = s 'DecalInput.WinMsgHook'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}

View file

@ -0,0 +1,50 @@
// WndMsg.cpp : Implementation of cWndMsg
#include "stdafx.h"
#include "DecalInput.h"
#include "WndMsg.h"
/////////////////////////////////////////////////////////////////////////////
// cWndMsg
STDMETHODIMP cWndMsg::get_HWND(long *pVal)
{
// TODO: Add your implementation code here
return S_OK;
}
STDMETHODIMP cWndMsg::get_Message(long *pVal)
{
// TODO: Add your implementation code here
return S_OK;
}
STDMETHODIMP cWndMsg::get_WParam(long *pVal)
{
// TODO: Add your implementation code here
return S_OK;
}
STDMETHODIMP cWndMsg::get_LParam(long *pVal)
{
// TODO: Add your implementation code here
return S_OK;
}
STDMETHODIMP cWndMsg::get_Eat(VARIANT_BOOL *pVal)
{
// TODO: Add your implementation code here
return S_OK;
}
STDMETHODIMP cWndMsg::put_Eat(VARIANT_BOOL newVal)
{
// TODO: Add your implementation code here
return S_OK;
}

View file

@ -0,0 +1,55 @@
// WndMsg.h : Declaration of the cWndMsg
#ifndef __WNDMSG_H_
#define __WNDMSG_H_
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// cWndMsg
class ATL_NO_VTABLE cWndMsg :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<cWndMsg, &CLSID_WndMsg>,
public IDispatchImpl<IWndMsg, &IID_IWndMsg, &LIBID_DecalInput>
{
public:
cWndMsg()
{
}
long m_hWnd,
m_nMsg,
m_nWParam,
m_nLParam;
bool m_bEaten;
void loadMessage( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
{
m_hWnd = reinterpret_cast< long >( hWnd );
m_nMsg = static_cast< long >( nMsg );
m_nWParam = static_cast< long >( wParam );
m_nLParam = static_cast< long >( lParam );
m_bEaten = false;
}
DECLARE_REGISTRY_RESOURCEID(IDR_WNDMSG)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(cWndMsg)
COM_INTERFACE_ENTRY(IWndMsg)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
// IWndMsg
public:
STDMETHOD(get_Eat)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Eat)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_LParam)(/*[out, retval]*/ long *pVal);
STDMETHOD(get_WParam)(/*[out, retval]*/ long *pVal);
STDMETHOD(get_Message)(/*[out, retval]*/ long *pVal);
STDMETHOD(get_HWND)(/*[out, retval]*/ long *pVal);
};
#endif //__WNDMSG_H_

View file

@ -0,0 +1,26 @@
HKCR
{
DecalInput.WndMsg.1 = s 'WndMsg Class'
{
CLSID = s '{85AB0296-124E-4E68-A6A8-FCF5721AC09B}'
}
DecalInput.WndMsg = s 'WndMsg Class'
{
CLSID = s '{85AB0296-124E-4E68-A6A8-FCF5721AC09B}'
CurVer = s 'DecalInput.WndMsg.1'
}
NoRemove CLSID
{
ForceRemove {85AB0296-124E-4E68-A6A8-FCF5721AC09B} = s 'WndMsg Class'
{
ProgID = s 'DecalInput.WndMsg.1'
VersionIndependentProgID = s 'DecalInput.WndMsg'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Both'
}
'TypeLib' = s '{3A985F2B-BAD5-43BF-9008-ED4EBBB45B6E}'
}
}
}

View file

@ -0,0 +1,28 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by DecalInput.rc
//
#define IDS_PROJNAME 100
#define IDR_INPUTSERVICE 101
#define IDR_TIMER 102
#define IDR_HOTKEY 103
#define IDR_WINMSGHOOK 104
#define IDR_WNDMSG 105
#define IDR_INPUTBUFFER 106
#define IDR_TYPEACTION 107
#define IDR_MOUSEMOVEACTION 108
#define IDR_DELAYACTION 109
#define IDR_EVENTACTION 110
#define IDR_POLLEDDELAYACTION 111
#define IDR_RESTOREACTION 112
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 113
#endif
#endif