Skip to content

Instantly share code, notes, and snippets.

@WhiteMagic
Last active August 12, 2023 10:08
Show Gist options
  • Save WhiteMagic/3509b15e8f11f7af7846189f2380b3bd to your computer and use it in GitHub Desktop.
Save WhiteMagic/3509b15e8f11f7af7846189f2380b3bd to your computer and use it in GitHub Desktop.
import gremlin
from vjoy.vjoy import AxisName
hog = gremlin.input_devices.JoystickDecorator(
"Joystick - HOTAS Warthog",
gremlin.common.DeviceIdentifier(72287234, 1),
"Default"
)
# Sensitivity curve setup and deadzone
default_curve = gremlin.spline.CubicSpline([
(-1.00, -1.00),
(-0.75, -0.65),
(-0.25, -0.15),
( 0.00, 0.00),
( 0.25, 0.15),
( 0.75, 0.65),
( 1.00, 1.00),
])
deadzone = lambda value: gremlin.input_devices.deadzone(
value,
-1.0,
-0.05,
0.05,
1.0
)
# Create a macro that can be used repeatedly
key_macro = gremlin.macro.Macro()
key_macro.add_action(gremlin.macro.KeyAction(gremlin.macro.key_from_name("A"), True))
key_macro.add_action(gremlin.macro.PauseAction(0.1))
key_macro.add_action(gremlin.macro.KeyAction(gremlin.macro.key_from_name("A"), False))
@hog.button(1)
def fire_group1(event, vjoy):
vjoy[1].button(1).is_pressed = event.is_pressed
@hog.button(2)
def press_a(event):
if event.is_pressed:
gremlin.macro.MacroManager().queue_macro(key_macro)
@hog.axis(1)
def axis1(event, vjoy):
vjoy[1].axis(AxisName.X).value = default_curve(deadzone(event.value))
@hog.axis(2)
def axis2(event, vjoy):
vjoy[1].axis(AxisName.Y).value = default_curve(deadzone(event.value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment