JDK-4083501 : Need Input Polling for Games (keyboard, etc)
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.3,1.2.2,1.3.0,5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1997-10-02
  • Updated: 2008-06-21
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Name: rm29839			Date: 10/02/97


I've found that Java is actually fast enough for
*action* games on some JITs.  (I've gotten 
upwards of even around 90 frames per second.)

But I need keyboard/mouse/joystick *polling*
(equivalent of GetAsyncKeyState()/joyGetInfoEx()
on Win32) to make the games playable at all
(as action games, that is).

Please add them.  Those games depends on them.

Thank you.


company - Acorn Associates , email - ###@###.###
======================================================================

Name: krT82822			Date: 12/30/99


java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)

I need the ability to poll to find the mouse position.  I need this to support
an autoscroller, and there are plenty of people who would like to use it for
other purposes as well; see bug 4083501, for instance.

Here is the reason I need this for an autoscroller.  My autoscroller currently
triggers when the mouse is in a certain area.  Because there is no way to poll
the current position of the mouse I must use a Timer, and in that Timer I must
repost mouseDrag events.  When I do this for a view that takes a long time to
draw, the timer reposting mouse events takes precedence over actual mouse
motion.

(I think that is a bug also anyway, and I will submit a seperate report for it;
the bottom line, IMHO, is that your input event loop should be running in a
seperate thread from the paint event system; since it's not, the UI feels very
sluggish and unresponsive; I'm aware of the reasons you didn't do that, but I
think in the long run it was the wrong choice.  But if I could poll it wouldn't
matter as much.)

The result is that autoscroll events pile up and are handled before "real"
mouse drag events, so that when I move the mouse out of the autoscroll area to
stop autoscrolling, it takes 30sec-1min to stop scrolling, which is not very
user friendly.

If I could poll the mouse position, I wouldn't have to post a new mouse event
and my autoscroller would stop scrolling immediately.

As pointed out in bug 4083501, there are many other reasons people might want
to poll hardware input devices, and they all come down to the same reason:
eliminating innacuracy due to long event queue length.  But special support for
mouse/keyboard/joystick polling without having to do something radical like JNI
would be very nice.
(Review ID: 99448)
======================================================================

Comments
EVALUATION For the mouse java.awt.MouseInfo class is available since 1.5.0. It allows to track it's position asynchroneously. Another issue is a keyboard. Suppose it would be nice to be informed about any key state without KeyListener as it depends on JDK itself in particular on EventQueue length. Working with the analog of GetAsyncKeyState() much more comfortable in situations when a lot of KeyEvents need to be processed. For now we usually rely on autorepeat triggered by OS but seem it's too slow for games.
23-05-2006

WORK AROUND Name: rm29839 Date: 10/02/97 ======================================================================
17-09-2004

PUBLIC COMMENTS .
17-09-2004

EVALUATION Could be useful. Committing to Tiger. eric.hawkes@eng 2000-01-07 The following classes and methods in Java3D are useful as a model and a good starting point. Also, we would like to keep compatability with Java3D in this regard. javax.media.j3d.PhysicalEnvironment.getAllInputDevices(), addInputDevice(), etc. javax.media.j3d.InputDevice javax.media.j3d.Sensor ###@###.### 2001-11-26 Given a low priority by Tiger planning. ###@###.### 2002-09-10
26-11-2001