Created
January 8, 2019 18:44
-
-
Save WhiteMagic/04e6cd8b4460e33def2d83928c1bbb8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import time | |
| import gremlin | |
| # Last time the dial was "pressed" | |
| g_last_activation = 0 | |
| # How often since last reset the dial was "pressed" | |
| g_activation_count = 0 | |
| # Time window within the activation has to happen | |
| g_timeout = 1.0 | |
| # How often the dial has to be "pressed" in order for one activation to happen | |
| g_activation_limit = 3 | |
| # Device creation | |
| t16000m = gremlin.input_devices.JoystickDecorator( | |
| "T16000.M", | |
| gremlin.common.DeviceIdentifier(72331530, 2), | |
| "Default" | |
| ) | |
| @t16000m.button(1) | |
| def noisy_dial(event, vjoy): | |
| global g_last_activation | |
| global g_activation_count | |
| if not event.is_pressed: | |
| vjoy[1].button(1).is_pressed = False | |
| return | |
| if (time.time() - g_last_activation) > g_timeout: | |
| g_activation_count = 0 | |
| g_last_activation = time.time() | |
| g_activation_count+= 1 | |
| if g_activation_count >= g_activation_limit: | |
| vjoy[1].button(1).is_pressed = event.is_pressed | |
| g_activation_count = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment