Don't really understand the main loop

Official forum for open source FreePIE discussion and development.
Post Reply
One Eyed Hopeful
Posts: 15
Joined: Tue Aug 21, 2018 5:35 pm

Don't really understand the main loop

Post by stupor-mundi »

My previous FreePIE script was using a MIDI controller, now I'm trying a script that only reads from keyboard and writes to VJoy.

According to the docs, all devices APART from keyboard and mouse, such as the MIDI controller I was using, need polling set up in this way:

Code: Select all

if starting:
    midi[0].update += update
This gave me the opportunity to write the update() function and use globals.

But now, without the MIDI device, I have no idea how to correctly initiate the main loop.
I tried to do it without using globals, without a function, assuming the entire code gets executed repeatedly, like this:

Code: Select all

v_speed = vJoy[0].x

v_down = keyboard.getKeyDown(Key.A)

v_up = keyboard.getKeyDown(Key.S)

if v_down:
	v_speed = v_speed - 10
if v_up:
	v_speed = v_speed + 10
vJoy[0].x = v_speed
but nothing seems to happen, no diagnostic values are shown.
Nothing seems to happen when I press keys.
Cross Eyed!
Posts: 196
Joined: Mon Mar 02, 2015 3:58 pm

Re: Don't really understand the main loop

Post by Jabberwock »

The function diagnostic.debug just dumps the values into the console, so it might be not displaying what you want at all. Use - I did that with your script and everything works fine (you can watch the values in the 'watch' tab on the right).
Post Reply

Return to “FreePIE”