Skip to content

Commit bbadb39

Browse files
committed
v1.0.4
1 parent 68a39c4 commit bbadb39

File tree

4 files changed

+110
-14
lines changed

4 files changed

+110
-14
lines changed

D2RSO/Classes/DataClass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public KeyEntry(string name, string key)
3434
}
3535
}
3636

37-
private const string KEYS = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Comma|OemComma,~|OemTilde,[|OemOpenBrackets,]|OemCloseBrackets,:|OemSemicolon,'|OemQuotes,1|D1,2|D2,3|D3,4|D4,5|D5,6|D6,7|D7,8|D8,9|D9,0|D0,+|Add,-|Subtract,Esc|Escape,Enter,Return,Left Shift|LShiftKey,Right Shift|RShiftKey,Left Alt|LMenu,Right Alt|RMenu,Left Control|LControlKey,Right Control|RControlKey,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,NumPad0,NumPad1,NumPad2,NumPad3,NumPad4,NumPad5,NumPad6,NumPad7,NumPad8,NumPad9,Tab,Back,MOUSE1,MOUSE2,GamePad Button 0|Buttons0,GamePad Button 1|Buttons1,GamePad Button 2|Buttons2,GamePad Button 3|Buttons3,GamePad Button 4|Buttons4,GamePad Button 5|Buttons5,GamePad Button 6|Buttons6,GamePad Button 7|Buttons7,GamePad Button 8|Buttons8,GamePad Button 9|Buttons9";
37+
private const string KEYS = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Comma|OemComma,~|OemTilde,[|OemOpenBrackets,]|OemCloseBrackets,:|OemSemicolon,'|OemQuotes,1|D1,2|D2,3|D3,4|D4,5|D5,6|D6,7|D7,8|D8,9|D9,0|D0,+|Add,-|Subtract,Esc|Escape,Enter,Return,Left Shift|LShiftKey,Right Shift|RShiftKey,Left Alt|LMenu,Right Alt|RMenu,Left Control|LControlKey,Right Control|RControlKey,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,NumPad0,NumPad1,NumPad2,NumPad3,NumPad4,NumPad5,NumPad6,NumPad7,NumPad8,NumPad9,Tab,Back,MOUSE1,MOUSE2,MOUSE3,MOUSEX1,MOUSEX2,GamePad Button 0|Buttons0,GamePad Button 1|Buttons1,GamePad Button 2|Buttons2,GamePad Button 3|Buttons3,GamePad Button 4|Buttons4,GamePad Button 5|Buttons5,GamePad Button 6|Buttons6,GamePad Button 7|Buttons7,GamePad Button 8|Buttons8,GamePad Button 9|Buttons9";
3838

3939
/// <summary>
4040
/// Load all images for faster access

D2RSO/Classes/GlobalInputHook.cs

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,49 @@ private enum MouseMessages
190190
WM_MOUSEMOVE = 0x0200,
191191
WM_MOUSEWHEEL = 0x020A,
192192
WM_RBUTTONDOWN = 0x0204,
193-
WM_RBUTTONUP = 0x0205
193+
WM_RBUTTONUP = 0x0205,
194+
195+
WM_BTN3 = 0x000000000000020b,
196+
WM_BTN_MID = 0x0000000000000207,
197+
198+
}
199+
200+
[Flags()]
201+
public enum RawMouseButtons : ushort
202+
{
203+
None = 0,
204+
LeftDown = 0x0001,
205+
LeftUp = 0x0002,
206+
RightDown = 0x0004,
207+
RightUp = 0x0008,
208+
MiddleDown = 0x0010,
209+
MiddleUp = 0x0020,
210+
Button4Down = 0x0040,
211+
Button4Up = 0x0080,
212+
Button5Down = 0x0100,
213+
Button5Up = 0x0200,
214+
MouseWheel = 0x0400
215+
}
216+
217+
[Flags()]
218+
public enum RawMouseFlags : ushort
219+
{
220+
MOVE_RELATIVE = 0,
221+
MOVE_ABSOLUTE = 1,
222+
VIRTUAL_DESKTOP = 2,
223+
ATTRIBUTES_CHANGED = 4
224+
}
225+
226+
[StructLayout(LayoutKind.Sequential)]
227+
public struct RawInputMouse
228+
{
229+
public RawMouseFlags flags;
230+
public ushort buttonData;
231+
public RawMouseButtons buttonflags;
232+
public uint rawButtons;
233+
public int lastX;
234+
public int lastY;
235+
public uint extraInformation;
194236
}
195237

196238
[StructLayout(LayoutKind.Sequential)]
@@ -281,21 +323,49 @@ public IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam)
281323
return fEatKeyStroke ? (IntPtr)1 : CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam);
282324
}
283325

326+
private const int EXTRA_INFO = 1000;
327+
328+
IntPtr extraInfoPointer = new IntPtr(EXTRA_INFO);
284329

285330
public IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam)
286331
{
287332
bool fEatKeyStroke = false;
288-
289-
if (MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
290-
{
291-
Action<int> handler = MouseButtonPressed;
292-
handler?.Invoke(0);
293-
}
294-
else if (MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam)
333+
var value = (MouseMessages)wParam;
334+
if (nCode >= 0)
295335
{
296-
Action<int> handler = MouseButtonPressed;
297-
handler?.Invoke(1);
336+
MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
298337

338+
if (MouseMessages.WM_MOUSEMOVE != value)
339+
{
340+
341+
if (MouseMessages.WM_LBUTTONDOWN == value)
342+
{
343+
Action<int> handler = MouseButtonPressed;
344+
handler?.Invoke(0);
345+
}
346+
else if (MouseMessages.WM_RBUTTONDOWN == value)
347+
{
348+
Action<int> handler = MouseButtonPressed;
349+
handler?.Invoke(1);
350+
351+
}
352+
else if (MouseMessages.WM_BTN_MID == value)
353+
{
354+
Action<int> handler = MouseButtonPressed;
355+
handler?.Invoke(2);
356+
357+
}
358+
else if (hookStruct.mouseData == 131072)
359+
{
360+
Action<int> handler = MouseButtonPressed;
361+
handler?.Invoke(3);
362+
}
363+
else if (hookStruct.mouseData == 65536)
364+
{
365+
Action<int> handler = MouseButtonPressed;
366+
handler?.Invoke(4);
367+
}
368+
}
299369
}
300370

301371
return fEatKeyStroke ? (IntPtr)1 : CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam);

D2RSO/MainWindow.xaml.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public MainWindow()
6969
InitializeComponent();
7070
DataContext = this;
7171

72-
Title = $"D2R Skill Overlay V1.0.3";
72+
Title = $"D2R Skill Overlay V1.0.4";
7373

7474
IsMaxRestoreButtonEnabled = false;
7575
IsMinButtonEnabled = true;
@@ -157,7 +157,30 @@ private void OnHookKeyPressed(object? sender, GlobalKeyboardHookEventArgs e)
157157
{
158158
if(!string.IsNullOrEmpty(e.KeyboardData.Code))
159159
loggedKey = e.KeyboardData.Code;
160-
else loggedKey = e.KeyboardData.Flags == 0 ? "MOUSE1" : "MOUSE2";
160+
else
161+
{
162+
switch (e.KeyboardData.Flags)
163+
{
164+
case 0:
165+
loggedKey = "MOUSE1";
166+
break;
167+
case 1:
168+
loggedKey = "MOUSE2";
169+
break;
170+
case 2:
171+
loggedKey = "MOUSE3";
172+
break;
173+
case 3:
174+
loggedKey = "MOUSEX1";
175+
break;
176+
case 4:
177+
loggedKey = "MOUSEX2";
178+
break;
179+
default:
180+
loggedKey = "UNKNOWN";
181+
break;
182+
}
183+
}
161184
}
162185
else
163186
loggedKey = e.KeyboardData.Key.ToString();

D2RSO/version.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
V1.0.3
1+
V1.0.4
2+
+ Support additional mouse buttons
3+
4+
V1.0.3
25
+ Added skill profiles
36
+ Fixed select key values
47

0 commit comments

Comments
 (0)