mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-22 19:50:59 +00:00
Fixed Raw Input keyboard registration under windows.
Fixed marshalling in GetRawInputData.
This commit is contained in:
parent
8f159aef72
commit
43a37e3ac2
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
#region --- License ---
|
||||||
using System.Collections.Generic;
|
/* Copyright (c) 2007 Stefanos Apostolopoulos
|
||||||
using System.Text;
|
* See license.txt for license info
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
namespace OpenTK.Input
|
namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
using System;
|
#region --- License ---
|
||||||
using System.Collections.Generic;
|
/* Copyright (c) 2007 Stefanos Apostolopoulos
|
||||||
using System.Text;
|
* See license.txt for license info
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- Using directives ---
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
namespace OpenTK.Input
|
namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,7 @@ namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
RawInputHeaderSize = (uint)Marshal.SizeOf(typeof(RawInputHeader));
|
RawInputHeaderSize = (uint)Marshal.SizeOf(typeof(RawInputHeader));
|
||||||
RawInputSize = (uint)Marshal.SizeOf(typeof(RawInput));
|
RawInputSize = (uint)Marshal.SizeOf(typeof(RawInput));
|
||||||
|
RawInputDeviceSize = (uint)Marshal.SizeOf(typeof(RawInputDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Constants
|
#region Constants
|
||||||
|
@ -905,7 +906,7 @@ namespace OpenTK.Platform.Windows
|
||||||
public static extern UINT GetRawInputData(
|
public static extern UINT GetRawInputData(
|
||||||
HRAWINPUT RawInput,
|
HRAWINPUT RawInput,
|
||||||
GetRawInputDataEnum Command,
|
GetRawInputDataEnum Command,
|
||||||
[MarshalAs(UnmanagedType.Struct)] [Out] RawInput Data,
|
[MarshalAs(UnmanagedType.LPStruct)] [Out] RawInput Data,
|
||||||
[In, Out] ref UINT Size,
|
[In, Out] ref UINT Size,
|
||||||
UINT SizeHeader
|
UINT SizeHeader
|
||||||
);
|
);
|
||||||
|
@ -1316,6 +1317,8 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#region RawInputDevice
|
#region RawInputDevice
|
||||||
|
|
||||||
|
public static readonly uint RawInputDeviceSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines information for the raw input devices.
|
/// Defines information for the raw input devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1323,7 +1326,7 @@ namespace OpenTK.Platform.Windows
|
||||||
/// If RIDEV_NOLEGACY is set for a mouse or a keyboard, the system does not generate any legacy message for that device for the application. For example, if the mouse TLC is set with RIDEV_NOLEGACY, WM_LBUTTONDOWN and related legacy mouse messages are not generated. Likewise, if the keyboard TLC is set with RIDEV_NOLEGACY, WM_KEYDOWN and related legacy keyboard messages are not generated.
|
/// If RIDEV_NOLEGACY is set for a mouse or a keyboard, the system does not generate any legacy message for that device for the application. For example, if the mouse TLC is set with RIDEV_NOLEGACY, WM_LBUTTONDOWN and related legacy mouse messages are not generated. Likewise, if the keyboard TLC is set with RIDEV_NOLEGACY, WM_KEYDOWN and related legacy keyboard messages are not generated.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public class RawInputDevice
|
public struct RawInputDevice
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Top level collection Usage page for the raw input device.
|
/// Top level collection Usage page for the raw input device.
|
||||||
|
@ -1344,6 +1347,11 @@ namespace OpenTK.Platform.Windows
|
||||||
/// Handle to the target window. If NULL it follows the keyboard focus.
|
/// Handle to the target window. If NULL it follows the keyboard focus.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HWND Target;
|
public HWND Target;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return String.Format("{0}/{1}, flags: {2}, window: {3}", UsagePage, Usage, Flags, Target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -1769,6 +1777,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#region RawInputDeviceFlags enum
|
#region RawInputDeviceFlags enum
|
||||||
|
|
||||||
|
[Flags]
|
||||||
public enum RawInputDeviceFlags : int
|
public enum RawInputDeviceFlags : int
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
using System;
|
#region --- License ---
|
||||||
|
/* Copyright (c) 2007 Stefanos Apostolopoulos
|
||||||
|
* See license.txt for license info
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- Using directives ---
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
namespace OpenTK.Platform.Windows
|
namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
static class WinRawInput
|
static class WinRawInput
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
using System;
|
#region --- License ---
|
||||||
|
/* Copyright (c) 2007 Stefanos Apostolopoulos
|
||||||
|
* See license.txt for license info
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- Using directives ---
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
namespace OpenTK.Platform.Windows
|
namespace OpenTK.Platform.Windows
|
||||||
{
|
{
|
||||||
internal class WinRawKeyboard : OpenTK.Input.IKeyboard
|
internal class WinRawKeyboard : OpenTK.Input.IKeyboard
|
||||||
|
@ -24,17 +34,18 @@ namespace OpenTK.Platform.Windows
|
||||||
rid[0].UsagePage = 1;
|
rid[0].UsagePage = 1;
|
||||||
rid[0].Usage = 6;
|
rid[0].Usage = 6;
|
||||||
|
|
||||||
rid[0].Flags =
|
rid[0].Flags = API.RawInputDeviceFlags.INPUTSINK;
|
||||||
API.RawInputDeviceFlags.APPKEYS |
|
|
||||||
API.RawInputDeviceFlags.NOLEGACY;
|
|
||||||
|
|
||||||
rid[0].Target = windowHandle;
|
rid[0].Target = windowHandle;
|
||||||
|
|
||||||
if (!API.RegisterRawInputDevices(rid, 1, API.RawInputHeaderSize))
|
if (!API.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
|
||||||
{
|
{
|
||||||
/*throw new ApplicationException(
|
throw new ApplicationException(
|
||||||
String.Format("Raw input registration failed for keyboard. Error {0}", Marshal.GetLastWin32Error())
|
String.Format(
|
||||||
);*/
|
"Raw input registration failed with error: {0}. Device: {1}",
|
||||||
|
Marshal.GetLastWin32Error(),
|
||||||
|
rid[0].ToString())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue