Skip to content

Instantly share code, notes, and snippets.

@WhiteMagic
Created December 10, 2016 03:13
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 WhiteMagic/237217bd870b2a7f8522bd1ae1f69202 to your computer and use it in GitHub Desktop.
Save WhiteMagic/237217bd870b2a7f8522bd1ae1f69202 to your computer and use it in GitHub Desktop.
import gremlin
# Joystick decorator
t16000 = gremlin.input_devices.JoystickDecorator(
"T.16000M",
1325664945,
"Default"
)
# Macro executed when the activation zone is entered by the axis
start_macro = gremlin.macro.Macro()
start_macro.action(gremlin.macro.Keys.LShift, True)
# Macro executed when the activation zon is left by the axis
stop_macro = gremlin.macro.Macro()
stop_macro.action(gremlin.macro.Keys.LShift, False)
# Virtual button that handles running the correct macro at the
# appropriate time
macro_axis_button = gremlin.util.AxisButton(0.8, 1.0)
# Function executing the start and stop macro as requested
def callback(is_pressed):
if is_pressed:
start_macro.run()
else:
stop_macro.run()
# Axis binding which forwards the value to a virtual axis and also has a
# macro that is executed when the throttle enters a specific region and
# executes another one upon leaving.
@t16000.axis(4)
def throttle_macro(event, vjoy):
vjoy[1].axis(4).value = event.value
macro_axis_button.process(event.value, lambda x: callback(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment