activate function to edit control

This commit is contained in:
AleaJactaEst 2022-02-25 01:28:14 +01:00
parent 4a29b547e5
commit 9ab0c999d8
18 changed files with 468 additions and 161 deletions

View file

@ -79,3 +79,37 @@ msgstr "OK"
msgid "Cancel"
msgstr "Cancel"
msgid "CONTROL_SELECT_TYPE/TITLE"
msgstr "Select type control"
msgid "CONTROL_SELECT_TYPE/KEY"
msgstr "Keyboard"
msgid "CONTROL_SELECT_TYPE/MOUSE"
msgstr "Button Mouse"
msgid "CONTROL_SELECT_TYPE/JOYPAD"
msgstr "Button Joypad"
msgid "CONTROL_SELECT_TYPE/QUIT"
msgstr "Cancel"
msgid "OPTION_DEFINE_INPUT/TITLE"
msgstr "Define input"
msgid "OPTION_DEFINE_INPUT/CANCEL"
msgstr "Cancel"
msgid "OPTION_DEFINE_INPUT/OK"
msgstr "OK"
msgid "OPTION_DEFINE_INPUT/MESSAGE_KEY"
msgstr "Please select your key"
msgid "OPTION_DEFINE_INPUT/MESSAGE_MOUSE"
msgstr "Please select your button mouse"
msgid "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
msgstr "Please select your button joypad"

View file

@ -48,7 +48,7 @@ msgid "EDIT_CONTROL/TITLE"
msgstr "Modifier les contrôles"
msgid "EDIT_CONTROL/SORT_BY_INPUT"
msgstr "Trié par rapport aux entrées"
msgstr "Trier par rapport aux entrées"
msgid "EDIT_CONTROL/RELOAD_SYSTEM_CONFIG"
msgstr "Recharger la configuration système"
@ -75,7 +75,40 @@ msgid "POPUP_CONFIRM_QUIT/MESSAGE"
msgstr "Voulez-vous fermer le jeux ?"
msgid "OK"
msgstr "Oui"
msgstr "Valider"
msgid "Cancel"
msgstr "Annuler"
msgid "CONTROL_SELECT_TYPE/TITLE"
msgstr "Sélectionner le type de contrôle"
msgid "CONTROL_SELECT_TYPE/KEY"
msgstr "Clavier"
msgid "CONTROL_SELECT_TYPE/MOUSE"
msgstr "Bouton de souris"
msgid "CONTROL_SELECT_TYPE/JOYPAD"
msgstr "Bouton de manette"
msgid "CONTROL_SELECT_TYPE/QUIT"
msgstr "Sortir"
msgid "OPTION_DEFINE_INPUT/TITLE"
msgstr "Définir votre entrée"
msgid "OPTION_DEFINE_INPUT/CANCEL"
msgstr "Annuler"
msgid "OPTION_DEFINE_INPUT/OK"
msgstr "Valider"
msgid "OPTION_DEFINE_INPUT/MESSAGE_KEY"
msgstr "Merci d'appuyer sur une touche"
msgid "OPTION_DEFINE_INPUT/MESSAGE_MOUSE"
msgstr "Merci d'appuyer sur un bouton de la souris"
msgid "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
msgstr "Merci d'appuyer sur un bouton de votre manette de jeux"

Binary file not shown.

View file

@ -70,3 +70,37 @@ msgstr ""
msgid "Cancel"
msgstr ""
msgid "CONTROL_SELECT_TYPE/TITLE"
msgstr ""
msgid "CONTROL_SELECT_TYPE/KEY"
msgstr ""
msgid "CONTROL_SELECT_TYPE/MOUSE"
msgstr ""
msgid "CONTROL_SELECT_TYPE/JOYPAD"
msgstr ""
msgid "CONTROL_SELECT_TYPE/QUIT"
msgstr ""
msgid "OPTION_DEFINE_INPUT/TITLE"
msgstr ""
msgid "OPTION_DEFINE_INPUT/CANCEL"
msgstr ""
msgid "OPTION_DEFINE_INPUT/OK"
msgstr ""
msgid "OPTION_DEFINE_INPUT/MESSAGE_KEY"
msgstr ""
msgid "OPTION_DEFINE_INPUT/MESSAGE_MOUSE"
msgstr ""
msgid "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
msgstr ""

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -18,6 +18,7 @@ config/features=PackedStringArray("4.0", "Vulkan Clustered")
[autoload]
Themes="*res://scripts/themes.gd"
Common="*res://scripts/common.gd"
[input]

View file

@ -6,10 +6,10 @@ signal del_pressed( command, control, eventInput )
var command:String
var eventInput
func set_param( command:String, control:String, param_comment:String, eventInput ):
self.command = command
func set_param( _command:String, control:String, param_comment:String, _eventInput ):
self.command = _command
$Label.text = control
self.eventInput = eventInput
self.eventInput = _eventInput
if param_comment.length() > 0:
$Comment.text = param_comment
$Empty.visible = false

View file

@ -1,6 +1,6 @@
extends Control
signal reload_control
#signal reload_control
var control_system_conf = {}
@ -10,11 +10,11 @@ func _init():
func _ready():
pass
$SelectType.connect("refresh_select_type_control", refresh.bind() )
func reload_system_config():
pass
func refresh():
configure_control()
func reload_control_system():
@ -37,7 +37,7 @@ func reload_control_system():
if not foundAction:
InputMap.erase_action(keyInput)
continue
var listInput = InputMap.get_action_list(keyInput)
var listInput = InputMap.action_get_events(keyInput)
for eventInput in listInput:
var foundEvent:bool = false
var vis = get_dict_inputevent(eventInput)
@ -47,6 +47,7 @@ func reload_control_system():
break
if not foundEvent:
InputMap.action_erase_event(keyInput, eventInput)
configure_control()
func compare_dict_inputevent(ref, cmp):
@ -84,16 +85,16 @@ func get_dict_inputevent(event):
func generate_inputevent(param):
if param['type'] == 'InputEventKey':
var ele:InputEventKey = InputEventKey.new()
ele.set_physical_scancode(param['physical_scancode'])
ele.set_scancode(param['scancode'])
ele.set_keycode(param['keycode'])
ele.set_physical_keycode(param['physical_keycode'])
ele.set_unicode(param['unicode'])
ele.set_echo(param['echo'])
if OS.get_ime_selection():
ele.set_unicode(param['unicode'])
ele.set_alt(param['alt'])
ele.set_command(param['command'])
ele.set_control(param['control'])
ele.set_metakey(param['meta'])
ele.set_shift(param['shift'])
ele.set_alt_pressed(param['alt'])
ele.set_command_pressed(param['command'])
ele.set_ctrl_pressed(param['control'])
ele.set_meta_pressed(param['meta'])
ele.set_shift_pressed(param['shift'])
ele.set_store_command(param['storing_command'])
return ele
elif param['type'] == 'InputEventMouseButton':
var ele:InputEventMouseButton = InputEventMouseButton.new()
@ -116,101 +117,7 @@ func get_hash_inputevent(event):
head = 'j'
else:
head ='z'
return head + str(get_string_input(event))
func get_string_input_mousse_button(event:InputEventMouseButton):
match event.get_button_index():
1:
return "BUTTON_LEFT"
3:
return "BUTTON_MIDDLE"
2:
return "BUTTON_RIGHT"
4:
return "BUTTON_WHEEL_UP"
5:
return "BUTTON_WHEEL_DOWN"
6:
return "BUTTON_WHEEL_LEFT"
7:
return "BUTTON_WHEEL_RIGHT"
8:
return "BUTTON_XBUTTON1"
9:
return "BUTTON_XBUTTON2"
_:
return "MOUSSE BUTTON: " + str(event.get_button_index())
func get_string_input_joypad_button(event:InputEventJoypadButton):
match event.get_button_index():
0:
return "JOY_BUTTON_A"
1:
return "JOY_BUTTON_B"
2:
return "JOY_BUTTON_X"
3:
return "JOY_BUTTON_Y"
4:
return "JOY_BUTTON_BACK"
5:
return "JOY_BUTTON_GUIDE"
6:
return "JOY_BUTTON_START"
7:
return "JOY_BUTTON_LEFT_STICK"
8:
return "JOY_BUTTON_RIGHT_STICK"
9:
return "JOY_BUTTON_LEFT_SHOULDER"
10:
return "JOY_BUTTON_RIGHT_SHOULDER"
11:
return "JOY_BUTTON_DPAD_UP"
12:
return "JOY_BUTTON_DPAD_DOWN"
13:
return "JOY_BUTTON_DPAD_LEFT"
14:
return "JOY_BUTTON_DPAD_RIGHT"
_:
return "JOYPAD BUTTON: " + str(event.get_button_index())
func get_string_input_keyboard(event:InputEventKey):
var option:String = ""
if event.is_ctrl_pressed():
option += "Control+"
if event.is_shift_pressed():
option += "Shift+"
if event.is_alt_pressed():
option += "Alt+"
if event.is_meta_pressed():
option += "MetaKey+"
# if event.is_command_pressed():
# option += "Command+"
if event.keycode == 0:
if event.physical_keycode > 0:
return option + OS.get_keycode_string(event.physical_keycode)
else:
print("Error Event unknown keycode:" , event.keycode, ", physical_keycode:", event.physical_keycode)
return option + OS.get_keycode_string(event.keycode)
func get_string_input(event):
if event is InputEventKey:
return get_string_input_keyboard(event) # OS.get_scancode_string(event.get_scancode_with_modifiers())
elif event is InputEventMouseButton:
return get_string_input_mousse_button(event)
elif event is InputEventJoypadButton:
return get_string_input_joypad_button(event)
else:
return str(event)
return head + str(Common.get_string_input(event))
func load_current_control():
@ -225,7 +132,6 @@ func load_current_control():
func configure_control():
print("update list control")
if $Window/VBox/Menu/SortByInput.is_pressed():
configure_control_sort_by_input()
else:
@ -253,65 +159,51 @@ func configure_control_sort_by_input():
lastevent = zhash
if z is InputEventKey:
var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate() #.instance()
item.set_param(action, "Key: " + get_string_input_keyboard(z), action, z)
#item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
item.set_param(action, "Key: " + Common.get_string_input_keyboard(z), action, z)
item.connect( "del_pressed", _on_input_box_del_pressed.bind() )
#print(action,':', z, z.get_scancode_with_modifiers(),' - ', z.get_scancode(), ' - ', z.unicode , ' - ', OS.get_scancode_string(z.get_scancode_with_modifiers()))
$Window/VBox/Input/Control.add_child( item )
#$Window/VBox/Test.add_child( item )
elif z is InputEventMouseButton:
var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate()
#item.set_label(action, "Mouse Button: " + str(z.get_button_index()))
item.set_param(action, "Mouse Button: " + get_string_input_mousse_button(z), action, z)
#item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
item.set_param(action, "Mouse Button: " + Common.get_string_input_mousse_button(z), action, z)
item.connect( "del_pressed", _on_input_box_del_pressed.bind() )
$Window/VBox/Input/Control.add_child( item )
#print(action,':', z, z.get_button_mask(), ' - ', z.get_factor(), ' - ' , z.get_button_index() )
elif z is InputEventJoypadButton:
#print(action,':', z, z.get_button_index() )
var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate()
#item.set_label(action, "Joypad Button: " + str(z.get_button_index()))
item.set_param(action, "Joypad Button: " + get_string_input_joypad_button(z), action, z)
#item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
item.set_param(action, "Joypad Button: " + Common.get_string_input_joypad_button(z), action, z)
item.connect( "del_pressed", _on_input_box_del_pressed.bind() )
$Window/VBox/Input/Control.add_child( item )
for action in InputMap.get_actions():
var separator = HSeparator.new()
$Window/VBox/Input/Control.add_child( separator )
var control_box = preload( "res://scenes/controls/control_function.tscn" ).instantiate()
#control_box.set_label(key)
control_box.set_param(action, action, true)
control_box.connect( "add_pressed", _on_control_box_add_pressed.bind() )
$Window/VBox/Input/Control.add_child( control_box )
func configure_control_sort_by_categories():
print("configure_control_sort_by_categories")
for child in $Window/VBox/Input/Control.get_children():
child.queue_free()
for action in InputMap.get_actions():
var control_box = preload( "res://scenes/controls/control_function.tscn" ).instantiate()
#control_box.set_label(key)
control_box.set_param(action, action, false)
control_box.connect( "add_pressed", _on_control_box_add_pressed.bind() )
$Window/VBox/Input/Control.add_child( control_box )
var a = InputMap.action_get_events(action)
for z in a:
#print(action,':', z)
if z is InputEventKey:
var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate()
item.set_param(action, "Key: " + get_string_input_keyboard(z), "", z)
item.set_param(action, "Key: " + Common.get_string_input_keyboard(z), "", z)
item.connect( "del_pressed", _on_input_box_del_pressed.bind() )
$Window/VBox/Input/Control.add_child( item )
elif z is InputEventMouseButton:
var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate()
#item.set_label(action, "Mouse Button: " + str(z.get_button_index()))
item.set_param(action, "Mouse Button: " + get_string_input_mousse_button(z), "", z)
item.set_param(action, "Mouse Button: " + Common.get_string_input_mousse_button(z), "", z)
item.connect( "del_pressed", _on_input_box_del_pressed.bind() )
$Window/VBox/Input/Control.add_child( item )
elif z is InputEventJoypadButton:
var item = preload( "res://scenes/controls/control_input.tscn" ).instantiate()
item.set_param(action, "Joypad Button: " + get_string_input_joypad_button(z), "", z)
item.set_param(action, "Joypad Button: " + Common.get_string_input_joypad_button(z), "", z)
item.connect( "del_pressed", _on_input_box_del_pressed.bind() )
$Window/VBox/Input/Control.add_child( item )
var separator = HSeparator.new()
@ -331,11 +223,12 @@ func _on_sort_by_input_pressed():
func _on_input_box_del_pressed(command, control, inputevent):
print("Del:" + command + " " + control)
emit_signal("reload_control")
InputMap.action_erase_event(command, inputevent)
configure_control()
func _on_control_box_add_pressed(action, command):
print("Start Add:" + command)
# get_input(action, "Appuyer sur votre touche")
$SelectType.set_param(action, "signal_refresh" )
$SelectType/Window.popup_centered()
$SelectType/Window.visible = true

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://cl8xk8w3jmta0"]
[gd_scene load_steps=3 format=3 uid="uid://cl8xk8w3jmta0"]
[ext_resource type="Script" path="res://scenes/controls/controls.gd" id="1_2c8s6"]
[ext_resource type="PackedScene" uid="uid://bhidap7eniou8" path="res://scenes/controls/select_type_control.tscn" id="2_ps0mu"]
[node name="Control" type="Control"]
visible = false
@ -70,7 +71,9 @@ size_flags_horizontal = 6
size_flags_vertical = 8
text = "EDIT_CONTROL/QUIT"
[node name="SelectType" parent="." instance=ExtResource( "2_ps0mu" )]
[connection signal="close_requested" from="Window" to="." method="_on_quit_pressed"]
[connection signal="pressed" from="Window/VBox/Menu/SortByInput" to="." method="_on_sort_by_input_pressed"]
[connection signal="pressed" from="Window/VBox/Menu/Reload" to="." method="reload_system_config"]
[connection signal="pressed" from="Window/VBox/Menu/Reload" to="." method="reload_control_system"]
[connection signal="pressed" from="Window/VBox/Quit" to="." method="_on_quit_pressed"]

View file

@ -0,0 +1,57 @@
extends Control
signal refresh_control_define_input
var type_event:int
var action = null
var last_event = null
func _ready():
type_event = 0
func set_disabled(state:bool):
$Window/v/h/Ok.disabled = state
func set_param(typeevent:int, _action):
var comment = ""
if typeevent == 1:
comment = "OPTION_DEFINE_INPUT/MESSAGE_KEY"
elif typeevent == 2:
comment = "OPTION_DEFINE_INPUT/MESSAGE_MOUSE"
else:
comment = "OPTION_DEFINE_INPUT/MESSAGE_JOYPAD"
type_event = typeevent
action = _action
last_event = null
$Window/v/result.set_text("")
$Window/v/label.set_text(comment)
set_disabled(true)
func _on_cancel_pressed():
$Window.hide()
func _on_ok_pressed():
$Window.hide()
InputMap.action_add_event(action, last_event)
emit_signal("refresh_control_define_input")
func _on_window_window_input(event):
if event.is_pressed() == false:
return
if (event is InputEventKey) && (self.type_event == 1):
last_event = event
$Window/v/result.set_text( Common.get_string_input(event) )
elif event is InputEventMouseButton and self.type_event == 2:
last_event = event
$Window/v/result.set_text( Common.get_string_input(event) )
elif event is InputEventJoypadButton and self.type_event == 3:
last_event = event
$Window/v/result.set_text( Common.get_string_input(event) )
if last_event != null:
set_disabled(false)

View file

@ -0,0 +1,55 @@
[gd_scene load_steps=2 format=3 uid="uid://cvmel2sx7qfvy"]
[ext_resource type="Script" path="res://scenes/controls/option_define_input.gd" id="1_pgm2r"]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( "1_pgm2r" )
[node name="Window" type="Window" parent="."]
title = "OPTION_DEFINE_INPUT/TITLE"
position = Vector2i(30, 70)
visible = false
[node name="v" type="VBoxContainer" parent="Window"]
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
__meta__ = {
"_edit_use_custom_anchors": false
}
[node name="label" type="Label" parent="Window/v"]
offset_right = 1024.0
offset_bottom = 26.0
text = "OPTION_DEFINE_INPUT/MESSAGE_KEY"
[node name="result" type="Label" parent="Window/v"]
offset_top = 30.0
offset_right = 1024.0
offset_bottom = 53.0
[node name="h" type="HBoxContainer" parent="Window/v"]
offset_top = 57.0
offset_right = 1024.0
offset_bottom = 88.0
size_flags_vertical = 3
[node name="Cancel" type="Button" parent="Window/v/h"]
offset_right = 255.0
offset_bottom = 31.0
size_flags_horizontal = 6
text = "OPTION_DEFINE_INPUT/CANCEL"
[node name="Ok" type="Button" parent="Window/v/h"]
offset_left = 259.0
offset_right = 476.0
offset_bottom = 31.0
size_flags_horizontal = 6
text = "OPTION_DEFINE_INPUT/OK"
[connection signal="window_input" from="Window" to="." method="_on_window_window_input"]
[connection signal="pressed" from="Window/v/h/Cancel" to="." method="_on_cancel_pressed"]
[connection signal="pressed" from="Window/v/h/Ok" to="." method="_on_ok_pressed"]

View file

@ -0,0 +1,47 @@
extends Control
signal refresh_select_type_control
var action = null
var signalrefresh = null
func _ready():
$DefineInput.connect("refresh_control_define_input", refresh.bind() )
func refresh():
emit_signal("refresh_select_type_control")
func set_param(_action, _signalrefresh):
self.action = _action
self.signalrefresh = _signalrefresh
func _on_quit_pressed():
$Window.visible = false
func get_input(typevent) -> void:
$Window.visible = false
if typevent == 1:
$DefineInput.set_param(typevent, self.action)
elif typevent == 2:
$DefineInput.set_param(typevent, self.action)
else:
$DefineInput.set_param(typevent, self.action)
$DefineInput/Window.popup_centered()
$DefineInput/Window.visible = true
func _on_key_pressed():
get_input(1)
func _on_mouse_pressed():
get_input(2)
func _on_joypad_pressed():
get_input(3)

View file

@ -0,0 +1,55 @@
[gd_scene load_steps=3 format=3 uid="uid://bhidap7eniou8"]
[ext_resource type="Script" path="res://scenes/controls/select_type_control.gd" id="1_7tgwh"]
[ext_resource type="PackedScene" uid="uid://cvmel2sx7qfvy" path="res://scenes/controls/option_define_input.tscn" id="2_44t37"]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( "1_7tgwh" )
[node name="Window" type="Window" parent="."]
title = "CONTROL_SELECT_TYPE/TITLE"
position = Vector2i(30, 70)
size = Vector2i(300, 100)
visible = false
[node name="VBoxContainer" type="VBoxContainer" parent="Window"]
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
__meta__ = {
"_edit_use_custom_anchors": false
}
[node name="Key" type="Button" parent="Window/VBoxContainer"]
offset_right = 1024.0
offset_bottom = 31.0
text = "CONTROL_SELECT_TYPE/KEY"
[node name="Mouse" type="Button" parent="Window/VBoxContainer"]
offset_top = 41.0
offset_right = 1024.0
offset_bottom = 72.0
text = "CONTROL_SELECT_TYPE/MOUSE"
[node name="Joypad" type="Button" parent="Window/VBoxContainer"]
offset_top = 82.0
offset_right = 1024.0
offset_bottom = 113.0
text = "CONTROL_SELECT_TYPE/JOYPAD"
[node name="Quit" type="Button" parent="Window/VBoxContainer"]
offset_top = 123.0
offset_right = 1024.0
offset_bottom = 154.0
text = "CONTROL_SELECT_TYPE/QUIT"
[node name="DefineInput" parent="." instance=ExtResource( "2_44t37" )]
[connection signal="close_requested" from="Window" to="." method="_on_quit_pressed"]
[connection signal="pressed" from="Window/VBoxContainer/Key" to="." method="_on_key_pressed"]
[connection signal="pressed" from="Window/VBoxContainer/Mouse" to="." method="_on_mouse_pressed"]
[connection signal="pressed" from="Window/VBoxContainer/Joypad" to="." method="_on_joypad_pressed"]
[connection signal="pressed" from="Window/VBoxContainer/Quit" to="." method="_on_quit_pressed"]

View file

@ -36,7 +36,6 @@ visible = false
anchor_right = 1.0
offset_right = 40.0
offset_bottom = 40.0
theme_override_constants/separation = 10
alignment = 1
__meta__ = {
"_edit_use_anchors_": false

View file

@ -39,7 +39,7 @@ func _on_quit_pressed():
$Window.visible = false
func _on_select_item_selected(index):
func _on_select_item_selected(_index):
var pos = 0
for key in Themes.THEMES_CONTROL:
if pos == $Window/VBoxContainer/Select.get_selected():

96
scripts/common.gd Normal file
View file

@ -0,0 +1,96 @@
extends Node
func get_string_input_mousse_button(event:InputEventMouseButton) -> String:
match event.get_button_index():
1:
return "BUTTON_LEFT"
3:
return "BUTTON_MIDDLE"
2:
return "BUTTON_RIGHT"
4:
return "BUTTON_WHEEL_UP"
5:
return "BUTTON_WHEEL_DOWN"
6:
return "BUTTON_WHEEL_LEFT"
7:
return "BUTTON_WHEEL_RIGHT"
8:
return "BUTTON_XBUTTON1"
9:
return "BUTTON_XBUTTON2"
_:
return "MOUSSE BUTTON: " + str(event.get_button_index())
func get_string_input_joypad_button(event:InputEventJoypadButton) -> String:
match event.get_button_index():
0:
return "JOY_BUTTON_A"
1:
return "JOY_BUTTON_B"
2:
return "JOY_BUTTON_X"
3:
return "JOY_BUTTON_Y"
4:
return "JOY_BUTTON_BACK"
5:
return "JOY_BUTTON_GUIDE"
6:
return "JOY_BUTTON_START"
7:
return "JOY_BUTTON_LEFT_STICK"
8:
return "JOY_BUTTON_RIGHT_STICK"
9:
return "JOY_BUTTON_LEFT_SHOULDER"
10:
return "JOY_BUTTON_RIGHT_SHOULDER"
11:
return "JOY_BUTTON_DPAD_UP"
12:
return "JOY_BUTTON_DPAD_DOWN"
13:
return "JOY_BUTTON_DPAD_LEFT"
14:
return "JOY_BUTTON_DPAD_RIGHT"
_:
return "JOYPAD BUTTON: " + str(event.get_button_index())
func get_string_input_keyboard(event:InputEventKey) -> String:
var option:String = ""
if event.is_ctrl_pressed():
option += "Control+"
if event.is_shift_pressed():
option += "Shift+"
if event.is_alt_pressed():
option += "Alt+"
if event.is_meta_pressed():
option += "MetaKey+"
# if event.is_command_pressed():
# option += "Command+"
if event.keycode == 0:
if event.physical_keycode > 0:
return option + OS.get_keycode_string(event.physical_keycode)
else:
print("Error Event unknown keycode:" , event.keycode, ", physical_keycode:", event.physical_keycode)
return option + OS.get_keycode_string(event.keycode)
func get_string_input(event) -> String:
if event is InputEventKey:
return get_string_input_keyboard(event) # OS.get_scancode_string(event.get_scancode_with_modifiers())
elif event is InputEventMouseButton:
return get_string_input_mousse_button(event)
elif event is InputEventJoypadButton:
return get_string_input_joypad_button(event)
else:
return str(event)