Maze / Library /PackageCache /com.unity.inputsystem@1.6.1 /InputSystem /Devices /Commands /QueryKeyNameCommand.cs
| using System; | |
| using System.Runtime.InteropServices; | |
| using UnityEngine.InputSystem.Utilities; | |
| namespace UnityEngine.InputSystem.LowLevel | |
| { | |
| /// <summary> | |
| /// Command to query the current name of a key according to the current keyboard layout. | |
| /// </summary> | |
| [] | |
| public unsafe struct QueryKeyNameCommand : IInputDeviceCommandInfo | |
| { | |
| public static FourCC Type => new FourCC('K', 'Y', 'C', 'F'); | |
| internal const int kMaxNameLength = 256; | |
| internal const int kSize = InputDeviceCommand.kBaseCommandSize + kMaxNameLength + 4; | |
| [] | |
| public InputDeviceCommand baseCommand; | |
| [] | |
| public int scanOrKeyCode; | |
| [] | |
| public fixed byte nameBuffer[kMaxNameLength]; | |
| public string ReadKeyName() | |
| { | |
| fixed(QueryKeyNameCommand * thisPtr = &this) | |
| { | |
| return StringHelpers.ReadStringFromBuffer(new IntPtr(thisPtr->nameBuffer), kMaxNameLength); | |
| } | |
| } | |
| public FourCC typeStatic => Type; | |
| public static QueryKeyNameCommand Create(Key key) | |
| { | |
| return new QueryKeyNameCommand | |
| { | |
| baseCommand = new InputDeviceCommand(Type, kSize), | |
| scanOrKeyCode = (int)key | |
| }; | |
| } | |
| } | |
| } | |