Thank you soooo much quijipixel!!! I would not have been able to do this without you!!
With your help I managed to create code which works and does the job exactly as I wanted. Here it is:
Variables:
const JOY_DEADZONE = 0.3
var axis1_x_value = 0
var axis1_y_value = 0
var pressed = false
var pressed2 = false
btns = [Array which contains all my Menu Buttons that I want to navigate through ]
Refreshing Axis:
func _fixed_process(delta):
axis1_x_value = Input.get_joy_axis(0, JOY_ANALOG_0_X)
axis1_y_value = Input.get_joy_axis(0, JOY_ANALOG_0_Y)
Listening to Input:
func _input(event):
# Down
btns[select_pos].grab_focus()
if btns[select_pos] == btns[btns.size() - 1] and axis1_y_value > JOY_DEADZONE and !pressed:
select_pos = -1
btns[select_pos].grab_focus()
if !pressed:
if axis1_y_value > JOY_DEADZONE:
select_pos += 1
pressed = true
elif pressed:
if not axis1_y_value > JOY_DEADZONE:
pressed = false
# Up
if btns[select_pos] == btns[-1] and axis1_y_value < -JOY_DEADZONE and !pressed2:
select_pos = btns.size()-1
btns[select_pos].grab_focus()
if !pressed2:
if axis1_y_value < -JOY_DEADZONE:
select_pos -= 1
pressed2 = true
elif pressed2:
if not axis1_y_value < -JOY_DEADZONE:
pressed2 = false
It is not a very clean, effective or well thought out code. But it works.
Thank you :)