Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » get_mouse_mickeys() alternative for windowed modes

Credits go to CGamesPlay, Dustin Dettmer, and Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
get_mouse_mickeys() alternative for windowed modes
Paul whoknows
Member #5,081
September 2004
avatar

I am using get_mouse_mickeys() a lot in my game, and it works fine in non-windowed modes, but as the documentation says

TFM said:

Note that the infinite movement may not work in windowed mode, since under some platforms the mouse would leave the window, and may not work at all if the hardware cursor is in use.

How can I replace this function for windowed modes?
I want my game running in both: fullscreen and windowed modes!

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

CGamesPlay
Member #2,559
July 2002
avatar

I just use:position_mouse(SCREEN_W / 2, SCREEN_H / 2)

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Paul whoknows
Member #5,081
September 2004
avatar

It seems that I was not clear enough.
As we all already know, get_mouse_mickeys() measures how far the mouse has moved since the last call to this function, that's exactly what I need to achieve without using this function(because it doesn't work in windowed modes)

Quote:

position_mouse(SCREEN_W / 2, SCREEN_H / 2)

You are positioning the mouse at the center of the screen, that's not what I want.

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Thomas Fjellstrom
Member #476
June 2000
avatar

get_mouse_mickeys will still function if you keep repositioning the mouse in the center.

--
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

CGamesPlay
Member #2,559
July 2002
avatar

If you position the mouse in the center of the screen, get_mouse_mickeys will work, because the user cannot move the mouse outside of the screen.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Dustin Dettmer
Member #3,935
October 2003
avatar

Except on OSX. Or has position_mouse been fixed for that yet?

I actually use delta mouse movement (ie storing the old position and comparing the difference). But I also want the mouse to be able to leave via the bottom in windowed mode. So mickies dont work.

And also most OSs have 'lock the mouse to my window' API calls, allegro should really make that available.

Paul whoknows
Member #5,081
September 2004
avatar

I am slow:P, but now I got it!
However I think that will raise another problems, (I am also using mouse_x, and mouse_y), I'll try it now!
Thanks!

EDIT

Quote:

And also most OSs have 'lock the mouse to my window' API calls

Which Windows specific functions should I use to do that?

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Evert
Member #794
November 2000
avatar

Quote:

How can I replace this function for windowed modes?

You can't, in a portable way.

Paul whoknows
Member #5,081
September 2004
avatar

Quote:

And also most OSs have 'lock the mouse to my window' API calls, allegro should really make that available.

Which Windows specific functions should I use to do that?

____

"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

Which Windows specific functions should I use to do that?

Well, position_mouse works fine, and it works in Linux, too.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Richard Phipps
Member #1,632
November 2001
avatar

Go to: