12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180 |
- using System;
- using System.Runtime.InteropServices;
- using UnityEngine.InputSystem.Controls;
- using UnityEngine.InputSystem.LowLevel;
- using UnityEngine.InputSystem.Utilities;
- using Unity.Collections.LowLevel.Unsafe;
- using UnityEngine.InputSystem.Layouts;
- namespace UnityEngine.InputSystem.LowLevel
- {
-
-
-
-
- [StructLayout(LayoutKind.Sequential)]
- public unsafe struct KeyboardState : IInputStateTypeInfo
- {
-
-
-
-
-
- public static FourCC Format => new FourCC('K', 'E', 'Y', 'S');
- private const int kSizeInBits = Keyboard.KeyCount;
- internal const int kSizeInBytes = (kSizeInBits + 7) / 8;
- [InputControl(name = "anyKey", displayName = "Any Key", layout = "AnyKey", sizeInBits = kSizeInBits - 1, synthetic = true)]
- [InputControl(name = "escape", displayName = "Escape", layout = "Key", usages = new[] {"Back", "Cancel"}, bit = (int)Key.Escape)]
- [InputControl(name = "space", displayName = "Space", layout = "Key", bit = (int)Key.Space)]
- [InputControl(name = "enter", displayName = "Enter", layout = "Key", usage = "Submit", bit = (int)Key.Enter)]
- [InputControl(name = "tab", displayName = "Tab", layout = "Key", bit = (int)Key.Tab)]
- [InputControl(name = "backquote", displayName = "`", layout = "Key", bit = (int)Key.Backquote)]
- [InputControl(name = "quote", displayName = "'", layout = "Key", bit = (int)Key.Quote)]
- [InputControl(name = "semicolon", displayName = ";", layout = "Key", bit = (int)Key.Semicolon)]
- [InputControl(name = "comma", displayName = ",", layout = "Key", bit = (int)Key.Comma)]
- [InputControl(name = "period", displayName = ".", layout = "Key", bit = (int)Key.Period)]
- [InputControl(name = "slash", displayName = "/", layout = "Key", bit = (int)Key.Slash)]
- [InputControl(name = "backslash", displayName = "\\", layout = "Key", bit = (int)Key.Backslash)]
- [InputControl(name = "leftBracket", displayName = "[", layout = "Key", bit = (int)Key.LeftBracket)]
- [InputControl(name = "rightBracket", displayName = "]", layout = "Key", bit = (int)Key.RightBracket)]
- [InputControl(name = "minus", displayName = "-", layout = "Key", bit = (int)Key.Minus)]
- [InputControl(name = "equals", displayName = "=", layout = "Key", bit = (int)Key.Equals)]
- [InputControl(name = "upArrow", displayName = "Up Arrow", layout = "Key", bit = (int)Key.UpArrow)]
- [InputControl(name = "downArrow", displayName = "Down Arrow", layout = "Key", bit = (int)Key.DownArrow)]
- [InputControl(name = "leftArrow", displayName = "Left Arrow", layout = "Key", bit = (int)Key.LeftArrow)]
- [InputControl(name = "rightArrow", displayName = "Right Arrow", layout = "Key", bit = (int)Key.RightArrow)]
- [InputControl(name = "a", displayName = "A", layout = "Key", bit = (int)Key.A)]
- [InputControl(name = "b", displayName = "B", layout = "Key", bit = (int)Key.B)]
- [InputControl(name = "c", displayName = "C", layout = "Key", bit = (int)Key.C)]
- [InputControl(name = "d", displayName = "D", layout = "Key", bit = (int)Key.D)]
- [InputControl(name = "e", displayName = "E", layout = "Key", bit = (int)Key.E)]
- [InputControl(name = "f", displayName = "F", layout = "Key", bit = (int)Key.F)]
- [InputControl(name = "g", displayName = "G", layout = "Key", bit = (int)Key.G)]
- [InputControl(name = "h", displayName = "H", layout = "Key", bit = (int)Key.H)]
- [InputControl(name = "i", displayName = "I", layout = "Key", bit = (int)Key.I)]
- [InputControl(name = "j", displayName = "J", layout = "Key", bit = (int)Key.J)]
- [InputControl(name = "k", displayName = "K", layout = "Key", bit = (int)Key.K)]
- [InputControl(name = "l", displayName = "L", layout = "Key", bit = (int)Key.L)]
- [InputControl(name = "m", displayName = "M", layout = "Key", bit = (int)Key.M)]
- [InputControl(name = "n", displayName = "N", layout = "Key", bit = (int)Key.N)]
- [InputControl(name = "o", displayName = "O", layout = "Key", bit = (int)Key.O)]
- [InputControl(name = "p", displayName = "P", layout = "Key", bit = (int)Key.P)]
- [InputControl(name = "q", displayName = "Q", layout = "Key", bit = (int)Key.Q)]
- [InputControl(name = "r", displayName = "R", layout = "Key", bit = (int)Key.R)]
- [InputControl(name = "s", displayName = "S", layout = "Key", bit = (int)Key.S)]
- [InputControl(name = "t", displayName = "T", layout = "Key", bit = (int)Key.T)]
- [InputControl(name = "u", displayName = "U", layout = "Key", bit = (int)Key.U)]
- [InputControl(name = "v", displayName = "V", layout = "Key", bit = (int)Key.V)]
- [InputControl(name = "w", displayName = "W", layout = "Key", bit = (int)Key.W)]
- [InputControl(name = "x", displayName = "X", layout = "Key", bit = (int)Key.X)]
- [InputControl(name = "y", displayName = "Y", layout = "Key", bit = (int)Key.Y)]
- [InputControl(name = "z", displayName = "Z", layout = "Key", bit = (int)Key.Z)]
- [InputControl(name = "1", displayName = "1", layout = "Key", bit = (int)Key.Digit1)]
- [InputControl(name = "2", displayName = "2", layout = "Key", bit = (int)Key.Digit2)]
- [InputControl(name = "3", displayName = "3", layout = "Key", bit = (int)Key.Digit3)]
- [InputControl(name = "4", displayName = "4", layout = "Key", bit = (int)Key.Digit4)]
- [InputControl(name = "5", displayName = "5", layout = "Key", bit = (int)Key.Digit5)]
- [InputControl(name = "6", displayName = "6", layout = "Key", bit = (int)Key.Digit6)]
- [InputControl(name = "7", displayName = "7", layout = "Key", bit = (int)Key.Digit7)]
- [InputControl(name = "8", displayName = "8", layout = "Key", bit = (int)Key.Digit8)]
- [InputControl(name = "9", displayName = "9", layout = "Key", bit = (int)Key.Digit9)]
- [InputControl(name = "0", displayName = "0", layout = "Key", bit = (int)Key.Digit0)]
- [InputControl(name = "leftShift", displayName = "Left Shift", layout = "Key", usage = "Modifier", bit = (int)Key.LeftShift)]
- [InputControl(name = "rightShift", displayName = "Right Shift", layout = "Key", usage = "Modifier", bit = (int)Key.RightShift)]
- [InputControl(name = "shift", displayName = "Shift", layout = "DiscreteButton", usage = "Modifier", bit = (int)Key.LeftShift, sizeInBits = 2, synthetic = true, parameters = "minValue=1,maxValue=3")]
- [InputControl(name = "leftAlt", displayName = "Left Alt", layout = "Key", usage = "Modifier", bit = (int)Key.LeftAlt)]
- [InputControl(name = "rightAlt", displayName = "Right Alt", layout = "Key", usage = "Modifier", bit = (int)Key.RightAlt, alias = "AltGr")]
- [InputControl(name = "alt", displayName = "Alt", layout = "DiscreteButton", usage = "Modifier", bit = (int)Key.LeftAlt, sizeInBits = 2, synthetic = true, parameters = "minValue=1,maxValue=3")]
- [InputControl(name = "leftCtrl", displayName = "Left Control", layout = "Key", usage = "Modifier", bit = (int)Key.LeftCtrl)]
- [InputControl(name = "rightCtrl", displayName = "Right Control", layout = "Key", usage = "Modifier", bit = (int)Key.RightCtrl)]
- [InputControl(name = "ctrl", displayName = "Control", layout = "DiscreteButton", usage = "Modifier", bit = (int)Key.LeftCtrl, sizeInBits = 2, synthetic = true, parameters = "minValue=1,maxValue=3")]
- [InputControl(name = "leftMeta", displayName = "Left System", layout = "Key", usage = "Modifier", bit = (int)Key.LeftMeta, aliases = new[] { "LeftWindows", "LeftApple", "LeftCommand" })]
- [InputControl(name = "rightMeta", displayName = "Right System", layout = "Key", usage = "Modifier", bit = (int)Key.RightMeta, aliases = new[] { "RightWindows", "RightApple", "RightCommand" })]
- [InputControl(name = "contextMenu", displayName = "Context Menu", layout = "Key", usage = "Modifier", bit = (int)Key.ContextMenu)]
- [InputControl(name = "backspace", displayName = "Backspace", layout = "Key", bit = (int)Key.Backspace)]
- [InputControl(name = "pageDown", displayName = "Page Down", layout = "Key", bit = (int)Key.PageDown)]
- [InputControl(name = "pageUp", displayName = "Page Up", layout = "Key", bit = (int)Key.PageUp)]
- [InputControl(name = "home", displayName = "Home", layout = "Key", bit = (int)Key.Home)]
- [InputControl(name = "end", displayName = "End", layout = "Key", bit = (int)Key.End)]
- [InputControl(name = "insert", displayName = "Insert", layout = "Key", bit = (int)Key.Insert)]
- [InputControl(name = "delete", displayName = "Delete", layout = "Key", bit = (int)Key.Delete)]
- [InputControl(name = "capsLock", displayName = "Caps Lock", layout = "Key", bit = (int)Key.CapsLock)]
- [InputControl(name = "numLock", displayName = "Num Lock", layout = "Key", bit = (int)Key.NumLock)]
- [InputControl(name = "printScreen", displayName = "Print Screen", layout = "Key", bit = (int)Key.PrintScreen)]
- [InputControl(name = "scrollLock", displayName = "Scroll Lock", layout = "Key", bit = (int)Key.ScrollLock)]
- [InputControl(name = "pause", displayName = "Pause/Break", layout = "Key", bit = (int)Key.Pause)]
- [InputControl(name = "numpadEnter", displayName = "Numpad Enter", layout = "Key", bit = (int)Key.NumpadEnter)]
- [InputControl(name = "numpadDivide", displayName = "Numpad /", layout = "Key", bit = (int)Key.NumpadDivide)]
- [InputControl(name = "numpadMultiply", displayName = "Numpad *", layout = "Key", bit = (int)Key.NumpadMultiply)]
- [InputControl(name = "numpadPlus", displayName = "Numpad +", layout = "Key", bit = (int)Key.NumpadPlus)]
- [InputControl(name = "numpadMinus", displayName = "Numpad -", layout = "Key", bit = (int)Key.NumpadMinus)]
- [InputControl(name = "numpadPeriod", displayName = "Numpad .", layout = "Key", bit = (int)Key.NumpadPeriod)]
- [InputControl(name = "numpadEquals", displayName = "Numpad =", layout = "Key", bit = (int)Key.NumpadEquals)]
- [InputControl(name = "numpad1", displayName = "Numpad 1", layout = "Key", bit = (int)Key.Numpad1)]
- [InputControl(name = "numpad2", displayName = "Numpad 2", layout = "Key", bit = (int)Key.Numpad2)]
- [InputControl(name = "numpad3", displayName = "Numpad 3", layout = "Key", bit = (int)Key.Numpad3)]
- [InputControl(name = "numpad4", displayName = "Numpad 4", layout = "Key", bit = (int)Key.Numpad4)]
- [InputControl(name = "numpad5", displayName = "Numpad 5", layout = "Key", bit = (int)Key.Numpad5)]
- [InputControl(name = "numpad6", displayName = "Numpad 6", layout = "Key", bit = (int)Key.Numpad6)]
- [InputControl(name = "numpad7", displayName = "Numpad 7", layout = "Key", bit = (int)Key.Numpad7)]
- [InputControl(name = "numpad8", displayName = "Numpad 8", layout = "Key", bit = (int)Key.Numpad8)]
- [InputControl(name = "numpad9", displayName = "Numpad 9", layout = "Key", bit = (int)Key.Numpad9)]
- [InputControl(name = "numpad0", displayName = "Numpad 0", layout = "Key", bit = (int)Key.Numpad0)]
- [InputControl(name = "f1", displayName = "F1", layout = "Key", bit = (int)Key.F1)]
- [InputControl(name = "f2", displayName = "F2", layout = "Key", bit = (int)Key.F2)]
- [InputControl(name = "f3", displayName = "F3", layout = "Key", bit = (int)Key.F3)]
- [InputControl(name = "f4", displayName = "F4", layout = "Key", bit = (int)Key.F4)]
- [InputControl(name = "f5", displayName = "F5", layout = "Key", bit = (int)Key.F5)]
- [InputControl(name = "f6", displayName = "F6", layout = "Key", bit = (int)Key.F6)]
- [InputControl(name = "f7", displayName = "F7", layout = "Key", bit = (int)Key.F7)]
- [InputControl(name = "f8", displayName = "F8", layout = "Key", bit = (int)Key.F8)]
- [InputControl(name = "f9", displayName = "F9", layout = "Key", bit = (int)Key.F9)]
- [InputControl(name = "f10", displayName = "F10", layout = "Key", bit = (int)Key.F10)]
- [InputControl(name = "f11", displayName = "F11", layout = "Key", bit = (int)Key.F11)]
- [InputControl(name = "f12", displayName = "F12", layout = "Key", bit = (int)Key.F12)]
- [InputControl(name = "OEM1", layout = "Key", bit = (int)Key.OEM1)]
- [InputControl(name = "OEM2", layout = "Key", bit = (int)Key.OEM2)]
- [InputControl(name = "OEM3", layout = "Key", bit = (int)Key.OEM3)]
- [InputControl(name = "OEM4", layout = "Key", bit = (int)Key.OEM4)]
- [InputControl(name = "OEM5", layout = "Key", bit = (int)Key.OEM5)]
- [InputControl(name = "IMESelected", layout = "Button", bit = (int)Key.IMESelected, synthetic = true)]
- public fixed byte keys[kSizeInBytes];
- public KeyboardState(params Key[] pressedKeys)
- {
- if (pressedKeys == null)
- throw new ArgumentNullException(nameof(pressedKeys));
- fixed(byte* keysPtr = keys)
- {
- UnsafeUtility.MemClear(keysPtr, kSizeInBytes);
- for (var i = 0; i < pressedKeys.Length; ++i)
- MemoryHelpers.WriteSingleBit(keysPtr, (uint)pressedKeys[i], true);
- }
- }
- public void Set(Key key, bool state)
- {
- fixed(byte* keysPtr = keys)
- MemoryHelpers.WriteSingleBit(keysPtr, (uint)key, state);
- }
- public void Press(Key key)
- {
- Set(key, true);
- }
- public void Release(Key key)
- {
- Set(key, false);
- }
- public FourCC format => Format;
- }
- }
- namespace UnityEngine.InputSystem
- {
-
-
-
-
-
-
-
-
- public enum Key
- {
-
-
-
-
- None,
-
-
-
-
- Space,
-
-
-
- Enter,
-
-
-
- Tab,
-
-
-
- Backquote,
-
-
-
- Quote,
-
-
-
- Semicolon,
-
-
-
- Comma,
-
-
-
- Period,
-
-
-
- Slash,
-
-
-
- Backslash,
-
-
-
- LeftBracket,
-
-
-
- RightBracket,
-
-
-
- Minus,
-
-
-
- Equals,
-
-
-
- A,
-
-
-
- B,
-
-
-
- C,
-
-
-
- D,
-
-
-
- E,
-
-
-
- F,
-
-
-
- G,
-
-
-
- H,
-
-
-
- I,
-
-
-
- J,
-
-
-
- K,
-
-
-
- L,
-
-
-
- M,
-
-
-
- N,
-
-
-
- O,
-
-
-
- P,
-
-
-
- Q,
-
-
-
- R,
-
-
-
- S,
-
-
-
- T,
-
-
-
- U,
-
-
-
- V,
-
-
-
- W,
-
-
-
- X,
-
-
-
- Y,
-
-
-
- Z,
-
-
-
- Digit1,
-
-
-
- Digit2,
-
-
-
- Digit3,
-
-
-
- Digit4,
-
-
-
- Digit5,
-
-
-
- Digit6,
-
-
-
- Digit7,
-
-
-
- Digit8,
-
-
-
- Digit9,
-
-
-
- Digit0,
-
-
-
-
-
- LeftShift,
-
-
-
- RightShift,
-
-
-
- LeftAlt,
-
-
-
- RightAlt,
-
-
-
- AltGr = RightAlt,
-
-
-
- LeftCtrl,
-
-
-
- RightCtrl,
-
-
-
- LeftMeta,
-
-
-
- RightMeta,
-
-
-
- LeftWindows = LeftMeta,
-
-
-
- RightWindows = RightMeta,
-
-
-
- LeftApple = LeftMeta,
-
-
-
- RightApple = RightMeta,
-
-
-
- LeftCommand = LeftMeta,
-
-
-
- RightCommand = RightMeta,
-
-
-
- ContextMenu,
-
-
-
- Escape,
-
-
-
- LeftArrow,
-
-
-
- RightArrow,
-
-
-
- UpArrow,
-
-
-
- DownArrow,
-
-
-
- Backspace,
-
-
-
- PageDown,
-
-
-
- PageUp,
-
-
-
- Home,
-
-
-
- End,
-
-
-
- Insert,
-
-
-
- Delete,
-
-
-
- CapsLock,
-
-
-
- NumLock,
-
-
-
- PrintScreen,
-
-
-
- ScrollLock,
-
-
-
- Pause,
-
-
-
-
-
-
-
-
-
- NumpadEnter,
-
-
-
- NumpadDivide,
-
-
-
- NumpadMultiply,
-
-
-
- NumpadPlus,
-
-
-
- NumpadMinus,
-
-
-
- NumpadPeriod,
-
-
-
- NumpadEquals,
-
-
-
- Numpad0,
-
-
-
- Numpad1,
-
-
-
- Numpad2,
-
-
-
- Numpad3,
-
-
-
- Numpad4,
-
-
-
- Numpad5,
-
-
-
- Numpad6,
-
-
-
- Numpad7,
-
-
-
- Numpad8,
-
-
-
- Numpad9,
-
-
-
- F1,
-
-
-
- F2,
-
-
-
- F3,
-
-
-
- F4,
-
-
-
- F5,
-
-
-
- F6,
-
-
-
- F7,
-
-
-
- F8,
-
-
-
- F9,
-
-
-
- F10,
-
-
-
- F11,
-
-
-
- F12,
-
-
-
-
-
- OEM1,
-
-
-
- OEM2,
-
-
-
- OEM3,
-
-
-
- OEM4,
-
-
-
- OEM5,
-
-
- IMESelected
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [InputControlLayout(stateType = typeof(KeyboardState), isGenericTypeOfDevice = true)]
- [Scripting.Preserve]
- public class Keyboard : InputDevice, ITextInputReceiver
- {
-
-
-
-
-
- public const int KeyCount = (int)Key.OEM5;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public event Action<char> onTextInput
- {
- add
- {
- if (value == null)
- throw new ArgumentNullException(nameof(value));
- if (!m_TextInputListeners.Contains(value))
- m_TextInputListeners.Append(value);
- }
- remove => m_TextInputListeners.Remove(value);
- }
-
-
-
-
-
-
-
-
-
-
- public event Action<IMECompositionString> onIMECompositionChange
- {
- add
- {
- if (value == null)
- throw new ArgumentNullException(nameof(value));
- if (!m_ImeCompositionListeners.Contains(value))
- m_ImeCompositionListeners.Append(value);
- }
- remove => m_ImeCompositionListeners.Remove(value);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public void SetIMEEnabled(bool enabled)
- {
- EnableIMECompositionCommand command = EnableIMECompositionCommand.Create(enabled);
- ExecuteCommand(ref command);
- }
-
-
-
-
-
-
-
-
-
- public void SetIMECursorPosition(Vector2 position)
- {
- SetIMECursorPositionCommand command = SetIMECursorPositionCommand.Create(position);
- ExecuteCommand(ref command);
- }
-
-
-
-
-
-
-
-
-
-
-
- public string keyboardLayout
- {
- get
- {
- RefreshConfigurationIfNeeded();
- return m_KeyboardLayoutName;
- }
- protected set => m_KeyboardLayoutName = value;
- }
-
-
-
-
- public AnyKeyControl anyKey { get; private set; }
-
-
-
-
- public KeyControl spaceKey => this[Key.Space];
-
-
-
-
-
-
-
- public KeyControl enterKey => this[Key.Enter];
-
-
-
-
- public KeyControl tabKey => this[Key.Tab];
-
-
-
-
- public KeyControl backquoteKey => this[Key.Backquote];
-
-
-
-
- public KeyControl quoteKey => this[Key.Quote];
-
-
-
-
- public KeyControl semicolonKey => this[Key.Semicolon];
-
-
-
-
- public KeyControl commaKey => this[Key.Comma];
-
-
-
-
- public KeyControl periodKey => this[Key.Period];
-
-
-
-
- public KeyControl slashKey => this[Key.Slash];
-
-
-
-
-
- public KeyControl backslashKey => this[Key.Backslash];
-
-
-
-
- public KeyControl leftBracketKey => this[Key.LeftBracket];
-
-
-
-
-
- public KeyControl rightBracketKey => this[Key.RightBracket];
-
-
-
-
- public KeyControl minusKey => this[Key.Minus];
-
-
-
-
-
- public KeyControl equalsKey => this[Key.Equals];
-
-
-
-
- public KeyControl aKey => this[Key.A];
-
-
-
-
-
- public KeyControl bKey => this[Key.B];
-
-
-
-
-
- public KeyControl cKey => this[Key.C];
-
-
-
-
-
- public KeyControl dKey => this[Key.D];
-
-
-
-
-
- public KeyControl eKey => this[Key.E];
-
-
-
-
-
- public KeyControl fKey => this[Key.F];
-
-
-
-
-
- public KeyControl gKey => this[Key.G];
-
-
-
-
-
- public KeyControl hKey => this[Key.H];
-
-
-
-
- public KeyControl iKey => this[Key.I];
-
-
-
-
-
- public KeyControl jKey => this[Key.J];
-
-
-
-
-
- public KeyControl kKey => this[Key.K];
-
-
-
-
-
- public KeyControl lKey => this[Key.L];
-
-
-
-
-
- public KeyControl mKey => this[Key.M];
-
-
-
-
-
- public KeyControl nKey => this[Key.N];
-
-
-
-
-
- public KeyControl oKey => this[Key.O];
-
-
-
-
-
- public KeyControl pKey => this[Key.P];
-
-
-
-
-
- public KeyControl qKey => this[Key.Q];
-
-
-
-
-
- public KeyControl rKey => this[Key.R];
-
-
-
-
-
- public KeyControl sKey => this[Key.S];
-
-
-
-
-
- public KeyControl tKey => this[Key.T];
-
-
-
-
-
- public KeyControl uKey => this[Key.U];
-
-
-
-
-
- public KeyControl vKey => this[Key.V];
-
-
-
-
-
- public KeyControl wKey => this[Key.W];
-
-
-
-
-
- public KeyControl xKey => this[Key.X];
-
-
-
-
-
- public KeyControl yKey => this[Key.Y];
-
-
-
-
-
- public KeyControl zKey => this[Key.Z];
-
-
-
-
-
- public KeyControl digit1Key => this[Key.Digit1];
-
-
-
-
-
- public KeyControl digit2Key => this[Key.Digit2];
-
-
-
-
-
- public KeyControl digit3Key => this[Key.Digit3];
-
-
-
-
-
- public KeyControl digit4Key => this[Key.Digit4];
-
-
-
-
-
- public KeyControl digit5Key => this[Key.Digit5];
-
-
-
-
-
- public KeyControl digit6Key => this[Key.Digit6];
-
-
-
-
-
- public KeyControl digit7Key => this[Key.Digit7];
-
-
-
-
-
- public KeyControl digit8Key => this[Key.Digit8];
-
-
-
-
-
- public KeyControl digit9Key => this[Key.Digit9];
-
-
-
-
-
- public KeyControl digit0Key => this[Key.Digit0];
-
-
-
-
- public KeyControl leftShiftKey => this[Key.LeftShift];
-
-
-
-
- public KeyControl rightShiftKey => this[Key.RightShift];
-
-
-
-
- public KeyControl leftAltKey => this[Key.LeftAlt];
-
-
-
-
- public KeyControl rightAltKey => this[Key.RightAlt];
-
-
-
-
- public KeyControl leftCtrlKey => this[Key.LeftCtrl];
-
-
-
-
-
- public KeyControl rightCtrlKey => this[Key.RightCtrl];
-
-
-
-
-
- public KeyControl leftMetaKey => this[Key.LeftMeta];
-
-
-
-
-
- public KeyControl rightMetaKey => this[Key.RightMeta];
-
-
-
-
- public KeyControl leftWindowsKey => this[Key.LeftWindows];
-
-
-
-
- public KeyControl rightWindowsKey => this[Key.RightWindows];
-
-
-
-
- public KeyControl leftAppleKey => this[Key.LeftApple];
-
-
-
-
- public KeyControl rightAppleKey => this[Key.RightApple];
-
-
-
-
- public KeyControl leftCommandKey => this[Key.LeftCommand];
-
-
-
-
- public KeyControl rightCommandKey => this[Key.RightCommand];
-
-
-
-
-
-
-
- public KeyControl contextMenuKey => this[Key.ContextMenu];
-
-
-
-
-
- public KeyControl escapeKey => this[Key.Escape];
-
-
-
-
-
- public KeyControl leftArrowKey => this[Key.LeftArrow];
-
-
-
-
-
- public KeyControl rightArrowKey => this[Key.RightArrow];
-
-
-
-
-
- public KeyControl upArrowKey => this[Key.UpArrow];
-
-
-
-
-
-
- public KeyControl downArrowKey => this[Key.DownArrow];
-
-
-
-
-
-
-
-
-
- public KeyControl backspaceKey => this[Key.Backspace];
-
-
-
-
-
- public KeyControl pageDownKey => this[Key.PageDown];
-
-
-
-
-
- public KeyControl pageUpKey => this[Key.PageUp];
-
-
-
-
-
- public KeyControl homeKey => this[Key.Home];
-
-
-
-
-
- public KeyControl endKey => this[Key.End];
-
-
-
-
-
- public KeyControl insertKey => this[Key.Insert];
-
-
-
-
-
-
-
-
-
- public KeyControl deleteKey => this[Key.Delete];
-
-
-
-
-
- public KeyControl capsLockKey => this[Key.CapsLock];
-
-
-
-
-
-
- public KeyControl scrollLockKey => this[Key.ScrollLock];
-
-
-
-
-
-
- public KeyControl numLockKey => this[Key.NumLock];
-
-
-
-
-
-
- public KeyControl printScreenKey => this[Key.PrintScreen];
-
-
-
-
-
- public KeyControl pauseKey => this[Key.Pause];
-
-
-
-
-
- public KeyControl numpadEnterKey => this[Key.NumpadEnter];
-
-
-
-
-
-
-
-
-
-
- public KeyControl numpadDivideKey => this[Key.NumpadDivide];
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl numpadMultiplyKey => this[Key.NumpadMultiply];
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl numpadMinusKey => this[Key.NumpadMinus];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl numpadPlusKey => this[Key.NumpadPlus];
-
-
-
-
-
-
-
-
- public KeyControl numpadPeriodKey => this[Key.NumpadPeriod];
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl numpadEqualsKey => this[Key.NumpadEquals];
-
-
-
-
-
- public KeyControl numpad0Key => this[Key.Numpad0];
-
-
-
-
-
- public KeyControl numpad1Key => this[Key.Numpad1];
-
-
-
-
-
- public KeyControl numpad2Key => this[Key.Numpad2];
-
-
-
-
-
- public KeyControl numpad3Key => this[Key.Numpad3];
-
-
-
-
-
- public KeyControl numpad4Key => this[Key.Numpad4];
-
-
-
-
-
- public KeyControl numpad5Key => this[Key.Numpad5];
-
-
-
-
-
- public KeyControl numpad6Key => this[Key.Numpad6];
-
-
-
-
-
- public KeyControl numpad7Key => this[Key.Numpad7];
-
-
-
-
-
- public KeyControl numpad8Key => this[Key.Numpad8];
-
-
-
-
-
-
- public KeyControl numpad9Key => this[Key.Numpad9];
-
-
-
-
-
- public KeyControl f1Key => this[Key.F1];
-
-
-
-
-
- public KeyControl f2Key => this[Key.F2];
-
-
-
-
-
- public KeyControl f3Key => this[Key.F3];
-
-
-
-
-
- public KeyControl f4Key => this[Key.F4];
-
-
-
-
-
- public KeyControl f5Key => this[Key.F5];
-
-
-
-
-
- public KeyControl f6Key => this[Key.F6];
-
-
-
-
-
- public KeyControl f7Key => this[Key.F7];
-
-
-
-
-
- public KeyControl f8Key => this[Key.F8];
-
-
-
-
-
- public KeyControl f9Key => this[Key.F9];
-
-
-
-
-
- public KeyControl f10Key => this[Key.F10];
-
-
-
-
-
- public KeyControl f11Key => this[Key.F11];
-
-
-
-
-
- public KeyControl f12Key => this[Key.F12];
-
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl oem1Key => this[Key.OEM1];
-
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl oem2Key => this[Key.OEM2];
-
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl oem3Key => this[Key.OEM3];
-
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl oem4Key => this[Key.OEM4];
-
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl oem5Key => this[Key.OEM5];
-
-
-
-
-
-
-
-
- public ButtonControl shiftKey { get; private set; }
-
-
-
-
-
-
-
-
- public ButtonControl ctrlKey { get; private set; }
-
-
-
-
-
-
-
-
- public ButtonControl altKey { get; private set; }
-
-
-
-
-
-
-
-
-
-
- public ButtonControl imeSelected { get; private set; }
-
-
-
-
-
-
-
-
- public KeyControl this[Key key]
- {
- get
- {
- var index = (int)key - 1;
- if (index < 0 || index >= m_Keys.Length)
- throw new ArgumentOutOfRangeException(nameof(key));
- return m_Keys[index];
- }
- }
-
-
-
- public ReadOnlyArray<KeyControl> allKeys => new ReadOnlyArray<KeyControl>(m_Keys);
-
-
-
- public static Keyboard current { get; private set; }
-
-
-
-
-
-
-
- public override void MakeCurrent()
- {
- base.MakeCurrent();
- current = this;
- }
-
-
-
- protected override void OnRemoved()
- {
- base.OnRemoved();
- if (current == this)
- current = null;
- }
-
-
-
-
- protected override void FinishSetup()
- {
- var keyStrings = new[]
- {
- "space",
- "enter",
- "tab",
- "backquote",
- "quote",
- "semicolon",
- "comma",
- "period",
- "slash",
- "backslash",
- "leftbracket",
- "rightbracket",
- "minus",
- "equals",
- "a",
- "b",
- "c",
- "d",
- "e",
- "f",
- "g",
- "h",
- "i",
- "j",
- "k",
- "l",
- "m",
- "n",
- "o",
- "p",
- "q",
- "r",
- "s",
- "t",
- "u",
- "v",
- "w",
- "x",
- "y",
- "z",
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "0",
- "leftshift",
- "rightshift",
- "leftalt",
- "rightalt",
- "leftctrl",
- "rightctrl",
- "leftmeta",
- "rightmeta",
- "contextmenu",
- "escape",
- "leftarrow",
- "rightarrow",
- "uparrow",
- "downarrow",
- "backspace",
- "pagedown",
- "pageup",
- "home",
- "end",
- "insert",
- "delete",
- "capslock",
- "numlock",
- "printscreen",
- "scrolllock",
- "pause",
- "numpadenter",
- "numpaddivide",
- "numpadmultiply",
- "numpadplus",
- "numpadminus",
- "numpadperiod",
- "numpadequals",
- "numpad0",
- "numpad1",
- "numpad2",
- "numpad3",
- "numpad4",
- "numpad5",
- "numpad6",
- "numpad7",
- "numpad8",
- "numpad9",
- "f1",
- "f2",
- "f3",
- "f4",
- "f5",
- "f6",
- "f7",
- "f8",
- "f9",
- "f10",
- "f11",
- "f12",
- "oem1",
- "oem2",
- "oem3",
- "oem4",
- "oem5",
- };
- m_Keys = new KeyControl[keyStrings.Length];
- for (var i = 0; i < keyStrings.Length; ++i)
- {
- m_Keys[i] = GetChildControl<KeyControl>(keyStrings[i]);
-
-
- m_Keys[i].keyCode = (Key)(i + 1);
- }
- Debug.Assert(keyStrings[(int)Key.OEM5 - 1] == "oem5",
- "keyString array layout doe not match Key enum layout");
- anyKey = GetChildControl<AnyKeyControl>("anyKey");
- shiftKey = GetChildControl<ButtonControl>("shift");
- ctrlKey = GetChildControl<ButtonControl>("ctrl");
- altKey = GetChildControl<ButtonControl>("alt");
- imeSelected = GetChildControl<ButtonControl>("IMESelected");
- base.FinishSetup();
- }
-
- protected override void RefreshConfiguration()
- {
- keyboardLayout = null;
- var command = QueryKeyboardLayoutCommand.Create();
- if (ExecuteCommand(ref command) >= 0)
- keyboardLayout = command.ReadLayoutName();
- }
-
-
-
-
-
-
-
-
- public void OnTextInput(char character)
- {
- for (var i = 0; i < m_TextInputListeners.length; ++i)
- m_TextInputListeners[i](character);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public KeyControl FindKeyOnCurrentKeyboardLayout(string displayName)
- {
- var keys = allKeys;
- for (var i = 0; i < keys.Count; ++i)
- if (string.Equals(keys[i].displayName, displayName, StringComparison.CurrentCultureIgnoreCase))
- return keys[i];
- return null;
- }
- public void OnIMECompositionChanged(IMECompositionString compositionString)
- {
- if (m_ImeCompositionListeners.length > 0)
- {
- for (var i = 0; i < m_ImeCompositionListeners.length; ++i)
- m_ImeCompositionListeners[i](compositionString);
- }
- }
- private InlinedArray<Action<char>> m_TextInputListeners;
- private string m_KeyboardLayoutName;
- private KeyControl[] m_Keys;
- private InlinedArray<Action<IMECompositionString>> m_ImeCompositionListeners;
- }
- }
|