2012-09-25 08:07:12 +00:00
|
|
|
|
using ANX.Framework;
|
|
|
|
|
using ANX.Framework.Input;
|
|
|
|
|
using ANX.Framework.NonXNA;
|
|
|
|
|
using ANX.Framework.NonXNA.Development;
|
|
|
|
|
using System;
|
2013-01-13 14:31:31 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Windows.System;
|
|
|
|
|
using Windows.UI.Core;
|
2012-09-25 08:07:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
|
|
|
|
|
|
|
|
|
namespace ANX.InputDevices.Windows.ModernUI
|
|
|
|
|
{
|
2013-01-13 14:31:31 +00:00
|
|
|
|
[PercentageComplete(80)]
|
|
|
|
|
[TestState(TestStateAttribute.TestState.InProgress)]
|
2012-09-25 08:07:12 +00:00
|
|
|
|
[Developer("rene87")]
|
2013-01-13 14:31:31 +00:00
|
|
|
|
public class Keyboard : IKeyboard
|
2012-09-25 08:07:12 +00:00
|
|
|
|
{
|
2013-01-13 14:31:31 +00:00
|
|
|
|
private IntPtr windowHandle;
|
|
|
|
|
KeyboardState _state;
|
2012-09-25 08:07:12 +00:00
|
|
|
|
public IntPtr WindowHandle
|
|
|
|
|
{
|
2013-01-13 14:31:31 +00:00
|
|
|
|
get { return windowHandle; }
|
|
|
|
|
set
|
2012-09-25 08:07:12 +00:00
|
|
|
|
{
|
2013-01-13 14:31:31 +00:00
|
|
|
|
if (windowHandle != value)
|
|
|
|
|
{
|
|
|
|
|
windowHandle = value;
|
|
|
|
|
}
|
2012-09-25 08:07:12 +00:00
|
|
|
|
}
|
2013-01-13 14:31:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Keyboard()
|
|
|
|
|
{
|
|
|
|
|
CoreWindow.GetForCurrentThread().KeyDown += Keyboard_KeyDown;
|
|
|
|
|
CoreWindow.GetForCurrentThread().KeyUp += Keyboard_KeyUp;
|
|
|
|
|
_state = new KeyboardState(Keys.None);
|
|
|
|
|
_state.RemovePressedKey(Keys.None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Keyboard_KeyUp(CoreWindow sender, KeyEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
var key = FormatConverter.Translate(args.VirtualKey);
|
|
|
|
|
|
|
|
|
|
_state.RemovePressedKey(key);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Keyboard_KeyDown(CoreWindow sender, KeyEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
var key = FormatConverter.Translate(args.VirtualKey);
|
|
|
|
|
if (key != Keys.None)
|
2012-09-25 08:07:12 +00:00
|
|
|
|
{
|
2013-01-13 14:31:31 +00:00
|
|
|
|
_state.AddPressedKey(key);
|
2012-09-25 08:07:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public KeyboardState GetState()
|
|
|
|
|
{
|
2013-01-13 14:31:31 +00:00
|
|
|
|
|
|
|
|
|
return _state;
|
2012-09-25 08:07:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public KeyboardState GetState(PlayerIndex playerIndex)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|