bool keys array example question
bool keys array example question
Hi!
I have problems with the movement of a scenenode:
When I push and hold the button for the movement, my node does one step, waits a second, and continues moving. It reacts the same way as if you hold a key (with the cursor in a textfield), and in your textfield there is a little break after the first letter (before the second and the following letters appear while you are pressing the key on the keyboard). I tried to solve the problem with the "isKeyInputPressedDown". but it doesen't make any difference.
I am using Jirr...is this a special Jirr problem??
Then I read the bool keys[] example, to create a smooth movement, on the wiki page. I tried it that way (with an array holding my key-actions) and my node didn't make a break any more. But now it also doesen't stop moving, because the value in the array is never set to false again. Where do I have to reset my array?
Hope anyone can help me...
I have problems with the movement of a scenenode:
When I push and hold the button for the movement, my node does one step, waits a second, and continues moving. It reacts the same way as if you hold a key (with the cursor in a textfield), and in your textfield there is a little break after the first letter (before the second and the following letters appear while you are pressing the key on the keyboard). I tried to solve the problem with the "isKeyInputPressedDown". but it doesen't make any difference.
I am using Jirr...is this a special Jirr problem??
Then I read the bool keys[] example, to create a smooth movement, on the wiki page. I tried it that way (with an array holding my key-actions) and my node didn't make a break any more. But now it also doesen't stop moving, because the value in the array is never set to false again. Where do I have to reset my array?
Hope anyone can help me...
I think the stopping is caused by:
so, add this to your code if you haven't and try again..
It works on my code (I can poste mine if you like to see it)
Code: Select all
bool keys[irr::KEY_KEY_CODES_COUNT];
for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
It works on my code (I can poste mine if you like to see it)
I've never used jIrr or java but I know that keyboard repeat delay is a setting in your operating system, it does not interfere with a "key down" and "key up" events, only "keypress". are you checking the right type of event?
if jIrr can't do key up/down events then you'll have to do some system call to set the key repeat delay and repeat rate manually, if thats even possible in java.
hope this helps
if jIrr can't do key up/down events then you'll have to do some system call to set the key repeat delay and repeat rate manually, if thats even possible in java.
hope this helps
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
I have the same annoying effect.
But I believe this is windows - system - specific.
Well, when you for example open the (text-)Editor, and hold any key, number or letter, pressed, then you write at first time one single letter, and then, after a short time, you begin to write a long row of the same keys.
This can be edited in the (windows)system - control - panel in thekeyboard- options. I can justify this delay here (other computers should have the same options). So I think it would be neccessary to find out where this data will be stored and then change it manually or by your programme.
-----------------------------------------------------
I just found this by googeling:
Keyboard Repeat Rate
The keyboard repeat rate, acceptance delay, and bounce rate can be set by the SystemInfoParameters function using the type of SPI_SETFILTERKEYS. Utilize this code to perform the task:
--------------------------------------------------------------------
You may have a look to the link:
http://www.section508.gov/IRSCourse/mod02/printVC.html
Ok, I hope, this could help you in any way.[/url]
But I believe this is windows - system - specific.
Well, when you for example open the (text-)Editor, and hold any key, number or letter, pressed, then you write at first time one single letter, and then, after a short time, you begin to write a long row of the same keys.
This can be edited in the (windows)system - control - panel in thekeyboard- options. I can justify this delay here (other computers should have the same options). So I think it would be neccessary to find out where this data will be stored and then change it manually or by your programme.
-----------------------------------------------------
I just found this by googeling:
Keyboard Repeat Rate
The keyboard repeat rate, acceptance delay, and bounce rate can be set by the SystemInfoParameters function using the type of SPI_SETFILTERKEYS. Utilize this code to perform the task:
Code: Select all
// establish the filterkeys structure
FILTERKEYS strFilterKeys;
// clear the structure
ZeroMemory(&strFilterKeys, sizeof(FILTERKEYS));
// initiate the size
strFilterKeys.cbSize = sizeof(FILTERKEYS);
// indicate filterkey will sound-off when hotkeys activate/de-activate them
// user can hold down right shift key for 8 seconds to activate/de-activate the filterkeys)
strFilterKeys.dwFlags = FKF_HOTKEYSOUND |FKF_HOTKEYACTIVE;
// set the time a key must be held down before accepted(one-quarter second)
strFilterKeys.iWaitMSec = 250;
// Set the time a key is held down before repeating to 1 second
strFilterKeys.iDelayMSec = 1000;
// set the repeat key rate to every one-half second
strFilterKeys.iRepeatMSec = 500;
// ensure the bounce rate is zero
strFilterKeys.iBounceMSec = 0;
// set the new keyboard repeat rate
SystemParametersInfo(SPI_SETFILTERKEYS, sizeof(FILTERKEYS),&strFilterKeys, 0);
You may have a look to the link:
http://www.section508.gov/IRSCourse/mod02/printVC.html
Ok, I hope, this could help you in any way.[/url]
it works....
it was another stupid mistake I made in my code.
I had an extra line of code in my loop where I reseted my array manually every loop. I don't know why that caused the delay (only after the first step and not the whole time) but now it works fine (without that line).
I also remember that I made tests with that line of code because of the problem. And I am sure, that I also tested without that line...
So, I am a little bit confused because I can't remember what was wrong before.
Well, thank you all for your help!!! (and excuse my stupidity)