Don't really understand the main loop

Official forum for open source FreePIE discussion and development.
Post Reply
stupor-mundi
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
diagnostics.debug(v_speed)

v_down = keyboard.getKeyDown(Key.A)
diagnostics.debug(v_down)

v_up = keyboard.getKeyDown(Key.S)
diagnostics.debug(v_up)

if v_down:
	v_speed = v_speed - 10
	diagnostics.debug("down")
else:	
	diagnostics.debug("nothn")
	
if v_up:
	v_speed = v_speed + 10
	diagnostics.debug("up")
else:	
	diagnostics.debug("nil")
	
vJoy[0].x = v_speed
but nothing seems to happen, no diagnostic values are shown.
Nothing seems to happen when I press keys.
Jabberwock
Cross Eyed!
Posts: 197
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 diagnostic.watch - 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”