Replication project for Mac OS mouse input issue, and fix. OpenTK issues 3242 and 2800
This commit is contained in:
parent
3c609872fe
commit
39c3f3f543
3 changed files with 34 additions and 26 deletions
|
@ -44,16 +44,16 @@
|
|||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>DEBUG;TRACE;</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>false</Optimize>
|
||||
<Optimize>False</Optimize>
|
||||
<OutputPath>..\..\Binaries\OpenTK\Debug\</OutputPath>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
|
@ -62,7 +62,7 @@
|
|||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
|
@ -70,7 +70,7 @@
|
|||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
|
@ -82,11 +82,11 @@
|
|||
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
|
||||
<DebugType>none</DebugType>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>True</Optimize>
|
||||
<DefineConstants>TRACE;</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
|
@ -94,7 +94,7 @@
|
|||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>True</Optimize>
|
||||
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
|
@ -103,7 +103,7 @@
|
|||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>..\..\OpenTK.snk</AssemblyOriginatorKeyFile>
|
||||
|
@ -111,23 +111,18 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing">
|
||||
<Name>System.Drawing</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<Name>System.Windows.Forms</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.Xml</Name>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -560,6 +555,9 @@
|
|||
<None Include="..\OpenTK\OpenTK.dll.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Compile Include="OpenTK\Test\BasicMouseInput.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
|
|
|
@ -40,7 +40,12 @@ namespace Examples.Tests
|
|||
{
|
||||
// Here's the big test!
|
||||
if(OpenTK.Input.Mouse.GetState()[MouseButton.Left]){
|
||||
Console.WriteLine("You clicked the left mouse button!");
|
||||
Console.WriteLine("The left mouse button is down!");
|
||||
}
|
||||
|
||||
// While we are here, test keyboard.
|
||||
if(OpenTK.Input.Keyboard.GetState()[Key.A]){
|
||||
Console.WriteLine("The A key is down!");
|
||||
}
|
||||
|
||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
if (!MouseDevices.ContainsKey(device))
|
||||
{
|
||||
Debug.Print("Mouse device {0} discovered", device);
|
||||
Debug.Print("Mouse device {0:x} discovered, sender is {1:x}", device, sender);
|
||||
MouseState state = new MouseState();
|
||||
state.IsConnected = true;
|
||||
MouseIndexToDevice.Add(MouseDevices.Count, device);
|
||||
|
@ -132,7 +132,7 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.Print("Mouse device {0} reconnected", device);
|
||||
Debug.Print("Mouse device {0:x} reconnected, sender is {1:x}", device, sender);
|
||||
MouseState state = MouseDevices[device];
|
||||
state.IsConnected = true;
|
||||
MouseDevices[device] = state;
|
||||
|
@ -144,7 +144,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
if (!KeyboardDevices.ContainsKey(device))
|
||||
{
|
||||
Debug.Print("Keyboard device {0} discovered", device);
|
||||
Debug.Print("Keyboard device {0:x} discovered, sender is {1:x}", device, sender);
|
||||
KeyboardState state = new KeyboardState();
|
||||
state.IsConnected = true;
|
||||
KeyboardIndexToDevice.Add(KeyboardDevices.Count, device);
|
||||
|
@ -152,15 +152,18 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.Print("Keyboard device {0} reconnected", device);
|
||||
Debug.Print("Keyboard device {0:x} reconnected, sender is {1:x}", device, sender);
|
||||
KeyboardState state = KeyboardDevices[device];
|
||||
state.IsConnected = true;
|
||||
KeyboardDevices[device] = state;
|
||||
}
|
||||
}
|
||||
|
||||
// The device is not normally available in the InputValueCallback (HandleDeviceValueReceived), so we include
|
||||
// the device identifier as the context variable, so we can identify it and figure out the device later.
|
||||
// Thanks to Jase: http://www.opentk.com/node/2800
|
||||
NativeMethods.IOHIDDeviceRegisterInputValueCallback(device,
|
||||
HandleDeviceValueReceived, IntPtr.Zero);
|
||||
HandleDeviceValueReceived, device);
|
||||
NativeMethods.IOHIDDeviceScheduleWithRunLoop(device, RunLoop, InputLoopMode);
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +173,7 @@ namespace OpenTK.Platform.MacOS
|
|||
if (NativeMethods.IOHIDDeviceConformsTo(device, HIDPage.GenericDesktop, (int)HIDUsageGD.Mouse) &&
|
||||
MouseDevices.ContainsKey(device))
|
||||
{
|
||||
Debug.Print("Mouse device {0} disconnected", device);
|
||||
Debug.Print("Mouse device {0:x} disconnected, sender is {1:x}", device, sender);
|
||||
|
||||
// Keep the device in case it comes back later on
|
||||
MouseState state = MouseDevices[device];
|
||||
|
@ -181,7 +184,7 @@ namespace OpenTK.Platform.MacOS
|
|||
if (NativeMethods.IOHIDDeviceConformsTo(device, HIDPage.GenericDesktop, (int)HIDUsageGD.Keyboard) &&
|
||||
KeyboardDevices.ContainsKey(device))
|
||||
{
|
||||
Debug.Print("Keyboard device {0} disconnected", device);
|
||||
Debug.Print("Keyboard device {0:x} disconnected, sender is {1:x}", device, sender);
|
||||
|
||||
// Keep the device in case it comes back later on
|
||||
KeyboardState state = KeyboardDevices[device];
|
||||
|
@ -197,13 +200,15 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
MouseState mouse;
|
||||
KeyboardState keyboard;
|
||||
if (MouseDevices.TryGetValue(sender, out mouse))
|
||||
if (MouseDevices.TryGetValue(context, out mouse))
|
||||
{
|
||||
MouseDevices[sender] = UpdateMouse(mouse, val);
|
||||
MouseDevices[context] = UpdateMouse(mouse, val);
|
||||
}
|
||||
else if (KeyboardDevices.TryGetValue(sender, out keyboard))
|
||||
else if (KeyboardDevices.TryGetValue(context, out keyboard))
|
||||
{
|
||||
KeyboardDevices[sender] = UpdateKeyboard(keyboard, val);
|
||||
KeyboardDevices[context] = UpdateKeyboard(keyboard, val);
|
||||
}else{
|
||||
//Debug.Print ("Device {0:x} not found in list of keyboards or mice", sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue