What this pull request is about?
This pull request implements an additional mode of passing mouse movement. When enabled, it passes the mouse motion in absolute coordinate: this changes in-dos pointer behavior of mouse pointer directly go to touched point, or iPad's pointing device point.
Essentially, this pull request is doing the same thing to that of pull request #60. But this pull request is more polished, and more up-to-date with current code base. Absolute coordinate mode is a small extension mode of current mouse handling code in SDL_uikitview, and it support all current features (right click, pointing device) in the same manner.
My motivation was originally on supporting better HW mouse. With this patch, pointing devices (ipad magic keyboard, or bluetooh mouse) finally behaves quite close to a native mouse. For example, there would be no more strange pointer-stuck-in-the-middle due to iPad pointer hitting screen limit. However, handling direct touch (pointer to touch location) was also carefully checked and implemented. After some days of testing, I believe this is more or less feature complete. Now I am making it a pull-request for further discussion, and/or improvements.
How to use? (user perspective)
The patch adds a settings group named "mouse absolute coordinate", which has single toggle switch (enables absolute mode), and two scale factor selection button (X scale and Y scale). By switch on "Enable" toggle, you can start using the patched absolute coordinate mode.
Touch will then bring the mouse to the touched location (if scale factor is correct, see below). Button behavior is the same to normal (relative) mode; where you can do left click by tab, or right click by dual touch tab, and so on, depending on your other settings. First touch (primary touch) will always have the mouse pointer. If you hold and drag, the pointer will also follow your finger location.
Note that, each dos program may need different scale factor. If you don't know about a program's mouse scale -- It is a good to start with 1x, since even if that isn't the right factor, you will see the mouse pointer and have some idea what additional factor you need to make it sync with your touch point.
How is it implemented? (code change overview)
- SDL_Mouse actually supports both absolute mode and relative mode. However, dosbox's mouse event handling part (sdlmain::HandleMouseMotion) picks up only the relative values, and do not really sync the reported absolute coordinate of SDL mouse.
- This patch changes dosbox mouse event handling code to respect absolute value, if the passed event was generated by a SDL_Mouse in absolute value mode. The event (SDL_MouseMotionEvent) and event sender (SDL_SendMouseMotion) has been updated to hold relative_mode flag in the event data structure.
With the above data path enabled, then actual absolute coordinate mode logic has been added to SDL_uikitview:
- ensureSDLMouse method is updated to ensure the single SDL_mouse's relative_mode value to relative / absolute according to the setting.
- added a method sendMouseCoordinate, which sends absolute coordinate (vs. movement of sendMouseMotion)
- touchesBegan, touchesMoved, touchesEnded and pointerInteraction has been updated to hold additional logic of absolute modes.