Alright. Sometimes to improve on something you have to redo the whole thing from scratch. That's what I did here and with workable results.
Now I know PICO is capable of more keystrokes than the simple Left, Right, Up, Down, (O), and (X).
But for purists who don't want to dabble with 2- or 3-player controls, there is this.
It's very good for what it does. It can read keystrokes, and by that I mean layered. You can be pressing 3-buttons down at a time and it will still recognize a unique 4th. It's that powerful. Let's go over it.
You have one string to get things going called, "KEYTYPE." It's a string and contains 6-characters which tell the state of reading for the keys in this order [Left, Right, Up, Down, (O), and (X). I.E:
You have an additional global variable called KEYTIME. I suggest you leave it at 8 as this is a good number for delays and the delay before showing extended keystrokes.
Each of the 6-characters can be the following.
-- "o" ... off -- "a" ... arcade -- "i" ... input mode -- "m" ... measured -- "s" ... single key only -- "r" ... release only -- "x" ... release+extended
"O" The first is OFF, meaning it will not be read or registered at all.
- "A" The next is arcade. The simplest mode to understand. If you're pressing it at any time it registers immediately, much like BTN().
It's also important to realize that while it uses the global string KEY, the keys you are pressing can be layered. That is, you can press all six keys down at the same time and get back "LRUDAB." And to check to see if any of these keys (or more) are pressed, you use the function KEYIN() as so.
if (keyin("l")) x-=1 if (keyin("r")) x+=1 if (keyin("u")) y-=1 if (keyin("d")) y+=1
So with this, it is indeed possible to move diagonally by holding down two keys simulataneously.
"I" The next is a bit more complex. It's designed for inputting data. When you hit this key, it registers once, waits, then registers again, waits, then does a repeat max speed like BTN().
"M" This one is measured. That is it is a bit slower than BTN() but consistent. It's useful if you are working with something that has a small scope, say 16 or so elements across. You don't want the slowness of INPUT or BTNP(), but you also don't want the total speed of BTN(). This is between that.
"S" Single key is just that. You hit it, it registers once and will not register again until you release the button and hit it again. Useful for places where that single keystroke can cause a problem if more than one was sent at a time.
"R" Release only. With this the key is not registered until you RELEASE your finger from the key. It also does not register at all if you hold it down for any appreciable time as a safety measure. You must TAP to get it to work properly.
- "X" Extended entry. This is just like "R" but now if you hold down that button you get an extended keystroke. These are listed in the table below:
-- "l" left -- "r" right -- "u" up -- "d" down -- "a" 🅾️ -- "b" ❎ -- "w" held left -- "e" held right -- "n" held up -- "s" held down -- "o" held 🅾️ -- "x" held ❎ -- "h" held left + right -- "v" held up + down -- "+" held 🅾️ + ❎
Only with "X" mode as one of the characters in KEYTYPE can you get the special "W" "E" "N" "S" and "O" and "X" strokes. And to get this keystroke you must hold the key down for a short time.
If you release the held key that created the special stroke, it is sent again. This makes it useful to have a menu that stays up as long as the key is held and can close again once you release the key.
Three new special strokes are also available for ALL modes except Arcade. That is if you hold the left and right key. The up and down key. And the (O) and (X) key. They each return "H" "V" and "+"
And they don't register immediately so as to not be activated in a misfire. You must hold these two keys down for a short time in order for them to register. Any time "H" "V" or "+" is registered, the routine is set for safety to ignore any other keystrokes until all keys are released.
And that's it ! If you set all six keys to "X" then you are capable of having a unique 15-keystrokes read from the default 6-keys.
If you have any questions, please let me know.
Hope This Helps !
[Please log in to post a comment]