Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mouse Not Returning Proper X/Y changes?  (Read 1729 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Posted 2006-12-15 20:03:10 »

I've been trying to translate the position of the Mouse to actual X/Y coordinates, using two integer variables mouseX and mouseY. When the program starts, I use java.awt.Robot to move the mouse to 300,300 and set the mouse position to that point. Then, every time I poll the mouse I add the value of its x component and its y component to the position variables, because what I understood as the mouse value was what its pixel change was. However, when I output the mouse values, they are completely wrong, changing much more over the same distance if I move the mouse slowly rather than quickly, sometimes eventually becoming entirely negative (which is obviously wrong).

Any ideas?

See my work:
OTC Software
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #1 - Posted 2006-12-18 13:38:43 »

From the directx documentation
Quote
The data returned for the x-axis and y-axis of a mouse indicates the movement of the mouse itself, not the cursor. The units of measurement are based on the values returned by the mouse hardware and have nothing to do with pixels or any other form of screen measurement. Because Microsoft?DirectInput?communicates directly with the mouse driver, the values for mouse speed and acceleration set by the user in Control Panel do not affect this data.

So, erm, your screwed Sad.

There are a number of things that might cause the negative data. The driver is one, the value from the mouse driver might be velocity, not distance moved, so you would need to factor time into figuring out the distance moved. You might also be filling the buffer when the mouse is moving quickly. In the old version of jinput it dumped a statement out when the buffer overflowed. I could do a magic build with it back in, just to see if this is your problem.

You might want to consider trying the raw plugin, but I suspect that again it talks to the mouse driver direct.

edit: The AWT plugin will give you the mouse movement in pixels.

Endolf

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2007-01-15 19:46:36 »

Okay, I'll look into the AWT plugin. For now, I simply made a certain key combination plus the arrow keys would move your mouse around, thereby allowing absolute mouse position control. The only problem with this, of course, is that if someone wants to record the key presses and mouse movements at the same time – then the buttons used to move the mouse can't be recorded.

I also thought of perhaps getting the mouse movement difference, then constraining it by moving it a set number of positive pixels with any sort of positive movement, and the same for negative movement. I didn't use this because it had the potential to get frustrating, and the OS still had use of the mouse so quite often it was moving where it should, then hopping to where I wanted it to be pretty awkwardly.

In any case, I'll check out the AWT plugin. Where exactly can I find it, by the way? And is it an AWT plugin for JInput, or for Java? I'm Googling it now, but the results so far aren't so great.

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #3 - Posted 2007-01-15 21:47:28 »

It should be in the jinput jar already. specify the property jinput.plugins with the value net.java.games.input.AWTEnvironmentPlugin

HTH

Endolf

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #4 - Posted 2007-01-16 18:12:50 »

Excellent, I'll take a look. Thanks. Smiley

See my work:
OTC Software
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #5 - Posted 2007-01-17 01:37:32 »

Okay, I've looked at it, and I don't quite understand what you want me to do. I found the AWTEnvironmentPlugin and got the controller from that instead of a ControllerEnvironment, but that makes no difference to anything as far as I can tell. And there is a jinput.util.plugins folder with Plugin, PluginLoader, and Plugins classes, but I am unsure what you want me to do with them.

Thanks.

See my work:
OTC Software
Offline endolf

JGO Coder


Medals: 7
Exp: 15 years


Current project release date: sometime in 3003


« Reply #6 - Posted 2007-01-17 07:20:19 »

1  
java -cp <your jar here>;jinput.jar -Djava.library.path=<path you dll's> -Djinput.plugins=net.java.games.input.AWTEnvironmentPlugin <your main class here>


Then just get the controllers from the
1  
ControllerEnvironment.getDefaultEnvironment().getControllers()
as before. You should find some new controllers in there. One of which would be a mouse.

HTH

Endolf

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!