19 November 2023, 08:30 | #1 |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Uninteruptable mouse movement events
How do I get the mouse position regardless of whether my window is selected or not? I want to get the same kind of coordinates that I get from the report mouse flag, but also get them if a window is selected other than mine.
The ideal solution would be if Intuition could report mouse events to my program, but it would be alright if I had to manually query the mouse position, as long as it always works even when my window is not selected. |
19 November 2023, 09:17 | #2 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,043
|
Add your interrupt handler to input.device.
|
19 November 2023, 09:25 | #3 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,247
|
Quote:
The mouse position in your window is relative to the window, and thus not relative to all other windows. You can get a mouse position relative to the screen from the screen structure, but that is also only valid if the screen contains the active window. Thus, in a sense, what you request is not exactly possible as users may certainly open more screens, and select active windows on other screens. Since such other screens may be larger or smaller, mouse movement on them may be also scaled differently. IOWs, while you can possibly get relative mouse movements, you do not get meaningful mouse coordinates without having a window and an input focus. Thus, please rethink your design - what is it that you need data from the mouse without having the focus? |
|
19 November 2023, 09:51 | #4 |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 532
|
Tricky. The raw mouse events which pass through the input handler contain no mouse position information, just movement delta information.
This has to be translated into the respective screen position of where Intuition has currently placed the mouse pointer. You need to find the screen in which the currently active window resides and copy the Screen->MouseX and Screen->MouseY values. For that to work, you ought to use LockIBase() and UnLockIBase() while you are looking for the active screen. And eventually notify your program where the mouse is currently at. All of this is doable, but easy to get wrong. Calling LockIBase() from within the input handler is strongly discouraged but works most of the time because Intuition was rewritten to allow for it, rather than to deadlock the Intuition state machine (this was easy enough in the Kickstart 1.x days). Generally, I would not recommend this approach. I would recommend using the simplest possible approach the operating system offers you and adapt your program to make the best of it. This is a multitasking operating system after all. You could try polling your program's Screen->MouseX and Screen->MouseY values by using timer.device. 1/10s intervals should be a good start. |
19 November 2023, 10:19 | #5 | |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Quote:
That thing about the screens and active window sounds a bit troublesome though. I think the best way would just be to check MouseX and MouseY every time my library's processing loop is called, and notify the program if it has changed. |
|
19 November 2023, 10:52 | #6 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,006
|
So you do have a window? All the other replyers seem to imply that you don't have a window. If you have a window you can read Window->MouseX and MouseY to get the same coordinates you would get from an IntuiMessage. They are kept up to date even if your window is not the active one.
|
19 November 2023, 11:05 | #7 | |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Quote:
|
|
19 November 2023, 11:21 | #8 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,006
|
Yes.
|
19 November 2023, 11:41 | #9 |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Nice. I'll have to implement a simple test using those to see if they work as I'm expecting.
|
19 November 2023, 13:17 | #10 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,247
|
Yes, but.... As stated earlier, this information is next to useless if a window on another screen has the focus, and intuition (unlike X) has the concept of screens, and multiple of them can be open at the same time, and the focus being somewhere on a different screen.
Thus, again, what makes you think that you need this information? Screen->MouseX,Y or Window->MouseX,Y may *not* be what you expect them to be, in particular if multiple screens are involved. |
19 November 2023, 13:38 | #11 | |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Quote:
To simplify with an example, something you could use to make xeyes, where if follows your pointer constantly. |
|
19 November 2023, 17:32 | #12 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,630
|
Amigas may have multiple screens visible at once, with different resolutions (unlike most other platforms), so I'm not sure that even makes sense - what would the pointer coordinates tell you in such a case?
|
19 November 2023, 21:44 | #13 |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Well the pointer coordinates are relative to the window, so it should still work fine on other screens.
|
19 November 2023, 22:10 | #14 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,247
|
No, it would not. Once again, mouse positions are scaled according to screen resolutions, and screens (in particular on RTG) have different resolutions. That means that a mouse position relative to a screen that is different from the screen your window is sitting on is next to meaningless. This may be quite irrelevant for toys like Xeyes, but if you use this as a design for more relevant software, things can go quite wrong. You can surely read window->MouseX,Y from your window while it is active, and even without receiving mouse movement events, but when your window is not active, these coordinates are not necessarily in a useful relation to where the mouse pointer actually is. It may be even on a completely different monitor for a two-monitor configuration.
|
20 November 2023, 02:18 | #15 |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
@thomas Thankyou for pointing me in this direction. MouseX and MouseY work perfectly for my use. Is there anything that modifies its function that I should be aware of?
|
20 November 2023, 07:30 | #16 |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,652
|
What does your program do that requires knowing the pointer position when another program has the focus?
|
20 November 2023, 07:40 | #17 |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Smoother mouse movement under WinUAE | hexaae | support.WinUAE | 23 | 29 December 2019 13:37 |
custom input events / mouse click? | E-Penguin | support.WinUAE | 2 | 24 November 2018 21:13 |
mouse wheel events | meynaf | Coders. System | 1 | 26 August 2018 16:06 |
Reverse left/right on mouse movement | musojon74 | support.Hardware | 7 | 14 February 2016 17:45 |
Jerky mouse movement | andreas | support.WinUAE | 3 | 02 June 2002 19:14 |
|
|