|
@@ -28,14 +28,10 @@
|
|
|
#include "nativeWindowHandle.h"
|
|
#include "nativeWindowHandle.h"
|
|
|
#include "virtualFileSystem.h"
|
|
#include "virtualFileSystem.h"
|
|
|
#include "get_x11.h"
|
|
#include "get_x11.h"
|
|
|
|
|
+#include "evdevInputDevice.h"
|
|
|
|
|
|
|
|
-#include <errno.h>
|
|
|
|
|
-#include <fcntl.h>
|
|
|
|
|
#include <sys/time.h>
|
|
#include <sys/time.h>
|
|
|
-
|
|
|
|
|
-#ifdef PHAVE_LINUX_INPUT_H
|
|
|
|
|
-#include <linux/input.h>
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
+#include <fcntl.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_XCURSOR
|
|
#ifdef HAVE_XCURSOR
|
|
|
static int xcursor_read(XcursorFile *file, unsigned char *buf, int len) {
|
|
static int xcursor_read(XcursorFile *file, unsigned char *buf, int len) {
|
|
@@ -69,8 +65,6 @@ static int xcursor_seek(XcursorFile *file, long offset, int whence) {
|
|
|
|
|
|
|
|
TypeHandle x11GraphicsWindow::_type_handle;
|
|
TypeHandle x11GraphicsWindow::_type_handle;
|
|
|
|
|
|
|
|
-#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)&7)))
|
|
|
|
|
-
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: x11GraphicsWindow::Constructor
|
|
// Function: x11GraphicsWindow::Constructor
|
|
|
// Access: Public
|
|
// Access: Public
|
|
@@ -107,9 +101,9 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|
|
_override_redirect = False;
|
|
_override_redirect = False;
|
|
|
_wm_delete_window = x11_pipe->_wm_delete_window;
|
|
_wm_delete_window = x11_pipe->_wm_delete_window;
|
|
|
|
|
|
|
|
- GraphicsWindowInputDevice device =
|
|
|
|
|
- GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
|
|
|
|
|
|
+ PT(GraphicsWindowInputDevice) device = GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse");
|
|
|
add_input_device(device);
|
|
add_input_device(device);
|
|
|
|
|
+ _input = device;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
@@ -143,26 +137,26 @@ move_pointer(int device, int x, int y) {
|
|
|
if (device == 0) {
|
|
if (device == 0) {
|
|
|
// Move the system mouse pointer.
|
|
// Move the system mouse pointer.
|
|
|
if (!_properties.get_foreground() ||
|
|
if (!_properties.get_foreground() ||
|
|
|
- !_input_devices[0].get_pointer().get_in_window()) {
|
|
|
|
|
|
|
+ !_input->get_pointer().get_in_window()) {
|
|
|
// If the window doesn't have input focus, or the mouse isn't
|
|
// If the window doesn't have input focus, or the mouse isn't
|
|
|
// currently within the window, forget it.
|
|
// currently within the window, forget it.
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const MouseData &md = _input_devices[0].get_pointer();
|
|
|
|
|
|
|
+ const MouseData &md = _input->get_pointer();
|
|
|
if (!md.get_in_window() || md.get_x() != x || md.get_y() != y) {
|
|
if (!md.get_in_window() || md.get_x() != x || md.get_y() != y) {
|
|
|
if (!_dga_mouse_enabled) {
|
|
if (!_dga_mouse_enabled) {
|
|
|
XWarpPointer(_display, None, _xwindow, 0, 0, 0, 0, x, y);
|
|
XWarpPointer(_display, None, _xwindow, 0, 0, 0, 0, x, y);
|
|
|
}
|
|
}
|
|
|
- _input_devices[0].set_pointer_in_window(x, y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(x, y);
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
} else {
|
|
} else {
|
|
|
// Move a raw mouse.
|
|
// Move a raw mouse.
|
|
|
- if ((device < 1)||(device >= _input_devices.size())) {
|
|
|
|
|
|
|
+ if (device < 1 || device >= _input_devices.size()) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- _input_devices[device].set_pointer_in_window(x, y);
|
|
|
|
|
|
|
+ //_input_devices[device]->set_pointer_in_window(x, y);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -249,8 +243,6 @@ process_events() {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- poll_raw_mice();
|
|
|
|
|
-
|
|
|
|
|
XEvent event;
|
|
XEvent event;
|
|
|
XKeyEvent keyrelease_event;
|
|
XKeyEvent keyrelease_event;
|
|
|
bool got_keyrelease_event = false;
|
|
bool got_keyrelease_event = false;
|
|
@@ -311,25 +303,25 @@ process_events() {
|
|
|
// This refers to the mouse buttons.
|
|
// This refers to the mouse buttons.
|
|
|
button = get_mouse_button(event.xbutton);
|
|
button = get_mouse_button(event.xbutton);
|
|
|
if (!_dga_mouse_enabled) {
|
|
if (!_dga_mouse_enabled) {
|
|
|
- _input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.xbutton.x, event.xbutton.y);
|
|
|
}
|
|
}
|
|
|
- _input_devices[0].button_down(button);
|
|
|
|
|
|
|
+ _input->button_down(button);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case ButtonRelease:
|
|
case ButtonRelease:
|
|
|
button = get_mouse_button(event.xbutton);
|
|
button = get_mouse_button(event.xbutton);
|
|
|
if (!_dga_mouse_enabled) {
|
|
if (!_dga_mouse_enabled) {
|
|
|
- _input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.xbutton.x, event.xbutton.y);
|
|
|
}
|
|
}
|
|
|
- _input_devices[0].button_up(button);
|
|
|
|
|
|
|
+ _input->button_up(button);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case MotionNotify:
|
|
case MotionNotify:
|
|
|
if (_dga_mouse_enabled) {
|
|
if (_dga_mouse_enabled) {
|
|
|
- const MouseData &md = _input_devices[0].get_raw_pointer();
|
|
|
|
|
- _input_devices[0].set_pointer_in_window(md.get_x() + event.xmotion.x_root, md.get_y() + event.xmotion.y_root);
|
|
|
|
|
|
|
+ const MouseData &md = _input->get_pointer();
|
|
|
|
|
+ _input->set_pointer_in_window(md.get_x() + event.xmotion.x_root, md.get_y() + event.xmotion.y_root);
|
|
|
} else {
|
|
} else {
|
|
|
- _input_devices[0].set_pointer_in_window(event.xmotion.x, event.xmotion.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.xmotion.x, event.xmotion.y);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -348,15 +340,15 @@ process_events() {
|
|
|
|
|
|
|
|
case EnterNotify:
|
|
case EnterNotify:
|
|
|
if (_dga_mouse_enabled) {
|
|
if (_dga_mouse_enabled) {
|
|
|
- const MouseData &md = _input_devices[0].get_raw_pointer();
|
|
|
|
|
- _input_devices[0].set_pointer_in_window(md.get_x(), md.get_y());
|
|
|
|
|
|
|
+ const MouseData &md = _input->get_pointer();
|
|
|
|
|
+ _input->set_pointer_in_window(md.get_x(), md.get_y());
|
|
|
} else {
|
|
} else {
|
|
|
- _input_devices[0].set_pointer_in_window(event.xcrossing.x, event.xcrossing.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.xcrossing.x, event.xcrossing.y);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case LeaveNotify:
|
|
case LeaveNotify:
|
|
|
- _input_devices[0].set_pointer_out_of_window();
|
|
|
|
|
|
|
+ _input->set_pointer_out_of_window();
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case FocusIn:
|
|
case FocusIn:
|
|
@@ -365,7 +357,7 @@ process_events() {
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case FocusOut:
|
|
case FocusOut:
|
|
|
- _input_devices[0].focus_lost();
|
|
|
|
|
|
|
+ _input->focus_lost();
|
|
|
properties.set_foreground(false);
|
|
properties.set_foreground(false);
|
|
|
changed_properties = true;
|
|
changed_properties = true;
|
|
|
break;
|
|
break;
|
|
@@ -751,7 +743,7 @@ set_properties_now(WindowProperties &properties) {
|
|
|
XQueryPointer(_display, _xwindow, &event.xbutton.root,
|
|
XQueryPointer(_display, _xwindow, &event.xbutton.root,
|
|
|
&event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root,
|
|
&event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root,
|
|
|
&event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
|
|
&event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
|
|
|
- _input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.xbutton.x, event.xbutton.y);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
x11display_cat.info() << "XF86DGA extension not available\n";
|
|
x11display_cat.info() << "XF86DGA extension not available\n";
|
|
@@ -1295,66 +1287,43 @@ open_raw_mice() {
|
|
|
bool any_mice = false;
|
|
bool any_mice = false;
|
|
|
|
|
|
|
|
for (int i=0; i<64; i++) {
|
|
for (int i=0; i<64; i++) {
|
|
|
- uint8_t evtypes[EV_MAX/8 + 1];
|
|
|
|
|
ostringstream fnb;
|
|
ostringstream fnb;
|
|
|
fnb << "/dev/input/event" << i;
|
|
fnb << "/dev/input/event" << i;
|
|
|
string fn = fnb.str();
|
|
string fn = fnb.str();
|
|
|
int fd = open(fn.c_str(), O_RDONLY | O_NONBLOCK, 0);
|
|
int fd = open(fn.c_str(), O_RDONLY | O_NONBLOCK, 0);
|
|
|
if (fd >= 0) {
|
|
if (fd >= 0) {
|
|
|
- any_present = true;
|
|
|
|
|
- char name[256];
|
|
|
|
|
- char phys[256];
|
|
|
|
|
- char uniq[256];
|
|
|
|
|
- if ((ioctl(fd, EVIOCGNAME(sizeof(name)), name) < 0)||
|
|
|
|
|
- (ioctl(fd, EVIOCGPHYS(sizeof(phys)), phys) < 0)||
|
|
|
|
|
- (ioctl(fd, EVIOCGPHYS(sizeof(uniq)), uniq) < 0)||
|
|
|
|
|
- (ioctl(fd, EVIOCGBIT(0, EV_MAX), &evtypes) < 0)) {
|
|
|
|
|
- close(fd);
|
|
|
|
|
- x11display_cat.error() <<
|
|
|
|
|
- "Opening raw mice: ioctl failed on " << fn << "\n";
|
|
|
|
|
- } else {
|
|
|
|
|
- if (test_bit(EV_REL, evtypes) || test_bit(EV_ABS, evtypes)) {
|
|
|
|
|
- for (char *p=name; *p; p++) {
|
|
|
|
|
- if (((*p<'a')||(*p>'z')) && ((*p<'A')||(*p>'Z')) && ((*p<'0')||(*p>'9'))) {
|
|
|
|
|
- *p = '_';
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- for (char *p=uniq; *p; p++) {
|
|
|
|
|
- if (((*p<'a')||(*p>'z')) && ((*p<'A')||(*p>'Z')) && ((*p<'0')||(*p>'9'))) {
|
|
|
|
|
- *p = '_';
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- string full_id = ((string)name) + "." + uniq;
|
|
|
|
|
- MouseDeviceInfo inf;
|
|
|
|
|
- inf._fd = fd;
|
|
|
|
|
- inf._input_device_index = _input_devices.size();
|
|
|
|
|
- inf._io_buffer = "";
|
|
|
|
|
- _mouse_device_info.push_back(inf);
|
|
|
|
|
- GraphicsWindowInputDevice device =
|
|
|
|
|
- GraphicsWindowInputDevice::pointer_only(this, full_id);
|
|
|
|
|
- add_input_device(device);
|
|
|
|
|
- x11display_cat.info() << "Raw mouse " <<
|
|
|
|
|
- inf._input_device_index << " detected: " << full_id << "\n";
|
|
|
|
|
- any_mice = true;
|
|
|
|
|
- } else {
|
|
|
|
|
- close(fd);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ EvdevInputDevice *device = new EvdevInputDevice(fd);
|
|
|
|
|
+ nassertd(device != NULL) continue;
|
|
|
|
|
+
|
|
|
|
|
+ if (device->has_pointer()) {
|
|
|
|
|
+ add_input_device(device);
|
|
|
|
|
+
|
|
|
|
|
+ x11display_cat.info()
|
|
|
|
|
+ << "Raw mouse " << _input_devices.size()
|
|
|
|
|
+ << " detected: " << device->get_name() << "\n";
|
|
|
|
|
+
|
|
|
|
|
+ any_mice = true;
|
|
|
|
|
+ any_present = true;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- if ((errno == ENOENT)||(errno == ENOTDIR)) {
|
|
|
|
|
|
|
+ if (errno == ENOENT || errno == ENOTDIR) {
|
|
|
break;
|
|
break;
|
|
|
} else {
|
|
} else {
|
|
|
any_present = true;
|
|
any_present = true;
|
|
|
- x11display_cat.error() <<
|
|
|
|
|
- "Opening raw mice: " << strerror(errno) << " " << fn << "\n";
|
|
|
|
|
|
|
+ x11display_cat.error()
|
|
|
|
|
+ << "Opening raw mice: " << strerror(errno) << " " << fn << "\n";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!any_present) {
|
|
|
|
|
|
|
+ if (any_mice) {
|
|
|
|
|
+ _properties.set_raw_mice(true);
|
|
|
|
|
+
|
|
|
|
|
+ } else if (!any_present) {
|
|
|
x11display_cat.error() <<
|
|
x11display_cat.error() <<
|
|
|
"Opening raw mice: files not found: /dev/input/event*\n";
|
|
"Opening raw mice: files not found: /dev/input/event*\n";
|
|
|
- } else if (!any_mice) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
x11display_cat.error() <<
|
|
x11display_cat.error() <<
|
|
|
"Opening raw mice: no mouse devices detected in /dev/input/event*\n";
|
|
"Opening raw mice: no mouse devices detected in /dev/input/event*\n";
|
|
|
}
|
|
}
|
|
@@ -1364,69 +1333,6 @@ open_raw_mice() {
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: x11GraphicsWindow::poll_raw_mice
|
|
|
|
|
-// Access: Private
|
|
|
|
|
-// Description: Reads events from the raw mouse device files.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-void x11GraphicsWindow::
|
|
|
|
|
-poll_raw_mice() {
|
|
|
|
|
-#ifdef PHAVE_LINUX_INPUT_H
|
|
|
|
|
- for (int di = 0; di < _mouse_device_info.size(); ++di) {
|
|
|
|
|
- MouseDeviceInfo &inf = _mouse_device_info[di];
|
|
|
|
|
-
|
|
|
|
|
- // Read all bytes into buffer.
|
|
|
|
|
- if (inf._fd >= 0) {
|
|
|
|
|
- while (1) {
|
|
|
|
|
- char tbuf[1024];
|
|
|
|
|
- int nread = read(inf._fd, tbuf, sizeof(tbuf));
|
|
|
|
|
- if (nread > 0) {
|
|
|
|
|
- inf._io_buffer += string(tbuf, nread);
|
|
|
|
|
- } else {
|
|
|
|
|
- if ((nread < 0) && ((errno == EWOULDBLOCK) || (errno==EAGAIN))) {
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- close(inf._fd);
|
|
|
|
|
- inf._fd = -1;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Process events.
|
|
|
|
|
- int nevents = inf._io_buffer.size() / sizeof(struct input_event);
|
|
|
|
|
- if (nevents == 0) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- const input_event *events = (const input_event *)(inf._io_buffer.c_str());
|
|
|
|
|
- GraphicsWindowInputDevice &dev = _input_devices[inf._input_device_index];
|
|
|
|
|
- int x = dev.get_raw_pointer().get_x();
|
|
|
|
|
- int y = dev.get_raw_pointer().get_y();
|
|
|
|
|
- for (int i = 0; i < nevents; i++) {
|
|
|
|
|
- if (events[i].type == EV_REL) {
|
|
|
|
|
- if (events[i].code == REL_X) x += events[i].value;
|
|
|
|
|
- if (events[i].code == REL_Y) y += events[i].value;
|
|
|
|
|
- } else if (events[i].type == EV_ABS) {
|
|
|
|
|
- if (events[i].code == ABS_X) x = events[i].value;
|
|
|
|
|
- if (events[i].code == ABS_Y) y = events[i].value;
|
|
|
|
|
- } else if (events[i].type == EV_KEY) {
|
|
|
|
|
- if ((events[i].code >= BTN_MOUSE) && (events[i].code < BTN_MOUSE + 8)) {
|
|
|
|
|
- int btn = events[i].code - BTN_MOUSE;
|
|
|
|
|
- dev.set_pointer_in_window(x, y);
|
|
|
|
|
- if (events[i].value) {
|
|
|
|
|
- dev.button_down(MouseButton::button(btn));
|
|
|
|
|
- } else {
|
|
|
|
|
- dev.button_up(MouseButton::button(btn));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- inf._io_buffer.erase(0, nevents * sizeof(struct input_event));
|
|
|
|
|
- dev.set_pointer_in_window(x, y);
|
|
|
|
|
- }
|
|
|
|
|
-#endif
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: x11GraphicsWindow::handle_keystroke
|
|
// Function: x11GraphicsWindow::handle_keystroke
|
|
|
// Access: Private
|
|
// Access: Private
|
|
@@ -1436,7 +1342,7 @@ poll_raw_mice() {
|
|
|
void x11GraphicsWindow::
|
|
void x11GraphicsWindow::
|
|
|
handle_keystroke(XKeyEvent &event) {
|
|
handle_keystroke(XKeyEvent &event) {
|
|
|
if (!_dga_mouse_enabled) {
|
|
if (!_dga_mouse_enabled) {
|
|
|
- _input_devices[0].set_pointer_in_window(event.x, event.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.x, event.y);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (_ic) {
|
|
if (_ic) {
|
|
@@ -1454,14 +1360,14 @@ handle_keystroke(XKeyEvent &event) {
|
|
|
// Now each of the returned wide characters represents a
|
|
// Now each of the returned wide characters represents a
|
|
|
// keystroke.
|
|
// keystroke.
|
|
|
for (int i = 0; i < len; i++) {
|
|
for (int i = 0; i < len; i++) {
|
|
|
- _input_devices[0].keystroke(buffer[i]);
|
|
|
|
|
|
|
+ _input->keystroke(buffer[i]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
// Without an input context, just get the ascii keypress.
|
|
// Without an input context, just get the ascii keypress.
|
|
|
ButtonHandle button = get_button(event, true);
|
|
ButtonHandle button = get_button(event, true);
|
|
|
if (button.has_ascii_equivalent()) {
|
|
if (button.has_ascii_equivalent()) {
|
|
|
- _input_devices[0].keystroke(button.get_ascii_equivalent());
|
|
|
|
|
|
|
+ _input->keystroke(button.get_ascii_equivalent());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1475,30 +1381,32 @@ handle_keystroke(XKeyEvent &event) {
|
|
|
void x11GraphicsWindow::
|
|
void x11GraphicsWindow::
|
|
|
handle_keypress(XKeyEvent &event) {
|
|
handle_keypress(XKeyEvent &event) {
|
|
|
if (!_dga_mouse_enabled) {
|
|
if (!_dga_mouse_enabled) {
|
|
|
- _input_devices[0].set_pointer_in_window(event.x, event.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.x, event.y);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Now get the raw unshifted button.
|
|
// Now get the raw unshifted button.
|
|
|
ButtonHandle button = get_button(event, false);
|
|
ButtonHandle button = get_button(event, false);
|
|
|
if (button != ButtonHandle::none()) {
|
|
if (button != ButtonHandle::none()) {
|
|
|
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
|
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
|
|
- _input_devices[0].button_down(KeyboardButton::control());
|
|
|
|
|
|
|
+ _input->button_down(KeyboardButton::control());
|
|
|
}
|
|
}
|
|
|
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
|
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
|
|
- _input_devices[0].button_down(KeyboardButton::shift());
|
|
|
|
|
|
|
+ _input->button_down(KeyboardButton::shift());
|
|
|
}
|
|
}
|
|
|
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
|
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
|
|
- _input_devices[0].button_down(KeyboardButton::alt());
|
|
|
|
|
|
|
+ _input->button_down(KeyboardButton::alt());
|
|
|
}
|
|
}
|
|
|
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
|
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
|
|
- _input_devices[0].button_down(KeyboardButton::meta());
|
|
|
|
|
|
|
+ _input->button_down(KeyboardButton::meta());
|
|
|
}
|
|
}
|
|
|
- _input_devices[0].button_down(button);
|
|
|
|
|
|
|
+ _input->button_down(button);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ButtonHandle raw_button = map_raw_button(event.keycode);
|
|
|
|
|
- if (raw_button != ButtonHandle::none()) {
|
|
|
|
|
- _input_devices[0].raw_button_down(raw_button);
|
|
|
|
|
|
|
+ if (event.keycode >= 9 && event.keycode <= 135) {
|
|
|
|
|
+ ButtonHandle raw_button = map_raw_button(event.keycode);
|
|
|
|
|
+ if (raw_button != ButtonHandle::none()) {
|
|
|
|
|
+ _input->raw_button_down(raw_button);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1511,30 +1419,32 @@ handle_keypress(XKeyEvent &event) {
|
|
|
void x11GraphicsWindow::
|
|
void x11GraphicsWindow::
|
|
|
handle_keyrelease(XKeyEvent &event) {
|
|
handle_keyrelease(XKeyEvent &event) {
|
|
|
if (!_dga_mouse_enabled) {
|
|
if (!_dga_mouse_enabled) {
|
|
|
- _input_devices[0].set_pointer_in_window(event.x, event.y);
|
|
|
|
|
|
|
+ _input->set_pointer_in_window(event.x, event.y);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Now get the raw unshifted button.
|
|
// Now get the raw unshifted button.
|
|
|
ButtonHandle button = get_button(event, false);
|
|
ButtonHandle button = get_button(event, false);
|
|
|
if (button != ButtonHandle::none()) {
|
|
if (button != ButtonHandle::none()) {
|
|
|
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
|
if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) {
|
|
|
- _input_devices[0].button_up(KeyboardButton::control());
|
|
|
|
|
|
|
+ _input->button_up(KeyboardButton::control());
|
|
|
}
|
|
}
|
|
|
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
|
if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) {
|
|
|
- _input_devices[0].button_up(KeyboardButton::shift());
|
|
|
|
|
|
|
+ _input->button_up(KeyboardButton::shift());
|
|
|
}
|
|
}
|
|
|
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
|
if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) {
|
|
|
- _input_devices[0].button_up(KeyboardButton::alt());
|
|
|
|
|
|
|
+ _input->button_up(KeyboardButton::alt());
|
|
|
}
|
|
}
|
|
|
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
|
if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) {
|
|
|
- _input_devices[0].button_up(KeyboardButton::meta());
|
|
|
|
|
|
|
+ _input->button_up(KeyboardButton::meta());
|
|
|
}
|
|
}
|
|
|
- _input_devices[0].button_up(button);
|
|
|
|
|
|
|
+ _input->button_up(button);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ButtonHandle raw_button = map_raw_button(event.keycode);
|
|
|
|
|
- if (raw_button != ButtonHandle::none()) {
|
|
|
|
|
- _input_devices[0].raw_button_up(raw_button);
|
|
|
|
|
|
|
+ if (event.keycode >= 9 && event.keycode <= 135) {
|
|
|
|
|
+ ButtonHandle raw_button = map_raw_button(event.keycode);
|
|
|
|
|
+ if (raw_button != ButtonHandle::none()) {
|
|
|
|
|
+ _input->raw_button_up(raw_button);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1617,7 +1527,7 @@ get_button(XKeyEvent &key_event, bool allow_shift) {
|
|
|
// can do this in just the ASCII set, because we handle
|
|
// can do this in just the ASCII set, because we handle
|
|
|
// international keyboards elsewhere (via an input context).
|
|
// international keyboards elsewhere (via an input context).
|
|
|
if ((key_event.state & (ShiftMask | LockMask)) != 0) {
|
|
if ((key_event.state & (ShiftMask | LockMask)) != 0) {
|
|
|
- if (key >= XK_a and key <= XK_z) {
|
|
|
|
|
|
|
+ if (key >= XK_a && key <= XK_z) {
|
|
|
key += (XK_A - XK_a);
|
|
key += (XK_A - XK_a);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1962,117 +1872,16 @@ map_button(KeySym key) const {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
ButtonHandle x11GraphicsWindow::
|
|
ButtonHandle x11GraphicsWindow::
|
|
|
map_raw_button(KeyCode key) const {
|
|
map_raw_button(KeyCode key) const {
|
|
|
- switch (key) {
|
|
|
|
|
- case 9: return KeyboardButton::escape();
|
|
|
|
|
- case 10: return KeyboardButton::ascii_key('1');
|
|
|
|
|
- case 11: return KeyboardButton::ascii_key('2');
|
|
|
|
|
- case 12: return KeyboardButton::ascii_key('3');
|
|
|
|
|
- case 13: return KeyboardButton::ascii_key('4');
|
|
|
|
|
- case 14: return KeyboardButton::ascii_key('5');
|
|
|
|
|
- case 15: return KeyboardButton::ascii_key('6');
|
|
|
|
|
- case 16: return KeyboardButton::ascii_key('7');
|
|
|
|
|
- case 17: return KeyboardButton::ascii_key('8');
|
|
|
|
|
- case 18: return KeyboardButton::ascii_key('9');
|
|
|
|
|
- case 19: return KeyboardButton::ascii_key('0');
|
|
|
|
|
- case 20: return KeyboardButton::ascii_key('-');
|
|
|
|
|
- case 21: return KeyboardButton::ascii_key('=');
|
|
|
|
|
- case 22: return KeyboardButton::backspace();
|
|
|
|
|
- case 23: return KeyboardButton::tab();
|
|
|
|
|
- case 24: return KeyboardButton::ascii_key('q');
|
|
|
|
|
- case 25: return KeyboardButton::ascii_key('w');
|
|
|
|
|
- case 26: return KeyboardButton::ascii_key('e');
|
|
|
|
|
- case 27: return KeyboardButton::ascii_key('r');
|
|
|
|
|
- case 28: return KeyboardButton::ascii_key('t');
|
|
|
|
|
- case 29: return KeyboardButton::ascii_key('y');
|
|
|
|
|
- case 30: return KeyboardButton::ascii_key('u');
|
|
|
|
|
- case 31: return KeyboardButton::ascii_key('i');
|
|
|
|
|
- case 32: return KeyboardButton::ascii_key('o');
|
|
|
|
|
- case 33: return KeyboardButton::ascii_key('p');
|
|
|
|
|
- case 34: return KeyboardButton::ascii_key('[');
|
|
|
|
|
- case 35: return KeyboardButton::ascii_key(']');
|
|
|
|
|
- case 36: return KeyboardButton::enter();
|
|
|
|
|
- case 37: return KeyboardButton::lcontrol();
|
|
|
|
|
- case 38: return KeyboardButton::ascii_key('a');
|
|
|
|
|
- case 39: return KeyboardButton::ascii_key('s');
|
|
|
|
|
- case 40: return KeyboardButton::ascii_key('d');
|
|
|
|
|
- case 41: return KeyboardButton::ascii_key('f');
|
|
|
|
|
- case 42: return KeyboardButton::ascii_key('g');
|
|
|
|
|
- case 43: return KeyboardButton::ascii_key('h');
|
|
|
|
|
- case 44: return KeyboardButton::ascii_key('j');
|
|
|
|
|
- case 45: return KeyboardButton::ascii_key('k');
|
|
|
|
|
- case 46: return KeyboardButton::ascii_key('l');
|
|
|
|
|
- case 47: return KeyboardButton::ascii_key(';');
|
|
|
|
|
- case 48: return KeyboardButton::ascii_key('\'');
|
|
|
|
|
- case 49: return KeyboardButton::ascii_key('`');
|
|
|
|
|
- case 50: return KeyboardButton::lshift();
|
|
|
|
|
- case 51: return KeyboardButton::ascii_key('\\');
|
|
|
|
|
- case 52: return KeyboardButton::ascii_key('z');
|
|
|
|
|
- case 53: return KeyboardButton::ascii_key('x');
|
|
|
|
|
- case 54: return KeyboardButton::ascii_key('c');
|
|
|
|
|
- case 55: return KeyboardButton::ascii_key('v');
|
|
|
|
|
- case 56: return KeyboardButton::ascii_key('b');
|
|
|
|
|
- case 57: return KeyboardButton::ascii_key('n');
|
|
|
|
|
- case 58: return KeyboardButton::ascii_key('m');
|
|
|
|
|
- case 59: return KeyboardButton::ascii_key(',');
|
|
|
|
|
- case 60: return KeyboardButton::ascii_key('.');
|
|
|
|
|
- case 61: return KeyboardButton::ascii_key('/');
|
|
|
|
|
- case 62: return KeyboardButton::rshift();
|
|
|
|
|
- case 63: return KeyboardButton::ascii_key('*');
|
|
|
|
|
- case 64: return KeyboardButton::lalt();
|
|
|
|
|
- case 65: return KeyboardButton::space();
|
|
|
|
|
- case 66: return KeyboardButton::caps_lock();
|
|
|
|
|
- case 67: return KeyboardButton::f1();
|
|
|
|
|
- case 68: return KeyboardButton::f2();
|
|
|
|
|
- case 69: return KeyboardButton::f3();
|
|
|
|
|
- case 70: return KeyboardButton::f4();
|
|
|
|
|
- case 71: return KeyboardButton::f5();
|
|
|
|
|
- case 72: return KeyboardButton::f6();
|
|
|
|
|
- case 73: return KeyboardButton::f7();
|
|
|
|
|
- case 74: return KeyboardButton::f8();
|
|
|
|
|
- case 75: return KeyboardButton::f9();
|
|
|
|
|
- case 76: return KeyboardButton::f10();
|
|
|
|
|
- case 77: return KeyboardButton::num_lock();
|
|
|
|
|
- case 78: return KeyboardButton::scroll_lock();
|
|
|
|
|
- case 79: return KeyboardButton::ascii_key('7');
|
|
|
|
|
- case 80: return KeyboardButton::ascii_key('8');
|
|
|
|
|
- case 81: return KeyboardButton::ascii_key('9');
|
|
|
|
|
- case 82: return KeyboardButton::ascii_key('-');
|
|
|
|
|
- case 83: return KeyboardButton::ascii_key('4');
|
|
|
|
|
- case 84: return KeyboardButton::ascii_key('5');
|
|
|
|
|
- case 85: return KeyboardButton::ascii_key('6');
|
|
|
|
|
- case 86: return KeyboardButton::ascii_key('+');
|
|
|
|
|
- case 87: return KeyboardButton::ascii_key('1');
|
|
|
|
|
- case 88: return KeyboardButton::ascii_key('2');
|
|
|
|
|
- case 89: return KeyboardButton::ascii_key('3');
|
|
|
|
|
- case 90: return KeyboardButton::ascii_key('0');
|
|
|
|
|
- case 91: return KeyboardButton::ascii_key('.');
|
|
|
|
|
-
|
|
|
|
|
- case 95: return KeyboardButton::f11();
|
|
|
|
|
- case 96: return KeyboardButton::f12();
|
|
|
|
|
-
|
|
|
|
|
- case 104: return KeyboardButton::enter();
|
|
|
|
|
- case 105: return KeyboardButton::rcontrol();
|
|
|
|
|
- case 106: return KeyboardButton::ascii_key('/');
|
|
|
|
|
- case 107: return KeyboardButton::print_screen();
|
|
|
|
|
- case 108: return KeyboardButton::ralt();
|
|
|
|
|
-
|
|
|
|
|
- case 110: return KeyboardButton::home();
|
|
|
|
|
- case 111: return KeyboardButton::up();
|
|
|
|
|
- case 112: return KeyboardButton::page_up();
|
|
|
|
|
- case 113: return KeyboardButton::left();
|
|
|
|
|
- case 114: return KeyboardButton::right();
|
|
|
|
|
- case 115: return KeyboardButton::end();
|
|
|
|
|
- case 116: return KeyboardButton::down();
|
|
|
|
|
- case 117: return KeyboardButton::page_down();
|
|
|
|
|
- case 118: return KeyboardButton::insert();
|
|
|
|
|
- case 119: return KeyboardButton::del();
|
|
|
|
|
-
|
|
|
|
|
- case 127: return KeyboardButton::pause();
|
|
|
|
|
-
|
|
|
|
|
- case 133: return KeyboardButton::lmeta();
|
|
|
|
|
- case 134: return KeyboardButton::rmeta();
|
|
|
|
|
- case 135: return KeyboardButton::menu();
|
|
|
|
|
|
|
+#ifdef PHAVE_LINUX_INPUT_H
|
|
|
|
|
+ // Most X11 servers are configured to use the evdev driver, which
|
|
|
|
|
+ // adds 8 to the underlying evdev keycodes (not sure why).
|
|
|
|
|
+ // In any case, this means we can use the same mapping as our raw
|
|
|
|
|
+ // input code, which uses evdev directly.
|
|
|
|
|
+ int index = key - 8;
|
|
|
|
|
+ if (index >= 0) {
|
|
|
|
|
+ return EvdevInputDevice::map_button(index);
|
|
|
}
|
|
}
|
|
|
|
|
+#endif
|
|
|
return ButtonHandle::none();
|
|
return ButtonHandle::none();
|
|
|
}
|
|
}
|
|
|
|
|
|