Custom Mouse

Hello all,

I have a SDL application that runs in portrait mode. Now I have a problem, the
mouse is still working in landscape. So I thought I would just hide the system
mouse and make my own.

My question is what’s the best way to do it. I’m still a beginner with SDL, so
I don’t know the sources very well. Is it easier to change the sources so that
the mouse is now inverted !?

TIA for any insights/ideas.

wpr.

I think you can define your own image for the mouse fairly simply
through a simple SDL call (although the call espcaes me).
Personally, I hide the mouse and blit a custom image instead. This
has the advantage of showing anything at all, but of course is prone
to the same frame rate jerks that any lowly blit is.On Fri, 23 Jul 2004 09:17:42 +0000 (UTC), wpr <mlopes_filho at yahoo.com.br> wrote:

Hello all,

I have a SDL application that runs in portrait mode. Now I have a problem, the
mouse is still working in landscape. So I thought I would just hide the system
mouse and make my own.

My question is what’s the best way to do it. I’m still a beginner with SDL, so
I don’t know the sources very well. Is it easier to change the sources so that
the mouse is now inverted !?

TIA for any insights/ideas.

wpr.


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


Rob Sadedin
No Substance Software (www.nosubstancesoftware.com)

Hello all,

I have a SDL application that runs in portrait mode. Now I have a
problem, the
mouse is still working in landscape. So I thought I would just hide
the system
mouse and make my own.

My question is what’s the best way to do it. I’m still a beginner with
SDL, so
I don’t know the sources very well. Is it easier to change the sources
so that
the mouse is now inverted !?

I didn’t know what you meant until I read Rob Sadedin’s reply to your
email. It would have been more clear had you said “cursor” or “mouse
cursor.”

Use these:

http://sdldoc.csn.ul.ie/sdlsetcursor.php
http://sdldoc.csn.ul.ie/sdlcreatecursor.phpOn Jul 23, 2004, at 5:17 AM, wpr wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

I didn’t know what you meant until I read Rob Sadedin’s reply to your
email. It would have been more clear had you said “cursor” or “mouse
cursor.”

Use these:

http://sdldoc.csn.ul.ie/sdlsetcursor.php
http://sdldoc.csn.ul.ie/sdlcreatecursor.php

Sure!! You are right, I should make myself clearer next time.
But notice that I don’t only want to change the cursor, but the movement, so
that x axis becomes the y and the other way around.
I have already custom cursors.

The idea from Rob works, but as he said I’ll have to draw the mouse cursor in
the same frame rate as the application. I’ll probably end up doing so because
of time constraints. But I will try to find a way to do it inside the SDL.

Thanks for pointing it anyway.

wpr.

But notice that I don’t only want to change the cursor, but the
movement, so
that x axis becomes the y and the other way around.

What operating system are you using? Are you as of yet doing anything
special when capturing mouse movements?

To my understanding, your graphical working environment (ie XFree86,
Apple Quartz) is responsible for mouse movement. Please describe your
working environment a bit more.On Jul 23, 2004, at 7:08 AM, wpr wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

But notice that I don’t only want to change the cursor, but the
movement, so
that x axis becomes the y and the other way around.

What operating system are you using? Are you as of yet doing anything
special when capturing mouse movements?

To my understanding, your graphical working environment (ie XFree86,
Apple Quartz) is responsible for mouse movement. Please describe your
working environment a bit more.

Hi,

Right now my app runs only under windows since I wrote code to select the
monitor in a multi-display sytem. The software will run in 3D stereo, and the
monitor is in portrait format (it has to be).

Unfortunatelly I cannot rely on the graphic card or any other pivot software
because it’s my experience that everything becomes too slow.

So, now i have my OpenGL/SDL scene rotated 90 degrees, everything is fine, but
the mouse movements are still running as the display would be in landscape, so
if I move the mouse left, for my app it’s moving down. That’s why i need to
convert the x->y and then shown my custom cursor.

The resson I’m using SDL is basically because I want to port it later to Linux
and also because of the current audio and image loading support.
The application also supports video, only under windows using directshow. I
need to implement that also under Linux… later.

So, should I modify SDL, I was lokking inside the code and I found a method
called something private mouse (can’t remember now) and warpMouse something. I
usually don’t like to modify the library but it seems to me the best solution.

TIA

wpr> On Jul 23, 2004, at 7:08 AM, wpr wrote:

Donny Viszneki <smirk thebuicksix.com> writes:

But notice that I don’t only want to change the cursor, but the
movement, so
that x axis becomes the y and the other way around.

What operating system are you using? Are you as of yet doing anything
special when capturing mouse movements?

To my understanding, your graphical working environment (ie XFree86,
Apple Quartz) is responsible for mouse movement. Please describe your
working environment a bit more.

Hi,

Right now my app runs only under windows since I wrote code to select
the
monitor in a multi-display sytem.

Are you running in full screen or windowed mode? Running in a
pseudo-full screen environment may be a plausible solution (in other
words, creating a window that occupies the whole screen, but is in fact
not full-screen mode.)

This is still in my opinion a bug in Windows (though you may still want
to work around it, perhaps you should report it to Microsoft? I don’t
know how good they are about fixing bugs, and I doubt any commercial
game has been developed for pivoting displays.)

The software will run in 3D stereo, and the
monitor is in portrait format (it has to be).

Stereoscopy is so cool, as a matter of fact I have been spending a lot
of time trying to figure out a game design that makes stereoscopy more
than just eye candy, and actually an important strategic element to the
game. But I digress…

Out of curiosity, why does it have to be in portrait format?

Unfortunatelly I cannot rely on the graphic card or any other pivot
software
because it’s my experience that everything becomes too slow.

Could you provide some links to “pivot software?” Again, this is the OS
vendor’s responsibility, but it’s your choice if you wish to try and
find a work-around until they’ve addressed the problem.

So, now i have my OpenGL/SDL scene rotated 90 degrees, everything is
fine, but
the mouse movements are still running as the display would be in
landscape, so
if I move the mouse left, for my app it’s moving down. That’s why i
need to
convert the x->y and then shown my custom cursor.

I can’t stress enough that this is the responsibility of the Operating
System Vendor, in this case, Microsoft.

The best workaround you can probably use (and for all intents and
purposes, it’s a pretty good one,) would simply be to translate the
position coordinates for the mouse at the beginning of your mouse
message handling.

This is probably better than the solution I mentioned above, running in
pseudo-full-screen. The theory I’m working with here is that when
Windows is in control of video (not a full screen application) the
mouse cursor MUST be working fine in portrait mode (meaning, that
Windows DOES translate the cursor in this case.) Not even Microsoft
could have missed a bug like that. However it is quite likely that they
never tested a video game in portrait mode.

The resson I’m using SDL is basically because I want to port it later
to Linux
and also because of the current audio and image loading support.
The application also supports video, only under windows using
directshow. I
need to implement that also under Linux… later.

Kudos to you.

So, should I modify SDL, I was lokking inside the code and I found a
method
called something private mouse (can’t remember now) and warpMouse
something. I
usually don’t like to modify the library but it seems to me the best
solution.

Your best solution is probably just to have a binary value that tells
the game whether or not it needs to translate mouse position
coordinates! Like I said earlier, begin your loop by translating the
coordinates. This simply means swapping the X and Y values, plus
performing some polarity inversion depending on which way the screen
rotates (I guess.)

In your case, you said moving the cursor left (negative movement along
the X axis) moves down on your screen (positive movement along the Y
axis.) Which suggests that your screen rotates 90 degrees counter
clockwise for portrait mode. So to perform the translation, do
something like this:

if (PortraitModeEnabled && event->type == SDL_MOUSEMOTION)
{
int x = event->motion.x;
int y = event->motion.y;

// Which direction are we rotating?
if (CounterClockWisePortraitMode) x = - x;
else y = - y;

// Assign switched values!
event->motion.x = y;
event->motion.y = x;
}

}

Depending on your program, you may want to catch more event types than
mouse motion events. Perhaps you could catch mouse button events as
well this way.

I can’t really help you determine the value of
CounterClockWisePortraitMode or PortraitModeEnabled (although the
latter may be an easy one since you did say that it MUST be in
portrait mode, I’m still quite curious about that!) However it might be
best for it to be an option the first time you run the game. A message
could appear and a mouse cursor saying “move your mouse! is it working
alright?” And if the answer is no, perhaps they can hit the letter N on
the keyboard or something to invert the value of
CounterClockWisePortaitMode, thereby fixing the mouse rotation.

Hope this helps you get your project underway…

ps. please tell me more about your project, I’m very curious to hear
about this stereoscopic portrait-mode only application!On Jul 23, 2004, at 5:08 PM, wpr wrote:

On Jul 23, 2004, at 7:08 AM, wpr wrote:

TIA

wpr


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

Donny Viszneki <smirk thebuicksix.com> writes:

Are you running in full screen or windowed mode? Running in a
pseudo-full screen environment may be a plausible solution (in other
words, creating a window that occupies the whole screen, but is in fact
not full-screen mode.)

I’m running in pseudo-full screen.

This is still in my opinion a bug in Windows (though you may still want
to work around it, perhaps you should report it to Microsoft? I don’t
know how good they are about fixing bugs, and I doubt any commercial
game has been developed for pivoting displays.)

In this case, windows does not know that I’m in portrait since I’m rendering
the scene in portrait but the window is still a normal one.
Right now I’m testing it with NVIDIA’s Nview in horizontal span, this was the
best solution for performance till now.

Stereoscopy is so cool, as a matter of fact I have been spending a lot
of time trying to figure out a game design that makes stereoscopy more
than just eye candy, and actually an important strategic element to the
game. But I digress…

Out of curiosity, why does it have to be in portrait format?

Ok, the display works with lenticular lenses so because of the pixel
structure, if it would be placed in landscape, there would be only rainbows.
The advantadge is that you can use a LCD panel, and get less than 2%
crosstalking. The resulting 3D effect is pretty amazing.
It’s a pitty that there is no LCD panel with another technology, where the
pixels are rotated 90 degrees.
Note that the 3D display cannot be used as 2D. That’s why the multi-display
system.

Could you provide some links to “pivot software?” Again, this is the OS
vendor’s responsibility, but it’s your choice if you wish to try and
find a work-around until they’ve addressed the problem.

Until now I only used the one provided with the displays from NEC. I found
another one google but I can’t find it again. Sorry.

This is probably better than the solution I mentioned above, running in
pseudo-full-screen. The theory I’m working with here is that when
Windows is in control of video (not a full screen application) the
mouse cursor MUST be working fine in portrait mode (meaning, that
Windows DOES translate the cursor in this case.) Not even Microsoft
could have missed a bug like that. However it is quite likely that they
never tested a video game in portrait mode.

Here you are right, if I use the rotate software, it works fine but slow.

I need to implement that also under Linux… later.

Kudos to you.

I’ll check it. Thanks.

if (PortraitModeEnabled && event->type == SDL_MOUSEMOTION)
{
int x = event->motion.x;
int y = event->motion.y;

// Which direction are we rotating?
if (CounterClockWisePortraitMode) x = - x;
else y = - y;

// Assign switched values!
event->motion.x = y;
event->motion.y = x;
}
}

Depending on your program, you may want to catch more event types than
mouse motion events. Perhaps you could catch mouse button events as
well this way.

Uhm, looks good. I’ll try it.

it MUST be in
portrait mode, I’m still quite curious about that!)

:slight_smile: Just check it:
http://www.hhi.fraunhofer.de/english/im/products/Cebit/free2C/free2C.html

A message
could appear and a mouse cursor saying “move your mouse! is it working
alright?” And if the answer is no, perhaps they can hit the letter N on
the keyboard or something to invert the value

This is really what I need to do, since it could happen that the display is
rotated clockwise.

Hope this helps you get your project underway…

ps. please tell me more about your project, I’m very curious to hear
about this stereoscopic portrait-mode only application!

Right now I’m just writing a demo, for a presentation. Later I’ll try to
convert a flight simulator: http://www.dragonslayer.dk/ to this portrait mode.

But I’m a bit skeptical about the gaming market. Portrait mode is a big
disadvantage.

Thanks a lot.

wpr.