78 lines
2.0 KiB
C#
Raw Normal View History

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;
// 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)]
[Developer("rene87")]
2013-01-13 14:31:31 +00:00
public class Keyboard : IKeyboard
{
2013-01-13 14:31:31 +00:00
private IntPtr windowHandle;
KeyboardState _state;
public IntPtr WindowHandle
{
2013-01-13 14:31:31 +00:00
get { return windowHandle; }
set
{
2013-01-13 14:31:31 +00:00
if (windowHandle != value)
{
windowHandle = value;
}
}
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)
{
2013-01-13 14:31:31 +00:00
_state.AddPressedKey(key);
}
}
public KeyboardState GetState()
{
2013-01-13 14:31:31 +00:00
return _state;
}
public KeyboardState GetState(PlayerIndex playerIndex)
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
}
}