|
|
@ -7,15 +7,25 @@ |
|
|
namespace Perspex.Gtk |
|
|
namespace Perspex.Gtk |
|
|
{ |
|
|
{ |
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.Reflection; |
|
|
using Perspex.Input; |
|
|
using Perspex.Input; |
|
|
|
|
|
|
|
|
public class GtkKeyboardDevice : KeyboardDevice |
|
|
public class GtkKeyboardDevice : KeyboardDevice |
|
|
{ |
|
|
{ |
|
|
private static GtkKeyboardDevice instance; |
|
|
private static GtkKeyboardDevice instance; |
|
|
|
|
|
private static readonly Dictionary<Gdk.Key, string> NameDic = new Dictionary<Gdk.Key, string>(); |
|
|
|
|
|
|
|
|
static GtkKeyboardDevice() |
|
|
static GtkKeyboardDevice() |
|
|
{ |
|
|
{ |
|
|
instance = new GtkKeyboardDevice(); |
|
|
instance = new GtkKeyboardDevice(); |
|
|
|
|
|
foreach (var f in typeof (Gdk.Key).GetFields(BindingFlags.Public | BindingFlags.Static)) |
|
|
|
|
|
{ |
|
|
|
|
|
var key = (Gdk.Key) f.GetValue(null); |
|
|
|
|
|
if(NameDic.ContainsKey(key)) |
|
|
|
|
|
continue; |
|
|
|
|
|
NameDic[key] = f.Name; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private GtkKeyboardDevice() |
|
|
private GtkKeyboardDevice() |
|
|
@ -36,7 +46,9 @@ namespace Perspex.Gtk |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
var s = Enum.GetName(typeof(Gdk.Key), key); |
|
|
string s; |
|
|
|
|
|
if (!NameDic.TryGetValue(key, out s)) |
|
|
|
|
|
s = "Unknown"; |
|
|
Perspex.Input.Key result; |
|
|
Perspex.Input.Key result; |
|
|
|
|
|
|
|
|
if (Enum.TryParse(s, true, out result)) |
|
|
if (Enum.TryParse(s, true, out result)) |
|
|
|