Changes to support compiling input-overhaul branch on macOS
This commit is contained in:
parent
9d2e1f92cb
commit
ef9803b25e
|
|
@ -2359,6 +2359,7 @@ def WriteConfigSettings():
|
|||
dtool_config["HAVE_GLX"] = 'UNDEF'
|
||||
dtool_config["IS_LINUX"] = 'UNDEF'
|
||||
dtool_config["HAVE_VIDEO4LINUX"] = 'UNDEF'
|
||||
dtool_config["PHAVE_LINUX_INPUT_H"] = 'UNDEF'
|
||||
dtool_config["IS_OSX"] = '1'
|
||||
# 10.4 had a broken ucontext implementation
|
||||
if int(platform.mac_ver()[0][3]) <= 4:
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ private:
|
|||
NSView *_view;
|
||||
NSUInteger _modifier_keys;
|
||||
CGDirectDisplayID _display;
|
||||
PT(GraphicsWindowInputDevice) _input;
|
||||
bool _mouse_hidden;
|
||||
bool _context_needs_update;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,9 +65,10 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||
_fullscreen_mode = NULL;
|
||||
_windowed_mode = NULL;
|
||||
|
||||
GraphicsWindowInputDevice device =
|
||||
PT(GraphicsWindowInputDevice) device =
|
||||
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
||||
add_input_device(device);
|
||||
_input_devices.push_back(device.p());
|
||||
_input = move(device);
|
||||
|
||||
CocoaGraphicsPipe *cocoa_pipe;
|
||||
DCAST_INTO_V(cocoa_pipe, _pipe);
|
||||
|
|
@ -927,7 +928,7 @@ set_properties_now(WindowProperties &properties) {
|
|||
|
||||
if (properties.has_cursor_hidden()) {
|
||||
if (properties.get_cursor_hidden() != _properties.get_cursor_hidden()) {
|
||||
if (properties.get_cursor_hidden() && _input_devices[0].get_pointer().get_in_window()) {
|
||||
if (properties.get_cursor_hidden() && _input->get_pointer().get_in_window()) {
|
||||
[NSCursor hide];
|
||||
_mouse_hidden = true;
|
||||
} else if (_mouse_hidden) {
|
||||
|
|
@ -1502,7 +1503,7 @@ handle_key_event(NSEvent *event) {
|
|||
// flaws are: - OS eats unmodified F11, F12, scroll lock, pause - no up
|
||||
// events for caps lock - no robust way to distinguish updown for modkeys
|
||||
if ([event type] == NSKeyUp) {
|
||||
_input_devices[0].raw_button_up(raw_button);
|
||||
_input->raw_button_up(raw_button);
|
||||
|
||||
} else if ([event type] == NSFlagsChanged) {
|
||||
bool down = false;
|
||||
|
|
@ -1524,15 +1525,15 @@ handle_key_event(NSEvent *event) {
|
|||
down = (modifierFlags & 0x0010);
|
||||
} else if (raw_button == KeyboardButton::caps_lock()) {
|
||||
// Emulate down-up, annoying hack!
|
||||
_input_devices[0].raw_button_down(raw_button);
|
||||
_input->raw_button_down(raw_button);
|
||||
}
|
||||
if (down) {
|
||||
_input_devices[0].raw_button_down(raw_button);
|
||||
_input->raw_button_down(raw_button);
|
||||
} else {
|
||||
_input_devices[0].raw_button_up(raw_button);
|
||||
_input->raw_button_up(raw_button);
|
||||
}
|
||||
} else if (![event isARepeat]) {
|
||||
_input_devices[0].raw_button_down(raw_button);
|
||||
_input->raw_button_down(raw_button);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1556,7 +1557,7 @@ handle_key_event(NSEvent *event) {
|
|||
if ([event type] == NSKeyDown) {
|
||||
NSString *origstr = [event characters];
|
||||
c = [str characterAtIndex: 0];
|
||||
_input_devices[0].keystroke(c);
|
||||
_input->keystroke(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1585,9 +1586,9 @@ handle_key_event(NSEvent *event) {
|
|||
|
||||
// Let's get it off our chest.
|
||||
if ([event type] == NSKeyUp) {
|
||||
_input_devices[0].button_up(button);
|
||||
_input->button_up(button);
|
||||
} else {
|
||||
_input_devices[0].button_down(button);
|
||||
_input->button_down(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1598,9 +1599,9 @@ void CocoaGraphicsWindow::
|
|||
handle_modifier(NSUInteger modifierFlags, NSUInteger mask, ButtonHandle button) {
|
||||
if ((modifierFlags ^ _modifier_keys) & mask) {
|
||||
if (modifierFlags & mask) {
|
||||
_input_devices[0].button_down(button);
|
||||
_input->button_down(button);
|
||||
} else {
|
||||
_input_devices[0].button_up(button);
|
||||
_input->button_up(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1612,14 +1613,14 @@ handle_modifier(NSUInteger modifierFlags, NSUInteger mask, ButtonHandle button)
|
|||
void CocoaGraphicsWindow::
|
||||
handle_mouse_button_event(int button, bool down) {
|
||||
if (down) {
|
||||
_input_devices[0].button_down(MouseButton::button(button));
|
||||
_input->button_down(MouseButton::button(button));
|
||||
|
||||
#ifndef NDEBUG
|
||||
cocoadisplay_cat.spam()
|
||||
<< "Mouse button " << button << " down\n";
|
||||
#endif
|
||||
} else {
|
||||
_input_devices[0].button_up(MouseButton::button(button));
|
||||
_input->button_up(MouseButton::button(button));
|
||||
|
||||
#ifndef NDEBUG
|
||||
cocoadisplay_cat.spam()
|
||||
|
|
@ -1638,7 +1639,7 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) {
|
|||
|
||||
if (absolute) {
|
||||
if (cocoadisplay_cat.is_spam()) {
|
||||
if (in_window != _input_devices[0].get_pointer().get_in_window()) {
|
||||
if (in_window != _input->get_pointer().get_in_window()) {
|
||||
if (in_window) {
|
||||
cocoadisplay_cat.spam() << "Mouse pointer entered window\n";
|
||||
} else {
|
||||
|
|
@ -1653,7 +1654,7 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) {
|
|||
|
||||
} else {
|
||||
// We received deltas, so add it to the current mouse position.
|
||||
MouseData md = _input_devices[0].get_pointer();
|
||||
MouseData md = _input->get_pointer();
|
||||
nx = md.get_x() + x;
|
||||
ny = md.get_y() + y;
|
||||
}
|
||||
|
|
@ -1679,8 +1680,11 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) {
|
|||
}
|
||||
}
|
||||
|
||||
_input_devices[0].set_pointer(in_window, nx, ny,
|
||||
ClockObject::get_global_clock()->get_frame_time());
|
||||
if (in_window) {
|
||||
_input->set_pointer_in_window(nx, ny);
|
||||
} else {
|
||||
_input->set_pointer_out_of_window();
|
||||
}
|
||||
|
||||
if (in_window != _mouse_hidden && _properties.get_cursor_hidden()) {
|
||||
// Hide the cursor if the mouse enters the window, and unhide it when the
|
||||
|
|
@ -1703,20 +1707,20 @@ handle_wheel_event(double x, double y) {
|
|||
<< "Wheel delta " << x << ", " << y << "\n";
|
||||
|
||||
if (y > 0.0) {
|
||||
_input_devices[0].button_down(MouseButton::wheel_up());
|
||||
_input_devices[0].button_up(MouseButton::wheel_up());
|
||||
_input->button_down(MouseButton::wheel_up());
|
||||
_input->button_up(MouseButton::wheel_up());
|
||||
} else if (y < 0.0) {
|
||||
_input_devices[0].button_down(MouseButton::wheel_down());
|
||||
_input_devices[0].button_up(MouseButton::wheel_down());
|
||||
_input->button_down(MouseButton::wheel_down());
|
||||
_input->button_up(MouseButton::wheel_down());
|
||||
}
|
||||
|
||||
// TODO: check if this is correct, I don't own a MacBook
|
||||
if (x > 0.0) {
|
||||
_input_devices[0].button_down(MouseButton::wheel_right());
|
||||
_input_devices[0].button_up(MouseButton::wheel_right());
|
||||
_input->button_down(MouseButton::wheel_right());
|
||||
_input->button_up(MouseButton::wheel_right());
|
||||
} else if (x < 0.0) {
|
||||
_input_devices[0].button_down(MouseButton::wheel_left());
|
||||
_input_devices[0].button_up(MouseButton::wheel_left());
|
||||
_input->button_down(MouseButton::wheel_left());
|
||||
_input->button_up(MouseButton::wheel_left());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,9 +35,8 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||
GraphicsOutput *host) :
|
||||
GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
|
||||
{
|
||||
GraphicsWindowInputDevice device =
|
||||
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard/mouse");
|
||||
_input_devices.push_back(device);
|
||||
_input = GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard/mouse");
|
||||
_input_devices.push_back(_input.p());
|
||||
|
||||
// This will be an offscreen buffer that we use to render the actual
|
||||
// contents.
|
||||
|
|
@ -79,9 +78,9 @@ process_events() {
|
|||
while (_swbuffer->get_event(swb_event)) {
|
||||
// Deal with this event.
|
||||
if (swb_event._flags & SubprocessWindowBuffer::EF_mouse_position) {
|
||||
_input_devices[0].set_pointer_in_window(swb_event._x, swb_event._y);
|
||||
_input->set_pointer_in_window(swb_event._x, swb_event._y);
|
||||
} else if ((swb_event._flags & SubprocessWindowBuffer::EF_has_mouse) == 0) {
|
||||
_input_devices[0].set_pointer_out_of_window();
|
||||
_input->set_pointer_out_of_window();
|
||||
}
|
||||
|
||||
unsigned int diff = swb_event._flags ^ _last_event_flags;
|
||||
|
|
@ -108,14 +107,14 @@ process_events() {
|
|||
int keycode;
|
||||
button = translate_key(keycode, swb_event._code, swb_event._flags);
|
||||
if (keycode != 0 && swb_event._type != SubprocessWindowBuffer::ET_button_up) {
|
||||
_input_devices[0].keystroke(keycode);
|
||||
_input->keystroke(keycode);
|
||||
}
|
||||
}
|
||||
|
||||
if (swb_event._type == SubprocessWindowBuffer::ET_button_up) {
|
||||
_input_devices[0].button_up(button);
|
||||
_input->button_up(button);
|
||||
} else if (swb_event._type == SubprocessWindowBuffer::ET_button_down) {
|
||||
_input_devices[0].button_down(button);
|
||||
_input->button_down(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -552,9 +551,9 @@ translate_key(int &keycode, int os_code, unsigned int flags) const {
|
|||
void SubprocessWindow::
|
||||
transition_button(unsigned int flags, ButtonHandle button) {
|
||||
if (flags) {
|
||||
_input_devices[0].button_down(button);
|
||||
_input->button_down(button);
|
||||
} else {
|
||||
_input_devices[0].button_up(button);
|
||||
_input->button_up(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ private:
|
|||
private:
|
||||
PT(GraphicsBuffer) _buffer;
|
||||
PT(Texture) _texture;
|
||||
PT(GraphicsWindowInputDevice) _input;
|
||||
|
||||
int _fd;
|
||||
size_t _mmap_size;
|
||||
|
|
|
|||
Loading…
Reference in New Issue