Skip to content

Instantly share code, notes, and snippets.

@WhiteMagic
Created December 9, 2018 04:34
Show Gist options
  • Save WhiteMagic/18f9feb58f2bf7fdc54ddc2fb5f4678a to your computer and use it in GitHub Desktop.
Save WhiteMagic/18f9feb58f2bf7fdc54ddc2fb5f4678a to your computer and use it in GitHub Desktop.
Axis sniper mode
import gremlin
from vjoy.vjoy import AxisName
hog = gremlin.input_devices.JoystickDecorator(
"Joystick - HOTAS Warthog",
72287234,
"Default"
)
# Sensitivity curve setup
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),
])
sniper_curve = gremlin.spline.CubicSpline([
(-1.00, -0.50),
(-0.50, -0.175),
( 0.00, 0.00),
( 0.50, 0.175),
( 1.00, 0.50)
])
active_curve = default_curve
@hog.button(1)
def fire_group1(event, joy, vjoy):
global active_curve
if event.is_pressed:
active_curve = sniper_curve
else:
active_curve = default_curve
vjoy[1].axis(AxisName.X).value = active_curve(joy[2].axis(1).value)
vjoy[1].axis(AxisName.Y).value = active_curve(joy[2].axis(2).value)
@hog.axis(1)
def axis1(event, vjoy):
vjoy[1].axis(AxisName.X).value = active_curve(event.value)
@hog.axis(2)
def axis2(event, vjoy):
vjoy[1].axis(AxisName.Y).value = active_curve(event.value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment