Skip to content

Commit

Permalink
add mouse xbutton (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
elringus authored Aug 30, 2022
1 parent 6feeef8 commit 6097f14
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Assets/UnityRawInput/Runtime/RawInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ private static int HandleMouseProc (int code, IntPtr wParam, IntPtr lParam)
if (state == RawMouseState.LeftButtonDown) HandleKeyDown(RawKey.LeftButton);
else if (state == RawMouseState.MiddleButtonDown) HandleKeyDown(RawKey.MiddleButton);
else if (state == RawMouseState.RightButtonDown) HandleKeyDown(RawKey.RightButton);
else if (state == RawMouseState.ExtraButtonDown) HandleKeyDown(RawKey.ExtraButton1);
else if (state == RawMouseState.LeftButtonUp) HandleKeyUp(RawKey.LeftButton);
else if (state == RawMouseState.MiddleButtonUp) HandleKeyUp(RawKey.MiddleButton);
else if (state == RawMouseState.RightButtonUp) HandleKeyUp(RawKey.RightButton);
else if (state == RawMouseState.ExtraButtonUp) HandleKeyUp(RawKey.ExtraButton1);
else return Win32API.CallNextHookEx(IntPtr.Zero, code, wParam, lParam);
return InterceptMessages ? 1 : Win32API.CallNextHookEx(IntPtr.Zero, 0, wParam, lParam);
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/UnityRawInput/Runtime/RawKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,6 @@ public enum RawKey : ushort
PA1 = 0xFD,
OEMClear = 0xFE
}

// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
}
8 changes: 6 additions & 2 deletions Assets/UnityRawInput/Runtime/RawMouseState.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace UnityRawInput
{
public enum RawMouseState
public enum RawMouseState : ushort
{
MouseMove = 0x0200,
LeftButtonDown = 0x0201,
Expand All @@ -9,6 +9,10 @@ public enum RawMouseState
MiddleButtonDown = 0x0207,
MiddleButtonUp = 0x0208,
RightButtonDown = 0x0204,
RightButtonUp = 0x0205
RightButtonUp = 0x0205,
ExtraButtonDown = 0x20B,
ExtraButtonUp = 0x20C
}

// https://www.pinvoke.net/default.aspx/Constants/WM.html
}
Binary file modified UnityRawInput.unitypackage
Binary file not shown.

0 comments on commit 6097f14

Please sign in to comment.