Input problem : multi keys pressed --> some doesnt work

input problem : multi keys pressed → some doesnt work



Hi everyone

I got this problem:

when I press YXCV together or one after each other and at the end all of them are pressed and hold then I see that all 4 boolean values are true.(that is good and what I want)

but when I press up,down,left right arrows (together or one after each other) then I can see that one or two of them are false. (I also tried with FTGH and got similar problem) (yeah, and if I press one of 4 then that one will be true,so it works when pressed alone)

is it a bug? or did I make something wrong ?



here is the code and some screenshot



[java]

package input;



import com.jme3.app.SimpleApplication;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;



public class main extends SimpleApplication implements ActionListener{

protected boolean pyb,pxb,pcb,pvb, //action

pjb,plb,prb,pdb, pfb,pbb; //analog

@Override

public void simpleInitApp() {

initKeys();

flyCam.setEnabled(false);

}

@Override

public void simpleUpdate(float tpf) {

System.out.println("up,down,left,right “+pjb+” “+pdb+” “+plb+” "+prb);

System.out.println("y,x,c,v “+pyb+” “+pxb+” “+pcb+” "+pvb);

}



protected void initKeys() {

inputManager.addMapping(“left”, new KeyTrigger(keyInput.KEY_LEFT));

inputManager.addMapping(“right”, new KeyTrigger(keyInput.KEY_RIGHT));

inputManager.addMapping(“up”, new KeyTrigger(keyInput.KEY_UP));

inputManager.addMapping(“down”, new KeyTrigger(keyInput.KEY_DOWN));

inputManager.addMapping(“c”, new KeyTrigger(keyInput.KEY_C));

inputManager.addMapping(“v”, new KeyTrigger(keyInput.KEY_V));

inputManager.addMapping(“y”, new KeyTrigger(keyInput.KEY_Y));

inputManager.addMapping(“x”, new KeyTrigger(keyInput.KEY_X));



inputManager.addListener(this, new String[]{“left”,“right”,“up”,“down”,

“y”,“x”,“c”,“v”});

}

public static void main(String[] args) {

main app= new main(); app.setShowSettings(false); app.start();

}

@Override

public void onAction(String name, boolean keyPressed, float tpf) {

// StringBuffer a= new StringBuffer(name);

// a= a.replace(0, 2, “”); name=a.toString();

if (name.equals(“up”)) {

if (keyPressed) { pjb=true; }else{ pjb=false;}

}//Up

if (name.equals(“down”)) {

if (keyPressed) { pdb=true; }else{ pdb=false;}

}//Down

if (name.equals(“left”)) {

if (keyPressed) { plb=true; }else{ plb=false;}

}//Left

if (name.equals(“right”)) {

if (keyPressed) { prb=true; }else{ prb=false;}

}//Right





if (name.equals(“y”)) {

if (keyPressed) { pyb=true; }else{ pyb=false;}

}//Up

if (name.equals(“x”)) {

if (keyPressed) { pxb=true; }else{ pxb=false;}

}//Down

if (name.equals(“c”)) {

if (keyPressed) { pcb=true; }else{ pcb=false;}

}//Left

if (name.equals(“v”)) {

if (keyPressed) { pvb=true; }else{ pvb=false;}

}//Right



}

}



[/java]











Does the problem persist when you call:

[java]

inputManager.clearMappings();

[/java]

at the beginning of initKeys()?



EDIT: it does persist … checked it. On Arrows its just possible to press 3 buttons on the same time!

so it is only 3 arrows work for you too?

I also tried something like YXCV left down right or left right down

something like that, when all 7 of them true I press the up too and it was all 8 true, but if I press all 8 then only 7 true or 6.



so updownleftright can all be true when all 8 pressed and in right order but cant be all true when only 4 of them pressed.

so … ???

I think FGTH,YXCS ,RFVDhas the same problem like updownleftright.

somehow I feel that if 4 keys in the same row → ok

3 key in same row and near other and 1 key in other row+near other 3 → problem (updownleftright,asdw) asd u -->OK

RGVD -->OK

is it hardware problem or java problem ? or jmonkey problem ?

and are there anyway to solve this? I want all 4 arrows → OK ^^

I don’t know if this is your real problem but you will find that this varies from different keyboards to different drivers… at least that’s been my experience over way too many years of messing with this stuff.



Some will even have different behavior for different key combinations and how they choose to drop/ignore things.



There might be bugs in the code… I didn’t see any. But this is an actual hardware problem, too.

This thread from a hardware-forum should be interesting: http://www.tomshardware.co.uk/forum/50383-10-pressing-multiple-keys-keyboard-problem



see 4. post!

so it is a hardware problem, there is nothing I can do



@burnedtoast

it was an interesting thread indeed ^^

…and we dug up a 5 year old thread for… why?

and you care about someone digging up a 5 year old thread… why? :heink: :o :o :o :o :heink: :heink:



and now I read a 5 year old thread which I didnt read → still new ^^

There is a tutorial in the Jmonkey code that deals with combination of keys. I understand it might be a hardware problem but you might be able to use a software solution. Such that you use the keycombo detector to see if all four arrow keys were pressed within a certain boundaries then give the output you want. Just a thought.

Sorry for that :smiley: … havent seen the date (its realy bad to display light gray on white background),

@scrubalub

I think you mean this one

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:combo_moves

I tried it and I got so confused and cant use it, so in the end I have my own combo, and the above problem. may be that combo doesnt have that problem, but I cant use it …

@burnedtoast

it still has new and interesting information for me , old news is still new news if you havent heard of it

also those conversation made me laugh a lot today, that is good for my health

I have to thank you ^^