I am trying to use Java with JNA to grab character input from the console without the user having to hit enter.
I have been using this resource to achieve this, however it does not have OS X support. It works as expected on Windows and *nix (Ubuntu tested), however on OS X keystrokes appear in terminal and require you to press enter.
I am using a ConcurrentLinkedQueue to handle the keystrokes, with an external thread listening for them and adding them to the queue which is polled every tick on the main thread.
If anyone could help add OS X support to the resource aforementioned, or suggest a better way to solve the same problem, that would be greatly appreciated.
Thanks!
Self-solved, if you execute your program like so:
#!/bin/sh
stty raw -echo
java -jar ProgramName.jar
in a shell script, and it will work fine like Unix on OS X.
Explanation of "stty raw -echo"
"stty" is a command to change terminal settings
"raw" changes the terminal to non-canonical mode
"-echo" makes keypresses not show up when you type them