Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » [Linux] Mouse speed

This thread is locked; no one can reply to it. rss feed Print
[Linux] Mouse speed
miran
Member #2,407
June 2002

I noticed that the speed of the mouse cursor movement in Linux and Windows is different. I mean in 1280x960 (my desktop resolution) it's approximately the same, but when I run a 640x480 game in fullscreen mode there's a big difference. In Windows you physically have to move the same distance to get the cursor from left to right edge of the screen or from top to bottom as when you're in dektop mode. But on Linux the absolute speed of the cursor stays the same in fullscreen so in 640x480 you only need to move the mouse half as much as at 1280x960 to cover the entire screen. This makes the mouse feel twice as sensitive and it makes fullscreen Allegro games running at resolutions lower that 1280x960 (or similar) almost impossible to play.

Is there any way, either in the mouse settings in Linux or in Allegro, to fix this? If moving the mouse 4cm on my desk means the cursor to go from left edge to the right in the 1280x960 desktop, I want the same thing to happen in my 640x480 fullscreen game. Or am I asking too much?

Btw, set_mouse_speed() doesn't seem to have any effect.

--
sig used to be here

Onewing
Member #6,152
August 2005
avatar

That's interesting. Perhaps you just need to translate the mouse coordinates to fit to whatever resolution you change to:

// Untested

// Base Resolution
#define GFX_W 640
#define GFX_H 480

// Translated onto new Resolution (NFX_W, NFX_H)
void draw_mouse(int NFX_W, int NFX_H, BITMAP *bMouse)
{
   double x_rate = GFX_W / NFX_W;
   double y_rate = GFX_H / NFX_H;

   draw_sprite(buffer, bMouse, mouse_x * x_rate, mouse_y * y_rate);
}

------------
Solo-Games.org | My Tech Blog: The Digital Helm

miran
Member #2,407
June 2002

Yeah, but my point is why does this happen on Linux? I googled a bit and read somewhere that X simply can't do relative mouse movement. If this is true, then that's lame.

Btw, how would one find the base resolution? Is there a get_desktop_resolution() function in Allegro or something. If there is, I can't find it in the manual...

--
sig used to be here

Onewing
Member #6,152
August 2005
avatar

Quote:

Yeah, but my point is why does this happen on Linux?

Ah, I was wondering why you didn't put this in the programming forum.

Quote:

Btw, how would one find the base resolution?

Actually, I think you need to find the translated resolution. I was thinking the base resolution would be the resolution the game was set for. Of course, that doesn't answer how to get the desktop physical resolution. I'd do a search, but I'm sure you're perfectly capable of searching the manual and I'd only end up at the same dead end.

------------
Solo-Games.org | My Tech Blog: The Digital Helm

miran
Member #2,407
June 2002

Quote:

but I'm sure you're perfectly capable of searching the manual

Think again. :P I know how to use the .chm manual but there's no such thing on Linux...

--
sig used to be here

kentl
Member #2,905
November 2002

Have you tried xchm? (I haven't.)

miran
Member #2,407
June 2002

Hmm, looks interesting. Hehe, that's one of the things I miss a lot in Linux. The chm allegro manual... :)

--
sig used to be here

Kitty Cat
Member #2,815
October 2002
avatar

Quote:

Yeah, but my point is why does this happen on Linux?

Because when when using the XF86VidMode extension, it simply changes the physical screen resolution and leaves the virtual screen size, and everything else, alone (which is why you can't change color depths, because it'd mess up the pixel format on all the other running apps). There's a new(er) XRandR extension which may or may not help here (Allegro doesn't use this yet, though).

Quote:

Btw, how would one find the base resolution? Is there a get_desktop_resolution() function in Allegro or something. If there is, I can't find it in the manual...

It exists on my machine..
int get_desktop_resolution(int *width, int *height);
Returns 0 on success.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Thomas Fjellstrom
Member #476
June 2000
avatar

Actually, I find X's mouse speed different than Windows.. I think it sets the mouse DPI different or something. But then, KDE has a nice dialog for mouse acceleration and a nice Logitech config dialog, so everythings fine :)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Go to: