Re: [AD] Using system mouse cursor

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Evert Glebbeek wrote:
I've used the mickeys function directly and I've tried just repositioning the mouse and getting the difference myself. They both have stuttering problems, though the mickeys function moreso.

Weird... I don't understand this problem at all really... I'll see if I can reproduce it when I use some of my own programs a bit more (not just the tests provided by Allegro).

Well.. one think I suppose I should've mentioned, I'm polling a Vorbis stream in a timer, too. :x Don't totally freak out though, I'm making sure that Allegro's multithreading before even attempting that. AFAIK, X's input thread is seperate from the timer thread, so I don't see that really being a problem anyway.

What I'd propose is the following: disable the mouse warping hack in X11 windowed mode (so that it behaves as Windows does), but have a default warping mode in fullscreen mode. In this case, Allegro is responsible for drawing the mouse cursor, otherwise we can use the system cursor. Add a function that allows the user to override this behavior explicitly say, int set_mouse_mode(int mode) where mode can be any of (say) MOUSE_WARP, MOUSE_NORMAL, MOUSE_AUTO. MOUSE_WARP enables the mouse warping, MOUSE_NORMAL disables it, MOUSE_AUTO switches to whatever is the default (non-warped for X11 Windowed, warped for X11 fullscreen and non-warped for Windows in any case. Not sure how the MacOS X port handles these things). Returns 0 on succes, non-zero on failure (in Windows, it wouldn't do anything with the current design, or rather, it wouldn't be nescessary). We can add a flag to gfx_capabilities to tell the user wether or not mouse mickeys requires warping the cursor (although this may be abuse of the gfx_capabilities variable).

Sounds quite complex. I'm trying to get away from any kind of mouse warping though.. I would like the OS's cursor position to be the same as Allegro's cursor position as much as possible. AFAIK, this is 100% possible.. set_mouse_position calls XWarpMouse (or whatever it is) and offsets Allegro's internal position trackers so the next mouse movement event that re-positions the mouse is ignored (I thought I read the XWarpMouse causes X to send a mouse movement event), but otherwise the internal variables are updated as given by X.

Now, this obviously breaks Allegro programs.. get_mouse_mickeys is gauranteed (by default) unlimited mouse movement. So what I propose is this. Take a function like I've described, but extend it like so:

int enable_soft_mouse(int enable);
Enables/disables the software mouse cursor. When enabled, this causes Allegro to always trap the OS mouse position to the center of the program area, but still update mouse_x/mouse_y to cover the mouse range and provide unlimited mouse mickeys while using the timer to draw the mouse cursor. Turning it off will disable get_mouse_mickeys, but untrap the mouse and possibly allow Allegro to have the OS handle drawing the cursor. The mouse_* vars will still be updated as expected. Default is /enabled/ to maintain compatibility with existing programs.

So, this is sort of like a mouse warp hack, but it's not really a hack anymore since it would be a clean implemention at API-level.

- Kitty Cat




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/