jog moving

This commit is contained in:
OniriCorpe 2024-02-11 03:36:28 +01:00
parent e565b86c19
commit bbd8ca9280
3 changed files with 97 additions and 50 deletions

View file

@ -54,25 +54,33 @@ func _unhandled_input(input_event):
if input_event is InputEventMIDI:
if debug > 0:
_print_midi_info(input_event)
# animate a beat
if !midi_beat and input_event.channel == beat_channel and ((input_event.pitch == beat_note and input_event.velocity == 127) or input_event.controller_number == 10):
if !midi_beat:
$beat/AnimationPlayer.play("beat")
midi_beat = true
if input_event.channel == beat_channel and ((input_event.pitch == beat_note and input_event.velocity == 0) or input_event.controller_number == 9):
elif input_event.channel == beat_channel and ((input_event.pitch == beat_note and input_event.velocity == 0) or input_event.controller_number == 9):
if midi_beat:
$beat/AnimationPlayer.play_backwards("beat")
$beat/AnimationPlayer.play("RESET")
midi_beat = false
# animate a grabbed jog
if input_event.channel == jog_channel and ((input_event.pitch == jog_note and input_event.velocity == 127) or input_event.controller_number == spin_note_1):
if !midi_jog:
$jog/AnimationPlayer.play("jog")
midi_jog = true
if input_event.channel == jog_channel and ((input_event.pitch == jog_note and input_event.velocity == 0) or input_event.controller_number == spin_note_2):
elif input_event.channel == jog_channel and ((input_event.pitch == jog_note and input_event.velocity == 0) or input_event.controller_number == spin_note_2):
if midi_jog:
$jog/AnimationPlayer.play_backwards("jog")
$jog/AnimationPlayer.play("RESET")
midi_jog = false
# animate a moving jog
if (input_event.channel == spin_channel_1 or input_event.channel == spin_channel_2) and input_event.controller_value == left:
$jog/AnimationPlayer.play("move")
midi_turnleft = true
if (input_event.channel == spin_channel_1 or input_event.channel == spin_channel_2) and input_event.controller_value == right:
elif (input_event.channel == spin_channel_1 or input_event.channel == spin_channel_2) and input_event.controller_value == right:
$jog/AnimationPlayer.play_backwards("move")
midi_turnright = true
@ -110,6 +118,12 @@ func _process(_delta):
# trigger the right controller
print("turn right")
if !midi_turnleft and !midi_turnright:
if !midi_jog:
$jog/AnimationPlayer.play("RESET")
# reset the turn values before the next cycle
# needed because it can't be turned to false in the _unhandled_input function
# because apparently there is no MIDI command sended for that .___.