bool keys array example question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Hobi
Posts: 14
Joined: Sun Jul 25, 2004 9:32 am

bool keys array example question

Post by Hobi »

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...
MiRaX
Posts: 4
Joined: Thu Dec 01, 2005 6:24 pm

Post by MiRaX »

I think the stopping is caused by:

Code: Select all

			bool keys[irr::KEY_KEY_CODES_COUNT];
			for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
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)
Hobi
Posts: 14
Joined: Sun Jul 25, 2004 9:32 am

Post by Hobi »

oh, thank you...i made another mistake in my eventReceiver. because of that the array wasn't set back to false, after the key was released. i'll test it tomorrow.
Hobi
Posts: 14
Joined: Sun Jul 25, 2004 9:32 am

Post by Hobi »

yes, it worked, thank you.

but the movement is still with a "step" at the beginning.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

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
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Hobi as Guest

Post by Hobi as Guest »

I didn't find any functions to ask for "keypressed", "keyreleased" or "keytyped". A variable for "keypressed" would be the thing I need. I tried it with java.awt functions, which worked, but that was not a good way to program because I would like to stay with the Irrlicht(Jirr) event system.
MiRaX
Posts: 4
Joined: Thu Dec 01, 2005 6:24 pm

Post by MiRaX »

I've got a good message for you: It's not just a problem with java or jIrr, i've got the same on in my c++ programmed program :wink:
so, i hold the opinion that it's the event, so take a look at your event receiver and try to find a solution... ( I don't know one, but I'm searching too ;) )
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

SEvent.keyInput.PressedDown is the flag your looking for, when a key event happens lookup the key in the array and copy the pressed down status.
Abraxas
Posts: 57
Joined: Mon Nov 07, 2005 3:56 pm

Post by Abraxas »

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:

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]
Image
Hobi
Posts: 14
Joined: Sun Jul 25, 2004 9:32 am

Post by Hobi »

at first: thank you for all your help :wink: .

I am using the "keyInput.PressedDown" variable to set the value in the array. but it doesen't interpret the command correctly, because the delay is still there.

But...how is it done in the CameraSceneNodeFPS ???
There, the keyinput works.

:shock:
Hobi
Posts: 14
Joined: Sun Jul 25, 2004 9:32 am

Post by Hobi »

:D :D :D

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)
Post Reply