mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 17:05:37 +00:00
43a37e3ac2
Fixed marshalling in GetRawInputData.
62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
#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.Text;
|
|
using System.Windows.Forms;
|
|
using System.Runtime.InteropServices;
|
|
|
|
#endregion
|
|
|
|
namespace OpenTK.Platform.Windows
|
|
{
|
|
static class WinRawInput
|
|
{
|
|
private static API.RawInput data = new API.RawInput();
|
|
internal static API.RawInput ProcessEvent(ref System.Windows.Forms.Message msg)
|
|
{
|
|
if (msg.Msg == API.Constants.WM_INPUT)
|
|
{
|
|
uint size = 0;
|
|
// Get the size of the input data
|
|
API.GetRawInputData(
|
|
msg.LParam,
|
|
API.GetRawInputDataEnum.INPUT,
|
|
IntPtr.Zero,
|
|
ref size,
|
|
API.RawInputHeaderSize
|
|
);
|
|
|
|
if (data == null || API.RawInputSize < size)
|
|
{
|
|
throw new Exception("WTF?!");
|
|
}
|
|
|
|
if (size ==
|
|
API.GetRawInputData(
|
|
msg.LParam,
|
|
API.GetRawInputDataEnum.INPUT,
|
|
data,
|
|
ref size,
|
|
API.RawInputHeaderSize))
|
|
{
|
|
return data;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(
|
|
"GetRawInputData returned invalid data. Please file a bug in http://opentk.sourceforge.net"
|
|
);
|
|
}
|
|
}
|
|
throw new Exception("Never reach this!");
|
|
}
|
|
}
|
|
}
|