Ok, If I run my game in a windowed mode and I want to display the hardware cursor I can do:
And it appears and works fine.
However, when I want to hide the mouse cursor so I can return to the game I can't seem to get rid of the OS cursor!
I'm currently trying:
select_mouse_cursor(MOUSE_CURSOR_NONE); show_mouse(screen); scare_mouse(); disable_hardware_cursor();
And I'm tried various combinations but the hardware cursor is still there. Does anyone have any idea?
Allegro 4.2.0, Windows XP, using AllegroGL 0.4.0 and OpenLayer 2.0
Thanks!
Rich.
Try:
show_mouse(NULL);
Also, in case you do not want to fall back to the software cursor when no HW cursor is available, it's simpler to use show_os_cursor() instead of enable_hardware_cursor()/show_mouse().
Elias:
If that works, then I'm taking the credit 
Pete
Nope, I already tried show_mouse(NULL). I don't know whether because I am using AllegroGL this is relevant?
Any more ideas?
Nope, I already tried show_mouse(NULL).
Elias, that was terrible advice, you idiot. 
Pete
ps. That mouse code is platform dependent, so we really need a Windows person to determine what the problem is.
This is the disable_hardware_cursor section (mouse.c):
| 1 | /* disable_hardware_cursor: |
| 2 | * disables the hardware cursor on platforms where this interferes with |
| 3 | * mickeys and disables system cursors. |
| 4 | */ |
| 5 | void disable_hardware_cursor(void) |
| 6 | { |
| 7 | if ((mouse_driver) && (mouse_driver->enable_hardware_cursor)) { |
| 8 | mouse_driver->enable_hardware_cursor(FALSE); |
| 9 | allow_system_cursor = FALSE; |
| 10 | if (is_same_bitmap(_mouse_screen, screen)) { |
| 11 | BITMAP *bmp = _mouse_screen; |
| 12 | show_mouse(NULL); |
| 13 | show_mouse(bmp); |
| 14 | } |
| 15 | } |
| 16 | } |
However, the enable_hardware_cursor in the windows driver is empty (wmouse.c):
/* mouse_directx_enable_hardware_cursor: * enable the hardware cursor; actually a no-op in Windows, but we need to * put something in the vtable. */ static void mouse_directx_enable_hardware_cursor(int mode) { /* Do nothing */ (void)mode; }
So it seems only allow_system_cursor = FALSE; is really being changed and this is used in show_mouse():
| 1 | /* show_mouse: |
| 2 | * Tells Allegro to display a mouse pointer. This only works when the timer |
| 3 | * module is active. The mouse pointer will be drawn onto the bitmap bmp, |
| 4 | * which should normally be the hardware screen. To turn off the mouse |
| 5 | * pointer, which you must do before you draw anything onto the screen, call |
| 6 | * show_mouse(NULL). If you forget to turn off the mouse pointer when |
| 7 | * drawing something, the SVGA bank switching code will become confused and |
| 8 | * will produce garbage all over the screen. |
| 9 | */ |
| 10 | void show_mouse(BITMAP *bmp) |
| 11 | { |
| 12 | if (!mouse_driver) |
| 13 | return; |
| 14 | |
| 15 | remove_int(mouse_move); |
| 16 | |
| 17 | /* Remove the mouse cursor */ |
| 18 | if (_mouse_screen) { |
| 19 | acquire_bitmap(_mouse_screen); |
| 20 | |
| 21 | if (gfx_capabilities & GFX_HW_CURSOR) { |
| 22 | gfx_driver->hide_mouse(); |
| 23 | gfx_capabilities &= ~(GFX_HW_CURSOR|GFX_SYSTEM_CURSOR); |
| 24 | hw_cursor_dirty = TRUE; |
| 25 | } |
| 26 | else |
| 27 | draw_mouse(TRUE, FALSE); |
| 28 | |
| 29 | release_bitmap(_mouse_screen); |
| 30 | } |
| 31 | |
| 32 | _mouse_screen = bmp; |
| 33 | |
| 34 | if (bmp && (current_cursor != MOUSE_CURSOR_NONE)) { |
| 35 | acquire_bitmap(_mouse_screen); |
| 36 | |
| 37 | /* Default system cursor? */ |
| 38 | if ((current_cursor != MOUSE_CURSOR_ALLEGRO) && allow_system_cursor) { |
| 39 | if (mouse_driver && mouse_driver->select_system_cursor) { |
| 40 | use_system_cursor = mouse_driver->select_system_cursor(current_cursor); |
| 41 | if (use_system_cursor) { |
| 42 | gfx_capabilities |= GFX_HW_CURSOR|GFX_SYSTEM_CURSOR; |
| 43 | hw_cursor_dirty = FALSE; |
| 44 | got_hw_cursor = TRUE; |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | else { |
| 49 | use_system_cursor = FALSE; |
| 50 | } |
| 51 | |
| 52 | /* Custom hardware cursor? */ |
| 53 | if (hw_cursor_dirty) { |
| 54 | got_hw_cursor = FALSE; |
| 55 | |
| 56 | if ((gfx_driver) && (gfx_driver->set_mouse_sprite) && (!_dispsw_status)) |
| 57 | if (gfx_driver->set_mouse_sprite(mouse_sprite, mouse_x_focus, mouse_y_focus) == 0) |
| 58 | got_hw_cursor = TRUE; |
| 59 | |
| 60 | hw_cursor_dirty = FALSE; |
| 61 | } |
| 62 | |
| 63 | /* Try to display hardware (custom or system) cursor */ |
| 64 | if ((got_hw_cursor) && (is_same_bitmap(bmp, screen))) |
| 65 | if (gfx_driver->show_mouse(bmp, mx=mouse_x, my=mouse_y) == 0) |
| 66 | gfx_capabilities |= GFX_HW_CURSOR; |
| 67 | |
| 68 | /* Draw cursor manually if we can't do that */ |
| 69 | if (!(gfx_capabilities & GFX_HW_CURSOR)) { |
| 70 | draw_mouse(FALSE, TRUE); |
| 71 | use_system_cursor = FALSE; |
| 72 | } |
| 73 | |
| 74 | release_bitmap(_mouse_screen); |
| 75 | |
| 76 | install_int(mouse_move, 10); |
| 77 | } |
| 78 | else { |
| 79 | if (mouse_driver->timer_poll) |
| 80 | install_int(mouse_move, 10); |
| 81 | } |
| 82 | } |
Ok. Show mouse calls:
gfx_driver->hide_mouse();
But I can't find any entry in wmouse.c for this..?
My problem is I can't make the hardware cursor disappear on the Mac in fullscreen. It seems the Mac Allegro fullscreen driver shows the hardware cursor regardless of what you try to tell it.
If that works, then I'm taking the credit 
Elias, that was terrible advice, you idiot.
Yes, yes, now I see how you thought that out 
My guess is, the AllegroGL GFX_DRIVER needs the methods show_mouse and hide_mouse filled in. And we also need to find out why the current implementation doesn't work at all with fullscreen mode in Windows - I'm sure I have seen games use the mouse in fullscreen mode, so there should be a way to do it.
I've had to use a software cursor in the end, which is not ideal and of course looks different from the OS cursor.
I don't have time to try to add the changes myself or wait for them to be done. But these kind of things do really need doing..
However, the enable_hardware_cursor in the windows driver is empty (wmouse.c):
Right; that's because Windows doesn't need anything special to enable the hardware cursor (or rather, the hardware cursor in Windows doesn't interfere with get_mouse_mickeys() as it does in X11, where get_mouse_mickeys() causes the hardware cursor to be trapped in the window).
And we also need to find out why the current implementation doesn't work at all with fullscreen mode in Windows
Because Windows cannot display a mouse cursor in a full-screen DirectX application. At least the normal Windows way for setting the mouse cursor doesn't do anything in that case. This is documented, so it probably doesn't count as a bug.
If there is a DirectX way of doing this, I couldn't find it when I looked into this.
EDIT: I checked MSDN, several tutorials and SDL at the time; none of them gave a clue that it could be done.
I did try using the MSN commands ShowCursor(FALSE), ChangeCursor, but none of them seemed to have any effect. I suspect Allegro is rechanging the values.
Because Windows cannot display a mouse cursor in a full-screen DirectX application. At least the normal Windows way for setting the mouse cursor doesn't do anything in that case. This is documented, so it probably doesn't count as a bug.
If there is a DirectX way of doing this, I couldn't find it when I looked into this.
EDIT: I checked MSDN, several tutorials and SDL at the time; none of them gave a clue that it could be done.
Hm, I think I remember, I got the mouse cursor displayed in some fullscreen app when I did in fact not even want it. But well, probably makes sense in some way, the HW cursor probably interferes with the full control you get over the GFX card with DX. And maybe it changes in Vista.
That's strange because bugs.txt from AllegroGL says:
On Win32 platforms, the mouse cursor (Windows style) is not always hidden
in fullscreen mode.
Workaround while the bug is not fixed : call 'set_gfx_mode(GFX_TEXT,0,0,0,0)'
before the actual 'set_gfx_mode' (workaround suggested by Martin Dusek).
I guess bugs.txt can be declared deprecated
I did try using the MSN commands ShowCursor(FALSE), ChangeCursor, but none of them seemed to have any effect. I suspect Allegro is rechanging the values.
No, reread what I said: it doesn't work. I tried the exact same thing when I implemented the hardware cursor for Windows a year (two years?) ago.
I must have missed your edit then..
You were quick then, since I added my edit almost immediately. I actually thought it was a redundant addition... apparently not though 
(Redundant because we of course all do our homework before saying that X cannot do Y, right?)
EDIT: On fullscreen OpenGL, that may very well be a different issue (I have really no idea). My understanding is that Windows cannot display a cursor on a fullscreen DirectX surface.
So aside from the fullscreen cursor issue, we have no idea why we cannot remove the hardware cursor from the screen in windowed mode after being turned on?