gamepad test (wip)

This commit is contained in:
Page Asgardius 2024-01-26 21:38:12 -07:00
parent 4c6e795a74
commit 02d51b083e
5 changed files with 173 additions and 3 deletions

View file

@ -17,6 +17,17 @@ func _ready():
if OS.get_environment("MANGOHUD").contains("1"):
Global.mangohud = true
welcometext = welcometext+"\nYour overlay already has a FPS counter, built-in one is disabled"
#This can be used to detect background process, may be useful later
#var output = []
# Execute "get-process" in powershell and save data in "output":
#var chrome_active = false
#OS.execute('/bin/bash', ['-c', "ps aux | grep obs"], output, true)
#var result = output[0].rsplit("/", true, 7).size()
#print(output)
#chrome_active = result > 5 # If there is more than 0 chrome processes, it will be true
#if chrome_active:
# welcometext = welcometext+"\nBe careful"
#print("Number of chrome processes: " + str(result))
set_text(welcometext)
func _sk():

View file

@ -2,7 +2,7 @@ extends Control
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
Global.debug = true
$"VBoxContainer/Scene Selector".grab_focus()
$"VBoxContainer/Gamepad Test".grab_focus()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
@ -51,3 +51,7 @@ func _on_sound_test_pressed():
func _on_back_pressed():
Global.debug = false
get_tree().change_scene_to_file("res://levels/ui/tmenu.tscn")
func _on_gamepad_test_pressed():
get_tree().change_scene_to_file("res://levels/ui/gamepadtest.tscn")

View file

