|
@@ -65,9 +65,10 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|
|
_fullscreen_mode = NULL;
|
|
_fullscreen_mode = NULL;
|
|
|
_windowed_mode = NULL;
|
|
_windowed_mode = NULL;
|
|
|
|
|
|
|
|
- GraphicsWindowInputDevice device =
|
|
|
|
|
|
|
+ PT(GraphicsWindowInputDevice) device =
|
|
|
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
|
GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
|
|
- add_input_device(device);
|
|
|
|
|
|
|
+ _input_devices.push_back(device.p());
|
|
|
|
|
+ _input = move(device);
|
|
|
|
|
|
|
|
CocoaGraphicsPipe *cocoa_pipe;
|
|
CocoaGraphicsPipe *cocoa_pipe;
|
|
|
DCAST_INTO_V(cocoa_pipe, _pipe);
|
|
DCAST_INTO_V(cocoa_pipe, _pipe);
|
|
@@ -927,7 +928,7 @@ set_properties_now(WindowProperties &properties) {
|
|
|
|
|
|
|
|
if (properties.has_cursor_hidden()) {
|
|
if (properties.has_cursor_hidden()) {
|
|
|
if (properties.get_cursor_hidden() != _properties.get_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];
|
|
[NSCursor hide];
|
|
|
_mouse_hidden = true;
|
|
_mouse_hidden = true;
|
|
|
} else if (_mouse_hidden) {
|
|
} 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
|
|
// flaws are: - OS eats unmodified F11, F12, scroll lock, pause - no up
|
|
|
// events for caps lock - no robust way to distinguish updown for modkeys
|
|
// events for caps lock - no robust way to distinguish updown for modkeys
|
|
|
if ([event type] == NSKeyUp) {
|
|
if ([event type] == NSKeyUp) {
|
|
|
- _input_devices[0].raw_button_up(raw_button);
|
|
|
|
|
|
|
+ _input->raw_button_up(raw_button);
|
|
|
|
|
|
|
|
} else if ([event type] == NSFlagsChanged) {
|
|
} else if ([event type] == NSFlagsChanged) {
|
|
|
bool down = false;
|
|
bool down = false;
|
|
@@ -1524,15 +1525,15 @@ handle_key_event(NSEvent *event) {
|
|
|
down = (modifierFlags & 0x0010);
|
|
down = (modifierFlags & 0x0010);
|
|
|
} else if (raw_button == KeyboardButton::caps_lock()) {
|
|
} else if (raw_button == KeyboardButton::caps_lock()) {
|
|
|
// Emulate down-up, annoying hack!
|
|
// Emulate down-up, annoying hack!
|
|
|
- _input_devices[0].raw_button_down(raw_button);
|
|
|
|
|
|
|
+ _input->raw_button_down(raw_button);
|
|
|
}
|
|
}
|
|
|
if (down) {
|
|
if (down) {
|
|
|
- _input_devices[0].raw_button_down(raw_button);
|
|
|
|
|
|
|
+ _input->raw_button_down(raw_button);
|
|
|
} else {
|
|
} else {
|
|
|
- _input_devices[0].raw_button_up(raw_button);
|
|
|
|
|
|
|
+ _input->raw_button_up(raw_button);
|
|
|
}
|
|
}
|
|
|
} else if (![event isARepeat]) {
|
|
} 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) {
|
|
if ([event type] == NSKeyDown) {
|
|
|
NSString *origstr = [event characters];
|
|
NSString *origstr = [event characters];
|
|
|
c = [str characterAtIndex: 0];
|
|
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.
|
|
// Let's get it off our chest.
|
|
|
if ([event type] == NSKeyUp) {
|
|
if ([event type] == NSKeyUp) {
|
|
|
- _input_devices[0].button_up(button);
|
|
|
|
|
|
|
+ _input->button_up(button);
|
|
|
} else {
|
|
} 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) {
|
|
handle_modifier(NSUInteger modifierFlags, NSUInteger mask, ButtonHandle button) {
|
|
|
if ((modifierFlags ^ _modifier_keys) & mask) {
|
|
if ((modifierFlags ^ _modifier_keys) & mask) {
|
|
|
if (modifierFlags & mask) {
|
|
if (modifierFlags & mask) {
|
|
|
- _input_devices[0].button_down(button);
|
|
|
|
|
|
|
+ _input->button_down(button);
|
|
|
} else {
|
|
} 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::
|
|
void CocoaGraphicsWindow::
|
|
|
handle_mouse_button_event(int button, bool down) {
|
|
handle_mouse_button_event(int button, bool down) {
|
|
|
if (down) {
|
|
if (down) {
|
|
|
- _input_devices[0].button_down(MouseButton::button(button));
|
|
|
|
|
|
|
+ _input->button_down(MouseButton::button(button));
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
#ifndef NDEBUG
|
|
|
cocoadisplay_cat.spam()
|
|
cocoadisplay_cat.spam()
|
|
|
<< "Mouse button " << button << " down\n";
|
|
<< "Mouse button " << button << " down\n";
|
|
|
#endif
|
|
#endif
|
|
|
} else {
|
|
} else {
|
|
|
- _input_devices[0].button_up(MouseButton::button(button));
|
|
|
|
|
|
|
+ _input->button_up(MouseButton::button(button));
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
#ifndef NDEBUG
|
|
|
cocoadisplay_cat.spam()
|
|
cocoadisplay_cat.spam()
|
|
@@ -1638,7 +1639,7 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) {
|
|
|
|
|
|
|
|
if (absolute) {
|
|
if (absolute) {
|
|
|
if (cocoadisplay_cat.is_spam()) {
|
|
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) {
|
|
if (in_window) {
|
|
|
cocoadisplay_cat.spam() << "Mouse pointer entered window\n";
|
|
cocoadisplay_cat.spam() << "Mouse pointer entered window\n";
|
|
|
} else {
|
|
} else {
|
|
@@ -1653,7 +1654,7 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) {
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
// We received deltas, so add it to the current mouse position.
|
|
// 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;
|
|
nx = md.get_x() + x;
|
|
|
ny = md.get_y() + y;
|
|
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()) {
|
|
if (in_window != _mouse_hidden && _properties.get_cursor_hidden()) {
|
|
|
// Hide the cursor if the mouse enters the window, and unhide it when the
|
|
// 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";
|
|
<< "Wheel delta " << x << ", " << y << "\n";
|
|
|
|
|
|
|
|
if (y > 0.0) {
|
|
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) {
|
|
} 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
|
|
// TODO: check if this is correct, I don't own a MacBook
|
|
|
if (x > 0.0) {
|
|
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) {
|
|
} 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());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|