Just recently, I came across a dilemna why one of our pedal devices would not work with our Java program. We already incorporated the code to communicate with it by using key listeners and mapping key codes with the pedal.

Turns out that the pedal device was detected as a gamepad device. Luckily, there is an existing Java library to handle gaming device communication. I used JXInput and it worked flawlessly. Plus, the code is easy to write too.

JXInput gives access to any number of DirectInput gaming devices – although it seems to be quite unusual to have more than one connected. Additionally, JXInput allows to interpret each key on the keyboard as interpreted by Swing to be a JXInput button. This gives another source for about 100 additional buttons.

Here is a simple class I made to initialize the gamepad device to be usable in your Java program.

It is up to you to change the key code values with which you want to associate the pedal/button values. To use the class, simply instantiate it and set the Component that it should listen to whenever you step on the pedal.

To use the class, do this:

Where comp is your component UI that handles pedal functions in case users do not have any pedal device.

gamepadAs if the iPhone and iTouch units are not enough, ZodTTD, the creator of all those emulator games of past years now ported to Apple’s famous gadgets, has been working on a game control pad that can be hooked to the iPhone enabling us to freely play the emulator games without the worries of cramped space on the iPhone screen. They also are going to make one for the iTouch so this is quite big news for people who enjoy playing those old games from other consoles.

Remember though, that if this game controller were to become public for commercial use, this would only work for the emulator games. Although there is no official word on anything regarding game controllers for the iTouch, I do hope that soon, these would become a reality. It would make playing the games a lot easier on our part especially if touching buttons on the screen is required. Until then, keep your fingers crossed.

Related Posts Plugin for WordPress, Blogger...