Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to control gain between mouse movement and cursor movement ?

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to control gain between mouse movement and cursor movement ?

    Hello, I want to control the gain between the mouse and the cursor in Java using XP.

    For example, I want to be able to make the cursor move 10 pix when the mouse moves x cm (where x could be 2 cm, or 10 cm, or 20 cm, etc.). I want to use a simple parameter, a multiplier, to do this. I can find the value of the parameter empirically (I can move the mouse x cm and play around with the parameter value until I get the 10 pix of cursor movement).

    I know how to:

    - switch off the Windows mouse accelerator so that the relation between mouse movement and cursor movement is linear.

    I don't know how to:

    - access the mouse position data in the registry (?) and then feed that to the Java cursor via a variable/parameter/multiplier.

    Thanks in advance for any replies


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to control gain between mouse movement and cursor movement ?

    What is the difference between the mouse movements and the cursor movements?
    People often use both terms for the same thing, what I call the cursor.
    There is no way for a PC to move the mouse that a user has in his hand.

    Java has no way to go into the Control panel and change OS settings.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to control gain between mouse movement and cursor movement ?

    Thanks for your reply.

    "What is the difference between the mouse movements and the cursor movements?"

    The mouse is what I move with my hand, the cursor is what I see moving on the computer screen. Java must read the mouse position and use this information to position the cursor. For example, if the mouse moves x cm, Java reads this and moves the cursor y pixels. Now, what I want to do is to control the relation between x and y.

    Let's consider only the horizontal component of the movement and suppose that the relation that Java uses is:

    cursorposition = k*mouseposition, where k is a constant.

    I want to be able to change k, so that a mouse movement of x cm no longer produces a cursor movement of y pix. For example, I may want to produce a cursor movement of z pix, where z=l*y. Then I want to be able to implement this relation:

    cursorposition = l*k*mouseposition.

    I hope this clarifies things.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to control gain between mouse movement and cursor movement ?

    I don't think you can do that with pure Java, at least not as you described it. You could use a combination of a MouseListener and the Robot class to get the appearance of something similar though.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Resizing on mouse movement
    By java_novice in forum Java Theory & Questions
    Replies: 9
    Last Post: February 3rd, 2012, 07:53 AM
  2. Sync movement with sound?
    By cl2606 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 2nd, 2011, 05:12 PM
  3. 3D camera movement
    By macko in forum Java Theory & Questions
    Replies: 2
    Last Post: May 17th, 2011, 07:53 AM
  4. JFrame Movement Listening
    By aussiemcgr in forum AWT / Java Swing
    Replies: 3
    Last Post: March 9th, 2011, 11:48 AM
  5. movement
    By mlan in forum Java Theory & Questions
    Replies: 4
    Last Post: February 15th, 2010, 10:57 PM

Tags for this Thread