From: Brian M. <ma...@us...> - 2002-09-03 18:08:59
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test In directory usw-pr-cvs1:/tmp/cvs-serv23173/org/lwjgl/openal/test Modified Files: ALTest.java Log Message: fix: better keyboard handling Index: ALTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ALTest.java 3 Sep 2002 16:07:43 -0000 1.10 +++ ALTest.java 3 Sep 2002 18:08:52 -0000 1.11 @@ -552,7 +552,7 @@ try { ch = System.in.read(); - System.in.read(); + eatInput(); } catch (IOException ioe) { } @@ -999,31 +999,34 @@ if ((ch == 'S') || (ch == 's')) { return 0; } - if (ch == 0) { + if (ch == 10) { return 1; } } } protected int CRToContinue() { - int ch = 0; - int lastchar = 0; - - do { - lastchar = ch; - try { - ch = System.in.read(); - System.in.read(); - } catch (IOException ioe) { + int current = -1; + try { + //read one, and eat the rest + current = System.in.read(); + eatInput(); + } catch (Exception e) { + } + return (current == 13) ? 10 : current; + } + + protected void eatInput() { + try { + while(System.in.available() > 0) { + int eaten = System.in.read(); } - } while (ch != 10); - - return lastchar; + } catch (Exception e) { + } } protected void CRForNextTest() { System.out.print("\nPress Return to continue on to the next test.\n"); - CRToContinue(); } |