GFInputDeviceTextProvider¶
API Reference / Standard / 类索引
- 路径:
addons/gf/standard/input/formatting/gf_input_device_text_provider.gd - 模块:
Standard - 继承:
GFInputTextProvider - API:
public - 类别:资源定义 (
resource_definition) - 首次版本:
3.17.0
通用手柄输入文本 provider。 以抽象方位和轴名称描述 Joypad 输入,项目可通过字典覆盖为任意设备、平台或本地化文本。
成员概览¶
| 类型 | 名称 | 签名 |
|---|---|---|
| 属性 | button_labels |
var button_labels: Dictionary = _DEFAULT_BUTTON_LABELS |
| 属性 | axis_labels |
var axis_labels: Dictionary = _DEFAULT_AXIS_LABELS |
| 属性 | axis_positive_suffix |
var axis_positive_suffix: String = "+" |
| 属性 | axis_negative_suffix |
var axis_negative_suffix: String = "-" |
| 属性 | axis_direction_deadzone |
var axis_direction_deadzone: float = 0.1 |
| 方法 | create_standard |
static func create_standard(provider_priority: int = 0) -> GFInputDeviceTextProvider: |
| 方法 | format_joypad_event |
static func format_joypad_event(input_event: InputEvent, options: Dictionary = {}) -> String: |
| 方法 | supports_event |
func supports_event(input_event: InputEvent, _options: Dictionary = {}) -> bool: |
| 方法 | get_event_text |
func get_event_text(input_event: InputEvent, options: Dictionary = {}) -> String: |
属性¶
button_labels¶
- API:
public
Joypad 按钮标签表,Key 为 JoyButton int。
结构:
button_labels: Dictionary,以 JoyButton int 或枚举值为键,值为 String 显示标签。
axis_labels¶
- API:
public
Joypad 轴标签表,Key 为 JoyAxis int。
结构:
axis_labels: Dictionary,以 JoyAxis int 或枚举值为键,值为 String 显示标签。
axis_positive_suffix¶
- API:
public
正向轴后缀。
axis_negative_suffix¶
- API:
public
负向轴后缀。
axis_direction_deadzone¶
- API:
public
轴方向判断死区。
方法¶
create_standard¶
- API:
public
创建标准手柄文本 provider。
参数:
| 名称 | 说明 |
|---|---|
provider_priority |
provider 优先级。 |
返回:文本 provider。
format_joypad_event¶
- API:
public
使用标准标签格式化 Joypad 输入事件。
参数:
| 名称 | 说明 |
|---|---|
input_event |
输入事件。 |
options |
可选格式化参数。 |
返回:文本;非 Joypad 事件返回空字符串。
结构:
options: Dictionary,可包含 joypad_button_labels、joypad_axis_labels、joypad_axis_deadzone、joypad_axis_positive_suffix 和 joypad_axis_negative_suffix。
supports_event¶
- API:
public
判断是否支持指定输入事件。
参数:
| 名称 | 说明 |
|---|---|
input_event |
输入事件。 |
_options |
调用选项。 |
返回:支持返回 true。
结构:
_options: Dictionary,为 provider 接口兼容性接收的选项。
get_event_text¶
- API:
public
获取输入事件文本。
参数:
| 名称 | 说明 |
|---|---|
input_event |
输入事件。 |
options |
调用选项。 |
返回:文本;不支持时返回空字符串。
结构:
options: Dictionary,可包含 joypad_button_labels、joypad_axis_labels、joypad_axis_deadzone、joypad_axis_positive_suffix 和 joypad_axis_negative_suffix。