first commit
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
/* Copyright (C) 2009 Matthew Geyer
|
||||
*
|
||||
* This file is part of UO Machine.
|
||||
*
|
||||
* UO Machine is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* UO Machine is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with UO Machine. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
using System;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
/* NOTE: This class forces thread safety on every access to make it more user-friendly
|
||||
* in scripts at the expense of a bit of performance. Obviously if you use this code
|
||||
* elsewhere you would want to implement the thread-safety yourself. */
|
||||
|
||||
/// <summary>
|
||||
/// Thread-safe generic circular buffer (not a queue). Read position is remembered.
|
||||
/// </summary>
|
||||
public sealed class CircularBuffer<T>
|
||||
{
|
||||
private readonly object _syncRoot;
|
||||
private T[] _buffer;
|
||||
private int _capacity, _head, _tail, _readOffset;
|
||||
|
||||
public CircularBuffer( int capacity )
|
||||
{
|
||||
_capacity = capacity;
|
||||
Count = 0;
|
||||
_head = 0;
|
||||
_tail = 0;
|
||||
_readOffset = 0;
|
||||
_buffer = new T[capacity + 1];
|
||||
_syncRoot = new object();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or set buffer capacity. Buffer can only grow.
|
||||
/// </summary>
|
||||
public int Capacity
|
||||
{
|
||||
get => _capacity;
|
||||
set
|
||||
{
|
||||
lock ( _syncRoot )
|
||||
{
|
||||
if ( value <= _capacity )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
T[] newBuffer = new T[value + 1];
|
||||
T[] oldBuffer = GetBuffer();
|
||||
Array.Copy( oldBuffer, 0, newBuffer, 0, oldBuffer.Length );
|
||||
_buffer = newBuffer;
|
||||
_capacity = value;
|
||||
_head = 0;
|
||||
_tail = Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get number of elements actually contained in buffer.
|
||||
/// </summary>
|
||||
public int Count { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Reset buffer.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
lock ( _syncRoot )
|
||||
{
|
||||
Count = 0;
|
||||
_tail = 0;
|
||||
_head = 0;
|
||||
_readOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change read position to specified number of indices from the beginning.
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public void Seek( int count )
|
||||
{
|
||||
lock ( _syncRoot )
|
||||
{
|
||||
_readOffset = Math.Min( count, Count );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write item to buffer.
|
||||
/// </summary>
|
||||
public void Write( T item )
|
||||
{
|
||||
lock ( _syncRoot )
|
||||
{
|
||||
_buffer[_tail] = item;
|
||||
_tail = ++_tail % _buffer.Length;
|
||||
|
||||
if ( _tail == _head )
|
||||
{
|
||||
_head = ++_head % _buffer.Length;
|
||||
_readOffset = Math.Max( 0, _readOffset - 1 );
|
||||
}
|
||||
|
||||
Count++;
|
||||
Count = Math.Min( Count, _capacity );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read item from buffer and increment read position. Item remains in buffer until overwritten.
|
||||
/// </summary>
|
||||
/// <returns>True on success, false if nothing new to read.</returns>
|
||||
public bool Read( out T item )
|
||||
{
|
||||
lock ( _syncRoot )
|
||||
{
|
||||
int readPos = ( _head + _readOffset ) % _buffer.Length;
|
||||
|
||||
if ( readPos == _tail )
|
||||
{
|
||||
item = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
_readOffset = Math.Min( _readOffset + 1, Count );
|
||||
item = _buffer[readPos];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get array of elements contained in buffer.
|
||||
/// </summary>
|
||||
public T[] GetBuffer()
|
||||
{
|
||||
lock ( _syncRoot )
|
||||
{
|
||||
T[] buffer = new T[Count];
|
||||
|
||||
for ( int x = 0; x < Count; x++ )
|
||||
{
|
||||
buffer[x] = _buffer[( _head + x ) % _buffer.Length];
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using ClassicAssist.UO.Objects;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public class DisplayFormatAttribute : Attribute
|
||||
{
|
||||
private readonly Type _type;
|
||||
|
||||
public DisplayFormatAttribute( Type type )
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public string ToString( object value )
|
||||
{
|
||||
if ( _type.IsEnum )
|
||||
{
|
||||
return Enum.Parse( _type, value.ToString() ).ToString();
|
||||
}
|
||||
|
||||
return typeof( IFormatProvider ).IsAssignableFrom( _type )
|
||||
? string.Format( (IFormatProvider) Activator.CreateInstance( _type ), "{0}", value )
|
||||
: Convert.ChangeType( value, typeof( string ) ).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
internal class HexFormatProvider : IFormatProvider, ICustomFormatter
|
||||
{
|
||||
public string Format( string format, object arg, IFormatProvider formatProvider )
|
||||
{
|
||||
return $"0x{arg:x}";
|
||||
}
|
||||
|
||||
public object GetFormat( Type formatType )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class PropertyArrayFormatProvider : IFormatProvider, ICustomFormatter
|
||||
{
|
||||
public string Format( string format, object arg, IFormatProvider formatProvider )
|
||||
{
|
||||
if ( arg == null )
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
|
||||
if ( !( arg is Property[] properties ) )
|
||||
{
|
||||
return arg.ToString();
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for ( int index = 0; index < properties.Length; index++ )
|
||||
{
|
||||
Property property = properties[index];
|
||||
|
||||
if ( index != properties.Length - 1 )
|
||||
{
|
||||
sb.AppendLine( property.Text );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append( property.Text );
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public object GetFormat( Type formatType )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ClassicAssist.UO.Objects;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public class NameThenSerialComparer : IComparer<Entity>
|
||||
{
|
||||
public int Compare( Entity x, Entity y )
|
||||
{
|
||||
int result = string.Compare( x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase );
|
||||
|
||||
return result == 0 ? x.Serial.CompareTo( y.Serial ) : result;
|
||||
}
|
||||
}
|
||||
|
||||
public class SerialComparer : IComparer<Entity>
|
||||
{
|
||||
public int Compare( Entity x, Entity y )
|
||||
{
|
||||
if ( x == null || y == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return x.Serial.CompareTo( y.Serial );
|
||||
}
|
||||
}
|
||||
|
||||
public class HueThenAmountComparer : IComparer<Entity>
|
||||
{
|
||||
public int Compare( Entity x, Entity y )
|
||||
{
|
||||
if ( x == null || y == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result = x.Hue.CompareTo( y.Hue );
|
||||
|
||||
return result == 0 ? new QuantityThenSerialComparer().Compare( x, y ) : result;
|
||||
}
|
||||
}
|
||||
|
||||
public class IDThenSerialComparer : IComparer<Entity>
|
||||
{
|
||||
public int Compare( Entity x, Entity y )
|
||||
{
|
||||
if ( x == null || y == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result = x.ID.CompareTo( y.ID );
|
||||
|
||||
return result == 0 ? x.Serial.CompareTo( y.Serial ) : result;
|
||||
}
|
||||
}
|
||||
|
||||
public class QuantityThenSerialComparer : IComparer<Entity>
|
||||
{
|
||||
public int Compare( Entity x, Entity y )
|
||||
{
|
||||
if ( x == null || y == null )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( !( x is Item itemX ) || !( y is Item itemY ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int result = itemX.Count.CompareTo( itemY.Count );
|
||||
|
||||
return result == 0 ? x.Serial.CompareTo( y.Serial ) : result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public static class ExtensionMethods
|
||||
{
|
||||
public static T ReadStruct<T>( this Stream stream ) where T : struct
|
||||
{
|
||||
int size = Marshal.SizeOf( typeof( T ) );
|
||||
|
||||
byte[] buffer = new byte[size];
|
||||
|
||||
stream.Read( buffer, 0, size );
|
||||
|
||||
GCHandle pinnedBuffer = GCHandle.Alloc( buffer, GCHandleType.Pinned );
|
||||
|
||||
T structure = (T) Marshal.PtrToStructure( pinnedBuffer.AddrOfPinnedObject(), typeof( T ) );
|
||||
|
||||
pinnedBuffer.Free();
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
public static T GetPropertyAttribute<T>( this Type type, string propertyName )
|
||||
{
|
||||
if ( type == null )
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
T attr = default;
|
||||
|
||||
PropertyInfo pi = type.GetProperty( propertyName );
|
||||
|
||||
if ( pi != null )
|
||||
{
|
||||
attr = pi.GetCustomAttributes( false ).OfType<T>().SingleOrDefault();
|
||||
}
|
||||
|
||||
return attr != null ? attr : default;
|
||||
}
|
||||
|
||||
[DllImport( "gdi32.dll", EntryPoint = "DeleteObject" )]
|
||||
[return: MarshalAs( UnmanagedType.Bool )]
|
||||
public static extern bool DeleteObject( [In] IntPtr hObject );
|
||||
|
||||
public static void AddSorted<T>( this IList<T> list, T item, IComparer<T> comparer = null )
|
||||
{
|
||||
if ( comparer == null )
|
||||
{
|
||||
comparer = Comparer<T>.Default;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
while ( i < list.Count && comparer.Compare( list[i], item ) < 0 )
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
list.Insert( i, item );
|
||||
}
|
||||
|
||||
public static JArray ToJArray( this int[] arr )
|
||||
{
|
||||
JArray jArray = new JArray();
|
||||
|
||||
foreach ( int i in arr )
|
||||
{
|
||||
jArray.Add( i );
|
||||
}
|
||||
|
||||
return jArray;
|
||||
}
|
||||
|
||||
public static int[] ToIntArray( this JToken jToken )
|
||||
{
|
||||
return jToken.Select( token => token.ToObject<int>() ).ToArray();
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/interop-with-other-asynchronous-patterns-and-types?redirectedfrom=MSDN#WHToTap
|
||||
public static Task ToTask( this EventWaitHandle waitHandle )
|
||||
{
|
||||
if ( waitHandle == null )
|
||||
{
|
||||
throw new ArgumentNullException( nameof( waitHandle ) );
|
||||
}
|
||||
|
||||
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
RegisteredWaitHandle rwh = ThreadPool.RegisterWaitForSingleObject( waitHandle,
|
||||
delegate { tcs.TrySetResult( true ); }, null, -1, true );
|
||||
|
||||
Task<bool> t = tcs.Task;
|
||||
|
||||
t.ContinueWith( antecedent => rwh.Unregister( null ) );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Task ToTask( this IEnumerable<EventWaitHandle> waitHandles )
|
||||
{
|
||||
List<Task> tasks = waitHandles.Select( waitHandle => waitHandle.ToTask() ).ToList();
|
||||
|
||||
return Task.WhenAll( tasks );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using ClassicAssist.Data;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public interface ISettingProvider
|
||||
{
|
||||
void Serialize( JObject json );
|
||||
void Deserialize( JObject json, Options options );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,828 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public enum Key
|
||||
{
|
||||
/// <summary>No key pressed. </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>The Cancel key. </summary>
|
||||
Cancel = 1,
|
||||
|
||||
/// <summary>The Backspace key. </summary>
|
||||
Back = 2,
|
||||
|
||||
/// <summary>The Tab key. </summary>
|
||||
Tab = 3,
|
||||
|
||||
/// <summary>The Linefeed key. </summary>
|
||||
LineFeed = 4,
|
||||
|
||||
/// <summary>The Clear key. </summary>
|
||||
Clear = 5,
|
||||
|
||||
/// <summary>The Enter key. </summary>
|
||||
Enter = 6,
|
||||
|
||||
/// <summary>The Return key. </summary>
|
||||
Return = 6,
|
||||
|
||||
/// <summary>The Pause key. </summary>
|
||||
Pause = 7,
|
||||
|
||||
/// <summary>The Caps Lock key. </summary>
|
||||
Capital = 8,
|
||||
|
||||
/// <summary>The Caps Lock key. </summary>
|
||||
CapsLock = 8,
|
||||
|
||||
/// <summary>The IME Hangul mode key. </summary>
|
||||
HangulMode = 9,
|
||||
|
||||
/// <summary>The IME Kana mode key. </summary>
|
||||
KanaMode = 9,
|
||||
|
||||
/// <summary>The IME Junja mode key. </summary>
|
||||
JunjaMode = 10, // 0x0000000A
|
||||
|
||||
/// <summary>The IME Final mode key. </summary>
|
||||
FinalMode = 11, // 0x0000000B
|
||||
|
||||
/// <summary>The IME Hanja mode key. </summary>
|
||||
HanjaMode = 12, // 0x0000000C
|
||||
|
||||
/// <summary>The IME Kanji mode key. </summary>
|
||||
KanjiMode = 12, // 0x0000000C
|
||||
|
||||
/// <summary>The ESC key. </summary>
|
||||
Escape = 13, // 0x0000000D
|
||||
|
||||
/// <summary>The IME Convert key. </summary>
|
||||
ImeConvert = 14, // 0x0000000E
|
||||
|
||||
/// <summary>The IME NonConvert key. </summary>
|
||||
ImeNonConvert = 15, // 0x0000000F
|
||||
|
||||
/// <summary>The IME Accept key. </summary>
|
||||
ImeAccept = 16, // 0x00000010
|
||||
|
||||
/// <summary>The IME Mode change request. </summary>
|
||||
ImeModeChange = 17, // 0x00000011
|
||||
|
||||
/// <summary>The Spacebar key. </summary>
|
||||
Space = 18, // 0x00000012
|
||||
|
||||
/// <summary>The Page Up key. </summary>
|
||||
PageUp = 19, // 0x00000013
|
||||
|
||||
/// <summary>The Page Up key. </summary>
|
||||
Prior = 19, // 0x00000013
|
||||
|
||||
/// <summary>The Page Down key. </summary>
|
||||
Next = 20, // 0x00000014
|
||||
|
||||
/// <summary>The Page Down key. </summary>
|
||||
PageDown = 20, // 0x00000014
|
||||
|
||||
/// <summary>The End key. </summary>
|
||||
End = 21, // 0x00000015
|
||||
|
||||
/// <summary>The Home key. </summary>
|
||||
Home = 22, // 0x00000016
|
||||
|
||||
/// <summary>The Left Arrow key. </summary>
|
||||
Left = 23, // 0x00000017
|
||||
|
||||
/// <summary>The Up Arrow key. </summary>
|
||||
Up = 24, // 0x00000018
|
||||
|
||||
/// <summary>The Right Arrow key. </summary>
|
||||
Right = 25, // 0x00000019
|
||||
|
||||
/// <summary>The Down Arrow key. </summary>
|
||||
Down = 26, // 0x0000001A
|
||||
|
||||
/// <summary>The Select key. </summary>
|
||||
Select = 27, // 0x0000001B
|
||||
|
||||
/// <summary>The Print key. </summary>
|
||||
Print = 28, // 0x0000001C
|
||||
|
||||
/// <summary>The Execute key. </summary>
|
||||
Execute = 29, // 0x0000001D
|
||||
|
||||
/// <summary>The Print Screen key. </summary>
|
||||
PrintScreen = 30, // 0x0000001E
|
||||
|
||||
/// <summary>The Print Screen key. </summary>
|
||||
Snapshot = 30, // 0x0000001E
|
||||
|
||||
/// <summary>The Insert key. </summary>
|
||||
Insert = 31, // 0x0000001F
|
||||
|
||||
/// <summary>The Delete key. </summary>
|
||||
Delete = 32, // 0x00000020
|
||||
|
||||
/// <summary>The Help key. </summary>
|
||||
Help = 33, // 0x00000021
|
||||
|
||||
/// <summary>The 0 (zero) key. </summary>
|
||||
D0 = 34, // 0x00000022
|
||||
|
||||
/// <summary>The 1 (one) key. </summary>
|
||||
D1 = 35, // 0x00000023
|
||||
|
||||
/// <summary>The 2 key. </summary>
|
||||
D2 = 36, // 0x00000024
|
||||
|
||||
/// <summary>The 3 key. </summary>
|
||||
D3 = 37, // 0x00000025
|
||||
|
||||
/// <summary>The 4 key. </summary>
|
||||
D4 = 38, // 0x00000026
|
||||
|
||||
/// <summary>The 5 key. </summary>
|
||||
D5 = 39, // 0x00000027
|
||||
|
||||
/// <summary>The 6 key. </summary>
|
||||
D6 = 40, // 0x00000028
|
||||
|
||||
/// <summary>The 7 key. </summary>
|
||||
D7 = 41, // 0x00000029
|
||||
|
||||
/// <summary>The 8 key. </summary>
|
||||
D8 = 42, // 0x0000002A
|
||||
|
||||
/// <summary>The 9 key. </summary>
|
||||
D9 = 43, // 0x0000002B
|
||||
|
||||
/// <summary>The A key. </summary>
|
||||
A = 44, // 0x0000002C
|
||||
|
||||
/// <summary>The B key. </summary>
|
||||
B = 45, // 0x0000002D
|
||||
|
||||
/// <summary>The C key. </summary>
|
||||
C = 46, // 0x0000002E
|
||||
|
||||
/// <summary>The D key. </summary>
|
||||
D = 47, // 0x0000002F
|
||||
|
||||
/// <summary>The E key. </summary>
|
||||
E = 48, // 0x00000030
|
||||
|
||||
/// <summary>The F key. </summary>
|
||||
F = 49, // 0x00000031
|
||||
|
||||
/// <summary>The G key. </summary>
|
||||
G = 50, // 0x00000032
|
||||
|
||||
/// <summary>The H key. </summary>
|
||||
H = 51, // 0x00000033
|
||||
|
||||
/// <summary>The I key. </summary>
|
||||
I = 52, // 0x00000034
|
||||
|
||||
/// <summary>The J key. </summary>
|
||||
J = 53, // 0x00000035
|
||||
|
||||
/// <summary>The K key. </summary>
|
||||
K = 54, // 0x00000036
|
||||
|
||||
/// <summary>The L key. </summary>
|
||||
L = 55, // 0x00000037
|
||||
|
||||
/// <summary>The M key. </summary>
|
||||
M = 56, // 0x00000038
|
||||
|
||||
/// <summary>The N key. </summary>
|
||||
N = 57, // 0x00000039
|
||||
|
||||
/// <summary>The O key. </summary>
|
||||
O = 58, // 0x0000003A
|
||||
|
||||
/// <summary>The P key. </summary>
|
||||
P = 59, // 0x0000003B
|
||||
|
||||
/// <summary>The Q key. </summary>
|
||||
Q = 60, // 0x0000003C
|
||||
|
||||
/// <summary>The R key. </summary>
|
||||
R = 61, // 0x0000003D
|
||||
|
||||
/// <summary>The S key. </summary>
|
||||
S = 62, // 0x0000003E
|
||||
|
||||
/// <summary>The T key. </summary>
|
||||
T = 63, // 0x0000003F
|
||||
|
||||
/// <summary>The U key. </summary>
|
||||
U = 64, // 0x00000040
|
||||
|
||||
/// <summary>The V key. </summary>
|
||||
V = 65, // 0x00000041
|
||||
|
||||
/// <summary>The W key. </summary>
|
||||
W = 66, // 0x00000042
|
||||
|
||||
/// <summary>The X key. </summary>
|
||||
X = 67, // 0x00000043
|
||||
|
||||
/// <summary>The Y key. </summary>
|
||||
Y = 68, // 0x00000044
|
||||
|
||||
/// <summary>The Z key. </summary>
|
||||
Z = 69, // 0x00000045
|
||||
|
||||
/// <summary>The left Windows logo key (Microsoft Natural Keyboard). </summary>
|
||||
LWin = 70, // 0x00000046
|
||||
|
||||
/// <summary>The right Windows logo key (Microsoft Natural Keyboard). </summary>
|
||||
RWin = 71, // 0x00000047
|
||||
|
||||
/// <summary>The Application key (Microsoft Natural Keyboard). </summary>
|
||||
Apps = 72, // 0x00000048
|
||||
|
||||
/// <summary>The Computer Sleep key. </summary>
|
||||
Sleep = 73, // 0x00000049
|
||||
|
||||
/// <summary>The 0 key on the numeric keypad. </summary>
|
||||
NumPad0 = 74, // 0x0000004A
|
||||
|
||||
/// <summary>The 1 key on the numeric keypad. </summary>
|
||||
NumPad1 = 75, // 0x0000004B
|
||||
|
||||
/// <summary>The 2 key on the numeric keypad. </summary>
|
||||
NumPad2 = 76, // 0x0000004C
|
||||
|
||||
/// <summary>The 3 key on the numeric keypad. </summary>
|
||||
NumPad3 = 77, // 0x0000004D
|
||||
|
||||
/// <summary>The 4 key on the numeric keypad. </summary>
|
||||
NumPad4 = 78, // 0x0000004E
|
||||
|
||||
/// <summary>The 5 key on the numeric keypad. </summary>
|
||||
NumPad5 = 79, // 0x0000004F
|
||||
|
||||
/// <summary>The 6 key on the numeric keypad. </summary>
|
||||
NumPad6 = 80, // 0x00000050
|
||||
|
||||
/// <summary>The 7 key on the numeric keypad. </summary>
|
||||
NumPad7 = 81, // 0x00000051
|
||||
|
||||
/// <summary>The 8 key on the numeric keypad. </summary>
|
||||
NumPad8 = 82, // 0x00000052
|
||||
|
||||
/// <summary>The 9 key on the numeric keypad. </summary>
|
||||
NumPad9 = 83, // 0x00000053
|
||||
|
||||
/// <summary>The Multiply key. </summary>
|
||||
Multiply = 84, // 0x00000054
|
||||
|
||||
/// <summary>The Add key. </summary>
|
||||
Add = 85, // 0x00000055
|
||||
|
||||
/// <summary>The Separator key. </summary>
|
||||
Separator = 86, // 0x00000056
|
||||
|
||||
/// <summary>The Subtract key. </summary>
|
||||
Subtract = 87, // 0x00000057
|
||||
|
||||
/// <summary>The Decimal key. </summary>
|
||||
Decimal = 88, // 0x00000058
|
||||
|
||||
/// <summary>The Divide key. </summary>
|
||||
Divide = 89, // 0x00000059
|
||||
|
||||
/// <summary>The F1 key. </summary>
|
||||
F1 = 90, // 0x0000005A
|
||||
|
||||
/// <summary>The F2 key. </summary>
|
||||
F2 = 91, // 0x0000005B
|
||||
|
||||
/// <summary>The F3 key. </summary>
|
||||
F3 = 92, // 0x0000005C
|
||||
|
||||
/// <summary>The F4 key. </summary>
|
||||
F4 = 93, // 0x0000005D
|
||||
|
||||
/// <summary>The F5 key. </summary>
|
||||
F5 = 94, // 0x0000005E
|
||||
|
||||
/// <summary>The F6 key. </summary>
|
||||
F6 = 95, // 0x0000005F
|
||||
|
||||
/// <summary>The F7 key. </summary>
|
||||
F7 = 96, // 0x00000060
|
||||
|
||||
/// <summary>The F8 key. </summary>
|
||||
F8 = 97, // 0x00000061
|
||||
|
||||
/// <summary>The F9 key. </summary>
|
||||
F9 = 98, // 0x00000062
|
||||
|
||||
/// <summary>The F10 key. </summary>
|
||||
F10 = 99, // 0x00000063
|
||||
|
||||
/// <summary>The F11 key. </summary>
|
||||
F11 = 100, // 0x00000064
|
||||
|
||||
/// <summary>The F12 key. </summary>
|
||||
F12 = 101, // 0x00000065
|
||||
|
||||
/// <summary>The F13 key. </summary>
|
||||
F13 = 102, // 0x00000066
|
||||
|
||||
/// <summary>The F14 key. </summary>
|
||||
F14 = 103, // 0x00000067
|
||||
|
||||
/// <summary>The F15 key. </summary>
|
||||
F15 = 104, // 0x00000068
|
||||
|
||||
/// <summary>The F16 key. </summary>
|
||||
F16 = 105, // 0x00000069
|
||||
|
||||
/// <summary>The F17 key. </summary>
|
||||
F17 = 106, // 0x0000006A
|
||||
|
||||
/// <summary>The F18 key. </summary>
|
||||
F18 = 107, // 0x0000006B
|
||||
|
||||
/// <summary>The F19 key. </summary>
|
||||
F19 = 108, // 0x0000006C
|
||||
|
||||
/// <summary>The F20 key. </summary>
|
||||
F20 = 109, // 0x0000006D
|
||||
|
||||
/// <summary>The F21 key. </summary>
|
||||
F21 = 110, // 0x0000006E
|
||||
|
||||
/// <summary>The F22 key. </summary>
|
||||
F22 = 111, // 0x0000006F
|
||||
|
||||
/// <summary>The F23 key. </summary>
|
||||
F23 = 112, // 0x00000070
|
||||
|
||||
/// <summary>The F24 key. </summary>
|
||||
F24 = 113, // 0x00000071
|
||||
|
||||
/// <summary>The Num Lock key. </summary>
|
||||
NumLock = 114, // 0x00000072
|
||||
|
||||
/// <summary>The Scroll Lock key. </summary>
|
||||
Scroll = 115, // 0x00000073
|
||||
|
||||
/// <summary>The left Shift key. </summary>
|
||||
LeftShift = 116, // 0x00000074
|
||||
|
||||
/// <summary>The right Shift key. </summary>
|
||||
RightShift = 117, // 0x00000075
|
||||
|
||||
/// <summary>The left CTRL key. </summary>
|
||||
LeftCtrl = 118, // 0x00000076
|
||||
|
||||
/// <summary>The right CTRL key. </summary>
|
||||
RightCtrl = 119, // 0x00000077
|
||||
|
||||
/// <summary>The left ALT key. </summary>
|
||||
LeftAlt = 120, // 0x00000078
|
||||
|
||||
/// <summary>The right ALT key. </summary>
|
||||
RightAlt = 121, // 0x00000079
|
||||
|
||||
/// <summary>The Browser Back key. </summary>
|
||||
BrowserBack = 122, // 0x0000007A
|
||||
|
||||
/// <summary>The Browser Forward key. </summary>
|
||||
BrowserForward = 123, // 0x0000007B
|
||||
|
||||
/// <summary>The Browser Refresh key. </summary>
|
||||
BrowserRefresh = 124, // 0x0000007C
|
||||
|
||||
/// <summary>The Browser Stop key. </summary>
|
||||
BrowserStop = 125, // 0x0000007D
|
||||
|
||||
/// <summary>The Browser Search key. </summary>
|
||||
BrowserSearch = 126, // 0x0000007E
|
||||
|
||||
/// <summary>The Browser Favorites key. </summary>
|
||||
BrowserFavorites = 127, // 0x0000007F
|
||||
|
||||
/// <summary>The Browser Home key. </summary>
|
||||
BrowserHome = 128, // 0x00000080
|
||||
|
||||
/// <summary>The Volume Mute key. </summary>
|
||||
VolumeMute = 129, // 0x00000081
|
||||
|
||||
/// <summary>The Volume Down key. </summary>
|
||||
VolumeDown = 130, // 0x00000082
|
||||
|
||||
/// <summary>The Volume Up key. </summary>
|
||||
VolumeUp = 131, // 0x00000083
|
||||
|
||||
/// <summary>The Media Next Track key. </summary>
|
||||
MediaNextTrack = 132, // 0x00000084
|
||||
|
||||
/// <summary>The Media Previous Track key. </summary>
|
||||
MediaPreviousTrack = 133, // 0x00000085
|
||||
|
||||
/// <summary>The Media Stop key. </summary>
|
||||
MediaStop = 134, // 0x00000086
|
||||
|
||||
/// <summary>The Media Play Pause key. </summary>
|
||||
MediaPlayPause = 135, // 0x00000087
|
||||
|
||||
/// <summary>The Launch Mail key. </summary>
|
||||
LaunchMail = 136, // 0x00000088
|
||||
|
||||
/// <summary>The Select Media key. </summary>
|
||||
SelectMedia = 137, // 0x00000089
|
||||
|
||||
/// <summary>The Launch Application1 key. </summary>
|
||||
LaunchApplication1 = 138, // 0x0000008A
|
||||
|
||||
/// <summary>The Launch Application2 key. </summary>
|
||||
LaunchApplication2 = 139, // 0x0000008B
|
||||
|
||||
/// <summary>The OEM 1 key. </summary>
|
||||
Oem1 = 140, // 0x0000008C
|
||||
|
||||
/// <summary>The OEM Semicolon key. </summary>
|
||||
OemSemicolon = 140, // 0x0000008C
|
||||
|
||||
/// <summary>The OEM Addition key. </summary>
|
||||
OemPlus = 141, // 0x0000008D
|
||||
|
||||
/// <summary>The OEM Comma key. </summary>
|
||||
OemComma = 142, // 0x0000008E
|
||||
|
||||
/// <summary>The OEM Minus key. </summary>
|
||||
OemMinus = 143, // 0x0000008F
|
||||
|
||||
/// <summary>The OEM Period key. </summary>
|
||||
OemPeriod = 144, // 0x00000090
|
||||
|
||||
/// <summary>The OEM 2 key. </summary>
|
||||
Oem2 = 145, // 0x00000091
|
||||
|
||||
/// <summary>The OEM Question key. </summary>
|
||||
OemQuestion = 145, // 0x00000091
|
||||
|
||||
/// <summary>The OEM 3 key. </summary>
|
||||
Oem3 = 146, // 0x00000092
|
||||
|
||||
/// <summary>The OEM Tilde key. </summary>
|
||||
OemTilde = 146, // 0x00000092
|
||||
|
||||
/// <summary>The ABNT_C1 (Brazilian) key. </summary>
|
||||
AbntC1 = 147, // 0x00000093
|
||||
|
||||
/// <summary>The ABNT_C2 (Brazilian) key. </summary>
|
||||
AbntC2 = 148, // 0x00000094
|
||||
|
||||
/// <summary>The OEM 4 key. </summary>
|
||||
Oem4 = 149, // 0x00000095
|
||||
|
||||
/// <summary>The OEM Open Brackets key. </summary>
|
||||
OemOpenBrackets = 149, // 0x00000095
|
||||
|
||||
/// <summary>The OEM 5 key. </summary>
|
||||
Oem5 = 150, // 0x00000096
|
||||
|
||||
/// <summary>The OEM Pipe key. </summary>
|
||||
OemPipe = 150, // 0x00000096
|
||||
|
||||
/// <summary>The OEM 6 key. </summary>
|
||||
Oem6 = 151, // 0x00000097
|
||||
|
||||
/// <summary>The OEM Close Brackets key. </summary>
|
||||
OemCloseBrackets = 151, // 0x00000097
|
||||
|
||||
/// <summary>The OEM 7 key. </summary>
|
||||
Oem7 = 152, // 0x00000098
|
||||
|
||||
/// <summary>The OEM Quotes key. </summary>
|
||||
OemQuotes = 152, // 0x00000098
|
||||
|
||||
/// <summary>The OEM 8 key. </summary>
|
||||
Oem8 = 153, // 0x00000099
|
||||
|
||||
/// <summary>The OEM 102 key. </summary>
|
||||
Oem102 = 154, // 0x0000009A
|
||||
|
||||
/// <summary>The OEM Backslash key. </summary>
|
||||
OemBackslash = 154, // 0x0000009A
|
||||
|
||||
/// <summary>A special key masking the real key being processed by an IME. </summary>
|
||||
ImeProcessed = 155, // 0x0000009B
|
||||
|
||||
/// <summary>A special key masking the real key being processed as a system key. </summary>
|
||||
System = 156, // 0x0000009C
|
||||
|
||||
/// <summary>The DBE_ALPHANUMERIC key. </summary>
|
||||
DbeAlphanumeric = 157, // 0x0000009D
|
||||
|
||||
/// <summary>The OEM ATTN key. </summary>
|
||||
OemAttn = 157, // 0x0000009D
|
||||
|
||||
/// <summary>The DBE_KATAKANA key. </summary>
|
||||
DbeKatakana = 158, // 0x0000009E
|
||||
|
||||
/// <summary>The OEM FINISH key. </summary>
|
||||
OemFinish = 158, // 0x0000009E
|
||||
|
||||
/// <summary>The DBE_HIRAGANA key. </summary>
|
||||
DbeHiragana = 159, // 0x0000009F
|
||||
|
||||
/// <summary>The OEM COPY key. </summary>
|
||||
OemCopy = 159, // 0x0000009F
|
||||
|
||||
/// <summary>The DBE_SBCSCHAR key. </summary>
|
||||
DbeSbcsChar = 160, // 0x000000A0
|
||||
|
||||
/// <summary>The OEM AUTO key. </summary>
|
||||
OemAuto = 160, // 0x000000A0
|
||||
|
||||
/// <summary>The DBE_DBCSCHAR key. </summary>
|
||||
DbeDbcsChar = 161, // 0x000000A1
|
||||
|
||||
/// <summary>The OEM ENLW key. </summary>
|
||||
OemEnlw = 161, // 0x000000A1
|
||||
|
||||
/// <summary>The DBE_ROMAN key. </summary>
|
||||
DbeRoman = 162, // 0x000000A2
|
||||
|
||||
/// <summary>The OEM BACKTAB key. </summary>
|
||||
OemBackTab = 162, // 0x000000A2
|
||||
|
||||
/// <summary>The ATTN key. </summary>
|
||||
Attn = 163, // 0x000000A3
|
||||
|
||||
/// <summary>The DBE_NOROMAN key. </summary>
|
||||
DbeNoRoman = 163, // 0x000000A3
|
||||
|
||||
/// <summary>The CRSEL key. </summary>
|
||||
CrSel = 164, // 0x000000A4
|
||||
|
||||
/// <summary>The DBE_ENTERWORDREGISTERMODE key. </summary>
|
||||
DbeEnterWordRegisterMode = 164, // 0x000000A4
|
||||
|
||||
/// <summary>The DBE_ENTERIMECONFIGMODE key. </summary>
|
||||
DbeEnterImeConfigureMode = 165, // 0x000000A5
|
||||
|
||||
/// <summary>The EXSEL key. </summary>
|
||||
ExSel = 165, // 0x000000A5
|
||||
|
||||
/// <summary>The DBE_FLUSHSTRING key. </summary>
|
||||
DbeFlushString = 166, // 0x000000A6
|
||||
|
||||
/// <summary>The ERASE EOF key. </summary>
|
||||
EraseEof = 166, // 0x000000A6
|
||||
|
||||
/// <summary>The DBE_CODEINPUT key. </summary>
|
||||
DbeCodeInput = 167, // 0x000000A7
|
||||
|
||||
/// <summary>The PLAY key. </summary>
|
||||
Play = 167, // 0x000000A7
|
||||
|
||||
/// <summary>The DBE_NOCODEINPUT key. </summary>
|
||||
DbeNoCodeInput = 168, // 0x000000A8
|
||||
|
||||
/// <summary>The ZOOM key. </summary>
|
||||
Zoom = 168, // 0x000000A8
|
||||
|
||||
/// <summary>The DBE_DETERMINESTRING key. </summary>
|
||||
DbeDetermineString = 169, // 0x000000A9
|
||||
|
||||
/// <summary>A constant reserved for future use. </summary>
|
||||
NoName = 169, // 0x000000A9
|
||||
|
||||
/// <summary>The DBE_ENTERDLGCONVERSIONMODE key. </summary>
|
||||
DbeEnterDialogConversionMode = 170, // 0x000000AA
|
||||
|
||||
/// <summary>The PA1 key. </summary>
|
||||
Pa1 = 170, // 0x000000AA
|
||||
|
||||
/// <summary>The OEM Clear key. </summary>
|
||||
OemClear = 171, // 0x000000AB
|
||||
|
||||
/// <summary>The key is used with another key to create a single combined character.</summary>
|
||||
DeadCharProcessed = 172 // 0x000000AC
|
||||
}
|
||||
|
||||
public enum Keys
|
||||
{
|
||||
None = 0x00000000,
|
||||
LButton = 0x00000001,
|
||||
RButton = 0x00000002,
|
||||
Cancel = 0x00000003,
|
||||
MButton = 0x00000004,
|
||||
XButton1 = 0x00000005,
|
||||
XButton2 = 0x00000006,
|
||||
Back = 0x00000008,
|
||||
Tab = 0x00000009,
|
||||
LineFeed = 0x0000000A,
|
||||
Clear = 0x0000000C,
|
||||
Return = 0x0000000D,
|
||||
Enter = 0x0000000D,
|
||||
ShiftKey = 0x00000010,
|
||||
ControlKey = 0x00000011,
|
||||
Menu = 0x00000012,
|
||||
Pause = 0x00000013,
|
||||
CapsLock = 0x00000014,
|
||||
Capital = 0x00000014,
|
||||
KanaMode = 0x00000015,
|
||||
HanguelMode = 0x00000015,
|
||||
HangulMode = 0x00000015,
|
||||
JunjaMode = 0x00000017,
|
||||
FinalMode = 0x00000018,
|
||||
KanjiMode = 0x00000019,
|
||||
HanjaMode = 0x00000019,
|
||||
Escape = 0x0000001B,
|
||||
IMEConvert = 0x0000001C,
|
||||
IMENonconvert = 0x0000001D,
|
||||
IMEAceept = 0x0000001E,
|
||||
IMEModeChange = 0x0000001F,
|
||||
Space = 0x00000020,
|
||||
PageUp = 0x00000021,
|
||||
Prior = 0x00000021,
|
||||
PageDown = 0x00000022,
|
||||
Next = 0x00000022,
|
||||
End = 0x00000023,
|
||||
Home = 0x00000024,
|
||||
Left = 0x00000025,
|
||||
Up = 0x00000026,
|
||||
Right = 0x00000027,
|
||||
Down = 0x00000028,
|
||||
Select = 0x00000029,
|
||||
Print = 0x0000002A,
|
||||
Execute = 0x0000002B,
|
||||
PrintScreen = 0x0000002C,
|
||||
Snapshot = 0x0000002C,
|
||||
Insert = 0x0000002D,
|
||||
Delete = 0x0000002E,
|
||||
Help = 0x0000002F,
|
||||
D0 = 0x00000030,
|
||||
D1 = 0x00000031,
|
||||
D2 = 0x00000032,
|
||||
D3 = 0x00000033,
|
||||
D4 = 0x00000034,
|
||||
D5 = 0x00000035,
|
||||
D6 = 0x00000036,
|
||||
D7 = 0x00000037,
|
||||
D8 = 0x00000038,
|
||||
D9 = 0x00000039,
|
||||
A = 0x00000041,
|
||||
B = 0x00000042,
|
||||
C = 0x00000043,
|
||||
D = 0x00000044,
|
||||
E = 0x00000045,
|
||||
F = 0x00000046,
|
||||
G = 0x00000047,
|
||||
H = 0x00000048,
|
||||
I = 0x00000049,
|
||||
J = 0x0000004A,
|
||||
K = 0x0000004B,
|
||||
L = 0x0000004C,
|
||||
M = 0x0000004D,
|
||||
N = 0x0000004E,
|
||||
O = 0x0000004F,
|
||||
P = 0x00000050,
|
||||
Q = 0x00000051,
|
||||
R = 0x00000052,
|
||||
S = 0x00000053,
|
||||
T = 0x00000054,
|
||||
U = 0x00000055,
|
||||
V = 0x00000056,
|
||||
W = 0x00000057,
|
||||
X = 0x00000058,
|
||||
Y = 0x00000059,
|
||||
Z = 0x0000005A,
|
||||
LWin = 0x0000005B,
|
||||
RWin = 0x0000005C,
|
||||
Apps = 0x0000005D,
|
||||
NumPad0 = 0x00000060,
|
||||
NumPad1 = 0x00000061,
|
||||
NumPad2 = 0x00000062,
|
||||
NumPad3 = 0x00000063,
|
||||
NumPad4 = 0x00000064,
|
||||
NumPad5 = 0x00000065,
|
||||
NumPad6 = 0x00000066,
|
||||
NumPad7 = 0x00000067,
|
||||
NumPad8 = 0x00000068,
|
||||
NumPad9 = 0x00000069,
|
||||
Multiply = 0x0000006A,
|
||||
Add = 0x0000006B,
|
||||
Separator = 0x0000006C,
|
||||
Subtract = 0x0000006D,
|
||||
Decimal = 0x0000006E,
|
||||
Divide = 0x0000006F,
|
||||
F1 = 0x00000070,
|
||||
F2 = 0x00000071,
|
||||
F3 = 0x00000072,
|
||||
F4 = 0x00000073,
|
||||
F5 = 0x00000074,
|
||||
F6 = 0x00000075,
|
||||
F7 = 0x00000076,
|
||||
F8 = 0x00000077,
|
||||
F9 = 0x00000078,
|
||||
F10 = 0x00000079,
|
||||
F11 = 0x0000007A,
|
||||
F12 = 0x0000007B,
|
||||
F13 = 0x0000007C,
|
||||
F14 = 0x0000007D,
|
||||
F15 = 0x0000007E,
|
||||
F16 = 0x0000007F,
|
||||
F17 = 0x00000080,
|
||||
F18 = 0x00000081,
|
||||
F19 = 0x00000082,
|
||||
F20 = 0x00000083,
|
||||
F21 = 0x00000084,
|
||||
F22 = 0x00000085,
|
||||
F23 = 0x00000086,
|
||||
F24 = 0x00000087,
|
||||
NumLock = 0x00000090,
|
||||
Scroll = 0x00000091,
|
||||
LShiftKey = 0x000000A0,
|
||||
RShiftKey = 0x000000A1,
|
||||
LControlKey = 0x000000A2,
|
||||
RControlKey = 0x000000A3,
|
||||
LMenu = 0x000000A4,
|
||||
RMenu = 0x000000A5,
|
||||
BrowserBack = 0x000000A6,
|
||||
BrowserForward = 0x000000A7,
|
||||
BrowserRefresh = 0x000000A8,
|
||||
BrowserStop = 0x000000A9,
|
||||
BrowserSearch = 0x000000AA,
|
||||
BrowserFavorites = 0x000000AB,
|
||||
BrowserHome = 0x000000AC,
|
||||
VolumeMute = 0x000000AD,
|
||||
VolumeDown = 0x000000AE,
|
||||
VolumeUp = 0x000000AF,
|
||||
MediaNextTrack = 0x000000B0,
|
||||
MediaPreviousTrack = 0x000000B1,
|
||||
MediaStop = 0x000000B2,
|
||||
MediaPlayPause = 0x000000B3,
|
||||
LaunchMail = 0x000000B4,
|
||||
SelectMedia = 0x000000B5,
|
||||
LaunchApplication1 = 0x000000B6,
|
||||
LaunchApplication2 = 0x000000B7,
|
||||
OemSemicolon = 0x000000BA,
|
||||
Oemplus = 0x000000BB,
|
||||
Oemcomma = 0x000000BC,
|
||||
OemMinus = 0x000000BD,
|
||||
OemPeriod = 0x000000BE,
|
||||
OemQuestion = 0x000000BF,
|
||||
Oemtilde = 0x000000C0,
|
||||
OemOpenBrackets = 0x000000DB,
|
||||
OemPipe = 0x000000DC,
|
||||
OemCloseBrackets = 0x000000DD,
|
||||
OemQuotes = 0x000000DE,
|
||||
Oem8 = 0x000000DF,
|
||||
OemBackslash = 0x000000E2,
|
||||
ProcessKey = 0x000000E5,
|
||||
Attn = 0x000000F6,
|
||||
Crsel = 0x000000F7,
|
||||
Exsel = 0x000000F8,
|
||||
EraseEof = 0x000000F9,
|
||||
Play = 0x000000FA,
|
||||
Zoom = 0x000000FB,
|
||||
NoName = 0x000000FC,
|
||||
Pa1 = 0x000000FD,
|
||||
OemClear = 0x000000FE,
|
||||
KeyCode = 0x0000FFFF,
|
||||
Shift = 0x00010000,
|
||||
Control = 0x00020000,
|
||||
Alt = 0x00040000,
|
||||
Modifiers = unchecked( (int) 0xFFFF0000 ),
|
||||
IMEAccept = 0x0000001E,
|
||||
Oem1 = 0x000000BA,
|
||||
Oem102 = 0x000000E2,
|
||||
Oem2 = 0x000000BF,
|
||||
Oem3 = 0x000000C0,
|
||||
Oem4 = 0x000000DB,
|
||||
Oem5 = 0x000000DC,
|
||||
Oem6 = 0x000000DD,
|
||||
Oem7 = 0x000000DE,
|
||||
Packet = 0x000000E7,
|
||||
Sleep = 0x0000005F
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public enum WindowType
|
||||
{
|
||||
WPF,
|
||||
Avalonia
|
||||
}
|
||||
|
||||
public struct SharedWindow
|
||||
{
|
||||
public object Window;
|
||||
public WindowType Type;
|
||||
public string Caption;
|
||||
public string Text;
|
||||
public MessageBoxButtons Buttons;
|
||||
public MessageBoxImage? Icon;
|
||||
}
|
||||
|
||||
public enum MessageBoxButtons
|
||||
{
|
||||
OK,
|
||||
YesNo
|
||||
}
|
||||
|
||||
public enum MessageBoxResult
|
||||
{
|
||||
OK,
|
||||
Yes,
|
||||
No,
|
||||
Cancel
|
||||
}
|
||||
|
||||
public enum MessageBoxImage
|
||||
{
|
||||
Information,
|
||||
Error,
|
||||
Warning
|
||||
}
|
||||
|
||||
public interface IMessageBoxProvider
|
||||
{
|
||||
Task<MessageBoxResult> Show( string text, string caption = null,
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxImage? icon = null );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public static class NativeMethods
|
||||
{
|
||||
[DllImport( "user32" )]
|
||||
public static extern bool GetWindowRect( IntPtr hWnd, out RECT rect );
|
||||
|
||||
[StructLayout( LayoutKind.Sequential )]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left; // x position of upper-left corner
|
||||
public int Top; // y position of upper-left corner
|
||||
public int Right; // x position of lower-right corner
|
||||
public int Bottom; // y position of lower-right corner
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public class OffsetStopwatch : Stopwatch
|
||||
{
|
||||
private TimeSpan _offset;
|
||||
|
||||
public OffsetStopwatch( TimeSpan offset )
|
||||
{
|
||||
_offset = offset;
|
||||
Start();
|
||||
}
|
||||
|
||||
public new long ElapsedMilliseconds => base.ElapsedMilliseconds + (long) _offset.TotalMilliseconds;
|
||||
public new long ElapsedTicks => base.ElapsedTicks + _offset.Ticks;
|
||||
|
||||
public void Reset( TimeSpan offset )
|
||||
{
|
||||
_offset = offset;
|
||||
Reset();
|
||||
Start();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Elapsed: {TimeSpan.FromMilliseconds( ElapsedMilliseconds )}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,756 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Input;
|
||||
using ClassicAssist.Data.Hotkeys;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public static class SDLKeys
|
||||
{
|
||||
public enum SDL_Keycode
|
||||
{
|
||||
SDLK_UNKNOWN = 0,
|
||||
|
||||
SDLK_RETURN = '\r',
|
||||
SDLK_ESCAPE = 27, // '\033'
|
||||
SDLK_BACKSPACE = '\b',
|
||||
SDLK_TAB = '\t',
|
||||
SDLK_SPACE = ' ',
|
||||
SDLK_EXCLAIM = '!',
|
||||
SDLK_QUOTEDBL = '"',
|
||||
SDLK_HASH = '#',
|
||||
SDLK_PERCENT = '%',
|
||||
SDLK_DOLLAR = '$',
|
||||
SDLK_AMPERSAND = '&',
|
||||
SDLK_QUOTE = '\'',
|
||||
SDLK_LEFTPAREN = '(',
|
||||
SDLK_RIGHTPAREN = ')',
|
||||
SDLK_ASTERISK = '*',
|
||||
SDLK_PLUS = '+',
|
||||
SDLK_COMMA = ',',
|
||||
SDLK_MINUS = '-',
|
||||
SDLK_PERIOD = '.',
|
||||
SDLK_SLASH = '/',
|
||||
SDLK_0 = '0',
|
||||
SDLK_1 = '1',
|
||||
SDLK_2 = '2',
|
||||
SDLK_3 = '3',
|
||||
SDLK_4 = '4',
|
||||
SDLK_5 = '5',
|
||||
SDLK_6 = '6',
|
||||
SDLK_7 = '7',
|
||||
SDLK_8 = '8',
|
||||
SDLK_9 = '9',
|
||||
SDLK_COLON = ':',
|
||||
SDLK_SEMICOLON = ';',
|
||||
SDLK_LESS = '<',
|
||||
SDLK_EQUALS = '=',
|
||||
SDLK_GREATER = '>',
|
||||
SDLK_QUESTION = '?',
|
||||
SDLK_AT = '@',
|
||||
|
||||
/*
|
||||
Skip uppercase letters
|
||||
*/
|
||||
SDLK_LEFTBRACKET = '[',
|
||||
SDLK_BACKSLASH = '\\',
|
||||
SDLK_RIGHTBRACKET = ']',
|
||||
SDLK_CARET = '^',
|
||||
SDLK_UNDERSCORE = '_',
|
||||
SDLK_BACKQUOTE = '`',
|
||||
SDLK_a = 'a',
|
||||
SDLK_b = 'b',
|
||||
SDLK_c = 'c',
|
||||
SDLK_d = 'd',
|
||||
SDLK_e = 'e',
|
||||
SDLK_f = 'f',
|
||||
SDLK_g = 'g',
|
||||
SDLK_h = 'h',
|
||||
SDLK_i = 'i',
|
||||
SDLK_j = 'j',
|
||||
SDLK_k = 'k',
|
||||
SDLK_l = 'l',
|
||||
SDLK_m = 'm',
|
||||
SDLK_n = 'n',
|
||||
SDLK_o = 'o',
|
||||
SDLK_p = 'p',
|
||||
SDLK_q = 'q',
|
||||
SDLK_r = 'r',
|
||||
SDLK_s = 's',
|
||||
SDLK_t = 't',
|
||||
SDLK_u = 'u',
|
||||
SDLK_v = 'v',
|
||||
SDLK_w = 'w',
|
||||
SDLK_x = 'x',
|
||||
SDLK_y = 'y',
|
||||
SDLK_z = 'z',
|
||||
|
||||
SDLK_CAPSLOCK = SDL_Scancode.SDL_SCANCODE_CAPSLOCK | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_F1 = SDL_Scancode.SDL_SCANCODE_F1 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F2 = SDL_Scancode.SDL_SCANCODE_F2 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F3 = SDL_Scancode.SDL_SCANCODE_F3 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F4 = SDL_Scancode.SDL_SCANCODE_F4 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F5 = SDL_Scancode.SDL_SCANCODE_F5 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F6 = SDL_Scancode.SDL_SCANCODE_F6 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F7 = SDL_Scancode.SDL_SCANCODE_F7 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F8 = SDL_Scancode.SDL_SCANCODE_F8 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F9 = SDL_Scancode.SDL_SCANCODE_F9 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F10 = SDL_Scancode.SDL_SCANCODE_F10 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F11 = SDL_Scancode.SDL_SCANCODE_F11 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F12 = SDL_Scancode.SDL_SCANCODE_F12 | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_PRINTSCREEN = SDL_Scancode.SDL_SCANCODE_PRINTSCREEN | SDLK_SCANCODE_MASK,
|
||||
SDLK_SCROLLLOCK = SDL_Scancode.SDL_SCANCODE_SCROLLLOCK | SDLK_SCANCODE_MASK,
|
||||
SDLK_PAUSE = SDL_Scancode.SDL_SCANCODE_PAUSE | SDLK_SCANCODE_MASK,
|
||||
SDLK_INSERT = SDL_Scancode.SDL_SCANCODE_INSERT | SDLK_SCANCODE_MASK,
|
||||
SDLK_HOME = SDL_Scancode.SDL_SCANCODE_HOME | SDLK_SCANCODE_MASK,
|
||||
SDLK_PAGEUP = SDL_Scancode.SDL_SCANCODE_PAGEUP | SDLK_SCANCODE_MASK,
|
||||
SDLK_DELETE = 127,
|
||||
SDLK_END = SDL_Scancode.SDL_SCANCODE_END | SDLK_SCANCODE_MASK,
|
||||
SDLK_PAGEDOWN = SDL_Scancode.SDL_SCANCODE_PAGEDOWN | SDLK_SCANCODE_MASK,
|
||||
SDLK_RIGHT = SDL_Scancode.SDL_SCANCODE_RIGHT | SDLK_SCANCODE_MASK,
|
||||
SDLK_LEFT = SDL_Scancode.SDL_SCANCODE_LEFT | SDLK_SCANCODE_MASK,
|
||||
SDLK_DOWN = SDL_Scancode.SDL_SCANCODE_DOWN | SDLK_SCANCODE_MASK,
|
||||
SDLK_UP = SDL_Scancode.SDL_SCANCODE_UP | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_NUMLOCKCLEAR = SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_DIVIDE = SDL_Scancode.SDL_SCANCODE_KP_DIVIDE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_MULTIPLY = SDL_Scancode.SDL_SCANCODE_KP_MULTIPLY | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_MINUS = SDL_Scancode.SDL_SCANCODE_KP_MINUS | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_PLUS = SDL_Scancode.SDL_SCANCODE_KP_PLUS | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_ENTER = SDL_Scancode.SDL_SCANCODE_KP_ENTER | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_1 = SDL_Scancode.SDL_SCANCODE_KP_1 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_2 = SDL_Scancode.SDL_SCANCODE_KP_2 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_3 = SDL_Scancode.SDL_SCANCODE_KP_3 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_4 = SDL_Scancode.SDL_SCANCODE_KP_4 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_5 = SDL_Scancode.SDL_SCANCODE_KP_5 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_6 = SDL_Scancode.SDL_SCANCODE_KP_6 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_7 = SDL_Scancode.SDL_SCANCODE_KP_7 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_8 = SDL_Scancode.SDL_SCANCODE_KP_8 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_9 = SDL_Scancode.SDL_SCANCODE_KP_9 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_0 = SDL_Scancode.SDL_SCANCODE_KP_0 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_PERIOD = SDL_Scancode.SDL_SCANCODE_KP_PERIOD | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_APPLICATION = SDL_Scancode.SDL_SCANCODE_APPLICATION | SDLK_SCANCODE_MASK,
|
||||
SDLK_POWER = SDL_Scancode.SDL_SCANCODE_POWER | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_EQUALS = SDL_Scancode.SDL_SCANCODE_KP_EQUALS | SDLK_SCANCODE_MASK,
|
||||
SDLK_F13 = SDL_Scancode.SDL_SCANCODE_F13 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F14 = SDL_Scancode.SDL_SCANCODE_F14 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F15 = SDL_Scancode.SDL_SCANCODE_F15 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F16 = SDL_Scancode.SDL_SCANCODE_F16 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F17 = SDL_Scancode.SDL_SCANCODE_F17 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F18 = SDL_Scancode.SDL_SCANCODE_F18 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F19 = SDL_Scancode.SDL_SCANCODE_F19 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F20 = SDL_Scancode.SDL_SCANCODE_F20 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F21 = SDL_Scancode.SDL_SCANCODE_F21 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F22 = SDL_Scancode.SDL_SCANCODE_F22 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F23 = SDL_Scancode.SDL_SCANCODE_F23 | SDLK_SCANCODE_MASK,
|
||||
SDLK_F24 = SDL_Scancode.SDL_SCANCODE_F24 | SDLK_SCANCODE_MASK,
|
||||
SDLK_EXECUTE = SDL_Scancode.SDL_SCANCODE_EXECUTE | SDLK_SCANCODE_MASK,
|
||||
SDLK_HELP = SDL_Scancode.SDL_SCANCODE_HELP | SDLK_SCANCODE_MASK,
|
||||
SDLK_MENU = SDL_Scancode.SDL_SCANCODE_MENU | SDLK_SCANCODE_MASK,
|
||||
SDLK_SELECT = SDL_Scancode.SDL_SCANCODE_SELECT | SDLK_SCANCODE_MASK,
|
||||
SDLK_STOP = SDL_Scancode.SDL_SCANCODE_STOP | SDLK_SCANCODE_MASK,
|
||||
SDLK_AGAIN = SDL_Scancode.SDL_SCANCODE_AGAIN | SDLK_SCANCODE_MASK,
|
||||
SDLK_UNDO = SDL_Scancode.SDL_SCANCODE_UNDO | SDLK_SCANCODE_MASK,
|
||||
SDLK_CUT = SDL_Scancode.SDL_SCANCODE_CUT | SDLK_SCANCODE_MASK,
|
||||
SDLK_COPY = SDL_Scancode.SDL_SCANCODE_COPY | SDLK_SCANCODE_MASK,
|
||||
SDLK_PASTE = SDL_Scancode.SDL_SCANCODE_PASTE | SDLK_SCANCODE_MASK,
|
||||
SDLK_FIND = SDL_Scancode.SDL_SCANCODE_FIND | SDLK_SCANCODE_MASK,
|
||||
SDLK_MUTE = SDL_Scancode.SDL_SCANCODE_MUTE | SDLK_SCANCODE_MASK,
|
||||
SDLK_VOLUMEUP = SDL_Scancode.SDL_SCANCODE_VOLUMEUP | SDLK_SCANCODE_MASK,
|
||||
SDLK_VOLUMEDOWN = SDL_Scancode.SDL_SCANCODE_VOLUMEDOWN | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_COMMA = SDL_Scancode.SDL_SCANCODE_KP_COMMA | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_EQUALSAS400 = SDL_Scancode.SDL_SCANCODE_KP_EQUALSAS400 | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_ALTERASE = SDL_Scancode.SDL_SCANCODE_ALTERASE | SDLK_SCANCODE_MASK,
|
||||
SDLK_SYSREQ = SDL_Scancode.SDL_SCANCODE_SYSREQ | SDLK_SCANCODE_MASK,
|
||||
SDLK_CANCEL = SDL_Scancode.SDL_SCANCODE_CANCEL | SDLK_SCANCODE_MASK,
|
||||
SDLK_CLEAR = SDL_Scancode.SDL_SCANCODE_CLEAR | SDLK_SCANCODE_MASK,
|
||||
SDLK_PRIOR = SDL_Scancode.SDL_SCANCODE_PRIOR | SDLK_SCANCODE_MASK,
|
||||
SDLK_RETURN2 = SDL_Scancode.SDL_SCANCODE_RETURN2 | SDLK_SCANCODE_MASK,
|
||||
SDLK_SEPARATOR = SDL_Scancode.SDL_SCANCODE_SEPARATOR | SDLK_SCANCODE_MASK,
|
||||
SDLK_OUT = SDL_Scancode.SDL_SCANCODE_OUT | SDLK_SCANCODE_MASK,
|
||||
SDLK_OPER = SDL_Scancode.SDL_SCANCODE_OPER | SDLK_SCANCODE_MASK,
|
||||
SDLK_CLEARAGAIN = SDL_Scancode.SDL_SCANCODE_CLEARAGAIN | SDLK_SCANCODE_MASK,
|
||||
SDLK_CRSEL = SDL_Scancode.SDL_SCANCODE_CRSEL | SDLK_SCANCODE_MASK,
|
||||
SDLK_EXSEL = SDL_Scancode.SDL_SCANCODE_EXSEL | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_00 = SDL_Scancode.SDL_SCANCODE_KP_00 | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_000 = SDL_Scancode.SDL_SCANCODE_KP_000 | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_THOUSANDSSEPARATOR = SDL_Scancode.SDL_SCANCODE_THOUSANDSSEPARATOR | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_DECIMALSEPARATOR = SDL_Scancode.SDL_SCANCODE_DECIMALSEPARATOR | SDLK_SCANCODE_MASK,
|
||||
SDLK_CURRENCYUNIT = SDL_Scancode.SDL_SCANCODE_CURRENCYUNIT | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_CURRENCYSUBUNIT = SDL_Scancode.SDL_SCANCODE_CURRENCYSUBUNIT | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_LEFTPAREN = SDL_Scancode.SDL_SCANCODE_KP_LEFTPAREN | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_RIGHTPAREN = SDL_Scancode.SDL_SCANCODE_KP_RIGHTPAREN | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_LEFTBRACE = SDL_Scancode.SDL_SCANCODE_KP_LEFTBRACE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_RIGHTBRACE = SDL_Scancode.SDL_SCANCODE_KP_RIGHTBRACE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_TAB = SDL_Scancode.SDL_SCANCODE_KP_TAB | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_BACKSPACE = SDL_Scancode.SDL_SCANCODE_KP_BACKSPACE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_A = SDL_Scancode.SDL_SCANCODE_KP_A | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_B = SDL_Scancode.SDL_SCANCODE_KP_B | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_C = SDL_Scancode.SDL_SCANCODE_KP_C | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_D = SDL_Scancode.SDL_SCANCODE_KP_D | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_E = SDL_Scancode.SDL_SCANCODE_KP_E | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_F = SDL_Scancode.SDL_SCANCODE_KP_F | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_XOR = SDL_Scancode.SDL_SCANCODE_KP_XOR | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_POWER = SDL_Scancode.SDL_SCANCODE_KP_POWER | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_PERCENT = SDL_Scancode.SDL_SCANCODE_KP_PERCENT | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_LESS = SDL_Scancode.SDL_SCANCODE_KP_LESS | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_GREATER = SDL_Scancode.SDL_SCANCODE_KP_GREATER | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_AMPERSAND = SDL_Scancode.SDL_SCANCODE_KP_AMPERSAND | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_DBLAMPERSAND = SDL_Scancode.SDL_SCANCODE_KP_DBLAMPERSAND | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_VERTICALBAR = SDL_Scancode.SDL_SCANCODE_KP_VERTICALBAR | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_DBLVERTICALBAR = SDL_Scancode.SDL_SCANCODE_KP_DBLVERTICALBAR | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_COLON = SDL_Scancode.SDL_SCANCODE_KP_COLON | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_HASH = SDL_Scancode.SDL_SCANCODE_KP_HASH | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_SPACE = SDL_Scancode.SDL_SCANCODE_KP_SPACE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_AT = SDL_Scancode.SDL_SCANCODE_KP_AT | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_EXCLAM = SDL_Scancode.SDL_SCANCODE_KP_EXCLAM | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_MEMSTORE = SDL_Scancode.SDL_SCANCODE_KP_MEMSTORE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_MEMRECALL = SDL_Scancode.SDL_SCANCODE_KP_MEMRECALL | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_MEMCLEAR = SDL_Scancode.SDL_SCANCODE_KP_MEMCLEAR | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_MEMADD = SDL_Scancode.SDL_SCANCODE_KP_MEMADD | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_MEMSUBTRACT = SDL_Scancode.SDL_SCANCODE_KP_MEMSUBTRACT | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_MEMMULTIPLY = SDL_Scancode.SDL_SCANCODE_KP_MEMMULTIPLY | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_MEMDIVIDE = SDL_Scancode.SDL_SCANCODE_KP_MEMDIVIDE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_PLUSMINUS = SDL_Scancode.SDL_SCANCODE_KP_PLUSMINUS | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_CLEAR = SDL_Scancode.SDL_SCANCODE_KP_CLEAR | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_CLEARENTRY = SDL_Scancode.SDL_SCANCODE_KP_CLEARENTRY | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_BINARY = SDL_Scancode.SDL_SCANCODE_KP_BINARY | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_OCTAL = SDL_Scancode.SDL_SCANCODE_KP_OCTAL | SDLK_SCANCODE_MASK,
|
||||
SDLK_KP_DECIMAL = SDL_Scancode.SDL_SCANCODE_KP_DECIMAL | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KP_HEXADECIMAL = SDL_Scancode.SDL_SCANCODE_KP_HEXADECIMAL | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_LCTRL = SDL_Scancode.SDL_SCANCODE_LCTRL | SDLK_SCANCODE_MASK,
|
||||
SDLK_LSHIFT = SDL_Scancode.SDL_SCANCODE_LSHIFT | SDLK_SCANCODE_MASK,
|
||||
SDLK_LALT = SDL_Scancode.SDL_SCANCODE_LALT | SDLK_SCANCODE_MASK,
|
||||
SDLK_LGUI = SDL_Scancode.SDL_SCANCODE_LGUI | SDLK_SCANCODE_MASK,
|
||||
SDLK_RCTRL = SDL_Scancode.SDL_SCANCODE_RCTRL | SDLK_SCANCODE_MASK,
|
||||
SDLK_RSHIFT = SDL_Scancode.SDL_SCANCODE_RSHIFT | SDLK_SCANCODE_MASK,
|
||||
SDLK_RALT = SDL_Scancode.SDL_SCANCODE_RALT | SDLK_SCANCODE_MASK,
|
||||
SDLK_RGUI = SDL_Scancode.SDL_SCANCODE_RGUI | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_MODE = SDL_Scancode.SDL_SCANCODE_MODE | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_AUDIONEXT = SDL_Scancode.SDL_SCANCODE_AUDIONEXT | SDLK_SCANCODE_MASK,
|
||||
SDLK_AUDIOPREV = SDL_Scancode.SDL_SCANCODE_AUDIOPREV | SDLK_SCANCODE_MASK,
|
||||
SDLK_AUDIOSTOP = SDL_Scancode.SDL_SCANCODE_AUDIOSTOP | SDLK_SCANCODE_MASK,
|
||||
SDLK_AUDIOPLAY = SDL_Scancode.SDL_SCANCODE_AUDIOPLAY | SDLK_SCANCODE_MASK,
|
||||
SDLK_AUDIOMUTE = SDL_Scancode.SDL_SCANCODE_AUDIOMUTE | SDLK_SCANCODE_MASK,
|
||||
SDLK_MEDIASELECT = SDL_Scancode.SDL_SCANCODE_MEDIASELECT | SDLK_SCANCODE_MASK,
|
||||
SDLK_WWW = SDL_Scancode.SDL_SCANCODE_WWW | SDLK_SCANCODE_MASK,
|
||||
SDLK_MAIL = SDL_Scancode.SDL_SCANCODE_MAIL | SDLK_SCANCODE_MASK,
|
||||
SDLK_CALCULATOR = SDL_Scancode.SDL_SCANCODE_CALCULATOR | SDLK_SCANCODE_MASK,
|
||||
SDLK_COMPUTER = SDL_Scancode.SDL_SCANCODE_COMPUTER | SDLK_SCANCODE_MASK,
|
||||
SDLK_AC_SEARCH = SDL_Scancode.SDL_SCANCODE_AC_SEARCH | SDLK_SCANCODE_MASK,
|
||||
SDLK_AC_HOME = SDL_Scancode.SDL_SCANCODE_AC_HOME | SDLK_SCANCODE_MASK,
|
||||
SDLK_AC_BACK = SDL_Scancode.SDL_SCANCODE_AC_BACK | SDLK_SCANCODE_MASK,
|
||||
SDLK_AC_FORWARD = SDL_Scancode.SDL_SCANCODE_AC_FORWARD | SDLK_SCANCODE_MASK,
|
||||
SDLK_AC_STOP = SDL_Scancode.SDL_SCANCODE_AC_STOP | SDLK_SCANCODE_MASK,
|
||||
SDLK_AC_REFRESH = SDL_Scancode.SDL_SCANCODE_AC_REFRESH | SDLK_SCANCODE_MASK,
|
||||
SDLK_AC_BOOKMARKS = SDL_Scancode.SDL_SCANCODE_AC_BOOKMARKS | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_BRIGHTNESSDOWN = SDL_Scancode.SDL_SCANCODE_BRIGHTNESSDOWN | SDLK_SCANCODE_MASK,
|
||||
SDLK_BRIGHTNESSUP = SDL_Scancode.SDL_SCANCODE_BRIGHTNESSUP | SDLK_SCANCODE_MASK,
|
||||
SDLK_DISPLAYSWITCH = SDL_Scancode.SDL_SCANCODE_DISPLAYSWITCH | SDLK_SCANCODE_MASK,
|
||||
|
||||
SDLK_KBDILLUMTOGGLE = SDL_Scancode.SDL_SCANCODE_KBDILLUMTOGGLE | SDLK_SCANCODE_MASK,
|
||||
SDLK_KBDILLUMDOWN = SDL_Scancode.SDL_SCANCODE_KBDILLUMDOWN | SDLK_SCANCODE_MASK,
|
||||
SDLK_KBDILLUMUP = SDL_Scancode.SDL_SCANCODE_KBDILLUMUP | SDLK_SCANCODE_MASK,
|
||||
SDLK_EJECT = SDL_Scancode.SDL_SCANCODE_EJECT | SDLK_SCANCODE_MASK,
|
||||
SDLK_SLEEP = SDL_Scancode.SDL_SCANCODE_SLEEP | SDLK_SCANCODE_MASK
|
||||
}
|
||||
|
||||
/* Key modifiers (bitfield) */
|
||||
[Flags]
|
||||
public enum SDL_Keymod : ushort
|
||||
{
|
||||
KMOD_NONE = 0x0000,
|
||||
KMOD_LSHIFT = 0x0001,
|
||||
KMOD_RSHIFT = 0x0002,
|
||||
KMOD_LCTRL = 0x0040,
|
||||
KMOD_RCTRL = 0x0080,
|
||||
KMOD_LALT = 0x0100,
|
||||
KMOD_RALT = 0x0200,
|
||||
KMOD_LGUI = 0x0400,
|
||||
KMOD_RGUI = 0x0800,
|
||||
KMOD_NUM = 0x1000,
|
||||
KMOD_CAPS = 0x2000,
|
||||
KMOD_MODE = 0x4000,
|
||||
KMOD_RESERVED = 0x8000,
|
||||
|
||||
/* These are defines in the SDL headers */
|
||||
KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL,
|
||||
KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT,
|
||||
KMOD_ALT = KMOD_LALT | KMOD_RALT,
|
||||
KMOD_GUI = KMOD_LGUI | KMOD_RGUI
|
||||
}
|
||||
|
||||
/* Scancodes based off USB keyboard page (0x07) */
|
||||
public enum SDL_Scancode
|
||||
{
|
||||
SDL_SCANCODE_UNKNOWN = 0,
|
||||
|
||||
SDL_SCANCODE_A = 4,
|
||||
SDL_SCANCODE_B = 5,
|
||||
SDL_SCANCODE_C = 6,
|
||||
SDL_SCANCODE_D = 7,
|
||||
SDL_SCANCODE_E = 8,
|
||||
SDL_SCANCODE_F = 9,
|
||||
SDL_SCANCODE_G = 10,
|
||||
SDL_SCANCODE_H = 11,
|
||||
SDL_SCANCODE_I = 12,
|
||||
SDL_SCANCODE_J = 13,
|
||||
SDL_SCANCODE_K = 14,
|
||||
SDL_SCANCODE_L = 15,
|
||||
SDL_SCANCODE_M = 16,
|
||||
SDL_SCANCODE_N = 17,
|
||||
SDL_SCANCODE_O = 18,
|
||||
SDL_SCANCODE_P = 19,
|
||||
SDL_SCANCODE_Q = 20,
|
||||
SDL_SCANCODE_R = 21,
|
||||
SDL_SCANCODE_S = 22,
|
||||
SDL_SCANCODE_T = 23,
|
||||
SDL_SCANCODE_U = 24,
|
||||
SDL_SCANCODE_V = 25,
|
||||
SDL_SCANCODE_W = 26,
|
||||
SDL_SCANCODE_X = 27,
|
||||
SDL_SCANCODE_Y = 28,
|
||||
SDL_SCANCODE_Z = 29,
|
||||
|
||||
SDL_SCANCODE_1 = 30,
|
||||
SDL_SCANCODE_2 = 31,
|
||||
SDL_SCANCODE_3 = 32,
|
||||
SDL_SCANCODE_4 = 33,
|
||||
SDL_SCANCODE_5 = 34,
|
||||
SDL_SCANCODE_6 = 35,
|
||||
SDL_SCANCODE_7 = 36,
|
||||
SDL_SCANCODE_8 = 37,
|
||||
SDL_SCANCODE_9 = 38,
|
||||
SDL_SCANCODE_0 = 39,
|
||||
|
||||
SDL_SCANCODE_RETURN = 40,
|
||||
SDL_SCANCODE_ESCAPE = 41,
|
||||
SDL_SCANCODE_BACKSPACE = 42,
|
||||
SDL_SCANCODE_TAB = 43,
|
||||
SDL_SCANCODE_SPACE = 44,
|
||||
|
||||
SDL_SCANCODE_MINUS = 45,
|
||||
SDL_SCANCODE_EQUALS = 46,
|
||||
SDL_SCANCODE_LEFTBRACKET = 47,
|
||||
SDL_SCANCODE_RIGHTBRACKET = 48,
|
||||
SDL_SCANCODE_BACKSLASH = 49,
|
||||
SDL_SCANCODE_NONUSHASH = 50,
|
||||
SDL_SCANCODE_SEMICOLON = 51,
|
||||
SDL_SCANCODE_APOSTROPHE = 52,
|
||||
SDL_SCANCODE_GRAVE = 53,
|
||||
SDL_SCANCODE_COMMA = 54,
|
||||
SDL_SCANCODE_PERIOD = 55,
|
||||
SDL_SCANCODE_SLASH = 56,
|
||||
|
||||
SDL_SCANCODE_CAPSLOCK = 57,
|
||||
|
||||
SDL_SCANCODE_F1 = 58,
|
||||
SDL_SCANCODE_F2 = 59,
|
||||
SDL_SCANCODE_F3 = 60,
|
||||
SDL_SCANCODE_F4 = 61,
|
||||
SDL_SCANCODE_F5 = 62,
|
||||
SDL_SCANCODE_F6 = 63,
|
||||
SDL_SCANCODE_F7 = 64,
|
||||
SDL_SCANCODE_F8 = 65,
|
||||
SDL_SCANCODE_F9 = 66,
|
||||
SDL_SCANCODE_F10 = 67,
|
||||
SDL_SCANCODE_F11 = 68,
|
||||
SDL_SCANCODE_F12 = 69,
|
||||
|
||||
SDL_SCANCODE_PRINTSCREEN = 70,
|
||||
SDL_SCANCODE_SCROLLLOCK = 71,
|
||||
SDL_SCANCODE_PAUSE = 72,
|
||||
SDL_SCANCODE_INSERT = 73,
|
||||
SDL_SCANCODE_HOME = 74,
|
||||
SDL_SCANCODE_PAGEUP = 75,
|
||||
SDL_SCANCODE_DELETE = 76,
|
||||
SDL_SCANCODE_END = 77,
|
||||
SDL_SCANCODE_PAGEDOWN = 78,
|
||||
SDL_SCANCODE_RIGHT = 79,
|
||||
SDL_SCANCODE_LEFT = 80,
|
||||
SDL_SCANCODE_DOWN = 81,
|
||||
SDL_SCANCODE_UP = 82,
|
||||
|
||||
SDL_SCANCODE_NUMLOCKCLEAR = 83,
|
||||
SDL_SCANCODE_KP_DIVIDE = 84,
|
||||
SDL_SCANCODE_KP_MULTIPLY = 85,
|
||||
SDL_SCANCODE_KP_MINUS = 86,
|
||||
SDL_SCANCODE_KP_PLUS = 87,
|
||||
SDL_SCANCODE_KP_ENTER = 88,
|
||||
SDL_SCANCODE_KP_1 = 89,
|
||||
SDL_SCANCODE_KP_2 = 90,
|
||||
SDL_SCANCODE_KP_3 = 91,
|
||||
SDL_SCANCODE_KP_4 = 92,
|
||||
SDL_SCANCODE_KP_5 = 93,
|
||||
SDL_SCANCODE_KP_6 = 94,
|
||||
SDL_SCANCODE_KP_7 = 95,
|
||||
SDL_SCANCODE_KP_8 = 96,
|
||||
SDL_SCANCODE_KP_9 = 97,
|
||||
SDL_SCANCODE_KP_0 = 98,
|
||||
SDL_SCANCODE_KP_PERIOD = 99,
|
||||
|
||||
SDL_SCANCODE_NONUSBACKSLASH = 100,
|
||||
SDL_SCANCODE_APPLICATION = 101,
|
||||
SDL_SCANCODE_POWER = 102,
|
||||
SDL_SCANCODE_KP_EQUALS = 103,
|
||||
SDL_SCANCODE_F13 = 104,
|
||||
SDL_SCANCODE_F14 = 105,
|
||||
SDL_SCANCODE_F15 = 106,
|
||||
SDL_SCANCODE_F16 = 107,
|
||||
SDL_SCANCODE_F17 = 108,
|
||||
SDL_SCANCODE_F18 = 109,
|
||||
SDL_SCANCODE_F19 = 110,
|
||||
SDL_SCANCODE_F20 = 111,
|
||||
SDL_SCANCODE_F21 = 112,
|
||||
SDL_SCANCODE_F22 = 113,
|
||||
SDL_SCANCODE_F23 = 114,
|
||||
SDL_SCANCODE_F24 = 115,
|
||||
SDL_SCANCODE_EXECUTE = 116,
|
||||
SDL_SCANCODE_HELP = 117,
|
||||
SDL_SCANCODE_MENU = 118,
|
||||
SDL_SCANCODE_SELECT = 119,
|
||||
SDL_SCANCODE_STOP = 120,
|
||||
SDL_SCANCODE_AGAIN = 121,
|
||||
SDL_SCANCODE_UNDO = 122,
|
||||
SDL_SCANCODE_CUT = 123,
|
||||
SDL_SCANCODE_COPY = 124,
|
||||
SDL_SCANCODE_PASTE = 125,
|
||||
SDL_SCANCODE_FIND = 126,
|
||||
SDL_SCANCODE_MUTE = 127,
|
||||
SDL_SCANCODE_VOLUMEUP = 128,
|
||||
SDL_SCANCODE_VOLUMEDOWN = 129,
|
||||
|
||||
/* not sure whether there's a reason to enable these */
|
||||
/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */
|
||||
/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
|
||||
/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
|
||||
SDL_SCANCODE_KP_COMMA = 133,
|
||||
SDL_SCANCODE_KP_EQUALSAS400 = 134,
|
||||
|
||||
SDL_SCANCODE_INTERNATIONAL1 = 135,
|
||||
SDL_SCANCODE_INTERNATIONAL2 = 136,
|
||||
SDL_SCANCODE_INTERNATIONAL3 = 137,
|
||||
SDL_SCANCODE_INTERNATIONAL4 = 138,
|
||||
SDL_SCANCODE_INTERNATIONAL5 = 139,
|
||||
SDL_SCANCODE_INTERNATIONAL6 = 140,
|
||||
SDL_SCANCODE_INTERNATIONAL7 = 141,
|
||||
SDL_SCANCODE_INTERNATIONAL8 = 142,
|
||||
SDL_SCANCODE_INTERNATIONAL9 = 143,
|
||||
SDL_SCANCODE_LANG1 = 144,
|
||||
SDL_SCANCODE_LANG2 = 145,
|
||||
SDL_SCANCODE_LANG3 = 146,
|
||||
SDL_SCANCODE_LANG4 = 147,
|
||||
SDL_SCANCODE_LANG5 = 148,
|
||||
SDL_SCANCODE_LANG6 = 149,
|
||||
SDL_SCANCODE_LANG7 = 150,
|
||||
SDL_SCANCODE_LANG8 = 151,
|
||||
SDL_SCANCODE_LANG9 = 152,
|
||||
|
||||
SDL_SCANCODE_ALTERASE = 153,
|
||||
SDL_SCANCODE_SYSREQ = 154,
|
||||
SDL_SCANCODE_CANCEL = 155,
|
||||
SDL_SCANCODE_CLEAR = 156,
|
||||
SDL_SCANCODE_PRIOR = 157,
|
||||
SDL_SCANCODE_RETURN2 = 158,
|
||||
SDL_SCANCODE_SEPARATOR = 159,
|
||||
SDL_SCANCODE_OUT = 160,
|
||||
SDL_SCANCODE_OPER = 161,
|
||||
SDL_SCANCODE_CLEARAGAIN = 162,
|
||||
SDL_SCANCODE_CRSEL = 163,
|
||||
SDL_SCANCODE_EXSEL = 164,
|
||||
|
||||
SDL_SCANCODE_KP_00 = 176,
|
||||
SDL_SCANCODE_KP_000 = 177,
|
||||
SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
|
||||
SDL_SCANCODE_DECIMALSEPARATOR = 179,
|
||||
SDL_SCANCODE_CURRENCYUNIT = 180,
|
||||
SDL_SCANCODE_CURRENCYSUBUNIT = 181,
|
||||
SDL_SCANCODE_KP_LEFTPAREN = 182,
|
||||
SDL_SCANCODE_KP_RIGHTPAREN = 183,
|
||||
SDL_SCANCODE_KP_LEFTBRACE = 184,
|
||||
SDL_SCANCODE_KP_RIGHTBRACE = 185,
|
||||
SDL_SCANCODE_KP_TAB = 186,
|
||||
SDL_SCANCODE_KP_BACKSPACE = 187,
|
||||
SDL_SCANCODE_KP_A = 188,
|
||||
SDL_SCANCODE_KP_B = 189,
|
||||
SDL_SCANCODE_KP_C = 190,
|
||||
SDL_SCANCODE_KP_D = 191,
|
||||
SDL_SCANCODE_KP_E = 192,
|
||||
SDL_SCANCODE_KP_F = 193,
|
||||
SDL_SCANCODE_KP_XOR = 194,
|
||||
SDL_SCANCODE_KP_POWER = 195,
|
||||
SDL_SCANCODE_KP_PERCENT = 196,
|
||||
SDL_SCANCODE_KP_LESS = 197,
|
||||
SDL_SCANCODE_KP_GREATER = 198,
|
||||
SDL_SCANCODE_KP_AMPERSAND = 199,
|
||||
SDL_SCANCODE_KP_DBLAMPERSAND = 200,
|
||||
SDL_SCANCODE_KP_VERTICALBAR = 201,
|
||||
SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
|
||||
SDL_SCANCODE_KP_COLON = 203,
|
||||
SDL_SCANCODE_KP_HASH = 204,
|
||||
SDL_SCANCODE_KP_SPACE = 205,
|
||||
SDL_SCANCODE_KP_AT = 206,
|
||||
SDL_SCANCODE_KP_EXCLAM = 207,
|
||||
SDL_SCANCODE_KP_MEMSTORE = 208,
|
||||
SDL_SCANCODE_KP_MEMRECALL = 209,
|
||||
SDL_SCANCODE_KP_MEMCLEAR = 210,
|
||||
SDL_SCANCODE_KP_MEMADD = 211,
|
||||
SDL_SCANCODE_KP_MEMSUBTRACT = 212,
|
||||
SDL_SCANCODE_KP_MEMMULTIPLY = 213,
|
||||
SDL_SCANCODE_KP_MEMDIVIDE = 214,
|
||||
SDL_SCANCODE_KP_PLUSMINUS = 215,
|
||||
SDL_SCANCODE_KP_CLEAR = 216,
|
||||
SDL_SCANCODE_KP_CLEARENTRY = 217,
|
||||
SDL_SCANCODE_KP_BINARY = 218,
|
||||
SDL_SCANCODE_KP_OCTAL = 219,
|
||||
SDL_SCANCODE_KP_DECIMAL = 220,
|
||||
SDL_SCANCODE_KP_HEXADECIMAL = 221,
|
||||
|
||||
SDL_SCANCODE_LCTRL = 224,
|
||||
SDL_SCANCODE_LSHIFT = 225,
|
||||
SDL_SCANCODE_LALT = 226,
|
||||
SDL_SCANCODE_LGUI = 227,
|
||||
SDL_SCANCODE_RCTRL = 228,
|
||||
SDL_SCANCODE_RSHIFT = 229,
|
||||
SDL_SCANCODE_RALT = 230,
|
||||
SDL_SCANCODE_RGUI = 231,
|
||||
|
||||
SDL_SCANCODE_MODE = 257,
|
||||
|
||||
/* These come from the USB consumer page (0x0C) */
|
||||
SDL_SCANCODE_AUDIONEXT = 258,
|
||||
SDL_SCANCODE_AUDIOPREV = 259,
|
||||
SDL_SCANCODE_AUDIOSTOP = 260,
|
||||
SDL_SCANCODE_AUDIOPLAY = 261,
|
||||
SDL_SCANCODE_AUDIOMUTE = 262,
|
||||
SDL_SCANCODE_MEDIASELECT = 263,
|
||||
SDL_SCANCODE_WWW = 264,
|
||||
SDL_SCANCODE_MAIL = 265,
|
||||
SDL_SCANCODE_CALCULATOR = 266,
|
||||
SDL_SCANCODE_COMPUTER = 267,
|
||||
SDL_SCANCODE_AC_SEARCH = 268,
|
||||
SDL_SCANCODE_AC_HOME = 269,
|
||||
SDL_SCANCODE_AC_BACK = 270,
|
||||
SDL_SCANCODE_AC_FORWARD = 271,
|
||||
SDL_SCANCODE_AC_STOP = 272,
|
||||
SDL_SCANCODE_AC_REFRESH = 273,
|
||||
SDL_SCANCODE_AC_BOOKMARKS = 274,
|
||||
|
||||
/* These come from other sources, and are mostly mac related */
|
||||
SDL_SCANCODE_BRIGHTNESSDOWN = 275,
|
||||
SDL_SCANCODE_BRIGHTNESSUP = 276,
|
||||
SDL_SCANCODE_DISPLAYSWITCH = 277,
|
||||
SDL_SCANCODE_KBDILLUMTOGGLE = 278,
|
||||
SDL_SCANCODE_KBDILLUMDOWN = 279,
|
||||
SDL_SCANCODE_KBDILLUMUP = 280,
|
||||
SDL_SCANCODE_EJECT = 281,
|
||||
SDL_SCANCODE_SLEEP = 282,
|
||||
|
||||
SDL_SCANCODE_APP1 = 283,
|
||||
SDL_SCANCODE_APP2 = 284,
|
||||
|
||||
/* This is not a key, simply marks the number of scancodes
|
||||
* so that you know how big to make your arrays. */
|
||||
SDL_NUM_SCANCODES = 512
|
||||
}
|
||||
|
||||
public const int SDLK_SCANCODE_MASK = 1 << 30;
|
||||
|
||||
public const int SDL_BUTTON_LEFT = 1;
|
||||
public const int SDL_BUTTON_MIDDLE = 2;
|
||||
public const int SDL_BUTTON_RIGHT = 3;
|
||||
public const int SDL_BUTTON_X1 = 4;
|
||||
public const int SDL_BUTTON_X2 = 5;
|
||||
|
||||
private static readonly Dictionary<int, Key> INTERNAL_keyMap = new Dictionary<int, Key>
|
||||
{
|
||||
{ (int) SDL_Keycode.SDLK_a, Key.A },
|
||||
{ (int) SDL_Keycode.SDLK_b, Key.B },
|
||||
{ (int) SDL_Keycode.SDLK_c, Key.C },
|
||||
{ (int) SDL_Keycode.SDLK_d, Key.D },
|
||||
{ (int) SDL_Keycode.SDLK_e, Key.E },
|
||||
{ (int) SDL_Keycode.SDLK_f, Key.F },
|
||||
{ (int) SDL_Keycode.SDLK_g, Key.G },
|
||||
{ (int) SDL_Keycode.SDLK_h, Key.H },
|
||||
{ (int) SDL_Keycode.SDLK_i, Key.I },
|
||||
{ (int) SDL_Keycode.SDLK_j, Key.J },
|
||||
{ (int) SDL_Keycode.SDLK_k, Key.K },
|
||||
{ (int) SDL_Keycode.SDLK_l, Key.L },
|
||||
{ (int) SDL_Keycode.SDLK_m, Key.M },
|
||||
{ (int) SDL_Keycode.SDLK_n, Key.N },
|
||||
{ (int) SDL_Keycode.SDLK_o, Key.O },
|
||||
{ (int) SDL_Keycode.SDLK_p, Key.P },
|
||||
{ (int) SDL_Keycode.SDLK_q, Key.Q },
|
||||
{ (int) SDL_Keycode.SDLK_r, Key.R },
|
||||
{ (int) SDL_Keycode.SDLK_s, Key.S },
|
||||
{ (int) SDL_Keycode.SDLK_t, Key.T },
|
||||
{ (int) SDL_Keycode.SDLK_u, Key.U },
|
||||
{ (int) SDL_Keycode.SDLK_v, Key.V },
|
||||
{ (int) SDL_Keycode.SDLK_w, Key.W },
|
||||
{ (int) SDL_Keycode.SDLK_x, Key.X },
|
||||
{ (int) SDL_Keycode.SDLK_y, Key.Y },
|
||||
{ (int) SDL_Keycode.SDLK_z, Key.Z },
|
||||
{ (int) SDL_Keycode.SDLK_0, Key.D0 },
|
||||
{ (int) SDL_Keycode.SDLK_1, Key.D1 },
|
||||
{ (int) SDL_Keycode.SDLK_2, Key.D2 },
|
||||
{ (int) SDL_Keycode.SDLK_3, Key.D3 },
|
||||
{ (int) SDL_Keycode.SDLK_4, Key.D4 },
|
||||
{ (int) SDL_Keycode.SDLK_5, Key.D5 },
|
||||
{ (int) SDL_Keycode.SDLK_6, Key.D6 },
|
||||
{ (int) SDL_Keycode.SDLK_7, Key.D7 },
|
||||
{ (int) SDL_Keycode.SDLK_8, Key.D8 },
|
||||
{ (int) SDL_Keycode.SDLK_9, Key.D9 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_0, Key.NumPad0 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_1, Key.NumPad1 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_2, Key.NumPad2 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_3, Key.NumPad3 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_4, Key.NumPad4 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_5, Key.NumPad5 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_6, Key.NumPad6 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_7, Key.NumPad7 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_8, Key.NumPad8 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_9, Key.NumPad9 },
|
||||
{ (int) SDL_Keycode.SDLK_KP_CLEAR, Key.OemClear },
|
||||
{ (int) SDL_Keycode.SDLK_KP_DECIMAL, Key.Decimal },
|
||||
{ (int) SDL_Keycode.SDLK_KP_DIVIDE, Key.Divide },
|
||||
{ (int) SDL_Keycode.SDLK_KP_ENTER, Key.Enter },
|
||||
{ (int) SDL_Keycode.SDLK_KP_MINUS, Key.Subtract },
|
||||
{ (int) SDL_Keycode.SDLK_KP_MULTIPLY, Key.Multiply },
|
||||
{ (int) SDL_Keycode.SDLK_KP_PERIOD, Key.OemPeriod },
|
||||
{ (int) SDL_Keycode.SDLK_KP_PLUS, Key.Add },
|
||||
{ (int) SDL_Keycode.SDLK_F1, Key.F1 },
|
||||
{ (int) SDL_Keycode.SDLK_F2, Key.F2 },
|
||||
{ (int) SDL_Keycode.SDLK_F3, Key.F3 },
|
||||
{ (int) SDL_Keycode.SDLK_F4, Key.F4 },
|
||||
{ (int) SDL_Keycode.SDLK_F5, Key.F5 },
|
||||
{ (int) SDL_Keycode.SDLK_F6, Key.F6 },
|
||||
{ (int) SDL_Keycode.SDLK_F7, Key.F7 },
|
||||
{ (int) SDL_Keycode.SDLK_F8, Key.F8 },
|
||||
{ (int) SDL_Keycode.SDLK_F9, Key.F9 },
|
||||
{ (int) SDL_Keycode.SDLK_F10, Key.F10 },
|
||||
{ (int) SDL_Keycode.SDLK_F11, Key.F11 },
|
||||
{ (int) SDL_Keycode.SDLK_F12, Key.F12 },
|
||||
{ (int) SDL_Keycode.SDLK_F13, Key.F13 },
|
||||
{ (int) SDL_Keycode.SDLK_F14, Key.F14 },
|
||||
{ (int) SDL_Keycode.SDLK_F15, Key.F15 },
|
||||
{ (int) SDL_Keycode.SDLK_F16, Key.F16 },
|
||||
{ (int) SDL_Keycode.SDLK_F17, Key.F17 },
|
||||
{ (int) SDL_Keycode.SDLK_F18, Key.F18 },
|
||||
{ (int) SDL_Keycode.SDLK_F19, Key.F19 },
|
||||
{ (int) SDL_Keycode.SDLK_F20, Key.F20 },
|
||||
{ (int) SDL_Keycode.SDLK_F21, Key.F21 },
|
||||
{ (int) SDL_Keycode.SDLK_F22, Key.F22 },
|
||||
{ (int) SDL_Keycode.SDLK_F23, Key.F23 },
|
||||
{ (int) SDL_Keycode.SDLK_F24, Key.F24 },
|
||||
{ (int) SDL_Keycode.SDLK_SPACE, Key.Space },
|
||||
{ (int) SDL_Keycode.SDLK_UP, Key.Up },
|
||||
{ (int) SDL_Keycode.SDLK_DOWN, Key.Down },
|
||||
{ (int) SDL_Keycode.SDLK_LEFT, Key.Left },
|
||||
{ (int) SDL_Keycode.SDLK_RIGHT, Key.Right },
|
||||
{ (int) SDL_Keycode.SDLK_LALT, Key.LeftAlt },
|
||||
{ (int) SDL_Keycode.SDLK_RALT, Key.RightAlt },
|
||||
{ (int) SDL_Keycode.SDLK_LCTRL, Key.LeftCtrl },
|
||||
{ (int) SDL_Keycode.SDLK_RCTRL, Key.RightCtrl },
|
||||
{ (int) SDL_Keycode.SDLK_LGUI, Key.LWin },
|
||||
{ (int) SDL_Keycode.SDLK_RGUI, Key.RWin },
|
||||
{ (int) SDL_Keycode.SDLK_LSHIFT, Key.LeftShift },
|
||||
{ (int) SDL_Keycode.SDLK_RSHIFT, Key.RightShift },
|
||||
{ (int) SDL_Keycode.SDLK_APPLICATION, Key.Apps },
|
||||
{ (int) SDL_Keycode.SDLK_SLASH, Key.OemQuestion },
|
||||
{ (int) SDL_Keycode.SDLK_BACKSLASH, Key.OemBackslash },
|
||||
{ (int) SDL_Keycode.SDLK_LEFTBRACKET, Key.OemOpenBrackets },
|
||||
{ (int) SDL_Keycode.SDLK_RIGHTBRACKET, Key.OemCloseBrackets },
|
||||
{ (int) SDL_Keycode.SDLK_CAPSLOCK, Key.CapsLock },
|
||||
{ (int) SDL_Keycode.SDLK_COMMA, Key.OemComma },
|
||||
{ (int) SDL_Keycode.SDLK_DELETE, Key.Delete },
|
||||
{ (int) SDL_Keycode.SDLK_END, Key.End },
|
||||
{ (int) SDL_Keycode.SDLK_BACKSPACE, Key.Back },
|
||||
{ (int) SDL_Keycode.SDLK_RETURN, Key.Enter },
|
||||
{ (int) SDL_Keycode.SDLK_ESCAPE, Key.Escape },
|
||||
{ (int) SDL_Keycode.SDLK_HOME, Key.Home },
|
||||
{ (int) SDL_Keycode.SDLK_INSERT, Key.Insert },
|
||||
{ (int) SDL_Keycode.SDLK_MINUS, Key.OemMinus },
|
||||
{ (int) SDL_Keycode.SDLK_NUMLOCKCLEAR, Key.NumLock },
|
||||
{ (int) SDL_Keycode.SDLK_PAGEUP, Key.PageUp },
|
||||
{ (int) SDL_Keycode.SDLK_PAGEDOWN, Key.PageDown },
|
||||
{ (int) SDL_Keycode.SDLK_PAUSE, Key.Pause },
|
||||
{ (int) SDL_Keycode.SDLK_PERIOD, Key.OemPeriod },
|
||||
{ (int) SDL_Keycode.SDLK_EQUALS, Key.OemPlus },
|
||||
{ (int) SDL_Keycode.SDLK_PRINTSCREEN, Key.PrintScreen },
|
||||
{ (int) SDL_Keycode.SDLK_QUOTE, Key.OemQuotes },
|
||||
{ (int) SDL_Keycode.SDLK_SCROLLLOCK, Key.Scroll },
|
||||
{ (int) SDL_Keycode.SDLK_SEMICOLON, Key.OemSemicolon },
|
||||
{ (int) SDL_Keycode.SDLK_SLEEP, Key.Sleep },
|
||||
{ (int) SDL_Keycode.SDLK_TAB, Key.Tab },
|
||||
{ (int) SDL_Keycode.SDLK_BACKQUOTE, Key.OemTilde },
|
||||
{ (int) SDL_Keycode.SDLK_VOLUMEUP, Key.VolumeUp },
|
||||
{ (int) SDL_Keycode.SDLK_VOLUMEDOWN, Key.VolumeDown },
|
||||
{ (int) SDL_Keycode.SDLK_AUDIONEXT, Key.MediaNextTrack },
|
||||
{ (int) SDL_Keycode.SDLK_AUDIOPREV, Key.MediaPreviousTrack },
|
||||
{ (int) SDL_Keycode.SDLK_AUDIOSTOP, Key.MediaStop },
|
||||
{ (int) SDL_Keycode.SDLK_AUDIOPLAY, Key.MediaPlayPause },
|
||||
{ (int) SDL_Keycode.SDLK_AUDIOMUTE, Key.VolumeMute },
|
||||
{ (int) SDL_Keycode.SDLK_MEDIASELECT, Key.SelectMedia },
|
||||
{ '²' /* FIXME: AZERTY SDL2? -flibit */, Key.OemTilde },
|
||||
{ 'é' /* FIXME: BEPO SDL2? -flibit */, Key.None },
|
||||
{ '|' /* FIXME: Norwegian SDL2? -flibit */, Key.OemPipe },
|
||||
{ '+' /* FIXME: Norwegian SDL2? -flibit */, Key.OemPlus },
|
||||
{ 'ø' /* FIXME: Norwegian SDL2? -flibit */, Key.OemSemicolon },
|
||||
{ 'æ' /* FIXME: Norwegian SDL2? -flibit */, Key.OemQuotes },
|
||||
{ (int) SDL_Keycode.SDLK_UNKNOWN, Key.None }
|
||||
};
|
||||
|
||||
public static Key SDLKeyToKeys( int sdlKey )
|
||||
{
|
||||
if ( INTERNAL_keyMap.TryGetValue( sdlKey, out Key keys ) )
|
||||
{
|
||||
return keys;
|
||||
}
|
||||
|
||||
return Key.None;
|
||||
}
|
||||
|
||||
public static SDL_Keycode SDL_SCANCODE_TO_KEYCODE( SDL_Scancode X )
|
||||
{
|
||||
return (SDL_Keycode) ( (int) X | SDLK_SCANCODE_MASK );
|
||||
}
|
||||
|
||||
public static MouseOptions MouseButtonToMouseOptions( int button )
|
||||
{
|
||||
switch ( button )
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
return MouseOptions.LeftButton;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
return MouseOptions.MiddleButton;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
return MouseOptions.RightButton;
|
||||
case SDL_BUTTON_X1:
|
||||
return MouseOptions.XButton1;
|
||||
case SDL_BUTTON_X2:
|
||||
return MouseOptions.XButton2;
|
||||
default:
|
||||
return MouseOptions.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
#region License
|
||||
|
||||
// Copyright (C) 2020 Reetus
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Priority_Queue;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public enum QueuePriority
|
||||
{
|
||||
Immediate,
|
||||
High,
|
||||
Medium,
|
||||
Low
|
||||
}
|
||||
|
||||
public class ThreadPriorityQueue<T> : IDisposable
|
||||
{
|
||||
private readonly Action<T> _onAction;
|
||||
private readonly SimplePriorityQueue<T> _queue = new SimplePriorityQueue<T>();
|
||||
private readonly EventWaitHandle _wh = new AutoResetEvent( false );
|
||||
private readonly Thread _workerThread;
|
||||
|
||||
public ThreadPriorityQueue( Action<T> onAction )
|
||||
{
|
||||
_onAction = onAction;
|
||||
_workerThread = new Thread( ProcessQueue ) { IsBackground = true };
|
||||
_workerThread.Start();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
StopThread();
|
||||
}
|
||||
|
||||
public int Count()
|
||||
{
|
||||
return _queue.Count;
|
||||
}
|
||||
|
||||
public int Count( Predicate<T> predicate )
|
||||
{
|
||||
return _queue.Count( predicate.Invoke );
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_queue.Clear();
|
||||
}
|
||||
|
||||
private void ProcessQueue()
|
||||
{
|
||||
while ( _workerThread.IsAlive )
|
||||
{
|
||||
if ( _queue.TryDequeue( out T queueItem ) )
|
||||
{
|
||||
if ( queueItem == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_onAction( queueItem );
|
||||
}
|
||||
else
|
||||
{
|
||||
_wh.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Enqueue( T queueItem, QueuePriority priority )
|
||||
{
|
||||
_queue.Enqueue( queueItem, (float) priority );
|
||||
|
||||
try
|
||||
{
|
||||
_wh.Set();
|
||||
}
|
||||
catch ( ObjectDisposedException )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains( Predicate<T> predicate )
|
||||
{
|
||||
return _queue.Any( predicate.Invoke );
|
||||
}
|
||||
|
||||
private void StopThread()
|
||||
{
|
||||
_queue.Enqueue( default, (float) QueuePriority.Immediate );
|
||||
|
||||
try
|
||||
{
|
||||
_wh.Set();
|
||||
}
|
||||
catch ( ObjectDisposedException )
|
||||
{
|
||||
}
|
||||
|
||||
_workerThread.Join();
|
||||
_wh.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public class ThreadQueue<T> : IDisposable
|
||||
{
|
||||
private readonly Action<T> _onAction;
|
||||
private readonly ConcurrentQueue<T> _queue = new ConcurrentQueue<T>();
|
||||
private readonly EventWaitHandle _wh = new AutoResetEvent( false );
|
||||
private readonly Thread _workerThread;
|
||||
|
||||
public ThreadQueue( Action<T> onAction )
|
||||
{
|
||||
_onAction = onAction;
|
||||
_workerThread = new Thread( ProcessQueue ) { IsBackground = true };
|
||||
_workerThread.Start();
|
||||
}
|
||||
|
||||
public int Count => _queue.Count;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
StopThread();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
while ( _queue.TryDequeue( out T item ) )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessQueue()
|
||||
{
|
||||
while ( _workerThread.IsAlive )
|
||||
{
|
||||
if ( _queue.TryDequeue( out T queueItem ) )
|
||||
{
|
||||
if ( queueItem == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_onAction( queueItem );
|
||||
}
|
||||
else
|
||||
{
|
||||
_wh.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Enqueue( T queueItem )
|
||||
{
|
||||
_queue.Enqueue( queueItem );
|
||||
|
||||
try
|
||||
{
|
||||
_wh.Set();
|
||||
}
|
||||
catch ( ObjectDisposedException )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void StopThread()
|
||||
{
|
||||
_queue.Enqueue( default );
|
||||
|
||||
try
|
||||
{
|
||||
_wh.Set();
|
||||
}
|
||||
catch ( ObjectDisposedException )
|
||||
{
|
||||
}
|
||||
|
||||
_workerThread.Join();
|
||||
_wh.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace ClassicAssist.Misc
|
||||
{
|
||||
public class Utility
|
||||
{
|
||||
public static T GetEnumValueByName<T>( string value )
|
||||
{
|
||||
//TODO robust enough?
|
||||
|
||||
value = value.ToLower().Replace( ' ', '_' );
|
||||
|
||||
string[] enumValues = Enum.GetNames( typeof( T ) );
|
||||
|
||||
string enumValue = enumValues.FirstOrDefault( ev => ev.ToLower() == value );
|
||||
|
||||
T enumEntry = (T) Enum.Parse( typeof( T ), enumValue ?? throw new InvalidOperationException() );
|
||||
|
||||
return enumEntry;
|
||||
}
|
||||
|
||||
public static (byte[] data, int length) CopyBuffer( byte[] source, int sourceLength )
|
||||
{
|
||||
byte[] data = new byte[sourceLength];
|
||||
int dataLength = sourceLength;
|
||||
|
||||
Buffer.BlockCopy( source, 0, data, 0, sourceLength );
|
||||
|
||||
return ( data, dataLength );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user