You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the documentation and sample code on writing macros and running them from a plugin goes back to R7 (I think) and doesn't work with R13 - here's working code that does in the current version.
Figured I'd share since it took me a few hours to figure this out.
import gremlin
from gremlin.input_devices import keyboard, macro
from configuration import * # load constants from the configuration.py file in the same folder as the plugin - defining the devices connected to this PC
# example (for my TM throttle device):
# TM_THROTTLE_ID = 7
# TM_THROTTLE_HWID = 72287236
# TM_THROTTLE_NAME = "Throttle - HOTAS Warthog"
# TM_THROTTLE_GUID = "{A60B8530-25E9-11E7-8003-444553540000}"
#
# script mode:
# MODE_ALL = "Default"
# define devices
tmthrottle = gremlin.input_devices.JoystickDecorator( TM_THROTTLE_NAME, TM_THROTTLE_GUID, MODE_ALL )
# define macro
toggle_light_macro = macro.Macro()
toggle_light_macro.tap("L")
# other functions are press() release() pause(seconds_as_floating_point) - add them in sequence they need to be executed so
# issue a control-A, hold it for half a second
# m.press("leftcontrol")
# m.press("A")
# m.pause(0.5)
# m.release("A")
# m.release("leftcontrol")
# special keys are:
# "f1" "f2" "f3" "f4" "f5" "f6" "f7" "f8" "f9" "f10" "f11" "f12"
# "printscreen" "scrolllock" "pause" "insert" "home" "pageup" "delete" "end" "pagedown" "up" "left" "down" "right"
# "numlock" "npdivide" "npmultiply" "npminus" "npplus" "npenter" "npdelete"
# "np0" "np1" "np2" "np3" "np4" "np5" "np6" "np7" "np8" "np9"
# "backspace" "space" "tab" "capslock"
# "leftshift" "leftcontrol" "leftwin" "leftalt" "rightshift" "rightshift2" "rightcontrol" "rightwin" "rightalt"
# "apps" "enter" "esc"
# toggle lights on press or release
@tmthrottle.button(24)
def toggle_lights(event, joy, vjoy):
gremlin.macro.MacroManager().queue_macro(toggle_light_macro) # runs the macro
The text was updated successfully, but these errors were encountered:
Yeah, a bunch of the documentation needs updating :-) I hopefully get around to revising that at some point. I also did some work on making automatic code documentation via Sphinx but that still as some issues.
Since the documentation and sample code on writing macros and running them from a plugin goes back to R7 (I think) and doesn't work with R13 - here's working code that does in the current version.
Figured I'd share since it took me a few hours to figure this out.
The text was updated successfully, but these errors were encountered: