Skip to content

Instantly share code, notes, and snippets.

@seanirby
Last active June 11, 2020 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanirby/e94953aea4db840cc5ac16e4453f49b7 to your computer and use it in GitHub Desktop.
Save seanirby/e94953aea4db840cc5ac16e4453f49b7 to your computer and use it in GitHub Desktop.
Mission Pinball Framework Config for a Joystick Target
#config_version=5
# This mode detects collisions on our joystick target. It emits these
# 5 events for each of the different collisions that can occur:
# joystick_left_hit
# joystick_diagonal_left_hit
# joystick_up_hit
# joystick_diagonal_right_hit
# joystick_right_hit
# NOTE: This mode assumes you have your joystick switches configured
# elsewhere with the following names:
# s_joystick_left
# s_joystick_up
# s_joystick_right
# Since we didn't specify any 'stop_events', this mode will always run
# when a ball is active.
mode:
start_events: ball_starting
# Our detection logic is implemented with a state machine and a couple
# timers.
state_machines:
joystick:
states:
start:
label: Joystick at rest
events_when_stopped: joystick_hit_started
first_up:
label: Next state when the joystick's up switch is the first switch closed in a collision
first_left:
label: Next state when the joystick's left switch is the first switch closed in a collision
first_right:
label: Next state when the joystick's right switch is the first switch closed in a collision
wait:
label: Timeout period where we wait for the joystick to settle
events_when_started: joystick_wait_started
transitions:
- source: start
target: first_up
events: s_joystick_up_active
- source: start
target: first_left
events: s_joystick_right_active
- source: start
target: first_right
events: s_joystick_left_active
- source: first_up
target: wait
events: timer_joystick_hit_window_complete
events_when_transitioning: joystick_up_hit
- source: first_up
target: wait
events: s_joystick_left_active
events_when_transitioning: joystick_diagonal_right_hit
- source: first_up
target: wait
events: s_joystick_right_active
events_when_transitioning: joystick_diagonal_left_hit
- source: first_left
target: wait
events: timer_joystick_hit_window_complete
events_when_transitioning: joystick_left_hit
- source: first_left
target: wait
events: s_joystick_up_active
events_when_transitioning: joystick_diagonal_left_hit
- source: first_right
target: wait
events: timer_joystick_hit_window_complete
events_when_transitioning: joystick_right_hit
- source: first_right
target: wait
events: s_joystick_up_active
events_when_transitioning: joystick_diagonal_right_hit
- source: wait
target: start
events: timer_joystick_wait_complete
timers:
# Once a collision has started, this timer is started to listen for
# other possible switches to close
joystick_hit_window:
tick_interval: 100ms
end_value: 1
control_events:
- action: start
event: joystick_hit_started
- action: reset
event: timer_joystick_hit_window_complete
# Determines how long to stay in the 'wait' state
joystick_wait:
tick_interval: 200ms
end_value: 1
control_events:
- action: start
event: joystick_wait_started
- action: reset
event: timer_joystick_wait_complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment