Mouse n00b

Hello all,

Been looking through the docs, and chapter 3 (input handling)
has a bunch of stuff about keyb and joysticks, but nothing on mice…
Are there any docs out there for mice handling?

Anyway, I’ve just started doing some mouse stuff and I’ve got a couple of
Qs…
To make things easier to explain, assume the mouse is used to control
a camera.

  1. When running on windowed mode, if the mouse is outside the app window
    and you slowly bring it in, the minute it enters the window (it doens’t
    matter
    if you’ve got focus yet or not) the xrel/yrel values that are reported are
    HUGE.
    This causes the camera to jerk quite badly…
    I could use the SDL_ACTIVEEVENT to zero the mouse inputs for this given tick
    but I’m not sure if there are any guarantees about the order events get
    triggered.
    In other words if you have something like

SDL_Event event;

while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_ACTIVEEVENT:
// if the mouse just entered the window, reset mouse inputs
break;

	case SDL_MOUSEMOTION:
	// store mouse motion stuff
	break;
}

}

This will only work if SDL_ACTIVEEVENT is reported AFTER SDL_MOUSEMOTION.
Tbh, it doesn’t really matter what order events get reported…As long as
the
order is always the same you can make this work…
The main question is: are the events ALWAYS GUARANTEED to be reported in
the same order?

  1. When the cursor hits the edge of the window (in this case when running in
    fullscreen mode) you can’t get any more info for xrel/yrel. How can I:
  • hide the mouse cursor
  • every tick grab the mouse and force it to be in the middle of the screen
    (so that I can always have valid xrel/yrel values)

thanx in advance,
k.

ahem…ignore me…just came across this:

“If the cursor is hidden (SDL_ShowCursor(0)) and the input is grabbed
(SDL_WM_GrabInput(SDL_GRAB_ON)),
then the mouse will give relative motion events even when the cursor reaches
the edge fo the screen.
This is currently only implemented on Windows and Linux/Unix-a-likes.”

on

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

It seems to sort out both my problems…

cheers,
K.> ----- Original Message -----

From: sdl-bounces+kos=climaxgroup.com@libsdl.org
[mailto:sdl-bounces+kos=climaxgroup.com at libsdl.org]On Behalf Of Kostas
Kostiadis
Sent: 06 January 2005 11:37
To: SDL list (E-mail)
Subject: [SDL] mouse n00b

Hello all,

Been looking through the docs, and chapter 3 (input handling)
has a bunch of stuff about keyb and joysticks, but nothing on mice…
Are there any docs out there for mice handling?

Anyway, I’ve just started doing some mouse stuff and I’ve got a couple of
Qs…
To make things easier to explain, assume the mouse is used to control
a camera.

  1. When running on windowed mode, if the mouse is outside the app window
    and you slowly bring it in, the minute it enters the window (it doens’t
    matter
    if you’ve got focus yet or not) the xrel/yrel values that are reported are
    HUGE.
    This causes the camera to jerk quite badly…
    I could use the SDL_ACTIVEEVENT to zero the mouse inputs for this given tick
    but I’m not sure if there are any guarantees about the order events get
    triggered.
    In other words if you have something like

SDL_Event event;

while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_ACTIVEEVENT:
// if the mouse just entered the window, reset mouse inputs
break;

  case SDL_MOUSEMOTION:
  // store mouse motion stuff
  break;

}
}

This will only work if SDL_ACTIVEEVENT is reported AFTER SDL_MOUSEMOTION.
Tbh, it doesn’t really matter what order events get reported…As long as
the
order is always the same you can make this work…
The main question is: are the events ALWAYS GUARANTEED to be reported in
the same order?

  1. When the cursor hits the edge of the window (in this case when running in
    fullscreen mode) you can’t get any more info for xrel/yrel. How can I:
  • hide the mouse cursor
  • every tick grab the mouse and force it to be in the middle of the screen
    (so that I can always have valid xrel/yrel values)

thanx in advance,
k.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl