ares-openbsd/hiro/cocoa
David DeGraw 35299b18d3
macOS: Implement mouse driver (#1446)
There are a few ways to get mouse position: GCMouse and using NSEvent.

GCMouse is newer and better, it reports mouse movement in raw x/y deltas
which is exactly what we need. The issue is that it expects you to set
up handlers for the movement events , but I couldn't figure out a way to
do that with the existing `poll()` paradigm where it passes the device
into the function. Ideally I'd be able to do
`assign(HID::Mouse::GroupID::Axis, 0, deltaX);` directly in the event
handler.

The other advantage to GCMouse is that we can use
`CGAssociateMouseAndMouseCursorPosition` and then we don't have to worry
about moving the hidden cursor over built in UI (such as the dock).

This implementation uses regular NSEvent for mouse data which works
pretty well with the current poll() paradigm. I had difficulty handing
mouse centering/zeroing so I left it out. It works pretty well both full
screen and windowed but it is possible to accidentally click the dock.

Open to feedback so please let me know what you think! I'd love to get
GCMouse working.

Demo:
https://www.youtube.com/watch?v=UwPyVNWP5hM
2024-04-09 18:05:54 +01:00
..
action
widget macOS: Implement mouse driver (#1446) 2024-04-09 18:05:54 +01:00
application.cpp
application.hpp
browser-window.cpp
browser-window.hpp
desktop.cpp
desktop.hpp
font.cpp
font.hpp
group.cpp
group.hpp
header.hpp
keyboard.cpp
keyboard.hpp
menu-bar.cpp
menu-bar.hpp
message-window.cpp
message-window.hpp
monitor.cpp
monitor.hpp
mouse.cpp
mouse.hpp
object.cpp
object.hpp
platform.cpp
platform.hpp
popup-menu.cpp
popup-menu.hpp
sizable.cpp
sizable.hpp
status-bar.cpp
status-bar.hpp Update to v096r02 (OS X Preview for Developers) release. 2016-01-07 19:17:15 +11:00
timer.cpp
timer.hpp
utility.cpp
window.cpp
window.hpp