mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 15:55:31 +00:00
Updated BindStreamWriter to better handle endlines. Reverted WinRawInput to standard reads.
This commit is contained in:
parent
e277e3b272
commit
26f5d0dff4
|
@ -55,7 +55,7 @@ namespace Bind
|
||||||
public void Write(Bind.Structures.Enum e)
|
public void Write(Bind.Structures.Enum e)
|
||||||
{
|
{
|
||||||
foreach (string s in splitLines.Split(e.ToString()))
|
foreach (string s in splitLines.Split(e.ToString()))
|
||||||
WriteLine(s);
|
WriteLine(s.TrimEnd('\r', '\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(Bind.Structures.Function f)
|
public void Write(Bind.Structures.Function f)
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace Bind.Structures
|
||||||
sb.Append(c.ToString());
|
sb.Append(c.ToString());
|
||||||
sb.AppendLine(",");
|
sb.AppendLine(",");
|
||||||
}
|
}
|
||||||
sb.AppendLine("}");
|
sb.Append("}");
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ namespace Bind.Structures
|
||||||
{
|
{
|
||||||
sb.AppendLine(" " + s);
|
sb.AppendLine(" " + s);
|
||||||
}
|
}
|
||||||
sb.AppendLine("}");
|
sb.Append("}");
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ using OpenTK;
|
||||||
using OpenTK.Platform;
|
using OpenTK.Platform;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace Examples.Tests
|
namespace Examples.Tests
|
||||||
{
|
{
|
||||||
|
@ -95,13 +96,13 @@ namespace Examples.Tests
|
||||||
k.KeyUp += new KeyUpEvent(LogKeyUp);
|
k.KeyUp += new KeyUpEvent(LogKeyUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//PollTimer.Tick += new EventHandler(PollTimer_Tick);
|
Application.Idle += new EventHandler(UpdateDevices);
|
||||||
//PollTimer.Start();
|
|
||||||
Application.Idle += new EventHandler(Application_Idle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application_Idle(object sender, EventArgs e)
|
void UpdateDevices(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
driver.Poll();
|
||||||
|
|
||||||
// Update mouse coordinates.
|
// Update mouse coordinates.
|
||||||
MouseXText.Text = driver.Mouse[ChooseMouse.SelectedIndex].X.ToString();
|
MouseXText.Text = driver.Mouse[ChooseMouse.SelectedIndex].X.ToString();
|
||||||
MouseYText.Text = driver.Mouse[ChooseMouse.SelectedIndex].Y.ToString();
|
MouseYText.Text = driver.Mouse[ChooseMouse.SelectedIndex].Y.ToString();
|
||||||
|
@ -113,14 +114,14 @@ namespace Examples.Tests
|
||||||
|
|
||||||
void LogMouseButtonDown(IMouse sender, MouseButton button)
|
void LogMouseButtonDown(IMouse sender, MouseButton button)
|
||||||
{
|
{
|
||||||
Trace.WriteLine(String.Format("Mouse button down: {0} on device: {1}", button, sender.DeviceID));
|
//Trace.WriteLine(String.Format("Mouse button down: {0} on device: {1}", button, sender.DeviceID));
|
||||||
if (sender.DeviceID == driver.Mouse[ChooseMouse.SelectedIndex].DeviceID)
|
if (sender.DeviceID == driver.Mouse[ChooseMouse.SelectedIndex].DeviceID)
|
||||||
MouseButtons.Items.Add(button);
|
MouseButtons.Items.Add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogMouseButtonUp(IMouse sender, MouseButton button)
|
void LogMouseButtonUp(IMouse sender, MouseButton button)
|
||||||
{
|
{
|
||||||
Trace.WriteLine(String.Format("Mouse button up: {0} on device: {1}", button, sender.DeviceID));
|
//Trace.WriteLine(String.Format("Mouse button up: {0} on device: {1}", button, sender.DeviceID));
|
||||||
if (sender.DeviceID == driver.Mouse[ChooseMouse.SelectedIndex].DeviceID)
|
if (sender.DeviceID == driver.Mouse[ChooseMouse.SelectedIndex].DeviceID)
|
||||||
MouseButtons.Items.Remove(button);
|
MouseButtons.Items.Remove(button);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -11,7 +11,6 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenTK.Platform;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
|
||||||
|
@ -218,7 +217,7 @@ namespace OpenTK.OpenGL
|
||||||
{
|
{
|
||||||
MethodInfo m;
|
MethodInfo m;
|
||||||
return
|
return
|
||||||
Utilities.GetExtensionDelegate(name, signature) ??
|
GetExtensionDelegate(name, signature) ??
|
||||||
/*((m = importsClass.GetMethod(name.Substring(2), BindingFlags.Static | BindingFlags.NonPublic)) != null ?*/
|
/*((m = importsClass.GetMethod(name.Substring(2), BindingFlags.Static | BindingFlags.NonPublic)) != null ?*/
|
||||||
(Imports.import.TryGetValue((name.Substring(2)), out m) ?
|
(Imports.import.TryGetValue((name.Substring(2)), out m) ?
|
||||||
Delegate.CreateDelegate(signature, m) : null);
|
Delegate.CreateDelegate(signature, m) : null);
|
||||||
|
@ -349,5 +348,126 @@ namespace OpenTK.OpenGL
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region --- GetProcAddress ---
|
||||||
|
|
||||||
|
private static IGetProcAddress getProcAddress;
|
||||||
|
|
||||||
|
internal interface IGetProcAddress
|
||||||
|
{
|
||||||
|
IntPtr GetProcAddress(string function);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GetProcAddressWindows : IGetProcAddress
|
||||||
|
{
|
||||||
|
public IntPtr GetProcAddress(string function)
|
||||||
|
{
|
||||||
|
return OpenTK.Platform.Windows.Wgl.Imports.GetProcAddress(function);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GetProcAddressX11 : IGetProcAddress
|
||||||
|
{
|
||||||
|
public IntPtr GetProcAddress(string function)
|
||||||
|
{
|
||||||
|
return X11.Glx.GetProcAddress(function);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class GetProcAddressOSX : IGetProcAddress
|
||||||
|
{
|
||||||
|
public IntPtr GetProcAddress(string function)
|
||||||
|
{
|
||||||
|
string fname = "_" + function;
|
||||||
|
if (!OSX.Functions.NSIsSymbolNameDefined(fname))
|
||||||
|
return IntPtr.Zero;
|
||||||
|
|
||||||
|
IntPtr symbol = OSX.Functions.NSLookupAndBindSymbol(fname);
|
||||||
|
if (symbol != IntPtr.Zero)
|
||||||
|
symbol = OSX.Functions.NSAddressOfSymbol(symbol);
|
||||||
|
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region private static IntPtr GetAddress(string function)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the entry point for a dynamically exported OpenGL function.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The function string for the OpenGL function (eg. "glNewList")</param>
|
||||||
|
/// <returns>
|
||||||
|
/// An IntPtr contaning the address for the entry point, or IntPtr.Zero if the specified
|
||||||
|
/// OpenGL function is not dynamically exported.
|
||||||
|
/// </returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// The Marshal.GetDelegateForFunctionPointer method can be used to turn the return value
|
||||||
|
/// into a call-able delegate.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// This function is cross-platform. It determines the underlying platform and uses the
|
||||||
|
/// correct wgl, glx or agl GetAddress function to retrieve the function pointer.
|
||||||
|
/// </para>
|
||||||
|
/// <see cref="Marshal.GetDelegateForFunctionPointer"/>
|
||||||
|
/// <seealso cref="Gl.GetDelegateForExtensionMethod"/>
|
||||||
|
/// </remarks>
|
||||||
|
private static IntPtr GetAddress(string function)
|
||||||
|
{
|
||||||
|
if (getProcAddress == null)
|
||||||
|
{
|
||||||
|
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT ||
|
||||||
|
System.Environment.OSVersion.Platform == PlatformID.Win32S ||
|
||||||
|
System.Environment.OSVersion.Platform == PlatformID.Win32Windows ||
|
||||||
|
System.Environment.OSVersion.Platform == PlatformID.WinCE)
|
||||||
|
{
|
||||||
|
getProcAddress = new GetProcAddressWindows();
|
||||||
|
}
|
||||||
|
else if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
|
{
|
||||||
|
getProcAddress = new GetProcAddressX11();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new PlatformNotSupportedException(
|
||||||
|
"Extension loading is only supported under X11 and Windows. We are sorry for the inconvience.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getProcAddress.GetProcAddress(function);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region private static Delegate GetExtensionDelegate(string name, Type signature)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
|
||||||
|
/// <param name="signature">The signature of the OpenGL function.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A System.Delegate that can be used to call this OpenGL function or null
|
||||||
|
/// if the function is not available in the current OpenGL context.
|
||||||
|
/// </returns>
|
||||||
|
private static Delegate GetExtensionDelegate(string name, Type signature)
|
||||||
|
{
|
||||||
|
IntPtr address = GetAddress(name);
|
||||||
|
|
||||||
|
if (address == IntPtr.Zero ||
|
||||||
|
address == new IntPtr(1) || // Workaround for buggy nvidia drivers which return
|
||||||
|
address == new IntPtr(2)) // 1 or 2 instead of IntPtr.Zero for some extensions.
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Marshal.GetDelegateForFunctionPointer(address, signature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,147 +21,6 @@ namespace OpenTK.Platform
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Utilities
|
public static class Utilities
|
||||||
{
|
{
|
||||||
#region --- LoadAddress ---
|
|
||||||
|
|
||||||
internal interface ILoadAddress
|
|
||||||
{
|
|
||||||
IntPtr LoadAddress(string function);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class LoadAddressWindows : ILoadAddress
|
|
||||||
{
|
|
||||||
public IntPtr LoadAddress(string function)
|
|
||||||
{
|
|
||||||
return OpenTK.Platform.Windows.Wgl.Imports.GetProcAddress(function);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class LoadAddressX11 : ILoadAddress
|
|
||||||
{
|
|
||||||
public IntPtr LoadAddress(string function)
|
|
||||||
{
|
|
||||||
return X11.Glx.GetProcAddress(function);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class LoadAddressOSX : ILoadAddress
|
|
||||||
{
|
|
||||||
public IntPtr LoadAddress(string function)
|
|
||||||
{
|
|
||||||
string fname = "_" + function;
|
|
||||||
if (!OSX.Functions.NSIsSymbolNameDefined(fname))
|
|
||||||
return IntPtr.Zero;
|
|
||||||
|
|
||||||
IntPtr symbol = OSX.Functions.NSLookupAndBindSymbol(fname);
|
|
||||||
if (symbol != IntPtr.Zero)
|
|
||||||
symbol = OSX.Functions.NSAddressOfSymbol(symbol);
|
|
||||||
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- Fields ---
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enumerates the platforms OpenTK can run on.
|
|
||||||
/// </summary>
|
|
||||||
private enum Platform
|
|
||||||
{
|
|
||||||
Unknown,
|
|
||||||
Windows,
|
|
||||||
X11,
|
|
||||||
X11_ARB,
|
|
||||||
OSX
|
|
||||||
};
|
|
||||||
|
|
||||||
private static ILoadAddress loadAddress;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private static Platform platform = Platform.Unknown;
|
|
||||||
|
|
||||||
#region public static IntPtr GetAddress(string function)
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves the entry point for a dynamically exported OpenGL function.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The function string for the OpenGL function (eg. "glNewList")</param>
|
|
||||||
/// <returns>
|
|
||||||
/// An IntPtr contaning the address for the entry point, or IntPtr.Zero if the specified
|
|
||||||
/// OpenGL function is not dynamically exported.
|
|
||||||
/// </returns>
|
|
||||||
/// <remarks>
|
|
||||||
/// <para>
|
|
||||||
/// The Marshal.GetDelegateForFunctionPointer method can be used to turn the return value
|
|
||||||
/// into a call-able delegate.
|
|
||||||
/// </para>
|
|
||||||
/// <para>
|
|
||||||
/// This function is cross-platform. It determines the underlying platform and uses the
|
|
||||||
/// correct wgl, glx or agl GetAddress function to retrieve the function pointer.
|
|
||||||
/// </para>
|
|
||||||
/// <see cref="Marshal.GetDelegateForFunctionPointer"/>
|
|
||||||
/// <seealso cref="Gl.GetDelegateForExtensionMethod"/>
|
|
||||||
/// </remarks>
|
|
||||||
public static IntPtr GetAddress(string function)
|
|
||||||
{
|
|
||||||
if (platform == Platform.Unknown)
|
|
||||||
{
|
|
||||||
if (System.Environment.OSVersion.Platform == PlatformID.Win32NT ||
|
|
||||||
System.Environment.OSVersion.Platform == PlatformID.Win32S ||
|
|
||||||
System.Environment.OSVersion.Platform == PlatformID.Win32Windows ||
|
|
||||||
System.Environment.OSVersion.Platform == PlatformID.WinCE)
|
|
||||||
{
|
|
||||||
platform = Platform.Windows;
|
|
||||||
loadAddress = new LoadAddressWindows();
|
|
||||||
}
|
|
||||||
else if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
|
||||||
{
|
|
||||||
platform = Platform.X11;
|
|
||||||
loadAddress = new LoadAddressX11();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new PlatformNotSupportedException(
|
|
||||||
"Extension loading is only supported under X11 and Windows. We are sorry for the inconvience.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return loadAddress.LoadAddress(function);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region private static Delegate GetExtensionDelegate(string name, Type signature)
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a System.Delegate that can be used to call a dynamically exported OpenGL function.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name of the OpenGL function (eg. "glNewList")</param>
|
|
||||||
/// <param name="signature">The signature of the OpenGL function.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A System.Delegate that can be used to call this OpenGL function or null
|
|
||||||
/// if the function is not available in the current OpenGL context.
|
|
||||||
/// </returns>
|
|
||||||
internal static Delegate GetExtensionDelegate(string name, Type signature)
|
|
||||||
{
|
|
||||||
IntPtr address = GetAddress(name);
|
|
||||||
|
|
||||||
if (address == IntPtr.Zero ||
|
|
||||||
address == new IntPtr(1) || // Workaround for buggy nvidia drivers which return
|
|
||||||
address == new IntPtr(2)) // 1 or 2 instead of IntPtr.Zero for some extensions.
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Marshal.GetDelegateForFunctionPointer(address, signature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
static bool throw_on_error;
|
static bool throw_on_error;
|
||||||
internal static bool ThrowOnX11Error
|
internal static bool ThrowOnX11Error
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
|
|
||||||
AllocateBuffer();
|
//AllocateBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -115,7 +115,7 @@ namespace OpenTK.Platform.Windows
|
||||||
Marshal.GetLastWin32Error()));
|
Marshal.GetLastWin32Error()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WindowMessage.CLOSE:
|
case WindowMessage.CLOSE:
|
||||||
case WindowMessage.DESTROY:
|
case WindowMessage.DESTROY:
|
||||||
Debug.Print("Input window detached from parent {0}.", Handle);
|
Debug.Print("Input window detached from parent {0}.", Handle);
|
||||||
|
@ -145,53 +145,27 @@ namespace OpenTK.Platform.Windows
|
||||||
get { return mouseDriver.Mouse; }
|
get { return mouseDriver.Mouse; }
|
||||||
}
|
}
|
||||||
|
|
||||||
int allocated_buffer_size; // rin_data size in bytes.
|
|
||||||
IntPtr rin_data; // Unmanaged buffer with grow-only behavior. Freed at Dispose(bool).
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Allocates a buffer for buffered reading of RawInput structs. Starts at 16*sizeof(RawInput) and
|
|
||||||
/// doubles the buffer every call thereafter.
|
|
||||||
/// </summary>
|
|
||||||
private void AllocateBuffer()
|
|
||||||
{
|
|
||||||
// Find the size of the buffer (grow-only).
|
|
||||||
if (allocated_buffer_size == 0)
|
|
||||||
{
|
|
||||||
allocated_buffer_size = 16536 * rawInputStructSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
allocated_buffer_size *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate the new buffer.
|
|
||||||
if (rin_data != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
Marshal.FreeHGlobal(rin_data);
|
|
||||||
}
|
|
||||||
rin_data = Marshal.AllocHGlobal(allocated_buffer_size);
|
|
||||||
if (rin_data == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new OutOfMemoryException(String.Format(
|
|
||||||
"Failed to allocate {0} bytes for raw input structures.", allocated_buffer_size));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Poll()
|
public void Poll()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// We will do a buffered read for all input devices and route the RawInput structures
|
// We will do a buffered read for all input devices and route the RawInput structures
|
||||||
// to the correct 'ProcessData' handlers. First, we need to find out the size of the
|
// to the correct 'ProcessData' handlers. First, we need to find out the size of the
|
||||||
// buffer to allocate for the structures. Then we allocate the buffer and read the
|
// buffer to allocate for the structures. Then we allocate the buffer and read the
|
||||||
// structures, calling the correct handler for each one. Last, we free the allocated
|
// structures, calling the correct handler for each one. Last, we free the allocated
|
||||||
// buffer.
|
// buffer.
|
||||||
|
int size = 0;
|
||||||
|
API.GetRawInputBuffer(IntPtr.Zero, ref size, API.RawInputHeaderSize);
|
||||||
|
size *= 256;
|
||||||
|
IntPtr rin_data = Marshal.AllocHGlobal(size);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Iterate reading all available RawInput structures and routing them to their respective
|
// Iterate reading all available RawInput structures and routing them to their respective
|
||||||
// handlers.
|
// handlers.
|
||||||
int num = API.GetRawInputBuffer(rin_data, ref allocated_buffer_size, API.RawInputHeaderSize);
|
int num = API.GetRawInputBuffer(rin_data, ref size, API.RawInputHeaderSize);
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
return;
|
break;
|
||||||
else if (num < 0)
|
else if (num < 0)
|
||||||
{
|
{
|
||||||
/*int error = Marshal.GetLastWin32Error();
|
/*int error = Marshal.GetLastWin32Error();
|
||||||
|
@ -207,23 +181,32 @@ namespace OpenTK.Platform.Windows
|
||||||
}*/
|
}*/
|
||||||
Debug.Print("GetRawInputBuffer failed with code: {0}", Marshal.GetLastWin32Error());
|
Debug.Print("GetRawInputBuffer failed with code: {0}", Marshal.GetLastWin32Error());
|
||||||
//AllocateBuffer();
|
//AllocateBuffer();
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RawInput[] rin_structs = new RawInput[num];
|
||||||
IntPtr next_rin = rin_data;
|
IntPtr next_rin = rin_data;
|
||||||
int i = num;
|
for (int i = 0; i < num; i++)
|
||||||
while (--i > 0)
|
|
||||||
{
|
{
|
||||||
RawInput rin;
|
rin_structs[i] = (RawInput)Marshal.PtrToStructure(next_rin, typeof(RawInput));
|
||||||
rin = (RawInput)Marshal.PtrToStructure(next_rin, typeof(RawInput));
|
|
||||||
if (rin.Header.Type == RawInputDeviceType.KEYBOARD)
|
switch (rin_structs[i].Header.Type)
|
||||||
keyboardDriver.ProcessKeyboardEvent(rin);
|
{
|
||||||
else if (rin.Header.Type == RawInputDeviceType.MOUSE)
|
case RawInputDeviceType.KEYBOARD:
|
||||||
mouseDriver.ProcessEvent(rin);
|
keyboardDriver.ProcessKeyboardEvent(rin_structs[i]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RawInputDeviceType.MOUSE:
|
||||||
|
mouseDriver.ProcessEvent(rin_structs[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
next_rin = API.NextRawInputStructure(next_rin);
|
next_rin = API.NextRawInputStructure(next_rin);
|
||||||
}
|
}
|
||||||
API.DefRawInputProc(rin_data, num, (uint)API.RawInputHeaderSize);
|
API.DefRawInputProc(rin_structs, num, (uint)API.RawInputHeaderSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Marshal.FreeHGlobal(rin_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -242,11 +225,6 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
if (rin_data != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
Marshal.FreeHGlobal(rin_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
keyboardDriver.Dispose();
|
keyboardDriver.Dispose();
|
||||||
|
|
Loading…
Reference in a new issue