Keyboard input

For a game that only uses keyboard input, would JInput provide that much of performance gain. At the moment I am using:

Toolkit.getDefaultToolkit().addAWTEventListener(new MyAWTEventListener(),AWTEvent.KEY_EVENT_MASK);

and then in the eventDispatched() method of listener a switch statement.

it’s not so much a matter of performance but the question of whether you want to use AWT in the first place. JInput is your only choice for controllers other than keyb and mouse of course, so if you plan on using something else as well in the future you might as well go straight for jinput.

JInput can read controllers when the window is not in focus.

where you do not use AWT to do your drawing, you are limited on input too.

I would use JInput for a fullscreen game, a game that uses controller input, and even a windowed game but that’s just because i am used to it now.

i really dont think you are going to notice any diference in the performance between them. there are other places in most games where optimizing is much more beneficial (like graphics).

if you are after response times, awt is great, jinput depends on how often you poll. it’s usually best to poll at least every frame, then it’s just as good.

AWT listeners can be serialized, which is convenient to save your config.

Another issue is that I dont think JInput has any way of handling different keyboard layouts automaticly as awt does, so if you dont have an US-en (I think) keymap or wish to support different keymaps you will have to handle that yourself.

// Gregof

Hi
It’s down to the OS, I have no idea what osx does in this respect. The linux kernel does no mapping (all handled outside of the kernel), so when talking with it there doesn’t appear to be a way without writting a whole load of keymaps myself. Direct X sits above the windows kernel after the keyboard mapping is done, so on windows it’s fine, on osx I suspect it is, it’s only linux that is a little funny. As the console can have keyboard maps I assume there is someway to do it, but I need to explore further.
Elsewhere I have said that I am planning on doing an AWT plugin for jinput for mouse and keyboard control, this will mean that you can use which ever you feel like from jinput without worrying about having to re-write your input layer. It’s on the list, but a server crash has meant I’ve spent my free time the last few nights building a new mail/dns and web server box.

Endolf

Of course, I run Linux… :wink:

// Gregof