JInput question

Hey! Im making a controller config option for my game and I came across a little bug. Program works like this:
If Button is pressed on config screen, it calls for input.update() which polls every device (limited it to keyboard and gamepads) and returns a vector of strings. Now config program reads firstElement of the vector and assigns it as label text.
Anyways, if you pressed lets say “any” key before actually pressing any button and then pressed the button to assign a value, it would assign it as “any” key. Is there a way to clear input buffer or smth? :slight_smile:

Question 2: Is it good to save config as a file and in the main program if any key is pressed it checks if that key’s value is assigned to any function? (eg. Player 1 assigned “X” key to attack on his gamepad and if “X” key is pressed in game, it would make him attack?)

Nice to see that this forum is full of active members. :-\

No, there is no way to clear the buffer. If you know you are going to press a key to get past the menu, read the first value and ignore it.

Yes, saving the config is a good idea.

Sorry for going away for a week, I’ll try not to take any holiday and inconvenience anyone again :p.

Endolf

Ty! Since the subject is jinput question, I’m going to ask another question about it. :slight_smile:
Is it normal if my comp can flip through empty program like this:

class Test
{
public static void main(String args[])
{
int frames = 0;
long timer = System.currentTimeMillis();
while(true)
{
if(System.currentTimeMillis() >= timer + 1000)
{
System.out.println("fps: " + frames);
frames = 0;
timer = System.currentTimeMillis();
}
frames++;
}
}
}

-> about 17 million times per second and with input checking for Keyboard and 2x Joysticks(with exclusion of additional hardware like mouse, etc) about 45 000 times/s or does my jinput code blow? :slight_smile:

E: Nevermind after I used randomly colored and positioned QL_QUADS those frames were 585 per update w/o jinput and 550 w/ it.