2013-09-27 21:07:23 +00:00
|
|
|
#region License
|
|
|
|
//
|
|
|
|
// The Open Toolkit Library License
|
|
|
|
//
|
|
|
|
// Copyright (c) 2006 - 2013 Stefanos Apostolopoulos for the Open Toolkit library.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights to
|
|
|
|
// 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
|
|
|
|
// so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
|
|
// copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
#endregion
|
|
|
|
|
2013-09-27 12:41:37 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using OpenTK.Input;
|
|
|
|
|
|
|
|
namespace OpenTK.Platform.SDL2
|
|
|
|
{
|
2013-10-23 23:45:13 +00:00
|
|
|
using Code = Scancode;
|
2013-09-27 12:41:37 +00:00
|
|
|
|
2013-10-23 23:45:13 +00:00
|
|
|
class Sdl2KeyMap : Dictionary<Scancode, Key>
|
2013-09-27 12:41:37 +00:00
|
|
|
{
|
|
|
|
public Sdl2KeyMap()
|
|
|
|
{
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.ESCAPE, Key.Escape);
|
2013-09-27 12:41:37 +00:00
|
|
|
|
|
|
|
// Function keys
|
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
{
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.F1 + i, Key.F1 + i);
|
2013-09-27 12:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Number keys (0-9)
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.Num0, Key.Number0);
|
2013-10-11 07:51:08 +00:00
|
|
|
for (int i = 0; i < 9; i++)
|
2013-09-27 12:41:37 +00:00
|
|
|
{
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.Num1 + i, Key.Number1 + i);
|
2013-09-27 12:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Letters (A-Z)
|
|
|
|
for (int i = 0; i < 26; i++)
|
|
|
|
{
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.A + i, Key.A + i);
|
2013-09-27 12:41:37 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.TAB, Key.Tab);
|
|
|
|
Add(Code.CAPSLOCK, Key.CapsLock);
|
|
|
|
Add(Code.LCTRL, Key.ControlLeft);
|
|
|
|
Add(Code.LSHIFT, Key.ShiftLeft);
|
2014-02-17 22:17:13 +00:00
|
|
|
Add(Code.LALT, Key.AltLeft);
|
|
|
|
Add(Code.MENU, Key.WinLeft);
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.SPACE, Key.Space);
|
|
|
|
Add(Code.RALT, Key.AltRight);
|
2013-09-27 12:41:37 +00:00
|
|
|
//Add(Code., Key.WinRight);
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.APPLICATION, Key.Menu);
|
|
|
|
Add(Code.RCTRL, Key.ControlRight);
|
|
|
|
Add(Code.RSHIFT, Key.ShiftRight);
|
|
|
|
Add(Code.RETURN, Key.Enter);
|
|
|
|
Add(Code.BACKSPACE, Key.BackSpace);
|
2013-09-27 12:41:37 +00:00
|
|
|
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.SEMICOLON, Key.Semicolon); // Varies by keyboard, ;: on Win2K/US
|
|
|
|
Add(Code.SLASH, Key.Slash); // Varies by keyboard, /? on Win2K/US
|
|
|
|
Add(Code.GRAVE, Key.Tilde); // Varies by keyboard, `~ on Win2K/US
|
|
|
|
Add(Code.LEFTBRACKET, Key.BracketLeft); // Varies by keyboard, [{ on Win2K/US
|
|
|
|
Add(Code.BACKSLASH, Key.BackSlash); // Varies by keyboard, \| on Win2K/US
|
|
|
|
Add(Code.RIGHTBRACKET, Key.BracketRight); // Varies by keyboard, ]} on Win2K/US
|
|
|
|
Add(Code.APOSTROPHE, Key.Quote); // Varies by keyboard, '" on Win2K/US
|
|
|
|
Add(Code.EQUALS, Key.Plus);
|
|
|
|
Add(Code.COMMA, Key.Comma); // Invariant: ,
|
|
|
|
Add(Code.MINUS, Key.Minus); // Invariant: -
|
|
|
|
Add(Code.PERIOD, Key.Period); // Invariant: .
|
2013-09-27 12:41:37 +00:00
|
|
|
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.HOME, Key.Home);
|
|
|
|
Add(Code.END, Key.End);
|
|
|
|
Add(Code.DELETE, Key.Delete);
|
|
|
|
Add(Code.PAGEUP, Key.PageUp);
|
|
|
|
Add(Code.PAGEDOWN, Key.PageDown);
|
|
|
|
Add(Code.PAUSE, Key.Pause);
|
|
|
|
Add(Code.NUMLOCKCLEAR, Key.NumLock);
|
2013-09-27 12:41:37 +00:00
|
|
|
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.SCROLLLOCK, Key.ScrollLock);
|
|
|
|
Add(Code.PRINTSCREEN, Key.PrintScreen);
|
|
|
|
Add(Code.CLEAR, Key.Clear);
|
|
|
|
Add(Code.INSERT, Key.Insert);
|
2013-09-27 12:41:37 +00:00
|
|
|
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.SLEEP, Key.Sleep);
|
2013-09-27 12:41:37 +00:00
|
|
|
|
|
|
|
// Keypad
|
|
|
|
for (int i = 0; i < 9; i++)
|
|
|
|
{
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.KP_1 + i, Key.Keypad1 + i);
|
2013-09-27 12:41:37 +00:00
|
|
|
}
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.KP_0, Key.Keypad0); // Note: SDL2 goes KP_1..KP_9, then KP_0
|
2013-09-27 12:41:37 +00:00
|
|
|
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.KP_DECIMAL, Key.KeypadDecimal);
|
|
|
|
Add(Code.KP_PLUS, Key.KeypadAdd);
|
|
|
|
Add(Code.KP_MINUS, Key.KeypadSubtract);
|
|
|
|
Add(Code.KP_DIVIDE, Key.KeypadDivide);
|
|
|
|
Add(Code.KP_MULTIPLY, Key.KeypadMultiply);
|
2013-09-27 12:41:37 +00:00
|
|
|
|
|
|
|
// Navigation
|
2013-10-23 23:45:13 +00:00
|
|
|
Add(Code.UP, Key.Up);
|
|
|
|
Add(Code.DOWN, Key.Down);
|
|
|
|
Add(Code.LEFT, Key.Left);
|
|
|
|
Add(Code.RIGHT, Key.Right);
|
2013-09-27 12:41:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|