Mouse Stuff

Started by knoggly, October 21, 2004, 19:43:18

Previous topic - Next topic

knoggly

Hi,

i have some questions concerning the mouse and lwjgl (V0.92).

I have my mouse up and running and get input from the mouse, BUT

1) when the mouse reaches any border of my screen i get no more delta-values or better said they are 0. I tried setPosition() to reset the mouse to the center - doesn't work, I tried getScrollX() / getScrollY() - doesn't work either.
I looked at the MouseTest-Example and there is the same problem.

Am I doing something wrong or is it not possible what I try.

2) how can I hide the mouse-cursor setGrabbed() seems not to work.

If something is not clear just ask, I would be glad if I get some response.

knoggly

Gom Jabbar

What exactly is your problem with setGrabbed?
I just tried Mouse.setGrabbed(true) with 0.92 and it works perfectly fine.

princec

Knoggly, can we have your system specs?

Cas :)

knoggly

Hi,

this are my system spec's

PC(Athlon XP2000, Asus A7V266-Board)
OS: Windows 2000 SP4
JDK 1.4.2_02
JRE 1.4.2_02
lwjgl V0.92

but I don't think the hardware is the problem.

My problem with setGrabbed() is, that is does nothing :) . I setGrabbed() an still can see the mouse cursor in fullscreen and windowed mode.

Here is the code segment which does my mouse-polling and init:
------------snip--------------------
   
public static void init() throws Exception {
       Mouse.create();
       Mouse.enableBuffer();
       
       // Grab mouse
       Mouse.setGrabbed(true);
   }


public static void poll() {
       int dx;
       int dy;
       
       Mouse.poll();

       // get mouse-motion
       dx=Mouse.getDX()+Mouse.getScrollX();
       dy=Mouse.getDY()+Mouse.getScrollY();
       
       // process input here but left out for clarity
   }

------------snip--------------------

In my main-loop i call poll() repeadly and as I said it works fine until I reach the screen-border (e.g. when I reach the left border I get no more negative dx-values, the dy-values of course still work).

knoggly

princec

I can't see all of your init code there.. How are you creating the display and such?

Cas :)

knoggly

Well, if it helps :) here it is
my display init-code

----------------------snip-----------------------
public void createWindow(int width, int height, int bbp, int refreshRate, boolean fullscreen, java.lang.String title) throws Exception {
       if(fullscreen) {
           DisplayMode d[] = Display.getAvailableDisplayModes();
           int mode = -1;
           for (int i = 0; i < d.length; i++) {
               if (d.getWidth() == width && d.getHeight() == height && d.getBitsPerPixel() == bbp && d.getFrequency()==refreshRate ) {
                   mode = i;
                   break;
               }
           }
           if( mode==-1 )
               throw new Exception("Error - Display mode not supportet");
           else {
               try {
                   Display.setDisplayMode(d[mode]);
                   Display.setTitle(title);
                   Display.setFullscreen(fullscreen);
                   Display.create();
               }
               catch( Exception e ) {
                   throw new Exception("Error - Create window",e);
               }
           }
       }
       
       // init opengl
       initGL();
   }

----------------------snip-----------------------

but I can only repeat myself this stuff works it's only a problem with the mouse-coordinates at the borders.

knoggly

princec

getScrollX/Y only works when the mouse is grabbed. The mystery is why your system is unable to grab the mouse.

Cas :)

knoggly

ok, then i'll try a simpler example to test if the mouse grabbing works. But not today :).
Thanks for your help so far

knoggly

knoggly

aaaaah, SHAME ON ME !!!

I found my mistake (I didn't call my init-methods)  :oops:

now it works

Sorry and thanks for your help anyway

knoggly