Warping mouse position

I’m trying to write a game, where the mouse is used to control the camera
angle, Quake styles. However when the mouse cursor leaves the dimensions of
the window, movement stops. Is there a way to ‘warp’ the mouse position
when it gets close to the windows edge? Something like glutWarpMouse().

Secondly can the mouse cursor be changed within SDL, or removed totally?
Yes, it can be turned off. If I remember correctly, the function is
SDL_ShowCursor(0);

It can also be changed, take a look at the SDL docs for details, or get
the SDL color cursor example.

Bye, Karl.

I’m trying to write a game, where the mouse is used to control the camera
angle, Quake styles. However when the mouse cursor leaves the dimensions of
the window, movement stops. Is there a way to ‘warp’ the mouse position
when it gets close to the windows edge? Something like glutWarpMouse().

Secondly can the mouse cursor be changed within SDL, or removed totally?

Arthur.

Arthur J . Yarwood
Enviado el: s?bado, 05 de mayo de 2001 15:56

I’m trying to write a game, where the mouse is used to control the camera
angle, Quake styles. However when the mouse cursor leaves the
dimensions of
the window, movement stops. Is there a way to ‘warp’ the mouse position
when it gets close to the windows edge? Something like glutWarpMouse().

Secondly can the mouse cursor be changed within SDL, or removed totally?

try SDL_ShowCursor (SDL_DISABLED) to hide the cursor.> -----Mensaje original-----

De: owner-sdl at lokigames.com [mailto:owner-sdl at lokigames.com]En nombre de
Para: sdl at lokigames.com
Asunto: [SDL] Warping mouse position


Juan Jos? Pastor Garc?a
@Juan_Jose_Pastor
ICQ: 111208016

I’m trying to write a game, where the mouse is used to control the camera
angle, Quake styles. However when the mouse cursor leaves the dimensions of
the window, movement stops. Is there a way to ‘warp’ the mouse position
when it gets close to the windows edge? Something like glutWarpMouse().

There is an SDL_WarpMouse(…)

http://sdldoc.csn.ul.ie/sdlwarpmouse.php

But if you are doing OpenGL graphics, then by setting it to full screen should
capture the mouse anyway (AFAIK).

Secondly can the mouse cursor be changed within SDL, or removed totally?

SDL_ShowCursor(…) can turn it on or off:

http://sdldoc.csn.ul.ie/sdlshowcursor.php

You can also make your own cursors either with a surface or with SDL’s cursor
creation functions:
http://sdldoc.csn.ul.ie/sdlcreatecursor.php
http://sdldoc.csn.ul.ie/sdlfreecursor.php
http://sdldoc.csn.ul.ie/sdlsetcursor.php
http://sdldoc.csn.ul.ie/sdlgetcursor.phpOn Sat, 05 May 2001, you wrote:


Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >

You don’t have to warp the mouse to handle this.
Just grab the controls with “SDL_WM_GrabInput” and it will be fine.–

Xavier Le Pasteur
@Xavier_Le_Pasteur

----- Original Message -----
From: criswell@geekcomix.com (Sam Hart)
To:
Sent: Saturday, May 05, 2001 6:32 PM
Subject: Re: [SDL] Warping mouse position

On Sat, 05 May 2001, you wrote:

I’m trying to write a game, where the mouse is used to control the
camera

angle, Quake styles. However when the mouse cursor leaves the dimensions
of

the window, movement stops. Is there a way to ‘warp’ the mouse position
when it gets close to the windows edge? Something like glutWarpMouse().

There is an SDL_WarpMouse(…)

http://sdldoc.csn.ul.ie/sdlwarpmouse.php

But if you are doing OpenGL graphics, then by setting it to full screen
should
capture the mouse anyway (AFAIK).

Secondly can the mouse cursor be changed within SDL, or removed totally?

SDL_ShowCursor(…) can turn it on or off:

http://sdldoc.csn.ul.ie/sdlshowcursor.php

You can also make your own cursors either with a surface or with SDL’s
cursor
creation functions:
http://sdldoc.csn.ul.ie/sdlcreatecursor.php
http://sdldoc.csn.ul.ie/sdlfreecursor.php
http://sdldoc.csn.ul.ie/sdlsetcursor.php
http://sdldoc.csn.ul.ie/sdlgetcursor.php


Sam “Criswell” Hart AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >

There is an SDL_WarpMouse(…)

SDL_ShowCursor(…) can turn it on or off:

Cool, found them now, I was looking under the input sections of the docs,
rather than the viea sections. doh! Cheers for your help.

Just got to work out a way of keeping track of the mouse movement now, and
warping it’s positions when it’s going to leave the window, but also not
count the even from the warp as movement in itself. The effect I want is
such that if the user had a really wide mouse mat, they could keep moving
the mouse right, and the camera would keep going round and round to the
right, without the cursor ever leaving the window or hitting the screen
edge, causing motion to stop.

I’m just porting old glut code, and it’s warp function didn’t generate a
motion event you see. I’m thinking every frame grap mouse position, warp
the mouse to the window centre and use the distance between as the motion
values for camera movement. I’ll give it a go.

Thanks,

Arthur.On 2001.05.05 16:32:28 +0000 Samuel Hart wrote:

Just got to work out a way of keeping track of the mouse movement now, and
warping it’s positions when it’s going to leave the window, but also not
count the even from the warp as movement in itself. The effect I want is
such that if the user had a really wide mouse mat, they could keep moving
the mouse right, and the camera would keep going round and round to the
right, without the cursor ever leaving the window or hitting the screen
edge, causing motion to stop.

(Having made this mistake before myself…)

You don’t want to do that. Use SDL_WM_GrabInput(), and it achieves the
exact same effect (actually, on Linux, SDL is doing just that: warping the
mouse to the center of the window when it hits the edge.) … you’ll need
to look at the mouse’s relative position instead of it’s actual position
in the mousemotion events, but that’s probably also more convenient for
your code.

The end effect is that you don’t have to concern yourself with mouse
position, just whether it moved left, right, up, down, or some combination
therein.

–ryan.

Can’t seem to get it to do that. When I enable SDL_WM_GrabMouse(), all it
does is lock the mouse to within the confines of the window. Not tried it
in fullscreen mode yet. It gives the motion fine, but I really need it to
wrap the mouse around to say the left edge, when the user hits the right
edge. Any ideas?

Arthur.On 2001.05.08 08:28:14 +0000 Ryan C. Gordon wrote:

You don’t want to do that. Use SDL_WM_GrabInput(), and it achieves the
exact same effect (actually, on Linux, SDL is doing just that: warping
the
mouse to the center of the window when it hits the edge.) … you’ll need
to look at the mouse’s relative position instead of it’s actual position
in the mousemotion events, but that’s probably also more convenient for
your code.

You need to both grab the mouse and hide the cursor to get the effect you
want.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software> On 2001.05.08 08:28:14 +0000 Ryan C. Gordon wrote:

You don’t want to do that. Use SDL_WM_GrabInput(), and it achieves the
exact same effect (actually, on Linux, SDL is doing just that: warping
the
mouse to the center of the window when it hits the edge.) … you’ll need
to look at the mouse’s relative position instead of it’s actual position
in the mousemotion events, but that’s probably also more convenient for
your code.

Can’t seem to get it to do that. When I enable SDL_WM_GrabMouse(), all it
does is lock the mouse to within the confines of the window. Not tried it
in fullscreen mode yet. It gives the motion fine, but I really need it to
wrap the mouse around to say the left edge, when the user hits the right
edge. Any ideas?

I actually didn’t know about this one…

…well… you learn something new everyday ;-)On Mon, 07 May 2001, you wrote:

You don’t have to warp the mouse to handle this.
Just grab the controls with “SDL_WM_GrabInput” and it will be fine.


Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Advogato: < http://advogato.org/person/criswell/ >