PDA

View Full Version : Key State



matthew
14-03-2007, 23:08
At the moment I'm working on NeHe Lesson 07 but I've run into a problem.

When the 'F' Key is pressed the programme applies a Texture to the Cube on the Screen.

I want the Routine below to detect if the 'F' Key is already being pressed down and if it is don't do anything.

The problem with the Routine I've written is that it doesn't detect if the Key is already being held down.

Any ideas? :)




if tbgl_getasynckeystate(%vk_f) then
tbgl_usetexture Filter : tbgl_bindtexture Filter
Filter = Filter + 1
if Filter > 3 then
Filter = 1
endif
endif

ErosOlmi
14-03-2007, 23:38
I suppose you just need to add a flag variable switching it %TRUE/%FALSE unless you need to detect when "F" key has been keyUp and/or keyDown and / or still down.
In this case it is not so easy right now. There should be some API I can investigate about that otherwise you have to manage window events of TBGL window that, at the moment, are not yet handled by User Interface module.



DIM fKeyStateDown AS LONG VALUE %FALSE
'...
if tbgl_getasynckeystate(%vk_f) THEN
IF fKeyStateDown = %FALSE then
fKeyStateDown = %TRUE
'...
END IF
ELSE
fKeyStateDown = %FALSE
END IF