I'm looking for a way of making the difference between user mouse events and mouse events generated by java.awt.Robot. In AWTEvent, there is an attribute "isSystemGenerated" but it is always at true in my case Robot uses a peer (WRobotPeer, MRobotPeer, XRobotPeer). I would like to find a way of modifying the events that the robot creates in order to handle them differently in several engines that need a mouse look and that use AWT. Do you have an idea? Best regards. Thank you for your attention.

Robot hooks into the OS, with the sole purpose of being indistinguishable from real user input.

Therefore you cannot modify the AWTEvents created by the Robot, because the Robot does not create AWTEvents. The Robot is operating at a lower level, and eventually the JVM receives a signal from the OS and creates the AWTEvent. The JRE has no way of figuring out what caused the event.

You can however build heuristics and make assumptions on what is likely and what is not. If you told Robot to move the mouse to X,Y and you receive an event of the mouse being at X,Y you can be fairly sure you caused that event. If the mouse is not exactly at X,Y you can be fairly sure the user moved the mouse. This way you can simulate a grabbed mouse.

But... what are you trying to do? And are you sure Robot is the best way to achieve it?

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

But... what are you trying to do? And are you sure Robot is the best way to achieve it?

Some years ago, bienator and you helped me in fixing this bug in TUER. I want to handle the continuous mouse look in Ardor3D without JInput, only with AWT. Currently, when the mouse reaches an edge of the screen, you cannot turn anymore. Your heuristic solution may be a fine solution, thank you very much.

Do you think I could write a RFE in order to ask Sun/Oracle for help? I think it wouldn't be efficient.

Some years ago, bienator and you helped me in fixing this bug in TUER. I want to handle the continuous mouse look in Ardor3D without JInput, only with AWT. Currently, when the mouse reaches an edge of the screen, you cannot turn anymore. Your heuristic solution may be a fine solution, thank you very much.

Do you think I could write a RFE in order to ask Sun/Oracle for help? I think it wouldn't be efficient.

It works pretty well in your demo but the source code looks like my first implementation of mouse look; in some cases, it doesn't work, I don't know why Bienator & Riven's solution has worked better than this for me.

Anyway, if I don't want to rewrite the whole ardor3d-awt module, the most realistic solution is the latest Riven's suggestion, the heuristic one.

It works pretty well in your demo but the source code looks like my first implementation of mouse look; in some cases, it doesn't work, I don't know why Bienator & Riven's solution has worked better than this for me.

Anyway, if I don't want to rewrite the whole ardor3d-awt module, the most realistic solution is the latest Riven's suggestion, the heuristic one.

I cant see a case where it wont works ? any sample ? (maybe the aonly problem could be that you have to adjust screenWDiv2 and screenHeightDiv2 to fall in you windows, but dont know let me know what case may cause problems ?

I cant see a case where it wont works ? any sample ? (maybe the aonly problem could be that you have to adjust screenWDiv2 and screenHeightDiv2 to fall in you windows, but dont know let me know what case may cause problems ?

The threading of my own engine was strange, I did not need to deactivate DirectDraw on lots of machine under Vista whereas I have used OpenGL for years. Sometimes, the mouse cursor stayed frozen a few milliseconds, look at the TUER thread, we solved this problem in 2007.

In Ardor3D, its architecture does not rely on a delta, it uses the MouseEvent instances. That's why I will have to use Riven's suggestion.

The threading of my own engine was strange, I did not need to deactivate DirectDraw on lots of machine under Vista whereas I have used OpenGL for years. Sometimes, the mouse cursor stayed frozen a few milliseconds, look at the TUER thread, we solved this problem in 2007.

I have trouble to understand what you say .... nothing related to DD or openg here I use this class with both standar Java2D & opengl canvas it just worked nice for me

heu... seems that the implementation I posted follow what Riven's mention in its post above....

You're right, sorry.

I'm going to get the queue with Toolkit.getDefaultToolkit().getSystemEventQueue();Then, I can use peekEvent(MouseEvent.MOUSE_MOVED) to get the newly created event.If it is a centering event, I call getNextEvent.It might be slow

Edit.: cylab told me once that we could directly use the queue. Now I know what he meant.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org