Add Mouse+Keyboard Combo device class

presentation
Bryan Tan 6 years ago
parent 875a405605
commit d7a319db8d
  1. 1
      src/control/settings/Settings.h
  2. 10
      src/gui/inputdevices/InputContext.cpp
  3. 2
      src/gui/inputdevices/InputEvents.cpp
  4. 1
      src/gui/inputdevices/InputEvents.h
  5. 11
      src/gui/inputdevices/KeyboardInputHandler.cpp
  6. 1
      ui/settingsDeviceClassConfig.glade

@ -48,6 +48,7 @@ enum class InputDeviceTypeOption {
Pen = 2,
Eraser = 3,
Touchscreen = 4,
MouseKeyboardCombo = 5,
};
class ButtonConfig;

@ -103,6 +103,10 @@ auto InputContext::handle(GdkEvent* sourceEvent) -> bool {
return this->stylusHandler->handle(event);
}
if (event->deviceClass == INPUT_DEVICE_MOUSE_KEYBOARD_COMBO) {
return this->mouseHandler->handle(event) || this->keyboardHandler->handle(event);
}
// handle mouse devices
if (event->deviceClass == INPUT_DEVICE_MOUSE) {
return this->mouseHandler->handle(event);
@ -259,8 +263,10 @@ void InputContext::printDebug(GdkEvent* event) {
"GDK_SOURCE_TOUCHPAD", "GDK_SOURCE_TRACKPOINT", "GDK_SOURCE_TABLET_PAD"};
GdkDevice* device = gdk_event_get_source_device(event);
message += "Source device:\t" + gdkInputSources[gdk_device_get_source(device)] + "\n";
string gdkInputClasses[] = {"INPUT_DEVICE_MOUSE", "INPUT_DEVICE_PEN", "INPUT_DEVICE_ERASER",
"INPUT_DEVICE_TOUCHSCREEN", "INPUT_DEVICE_KEYBOARD", "INPUT_DEVICE_IGNORE"};
string gdkInputClasses[] = {"INPUT_DEVICE_MOUSE", "INPUT_DEVICE_PEN",
"INPUT_DEVICE_ERASER", "INPUT_DEVICE_TOUCHSCREEN",
"INPUT_DEVICE_KEYBOARD", "INPUT_DEVICE_MOUSE_KEYBOARD_COMBO",
"INPUT_DEVICE_IGNORE"};
InputDeviceClass deviceClass = InputEvents::translateDeviceType(device, this->getSettings());
message += "Device Class:\t" + gdkInputClasses[deviceClass] + "\n";

@ -86,6 +86,8 @@ auto InputEvents::translateDeviceType(const string& name, GdkInputSource source,
return INPUT_DEVICE_ERASER;
case InputDeviceTypeOption::Touchscreen:
return INPUT_DEVICE_TOUCHSCREEN;
case InputDeviceTypeOption::MouseKeyboardCombo:
return INPUT_DEVICE_MOUSE_KEYBOARD_COMBO;
default:
return INPUT_DEVICE_IGNORE;
}

@ -40,6 +40,7 @@ enum InputDeviceClass {
INPUT_DEVICE_ERASER,
INPUT_DEVICE_TOUCHSCREEN,
INPUT_DEVICE_KEYBOARD,
INPUT_DEVICE_MOUSE_KEYBOARD_COMBO,
INPUT_DEVICE_IGNORE
};

@ -13,10 +13,11 @@ KeyboardInputHandler::KeyboardInputHandler(InputContext* inputContext): Abstract
KeyboardInputHandler::~KeyboardInputHandler() = default;
auto KeyboardInputHandler::handleImpl(InputEvent* event) -> bool {
auto keyEvent = reinterpret_cast<GdkEventKey*>(event->sourceEvent);
GtkXournal* xournal = inputContext->getXournal();
GdkEvent* gdkEvent = event->sourceEvent;
if (keyEvent->type == GDK_KEY_PRESS) {
if (gdkEvent->type == GDK_KEY_PRESS) {
auto keyEvent = reinterpret_cast<GdkEventKey*>(gdkEvent);
EditSelection* selection = xournal->selection;
if (selection) {
int d = 3;
@ -46,9 +47,11 @@ auto KeyboardInputHandler::handleImpl(InputEvent* event) -> bool {
return true;
}
}
return xournal->view->onKeyPressEvent(keyEvent);
} else if (gdkEvent->type == GDK_KEY_RELEASE) {
auto keyEvent = reinterpret_cast<GdkEventKey*>(gdkEvent);
return inputContext->getView()->onKeyReleaseEvent(keyEvent);
}
return inputContext->getView()->onKeyReleaseEvent(keyEvent);
return false;
}

@ -40,6 +40,7 @@
<items>
<item id="0" translatable="yes">Disabled</item>
<item id="1" translatable="yes">Mouse</item>
<item id="5" translatable="yes">Mouse+Keyboard Combo</item>
<item id="2" translatable="yes">Pen</item>
<item id="3" translatable="yes">Eraser</item>
<item id="4" translatable="yes">Touchscreen</item>

Loading…
Cancel
Save