cpat
New Member
Posts: 8
|
Post by cpat on Feb 5, 2019 7:16:55 GMT -8
Hi guys,
As I'm typing with a keyboard with the command GD.cmd_keys, I've got several inputs of a key stroke because of the looping function while the key is still pressed. Is there any workaround (adding a delay() function is obviously not the solution). How can I disable the GD.inputs.tag in the Library ?
|
|
|
Post by jamesbowman on Feb 5, 2019 16:04:03 GMT -8
Well, the tag hardware just reports raw touches - a lot like the keys on a keyboard. So there needs to be some software state machine that processes the tags.
What I normally do is keep track of the tag from the previous cycle, and when the previous tag is zero, and the current tag is <something>, it means that this is the first press.
static int prev_tag = -1;
...
GD.get_inputs();
if ((prev_tag == 0) && (GD.inputs.tag == 100)) { // 100 was pressed for the first time } // etc
prev_tag = GD.inputs.tag;
|
|
cpat
New Member
Posts: 8
|
Post by cpat on Feb 7, 2019 1:38:28 GMT -8
Very clever way to achieve what I wanted, thanks !
|
|