Hi,
 
Now I can use my Xbox controller as joystick (thanks to Markus), I also want to catch a key click from my keyboard.
 
First I did try to use the keyboard service, but this only works when the button of this service has focus and  could nog figure out how to solve this.
 
So, as an alternative, I now try to use the joystick service for this purpose. 
It works great, but again focus is a problem.
Now the onJoystickInput function is only activated in the swing-gui and not in the web-gui.
 
Who knows a solution to get focus on the keyboard service and/or the joystick service?
 
Regards, Jan

Mats

7 years 4 months ago

Hi Jan

It's not easy ( impossible ) to do using pure Java. However:

Seems like somebody has created several native libraries for Mac, Windows and Linux ( X11 ) and made a Java library that detects the operating system and use the proper os methods.

https://github.com/kwhat/jnativehook

Would be very nice to borg so that keyboards and mouse can be used without focus.

This is what the documentation says:

The JNativeHook library ships with all the supported native libraries included in the jar file. The library will attempt to identify the host operating system and extract the appropriate library to the system's temporary directory and dynamically load it. If you need to extract the library to an alternative location, override the Java property "java.io.tmpdir" with a new temporary path. For most users, simply placing the jar file in the program's class path is all that is required.

Seems to be up to date with the latest changes made in September this year.

/Mats

 

Hi Mats,

Thank you for your reply.
So there is no easy solution like keyboard.focus() or joystick.focus() ;-(

I've read the info on the link you have send and understand the JNativeHook Lib should be "hooked into" myrobotlab, but that's a bit adacadabra fore me. Can you give me advice how to do that?
(probeply there is a reason rhis is not already part of myrobotlab??)

Greetings, Jan

Hi Jan

I downloaded JNativeHook, and I'm working on implementing it so that it becomes part of the Keyboard service. It looks fine so far in the Windows environment. I still have some work to do to test it out.

I hope that I will be able to make it available this weekend. So have a little patience until I'm finished.

It works now in the development environment. but for some reason it doesn't work from myrobotlab.jar.

I will have to do some more testing.

/Mats