I currently have a PS1 controller going through my Arduino sending messages to a Java program which then reads them and presses the correct key using a Robot. The problem with this is that the Robot class cannot send key presses to most applications and therefore will not send key presses to games which I would like to control using the PS1 controller. How are keyboard presses simulated without the use of a Robot, on a hardware level? I have previously tried having it run a Visual Basic Script, and it worked, but was much too slow. Is there any way to do it purely in java?
Asked
Active
Viewed 2,802 times
4
-
2You could use JNA or JNI to do it. – BevynQ Jul 15 '13 at 04:44
-
@BevynQ How might that be done? After some Google searching, I came up with nothing but 'use Robot' – Quaggles Jul 15 '13 at 04:58
-
I assume your vbscript is making some windows calls? You can do that with JNA. It might be easier to do this in C# though. – BevynQ Jul 15 '13 at 05:15
-
@BevynQ Well, it doesn't seem as if that will work. The vbscript won't send key presses to a fullscreen window. – Quaggles Jul 15 '13 at 05:21
-
See this question for some advice doing it in C++: http://stackoverflow.com/questions/5607849/how-to-simulate-a-key-press-in-c. JNA or JNI can probably call the C++ code, but I know nothing about actually doing that. – jpmc26 Jul 15 '13 at 05:35
1 Answers
0
Java Native Access (JNA) enables to access the Native levels of Operating systems using Pure Java. You can access the JNA Project here.
Furthermore I found a sample which uses JNA to Hook on to Hardware Keyboard to listen to key presses. I think this is what you looking for.
If it is not what you are looking for, then you can definitely look through the reference and implement your own.

shazin
- 21,379
- 3
- 54
- 71
-
Thanks for the help. I think I've decided to go with having Java call a native function from a C++ program. After hunting around for a while I couldn't find out if JNA could even perform the necessary function. – Quaggles Jul 15 '13 at 17:13