![]() |
|
Simple Mouse API feature request |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Currently, users drawing a mouse pointer themselves using draw_sprite in a windowed mode have no way to detect when the mouse moves off of the window. This means that users have no choice but to keep drawing their pointer stuck inside the edge of their program even while the OS mouse is being displayed out side of the window. Allegro uses two int variables called mon and _mouse_on to track whether the mouse is on-screen, but both are local to mouse.c so they can't currently be read. An easy fix would be to add an int mouse_on_screen(); function that returns the value of _mouse_on. This way users who draw the mouse themselves who wish to hide the mouse when it is off of the window can do so by using : if(mouse_on_screen()) {display_mouse();} So my humble request is that these be added to allegro if it is deemed to be proper : mouse.h // AL_FUNC(int, mouse_on_screen , (void)); // mouse.c // int mouse_on_screen() { return _mouse_on; } //
docs : Returns true if the mouse is currently on screen. This can be useful when drawing your own mouse pointers manually in a buffered windowed mode to let you know when to stop drawing your pointer on the buffer. This way you can prevent your pointer from being displayed on your window at the same time as an OS pointer is being displayed outside the window. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
OnlineCop
Member #7,919
October 2006
![]() |
Even if it doesn't get added to the main allegro distribution, this is something I'm adding to my own local copy. Thanks, Edgar, for finding that and posting the "patch" so I can drop it into my own code. You rock! EDIT:
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Yeah, I knew about the inconsistent naming, but thanks for pointing it out anyway. MouseOnScreen() is the way I would name it myself, but mouse_on_screen() fits the allegro naming conventions so I put up that up for the request part. I changed the post so it is consistent now. Please take note that I haven't tested the addition yet.
// c:\ctwoplus\progcode\allegro\GUI_Allegro>mingw32-g++ -Wall -ggdb -c -Ic:\mingw\allegro422modify\include MouseTest.cpp MouseTest.cpp: In function `int _mangled_main()': MouseTest.cpp:33: warning: unused variable 'mxo' MouseTest.cpp:34: warning: unused variable 'myo' c:\ctwoplus\progcode\allegro\GUI_Allegro>mingw32-g++ -Wall -ggdb -o MouseTest.exe MouseTest.o -Lc:\mingw\allegro422modify\lib\mingw32 -lalld -Wl,-subsystem,windows MouseTest.o: In function `Z13_mangled_mainv': c:\ctwoplus\progcode\allegro\GUI_Allegro/MouseTest.cpp:47: undefined reference to `mouse_on_screen' c:\ctwoplus\progcode\allegro\GUI_Allegro> // Even if I use unix fileslashes in the path it doesn't work. It seems the linker found liballd.a, but it must be the wrong one or the mouse.o module (and therefore the library) didn't get compiled properly. Any clues? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
torhu
Member #2,727
September 2002
![]() |
I don't have access to my own PC now, but you probably need to add the symbol to the .def file somehow, to get it added as an export in the DLL. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Quote: I don't have access to my own PC now, but you probably need to add the symbol to the .def file somehow, to get it added as an export in the DLL. I've been searching around and it looks like I need to use the fixdll script - I found fixdll.bat but it says to use fixdll.sh instead. fixdll.bat said:
echo *** Warning !!! // ..... Should I run fixdll.sh through MSYS and then build allegro normally? Or can I use fixdll.bat to make a temporary test? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
torhu
Member #2,727
September 2002
![]() |
For testing this you can probably just add the new symbol at the end of the .def file manually. Then it won't break binary compatibility either. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
... position_mouse_w @1404 mouse_on_screen @1405 I recompiled the dll and archives and the program links properly now. Here's a working example of the program in a zip file of the source, win32 exe, and modified allegro dll. Quote: For testing this you can probably just add the new symbol at the end of the .def file manually. Then it won't break binary compatibility either. Okay, I'll try that. I tried to use MSYS but it seems an AV program is interfering somehow. Description below. I tried to start MSYS but now it doesn't work anymore. I had a working installation and now it opens a couple console windows and closes them immediately. I uninstalled it and reinstalled MSYS and now I get this error in the installation : Quote:
C:\msys\1.0\postinstall>PATH ..\bin;C:\Windows\system32;C:\Windows;C:\Windows\Sy C:\msys\1.0\postinstall>..\bin\sh.exe pi.sh C:\msys\1.0\postinstall>pause I already disabled any AV stuff that I was running and it just doesn't work. I've been googling around and it seems it is related to AV programs so I'm trying a few different things... My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|