Skip to content

Instantly share code, notes, and snippets.

@WhiteMagic
Created December 5, 2016 10:57
Show Gist options
  • Save WhiteMagic/740fbc038f69bdcab6a4298afa4f6f84 to your computer and use it in GitHub Desktop.
Save WhiteMagic/740fbc038f69bdcab6a4298afa4f6f84 to your computer and use it in GitHub Desktop.
import os
import time
import gremlin
spacenavigator = gremlin.input_devices.JoystickDecorator(
"SpaceNavigator",
1828988614,
"Default"
)
connexion_kmj = gremlin.input_devices.JoystickDecorator(
"3Dconnexion KMJ Emulator",
4022234372,
"Default"
)
log_file_sn = open(os.path.join(gremlin.util.userprofile_path(), "axis_values_sn.csv"), "w")
log_file_km = open(os.path.join(gremlin.util.userprofile_path(), "axis_values_km.csv"), "w")
last_value_sn = 0
last_value_km = 0
@spacenavigator.axis(1)
def rec_sn_axis1(event):
global last_value_sn
global log_file_sn
log_file_sn.write("{:f},{:f},{:f}\n".format(
time.time(),
event.value,
last_value_sn - event.value
))
last_value_sn = event.value
@connexion_kmj.axis(1)
def rec_sn_axis1(event):
global last_value_km
global log_file_km
log_file_km.write("{:f},{:f},{:f}\n".format(
time.time(),
event.value,
last_value_km - event.value
))
last_value_km = event.value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment