Skip to content

Commit 213e9dc

Browse files
authored
Merge pull request #126 from SAM1430B/Work-in-progress
ProtoInput new options
2 parents 8b2c427 + c716c93 commit 213e9dc

5 files changed

Lines changed: 274 additions & 10 deletions

File tree

Master/NucleusGaming/Coop/ProtoInput/ProtoInput.cs

Lines changed: 200 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class ExposedValues
2929
public uint FindWindowHookID = (uint)ProtoHookIDs.FindWindowHookID;
3030
public uint CreateSingleHIDHookID = (uint)ProtoHookIDs.CreateSingleHIDHookID;
3131
public uint WindowStyleHookID = (uint)ProtoHookIDs.WindowStyleHookID;
32+
public uint MoveWindowHookID = (uint)ProtoHookIDs.MoveWindowHookID;
33+
public uint AdjustWindowRectHookID = (uint)ProtoHookIDs.AdjustWindowRectHookID;
34+
public uint RemoveBorderHookID = (uint)ProtoHookIDs.RemoveBorderHookID;
3235

3336
public uint RawInputFilterID = (uint)ProtoMessageFilterIDs.RawInputFilterID;
3437
public uint MouseMoveFilterID = (uint)ProtoMessageFilterIDs.MouseMoveFilterID;
@@ -62,7 +65,10 @@ public enum ProtoHookIDs : uint
6265
BlockRawInputHookID,
6366
FindWindowHookID,
6467
CreateSingleHIDHookID,
65-
WindowStyleHookID
68+
WindowStyleHookID,
69+
MoveWindowHookID,
70+
AdjustWindowRectHookID,
71+
RemoveBorderHookID
6672
};
6773

6874
public enum ProtoMessageFilterIDs : uint
@@ -123,7 +129,8 @@ public static extern void SetupMessagesToSend(uint instanceHandle,
123129
bool sendMouseWheelMessages,
124130
bool sendMouseButtonMessages,
125131
bool sendMouseMoveMessages,
126-
bool sendKeyboardPressMessages);
132+
bool sendKeyboardPressMessages,
133+
bool sendMouseDblClkMessages);
127134

128135
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
129136
public static extern void StartFocusMessageLoop(uint instanceHandle, int milliseconds,
@@ -160,6 +167,19 @@ public static extern void StartFocusMessageLoop(uint instanceHandle, int millise
160167
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
161168
public static extern void SetShowCursorWhenImageUpdated(uint instanceHandle, bool enable);
162169

170+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
171+
public static extern void SetPutMouseInsideWindow(uint instanceHandle, bool enable);
172+
173+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
174+
public static extern void SetDefaultTopLeftMouseBounds(uint instanceHandle, bool enable);
175+
176+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
177+
public static extern void SetDefaultBottomRightMouseBounds(uint instanceHandle, bool enable);
178+
179+
// This MUST be called before calling InstallHook on the RemoveBorderhook
180+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
181+
public static extern void SetDontWaitWindowBorder(uint instanceHandle, bool enable);
182+
163183
// Both of these functions require RenameHandlesHookHookID hook
164184
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
165185
public static extern void AddHandleToRename(uint instanceHandle, string name);
@@ -187,6 +207,12 @@ public static extern void SetDinputDeviceGUID(uint instanceHandle,
187207
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
188208
public static extern void SetSetWindowPosSettings(uint instanceHandle, int posx, int posy, int width, int height);
189209

210+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
211+
public static extern void SetSetWindowPosDontResize(uint instanceHandle, bool enable);
212+
213+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
214+
public static extern void SetSetWindowPosDontReposition(uint instanceHandle, bool enable);
215+
190216
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
191217
public static extern void SetCreateSingleHIDName(uint instanceHandle, string name);
192218

@@ -216,6 +242,18 @@ public static extern void SetDinputDeviceGUID(uint instanceHandle,
216242

217243
[DllImport("ProtoInputUtilDynamic32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
218244
public static extern void GetTaskbarVisibility(out bool autoHide, out bool alwaysOnTop);
245+
246+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
247+
public static extern void SetMoveWindowSettings(uint instanceHandle, int posx, int posy, int width, int height);
248+
249+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
250+
public static extern void SetMoveWindowDontResize(uint instanceHandle, bool enable);
251+
252+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
253+
public static extern void SetMoveWindowDontReposition(uint instanceHandle, bool enable);
254+
255+
[DllImport("ProtoInputLoader32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
256+
public static extern void SetAdjustWindowRectSettings(uint instanceHandle, int posx, int posy, int width, int height);
219257
}
220258

221259
private static class ProtoInput64
@@ -264,7 +302,8 @@ public static extern void SetupMessagesToSend(uint instanceHandle,
264302
bool sendMouseWheelMessages,
265303
bool sendMouseButtonMessages,
266304
bool sendMouseMoveMessages,
267-
bool sendKeyboardPressMessages);
305+
bool sendKeyboardPressMessages,
306+
bool sendMouseDblClkMessages);
268307

269308
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
270309
public static extern void StartFocusMessageLoop(uint instanceHandle, int milliseconds,
@@ -325,6 +364,12 @@ public static extern void SetDinputDeviceGUID(uint instanceHandle,
325364
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
326365
public static extern void SetSetWindowPosSettings(uint instanceHandle, int posx, int posy, int width, int height);
327366

367+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
368+
public static extern void SetSetWindowPosDontResize(uint instanceHandle, bool enable);
369+
370+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
371+
public static extern void SetSetWindowPosDontReposition(uint instanceHandle, bool enable);
372+
328373
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
329374
public static extern void SetCreateSingleHIDName(uint instanceHandle, string name);
330375

@@ -343,6 +388,19 @@ public static extern void SetDinputDeviceGUID(uint instanceHandle,
343388
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
344389
public static extern void SetShowCursorWhenImageUpdated(uint instanceHandle, bool enable);
345390

391+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
392+
public static extern void SetPutMouseInsideWindow(uint instanceHandle, bool enable);
393+
394+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
395+
public static extern void SetDefaultTopLeftMouseBounds(uint instanceHandle, bool enable);
396+
397+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
398+
public static extern void SetDefaultBottomRightMouseBounds(uint instanceHandle, bool enable);
399+
400+
// This MUST be called before calling InstallHook on the RemoveBorderhook
401+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
402+
public static extern void SetDontWaitWindowBorder(uint instanceHandle, bool enable);
403+
346404
[DllImport("ProtoInputUtilDynamic64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
347405
public static extern uint LockInput(bool lockInput);
348406

@@ -357,6 +415,18 @@ public static extern void SetDinputDeviceGUID(uint instanceHandle,
357415

358416
[DllImport("ProtoInputUtilDynamic64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
359417
public static extern void GetTaskbarVisibility(out bool autoHide, out bool alwaysOnTop);
418+
419+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
420+
public static extern void SetMoveWindowSettings(uint instanceHandle, int posx, int posy, int width, int height);
421+
422+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
423+
public static extern void SetMoveWindowDontResize(uint instanceHandle, bool enable);
424+
425+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
426+
public static extern void SetMoveWindowDontReposition(uint instanceHandle, bool enable);
427+
428+
[DllImport("ProtoInputLoader64.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
429+
public static extern void SetAdjustWindowRectSettings(uint instanceHandle, int posx, int posy, int width, int height);
360430
}
361431

362432
public uint LockInput(bool lockInput)
@@ -575,23 +645,26 @@ public void SetupMessagesToSend(uint instanceHandle,
575645
bool sendMouseWheelMessages,
576646
bool sendMouseButtonMessages,
577647
bool sendMouseMoveMessages,
578-
bool sendKeyboardPressMessages)
648+
bool sendKeyboardPressMessages,
649+
bool sendMouseDblClkMessages)
579650
{
580651
if (IntPtr.Size == 4)
581652
{
582653
ProtoInput32.SetupMessagesToSend(instanceHandle,
583654
sendMouseWheelMessages,
584655
sendMouseButtonMessages,
585656
sendMouseMoveMessages,
586-
sendKeyboardPressMessages);
657+
sendKeyboardPressMessages,
658+
sendMouseDblClkMessages);
587659
}
588660
else
589661
{
590662
ProtoInput64.SetupMessagesToSend(instanceHandle,
591663
sendMouseWheelMessages,
592664
sendMouseButtonMessages,
593665
sendMouseMoveMessages,
594-
sendKeyboardPressMessages);
666+
sendKeyboardPressMessages,
667+
sendMouseDblClkMessages);
595668
}
596669
}
597670

@@ -734,6 +807,54 @@ public void SetShowCursorWhenImageUpdated(uint instanceHandle, bool enable)
734807
}
735808
}
736809

810+
public void SetPutMouseInsideWindow(uint instanceHandle, bool enable)
811+
{
812+
if (IntPtr.Size == 4)
813+
{
814+
ProtoInput32.SetPutMouseInsideWindow(instanceHandle, enable);
815+
}
816+
else
817+
{
818+
ProtoInput64.SetPutMouseInsideWindow(instanceHandle, enable);
819+
}
820+
}
821+
822+
public void SetDefaultTopLeftMouseBounds(uint instanceHandle, bool enable)
823+
{
824+
if (IntPtr.Size == 4)
825+
{
826+
ProtoInput32.SetDefaultTopLeftMouseBounds(instanceHandle, enable);
827+
}
828+
else
829+
{
830+
ProtoInput64.SetDefaultTopLeftMouseBounds(instanceHandle, enable);
831+
}
832+
}
833+
834+
public void SetDefaultBottomRightMouseBounds(uint instanceHandle, bool enable)
835+
{
836+
if (IntPtr.Size == 4)
837+
{
838+
ProtoInput32.SetDefaultBottomRightMouseBounds(instanceHandle, enable);
839+
}
840+
else
841+
{
842+
ProtoInput64.SetDefaultBottomRightMouseBounds(instanceHandle, enable);
843+
}
844+
}
845+
846+
public void SetDontWaitWindowBorder(uint instanceHandle, bool enable)
847+
{
848+
if (IntPtr.Size == 4)
849+
{
850+
ProtoInput32.SetDontWaitWindowBorder(instanceHandle, enable);
851+
}
852+
else
853+
{
854+
ProtoInput64.SetDontWaitWindowBorder(instanceHandle, enable);
855+
}
856+
}
857+
737858
/// <summary>
738859
/// Require RenameHandlesHookHookID hook
739860
/// </summary>
@@ -848,6 +969,30 @@ public void SetSetWindowPosSettings(uint instanceHandle, int posx, int posy, int
848969
}
849970
}
850971

972+
public void SetSetWindowPosDontResize(uint instanceHandle, bool enable)
973+
{
974+
if (IntPtr.Size == 4)
975+
{
976+
ProtoInput32.SetSetWindowPosDontResize(instanceHandle, enable);
977+
}
978+
else
979+
{
980+
ProtoInput64.SetSetWindowPosDontResize(instanceHandle, enable);
981+
}
982+
}
983+
984+
public void SetSetWindowPosDontReposition(uint instanceHandle, bool enable)
985+
{
986+
if (IntPtr.Size == 4)
987+
{
988+
ProtoInput32.SetSetWindowPosDontReposition(instanceHandle, enable);
989+
}
990+
else
991+
{
992+
ProtoInput64.SetSetWindowPosDontReposition(instanceHandle, enable);
993+
}
994+
}
995+
851996
public void SetCreateSingleHIDName(uint instanceHandle, string name)
852997
{
853998
if (IntPtr.Size == 4)
@@ -935,5 +1080,54 @@ public void SetTaskbarAutohide(bool autohide)
9351080
ProtoInput64.SetTaskbarVisibility(autohide, false);
9361081
}
9371082
}
1083+
1084+
public void SetMoveWindowSettings(uint instanceHandle, int posx, int posy, int width, int height)
1085+
{
1086+
if (IntPtr.Size == 4)
1087+
{
1088+
ProtoInput32.SetMoveWindowSettings(instanceHandle, posx, posy, width, height);
1089+
}
1090+
else
1091+
{
1092+
ProtoInput64.SetMoveWindowSettings(instanceHandle, posx, posy, width, height);
1093+
}
1094+
}
1095+
1096+
public void SetMoveWindowDontResize(uint instanceHandle, bool enable)
1097+
{
1098+
if (IntPtr.Size == 4)
1099+
{
1100+
ProtoInput32.SetMoveWindowDontResize(instanceHandle, enable);
1101+
}
1102+
else
1103+
{
1104+
ProtoInput64.SetMoveWindowDontResize(instanceHandle, enable);
1105+
}
1106+
}
1107+
1108+
public void SetMoveWindowDontReposition(uint instanceHandle, bool enable)
1109+
{
1110+
if (IntPtr.Size == 4)
1111+
{
1112+
ProtoInput32.SetMoveWindowDontReposition(instanceHandle, enable);
1113+
}
1114+
else
1115+
{
1116+
ProtoInput64.SetMoveWindowDontReposition(instanceHandle, enable);
1117+
}
1118+
}
1119+
1120+
public void SetAdjustWindowRectSettings(uint instanceHandle, int posx, int posy, int width, int height)
1121+
{
1122+
if (IntPtr.Size == 4)
1123+
{
1124+
ProtoInput32.SetAdjustWindowRectSettings(instanceHandle, posx, posy, width, height);
1125+
}
1126+
else
1127+
{
1128+
ProtoInput64.SetAdjustWindowRectSettings(instanceHandle, posx, posy, width, height);
1129+
}
1130+
}
1131+
9381132
}
9391133
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace Nucleus.Gaming
2+
{
3+
public enum SetWindowPosHook
4+
{
5+
True = 1,
6+
DontResize,
7+
DontReposition
8+
}
9+
10+
public enum MoveWindowHook
11+
{
12+
True = 1,
13+
DontResize,
14+
DontReposition
15+
}
16+
17+
public enum DrawFakeCursor
18+
{
19+
True = 1,
20+
Fix
21+
}
22+
23+
public enum PutMouseInsideWindow
24+
{
25+
True = 1,
26+
IgnoreTopLeft,
27+
IgnoreBottomRight
28+
}
29+
30+
public enum SetRemoveBorderHook
31+
{
32+
True = 1,
33+
DontWait
34+
}
35+
}

0 commit comments

Comments
 (0)