Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6948525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:50:05+00:00 2026-05-27T13:50:05+00:00

I am working on a first person game in Java, and I am trying

  • 0

I am working on a first person game in Java, and I am trying to get the 3D movement working.

My problem is I would like to capture mouse movement, yet keep the mouse inside the window. After I capture the mouse movement, I figure the best way to keep the mouse in my window is to center the mouse in the window after moving, using Robot.moveMouse(x,y). This works fine, however the movement from the Robot triggers an event in my window which then gets interpreted as a normal event, and thus moves my character in the world.

I’ve tried various schemes of keeping state and ignoring movements until I am in the center, but they all seem finicky and don’t quite detect which events are user vs Robot controlled.

Is there an easy way to detect that a mouse movement came from the Robot?

Is there perhaps a simpler way to solve my problem that I am overlooking?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:50:05+00:00Added an answer on May 27, 2026 at 1:50 pm

    I solved this by switching to NEWT with JOGL 2.0 RC4. In particular, I use GLWindow and warpPointer instead of an AWT Frame with the Robot.mouseMove. With the switch, I instantly got smooth movements. Some sample code similar to what I’m doing (mileage may vary):

    public class MyClass implements MouseListener {
        private GLWindow window;
        private int centeredX = -1;
        private int centeredY = -1;
    
        // ...
    
        public void mouseMoved(MouseEvent e) {
            if (centeredX == -1 || centeredY == -1) {
                center();
                return;
            }
    
            int deltaX = e.getX() - centeredX;
            int deltaY = e.getY() - centeredY;
    
            // ... Do something with the deltas
    
            centeredX = window.getWidth() / 2;
            centeredY = window.getHeight() / 2;
            window.warpPointer(centeredX, centeredY);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a FPS (first person shooter) game at the moment, I want
I'm working on my first 'real' F# assembly, and trying to do things right.
I can't be the first person to have this problem, I must be missing
I am working on a system where hash collisions would be a problem. Essentially
This seems like an incredibly simple problem however it isn't working out as trivially
I am trying to get dynamic select menu's working in my Rails application. I
I have pretty much finished my first working Symbian application, but in my hastened
For some weird reason, the codes below are first working, then website is redirecting
Working on my first Rails project, I used Ryan Bates' Nifty-Generators to create the
I'm working for the first time with Forms Authentication, I'm using an example from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.