コード例 #1
0
ファイル: KeyControl.cs プロジェクト: BaseDorp/TankGame
        protected override void RefreshConfiguration()
        {
            // Wipe our last cached set of data (if any).
            displayName = null;
            m_ScanCode  = 0;

            var command = QueryKeyNameCommand.Create(keyCode);

            if (device.ExecuteCommand(ref command) > 0)
            {
                m_ScanCode = command.scanOrKeyCode;

                var rawKeyName = command.ReadKeyName();
                if (string.IsNullOrEmpty(rawKeyName))
                {
                    displayName = rawKeyName;
                    return;
                }

                var textInfo = CultureInfo.InvariantCulture.TextInfo;
                // We need to lower case first because ToTitleCase preserves upper casing.
                // For example on Swedish Windows layout right shift display name is "HÖGER SKIFT".
                // Just passing it to ToTitleCase won't change anything. But passing "höger skift" will return "Höger Skift".
                var keyNameLowerCase = textInfo.ToLower(rawKeyName);
                if (string.IsNullOrEmpty(keyNameLowerCase))
                {
                    displayName = rawKeyName;
                    return;
                }

                displayName = textInfo.ToTitleCase(keyNameLowerCase);
            }
        }
コード例 #2
0
        protected override void RefreshConfiguration()
        {
            // Wipe our last cached set of data (if any).
            displayName = null;
            m_ScanCode  = 0;

            var command = QueryKeyNameCommand.Create(keyCode);

            if (device.ExecuteCommand(ref command) > 0)
            {
                m_ScanCode  = command.scanOrKeyCode;
                displayName = command.ReadKeyName();
            }
        }