@ -54,7 +54,13 @@ offset_right = 129.5
grow_horizontal = 2
grow_vertical = 0
[node name="Scene Selector" type="Button" parent="VBoxContainer"]
[node name="Gamepad Test" type="Button" parent="VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 80
theme_override_styles/focus = SubResource("StyleBoxFlat_821nm")
text = "Gamepad Test"
[node name="Scene Selector2" type="Button" parent="VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 80
theme_override_styles/focus = SubResource("StyleBoxFlat_821nm")
@ -76,6 +82,7 @@ text = "Back"
layout_mode = 1
[connection signal="finished" from="nebula" to="nebula" method="_on_finished"]
[connection signal="pressed" from="VBoxContainer/Scene Selector" to="." method="_on_scene_selector_pressed"]
[connection signal="pressed" from="VBoxContainer/Gamepad Test" to="." method="_on_gamepad_test_pressed"]
[connection signal="pressed" from="VBoxContainer/Scene Selector2" to="." method="_on_scene_selector_pressed"]
[connection signal="pressed" from="VBoxContainer/Sound Test" to="." method="_on_sound_test_pressed"]
[connection signal="pressed" from="VBoxContainer/Back" to="." method="_on_back_pressed"]

37
levels/ui/gamepadtest.gd Normal file
View file

@ -0,0 +1,37 @@
extends Control
var joyname
var lxaxis
var lyaxis
var rxaxis
var ryaxis
var dpadup
var dpaddown
var dpadleft
var dpadright
# Called when the node enters the scene tree for the first time.
func _ready():
joyname = $Info
lxaxis = $"BoxContainer/VBoxContainer/Left X Axis"
lyaxis = $"BoxContainer/VBoxContainer/Left Y Axis"
rxaxis = $"BoxContainer/VBoxContainer2/Right X Axis"
ryaxis = $"BoxContainer/VBoxContainer2/Right Y Axis"
dpadup = $"BoxContainer/VBoxContainer/DPAD Up"
dpaddown = $"BoxContainer/VBoxContainer2/DPAD Down"
#pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _input(event):
if Input.is_key_pressed(KEY_ESCAPE) || (Input.is_joy_button_pressed(0,JOY_BUTTON_A) && (Input.is_joy_button_pressed(0,JOY_BUTTON_B))):
get_tree().change_scene_to_file("res://levels/ui/debug.tscn")
joyname.set_text("Current Device: "+str(Input.get_joy_name(0)))
lxaxis.set_text("Left X Axis "+str(Input.get_joy_axis(0,JOY_AXIS_LEFT_X)))
lyaxis.set_text("Left Y Axis "+str(Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)))
rxaxis.set_text("Right X Axis "+str(Input.get_joy_axis(0,JOY_AXIS_RIGHT_X)))
ryaxis.set_text("Right Y Axis "+str(Input.get_joy_axis(0,JOY_AXIS_RIGHT_Y)))

111
levels/ui/gamepadtest.tscn Normal file
View file

@ -0,0 +1,111 @@
[gd_scene load_steps=5 format=3 uid="uid://qun4scsrsp00"]
[ext_resource type="Script" path="res://levels/ui/gamepadtest.gd" id="1_w4qrm"]
[ext_resource type="VideoStream" path="res://backgounds/nebula_-_6044 (720p).ogv" id="2_i62na"]
[ext_resource type="Script" path="res://nebula.gd" id="3_5yjm5"]
[ext_resource type="PackedScene" uid="uid://d31udhuuwrajn" path="res://levels/bottomhud.tscn" id="4_88ejd"]
[node name="Gamepadtest" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_w4qrm")
[node name="nebula" type="VideoStreamPlayer" parent="."]
layout_mode = 0
offset_right = 640.0
offset_bottom = 368.0
scale = Vector2(2, 1.96)
stream = ExtResource("2_i62na")
autoplay = true
script = ExtResource("3_5yjm5")
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
[node name="Game name" type="Label" parent="."]
layout_mode = 0
offset_left = 496.0
offset_top = 3.0
offset_right = 790.0
offset_bottom = 73.0
theme_override_font_sizes/font_size = 40
text = "Gamepad Test"
[node name="Info" type="Label" parent="."]
layout_mode = 0
offset_left = 28.0
offset_top = 94.0
offset_right = 322.0
offset_bottom = 164.0
theme_override_font_sizes/font_size = 20
[node name="Stop" type="Label" parent="."]
layout_mode = 0
offset_left = 5.0
offset_top = 672.0
offset_right = 444.0
offset_bottom = 708.0
theme_override_font_sizes/font_size = 22
text = "Press Escape or A + B to return"
[node name="BoxContainer" type="BoxContainer" parent="."]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -640.0
offset_top = -419.0
grow_horizontal = 0
grow_vertical = 0
[node name="VBoxContainer" type="VBoxContainer" parent="BoxContainer"]
layout_mode = 2
[node name="Left X Axis" type="Label" parent="BoxContainer/VBoxContainer"]
layout_mode = 2
text = "Left X Axis"
[node name="Left Y Axis" type="Label" parent="BoxContainer/VBoxContainer"]
layout_mode = 2
text = "Left Y Axis"
[node name="DPAD Up" type="Label" parent="BoxContainer/VBoxContainer"]
layout_mode = 2
text = "DPAD Up"
[node name="DPAD Left" type="Label" parent="BoxContainer/VBoxContainer"]
layout_mode = 2
text = "X Axis"
[node name="VBoxContainer2" type="VBoxContainer" parent="BoxContainer"]
layout_mode = 2
[node name="Right X Axis" type="Label" parent="BoxContainer/VBoxContainer2"]
layout_mode = 2
text = "Right X Axis"
[node name="Right Y Axis" type="Label" parent="BoxContainer/VBoxContainer2"]
layout_mode = 2
text = "Right Y Axis"
[node name="DPAD Down" type="Label" parent="BoxContainer/VBoxContainer2"]
layout_mode = 2
text = "DPAD Down
"
[node name="DPAD Right" type="Label" parent="BoxContainer/VBoxContainer2"]
layout_mode = 2
text = "Y Axis"
[node name="Bottomhud" parent="." instance=ExtResource("4_88ejd")]
layout_mode = 1
[connection signal="finished" from="nebula" to="nebula" method="_on_finished"]