make layout swapping with numpad
This commit is contained in:
parent
0e63b16900
commit
1a407859e3
@ -54,11 +54,6 @@ reset_animations={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194340,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194340,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
swap_layout={
|
|
||||||
"deadzone": 0.2,
|
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194332,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|||||||
@ -48,20 +48,27 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
_rot_sod = SecondOrderDynamics.new(_rot_sod_fzr, _default_position)
|
_rot_sod = SecondOrderDynamics.new(_rot_sod_fzr, _default_position)
|
||||||
return
|
return
|
||||||
|
|
||||||
if event.is_action_pressed("swap_layout") and LayoutConfig.is_configuring:
|
|
||||||
_swap_layout()
|
|
||||||
return
|
|
||||||
|
|
||||||
if event is not InputEventKey:
|
if event is not InputEventKey:
|
||||||
return
|
return
|
||||||
|
|
||||||
var event_key := event as InputEventKey
|
var event_key := event as InputEventKey
|
||||||
|
|
||||||
|
if event_key.echo:
|
||||||
|
return
|
||||||
|
|
||||||
|
if (
|
||||||
|
event_key.is_pressed()
|
||||||
|
and LayoutConfig.is_configuring
|
||||||
|
and event_key.physical_keycode >= KEY_KP_0
|
||||||
|
and event_key.physical_keycode <= KEY_KP_9
|
||||||
|
):
|
||||||
|
_swap_layout(event_key.physical_keycode)
|
||||||
|
return
|
||||||
|
|
||||||
var keycode := event_key.get_physical_keycode_with_modifiers()
|
var keycode := event_key.get_physical_keycode_with_modifiers()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
event_key.is_pressed()
|
event_key.is_pressed()
|
||||||
and not event_key.echo
|
|
||||||
and (keycode == KEY_SHIFT | KEY_MASK_ALT or keycode == KEY_ALT | KEY_MASK_SHIFT)
|
and (keycode == KEY_SHIFT | KEY_MASK_ALT or keycode == KEY_ALT | KEY_MASK_SHIFT)
|
||||||
):
|
):
|
||||||
alt_layout = not alt_layout
|
alt_layout = not alt_layout
|
||||||
@ -147,19 +154,21 @@ func _get_row_key_step(key_props: KeyProps) -> float:
|
|||||||
|
|
||||||
|
|
||||||
#region layout swapping
|
#region layout swapping
|
||||||
func _swap_layout() -> void:
|
func _swap_layout(kp_key: Key) -> void:
|
||||||
_play_sfx(_layout_swap_sfx)
|
if kp_key == KEY_KP_1:
|
||||||
if LayoutConfig.current_layout is LayoutANSI:
|
LayoutConfig.swap_layout(LayoutANSI.name_static())
|
||||||
|
elif kp_key == KEY_KP_2:
|
||||||
LayoutConfig.swap_layout(LayoutANSIVariant.name_static())
|
LayoutConfig.swap_layout(LayoutANSIVariant.name_static())
|
||||||
elif LayoutConfig.current_layout is LayoutANSIVariant:
|
elif kp_key == KEY_KP_3:
|
||||||
LayoutConfig.swap_layout(LayoutISO.name_static())
|
LayoutConfig.swap_layout(LayoutISO.name_static())
|
||||||
elif LayoutConfig.current_layout is LayoutISO:
|
elif kp_key == KEY_KP_4:
|
||||||
LayoutConfig.swap_layout(LayoutJD40.name_static())
|
LayoutConfig.swap_layout(LayoutJD40.name_static())
|
||||||
elif LayoutConfig.current_layout is LayoutJD40:
|
elif kp_key == KEY_KP_5:
|
||||||
LayoutConfig.swap_layout(LayoutPlanck.name_static())
|
LayoutConfig.swap_layout(LayoutPlanck.name_static())
|
||||||
else:
|
else:
|
||||||
LayoutConfig.swap_layout(LayoutANSI.name_static())
|
return
|
||||||
_regenerate_keys(LayoutConfig.layout_rows)
|
_regenerate_keys(LayoutConfig.layout_rows)
|
||||||
|
_play_sfx(_layout_swap_sfx)
|
||||||
|
|
||||||
|
|
||||||
func _regenerate_keys(layout_rows: Array[Array]) -> void:
|
func _regenerate_keys(layout_rows: Array[Array]) -> void:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user