From d018b4825d8969c302a341dc3b43cb4375fc55e5 Mon Sep 17 00:00:00 2001
From: the_fiddler <the_fiddler@ebc5dd9b-fb1d-0410-b6f8-d24c324e9604>
Date: Sun, 9 Nov 2008 23:42:54 +0000
Subject: [PATCH] Final fix for mousewheel support on x64.

---
 Source/OpenTK/Platform/Windows/WMInput.cs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Source/OpenTK/Platform/Windows/WMInput.cs b/Source/OpenTK/Platform/Windows/WMInput.cs
index 9c34eda8..7c9acf0b 100644
--- a/Source/OpenTK/Platform/Windows/WMInput.cs
+++ b/Source/OpenTK/Platform/Windows/WMInput.cs
@@ -88,7 +88,9 @@ namespace OpenTK.Platform.Windows
                     return;
 
                 case WindowMessage.MOUSEWHEEL:
-                    mouse.Wheel += (int)(wparam.ToUInt32() >> 16) / 120;
+                    // This is due to inconsistent behavior of the WParam value on 64bit arch, whese
+                    // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000
+                    mouse.Wheel += (int)((long)msg.WParam << 32 >> 48) / 120;
                     return;
 
                 case WindowMessage.LBUTTONDOWN: