using System;
using System.Collections.Generic;
namespace UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard
{
///
/// Scriptable object that defines key mappings to support swapping . There should be one
/// instance of the for each layout (i.e. alphanumeric, symbols, etc.).
///
public class XRKeyboardConfig : ScriptableObject
{
///
/// Class representing the data needed to populate keys.
///
[Serializable]
public class KeyMapping
{
[SerializeField]
string m_Character;
///
/// Character for this key in non-shifted state. This string will be passed to the keyboard and appended to the keyboard text string or processed as a keyboard command.
///
public string character
{
get => m_Character;
set => m_Character = value;
}
[SerializeField]
string m_DisplayCharacter;
///
/// Display character for this key in a non-shifted state. This string will be displayed on the key text field.
/// If empty, character will be used as a fallback.
///
public string displayCharacter
{
get => m_DisplayCharacter;
set => m_DisplayCharacter = value;
}
[SerializeField]
Sprite m_DisplayIcon;
///
/// Display icon for this key in a non-shifted state. This icon will be displayed on the key image field.
/// If empty, the display character or character will be used as a fallback.
///
public Sprite displayIcon
{
get => m_DisplayIcon;
set => m_DisplayIcon = value;
}
[SerializeField]
string m_ShiftCharacter;
///
/// Character for this key in a shifted state. This string will be passed to the keyboard and appended to
/// the keyboard text string or processed as a keyboard command.
///
public string shiftCharacter
{
get => m_ShiftCharacter;
set => m_ShiftCharacter = value;
}
[SerializeField]
string m_ShiftDisplayCharacter;
///
/// Display character for this key in a shifted state. This string will be displayed on the key
/// text field. If empty, shift character will be used as a fallback.
///
public string shiftDisplayCharacter
{
get => m_ShiftDisplayCharacter;
set => m_ShiftDisplayCharacter = value;
}
[SerializeField]
Sprite m_ShiftDisplayIcon;
///
/// Display icon for this key in a shifted state. This icon will be displayed on the key image field.
/// If empty, the shift display character or shift character will be used as a fallback.
///
public Sprite shiftDisplayIcon
{
get => m_ShiftDisplayIcon;
set => m_ShiftDisplayIcon = value;
}
[SerializeField]
bool m_OverrideDefaultKeyFunction;
///
/// If true, this will expose a key function property to override the default key function of this config.
///
public bool overrideDefaultKeyFunction
{
get => m_OverrideDefaultKeyFunction;
set => m_OverrideDefaultKeyFunction = value;
}
[SerializeField]
KeyFunction m_KeyFunction;
///
/// used for this key. The function callback will be called on key press
/// and used to communicate with the keyboard API.
///
public KeyFunction keyFunction
{
get => m_KeyFunction;
set => m_KeyFunction = value;
}
[SerializeField]
KeyCode m_KeyCode;
///
/// (Optional) used for this key. Used with to
/// support already defined KeyCode values.
///
public KeyCode keyCode
{
get => m_KeyCode;
set => m_KeyCode = value;
}
[SerializeField]
bool m_Disabled;
///
/// If true, the key button interactable property will be set to false.
///
public bool disabled
{
get => m_Disabled;
set => m_Disabled = value;
}
}
[SerializeField, Tooltip("Default key function for each key in this mapping.")]
KeyFunction m_DefaultKeyFunction;
///
/// Default key function for each key in this mapping.
///
/// This is a utility feature that reduces the authoring needed when most key mappings share the same
/// functionality (i.e. value keys that append characters).
public KeyFunction defaultKeyFunction
{
get => m_DefaultKeyFunction;
set => m_DefaultKeyFunction = value;
}
///
/// List of each key mapping in this layout.
///
[SerializeField, Tooltip("List of each key mapping in this layout.")]
List m_KeyMappings;
///
/// List of each key mapping in this layout.
///
public List keyMappings
{
get => m_KeyMappings;
set => m_KeyMappings = value;
}
}
}