mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-03 15:38:15 +00:00
Reverted to wait for messages.
This commit is contained in:
parent
e695429db1
commit
1f037d077c
|
@ -1,28 +1,28 @@
|
||||||
#region License
|
#region License
|
||||||
//
|
//
|
||||||
// The Open Toolkit Library License
|
// The Open Toolkit Library License
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006 - 2010 the Open Toolkit library.
|
// Copyright (c) 2006 - 2010 the Open Toolkit library.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
// in the Software without restriction, including without limitation the rights to
|
// in the Software without restriction, including without limitation the rights to
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do
|
// the Software, and to permit persons to whom the Software is furnished to do
|
||||||
// so, subject to the following conditions:
|
// so, subject to the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
// copies or substantial portions of the Software.
|
// copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -44,51 +44,51 @@ namespace OpenTK.Platform.Windows
|
||||||
IntPtr OldWndProc;
|
IntPtr OldWndProc;
|
||||||
INativeWindow native;
|
INativeWindow native;
|
||||||
|
|
||||||
protected INativeWindow Native { get { return native; } private set { native = value; } }
|
protected INativeWindow Native { get { return native; } private set { native = value; } }
|
||||||
protected WinWindowInfo Parent { get { return (WinWindowInfo)Native.WindowInfo; } }
|
protected WinWindowInfo Parent { get { return (WinWindowInfo)Native.WindowInfo; } }
|
||||||
|
|
||||||
static readonly IntPtr Unhandled = new IntPtr(-1);
|
static readonly IntPtr Unhandled = new IntPtr(-1);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
public WinInputBase()
|
public WinInputBase()
|
||||||
{
|
{
|
||||||
WndProc = WindowProcedure;
|
WndProc = WindowProcedure;
|
||||||
|
|
||||||
InputThread = new Thread(ProcessEvents);
|
InputThread = new Thread(ProcessEvents);
|
||||||
InputThread.IsBackground = true;
|
InputThread.IsBackground = true;
|
||||||
InputThread.Start();
|
InputThread.Start();
|
||||||
|
|
||||||
InputReady.WaitOne();
|
InputReady.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Members
|
#region Private Members
|
||||||
|
|
||||||
#region ConstructMessageWindow
|
#region ConstructMessageWindow
|
||||||
|
|
||||||
INativeWindow ConstructMessageWindow()
|
INativeWindow ConstructMessageWindow()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Initializing input driver.");
|
Debug.WriteLine("Initializing input driver.");
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
// Create a new message-only window to retrieve WM_INPUT messages.
|
// Create a new message-only window to retrieve WM_INPUT messages.
|
||||||
INativeWindow native = new NativeWindow();
|
INativeWindow native = new NativeWindow();
|
||||||
native.ProcessEvents();
|
native.ProcessEvents();
|
||||||
WinWindowInfo parent = native.WindowInfo as WinWindowInfo;
|
WinWindowInfo parent = native.WindowInfo as WinWindowInfo;
|
||||||
Functions.SetParent(parent.WindowHandle, Constants.MESSAGE_ONLY);
|
Functions.SetParent(parent.WindowHandle, Constants.MESSAGE_ONLY);
|
||||||
native.ProcessEvents();
|
native.ProcessEvents();
|
||||||
|
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
return native;
|
return native;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ProcessEvents
|
#region ProcessEvents
|
||||||
|
|
||||||
void ProcessEvents()
|
void ProcessEvents()
|
||||||
|
@ -105,20 +105,19 @@ namespace OpenTK.Platform.Windows
|
||||||
MSG msg = new MSG();
|
MSG msg = new MSG();
|
||||||
while (Native.Exists)
|
while (Native.Exists)
|
||||||
{
|
{
|
||||||
Native.ProcessEvents();
|
int ret = Functions.GetMessage(ref msg, Parent.WindowHandle, 0, 0);
|
||||||
//int ret = Functions.GetMessage(ref msg, Parent.WindowHandle, 0, 0);
|
if (ret == -1)
|
||||||
//if (ret == -1)
|
{
|
||||||
//{
|
throw new PlatformException(String.Format(
|
||||||
// throw new PlatformException(String.Format(
|
"An error happened while processing the message queue. Windows error: {0}",
|
||||||
// "An error happened while processing the message queue. Windows error: {0}",
|
Marshal.GetLastWin32Error()));
|
||||||
// Marshal.GetLastWin32Error()));
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
//Functions.TranslateMessage(ref msg);
|
Functions.TranslateMessage(ref msg);
|
||||||
//Functions.DispatchMessage(ref msg);
|
Functions.DispatchMessage(ref msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region WndProcHandler
|
#region WndProcHandler
|
||||||
|
@ -160,45 +159,45 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
#region IInputDriver2 Members
|
#region IInputDriver2 Members
|
||||||
|
|
||||||
public abstract IMouseDriver2 MouseDriver { get; }
|
public abstract IMouseDriver2 MouseDriver { get; }
|
||||||
public abstract IKeyboardDriver2 KeyboardDriver { get; }
|
public abstract IKeyboardDriver2 KeyboardDriver { get; }
|
||||||
public abstract IGamePadDriver GamePadDriver { get; }
|
public abstract IGamePadDriver GamePadDriver { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
#region IDisposable Members
|
||||||
|
|
||||||
protected bool Disposed;
|
protected bool Disposed;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool manual)
|
protected virtual void Dispose(bool manual)
|
||||||
{
|
{
|
||||||
if (!Disposed)
|
if (!Disposed)
|
||||||
{
|
{
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
if (Native != null)
|
if (Native != null)
|
||||||
{
|
{
|
||||||
Native.Close();
|
Native.Close();
|
||||||
Native.Dispose();
|
Native.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Disposed = true;
|
Disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~WinInputBase()
|
~WinInputBase()
|
||||||
{
|
{
|
||||||
Debug.Print("[Warning] Resource leaked: {0}.", this);
|
Debug.Print("[Warning] Resource leaked: {0}.", this);
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue