FBA The Creator
http://www.fbacreator.com/fbaforum/

Input Keys
http://www.fbacreator.com/fbaforum/viewtopic.php?f=5&t=10
Page 1 of 1

Author:  FR4NK5T3R [ Fri Mar 28, 2008 1:30 pm ]
Post subject:  Input Keys

Ok next question (you're going to get fed up with me)

Is there any way to detect a key pressed other than keyleft, keyright, keyup, keydown, keyfire1, keyfire2 and keyfire3?

We have a few extra keys on the Gizmondo

Author:  evilmaio [ Fri Mar 28, 2008 1:47 pm ]
Post subject:  Re: Input Keys

keyleft(),keyright(), etc, give the ascii codes for main common keys sequence.
If you need more specific keycodes, you could use the onkeydown event and print the code on your device.

Then you can check it with this:
if (numkeypress(keycode) > 0) then

Regards.

Author:  FR4NK5T3R [ Sat Mar 29, 2008 11:55 pm ]
Post subject:  Re: Input Keys

Thanks for the quick answer. Bit confused though. Do you mean onbuttondown?

I feel this bit of code should work but it seems to crash FBA on the second key press



function onmainloop()
end

function onbuttondown(key)
print(50,100,"key pressed: "..key,0,255,0)
end

Author:  evilmaio [ Sun Mar 30, 2008 12:23 am ]
Post subject:  Re: Input Keys

This is almost correct.
Actually main display pointer is valid only inside onmainloop event (I'm going to update the documentation for this issue).
This means you should avoid screen output inside the input events. (see tutorial 05).
Here's the correct code:

Code:
local last_key = 0

function onmainloop()
        clear(0,0,0)
        print(50,100,"last key pressed: "..last_key,0,255,0)
end

function onbuttondown(key)
        last_key = key
end

Author:  FR4NK5T3R [ Mon Mar 31, 2008 8:22 am ]
Post subject:  Re: Input Keys

Thanks evilmaio

I've written a little app based on your code for us Gizmondo users to show which key you've pressed.

See here: http://www.gizmondoforums.com/forums/index.php?s=&showtopic=12742&view=findpost&p=164058

Author:  evilmaio [ Mon Mar 31, 2008 8:30 am ]
Post subject:  Re: Input Keys

Cool!
I knew gizmondo from your forum, it looks very nice ;)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/