I'm new to FreePIE and currently trying to map keypresses to slider ranges. I'm doing this in order to map a zoom function to the slider, with the zoom being set to 0 when the slider reaches the bottom and increasing/decreasing as you move the slider up/down. The zoom is controlled via three possible commands (increase zoom by one level, decrease zoom by one level, set zoom to 0); the commands can be mapped to keys. There are 9 different zoom levels (so 10 "zoom states" including "0 zoom") in the application.
I ran into two issues so far that I couldn't find any solution for.
This is the code I'm currently working on:
Code: Select all
if joystick[1].sliders[0] < -900:
keyboard.setPressed(Key.W)
elif -800 > joystick[1].sliders[0] >= -900:
keyboard.setPressed(Key.E)
diagnostics.watch(joystick[1].sliders[0])
What I thought my code would do (from looking at a number of script examples):
When condition is triggered, key is pressed once.
What actually happens:
As long as the slider is in the specified range, the according key gets pressed over and over again (like if it was held down on the keyboard), even if the slider isn't moving (watch value for the slider remains static).
2nd issue: How to trigger keypress depending on from where the range is added?
In order to use the zoom function correctly, the script would need to know if a certain slider range is reached from top or bottom, as I cannot directly switch to any zoom level besides "0". Does anyone have an idea how to tell FreePIE that, for example, the range -800 > x >= -900 is reached by crossing -900?
I hope someone has done something like this before. It doesn't feel like something ultraspecific (mapping keypresses to axis/slider ranges, I mean), but somehow I couldn't find anything even remotely like this.