diff --git a/headers/os/interface/Input.h b/headers/os/interface/Input.h index 6b691ac9b3..ee03d577f7 100644 --- a/headers/os/interface/Input.h +++ b/headers/os/interface/Input.h @@ -25,6 +25,14 @@ enum input_device_type { }; +enum input_pointing_device_subtype { + B_UNKNOWN_DEVICE_SUBTYPE = 0, + B_MOUSE_DEVICE_SUBTYPE = 1, + B_TOUCHPAD_DEVICE_SUBTYPE = 2, + B_TABLET_DEVICE_SUBTYPE = 3 +}; + + enum input_device_notification { B_INPUT_DEVICE_ADDED = 0x0001, B_INPUT_DEVICE_STARTED = 0x0002, diff --git a/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp b/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp index 0695e6e4c9..f47afb1091 100644 --- a/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp +++ b/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp @@ -277,6 +277,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg) } message->AddInt64("when", movements.timestamp); + message->AddInt32("be:device_subtype", B_TABLET_DEVICE_SUBTYPE); message->AddInt32("buttons", movements.buttons); message->AddFloat("x", movements.xpos); message->AddFloat("y", movements.ypos); @@ -287,6 +288,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg) message = new BMessage(B_MOUSE_MOVED); if (message) { message->AddInt64("when", movements.timestamp); + message->AddInt32("be:device_subtype", B_TABLET_DEVICE_SUBTYPE); message->AddInt32("buttons", movements.buttons); message->AddFloat("x", movements.xpos); message->AddFloat("y", movements.ypos); @@ -307,6 +309,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg) message = new BMessage(B_MOUSE_WHEEL_CHANGED); if (message) { message->AddInt64("when", movements.timestamp); + message->AddInt32("be:device_subtype", B_TABLET_DEVICE_SUBTYPE); message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta); message->AddFloat("be:wheel_delta_y", movements.wheel_ydelta); diff --git a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp index d2e5dff2f1..b5e624b2c5 100644 --- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp @@ -517,7 +517,11 @@ MouseDevice::_ControlThread() && message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta) == B_OK && message->AddFloat("be:wheel_delta_y", - movements.wheel_ydelta) == B_OK) + movements.wheel_ydelta) == B_OK + && message->AddInt32("be:device_subtype", + fIsTouchpad + ? B_TOUCHPAD_DEVICE_SUBTYPE + : B_MOUSE_DEVICE_SUBTYPE) == B_OK) fTarget.EnqueueMessage(message); else delete message; @@ -637,7 +641,9 @@ MouseDevice::_BuildMouseMessage(uint32 what, uint64 when, uint32 buttons, if (message->AddInt64("when", when) < B_OK || message->AddInt32("buttons", buttons) < B_OK || message->AddInt32("x", deltaX) < B_OK - || message->AddInt32("y", deltaY) < B_OK) { + || message->AddInt32("y", deltaY) < B_OK + || message->AddInt32("be:device_subtype", + fIsTouchpad ? B_TOUCHPAD_DEVICE_SUBTYPE : B_MOUSE_DEVICE_SUBTYPE) < B_OK) { delete message; return NULL; } diff --git a/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp index ab355fb116..e153b2ec0e 100644 --- a/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp @@ -276,6 +276,7 @@ MouseInputDevice::DeviceWatcher(void* arg) message = new BMessage(B_MOUSE_UP); message->AddInt64("when", movements.timestamp); + message->AddInt32("be:device_subtype", B_MOUSE_DEVICE_SUBTYPE); message->AddInt32("buttons", movements.buttons); if ((buttons & movements.buttons) > 0) { @@ -333,6 +334,7 @@ MouseInputDevice::DeviceWatcher(void* arg) message = new BMessage(B_MOUSE_MOVED); if (message) { message->AddInt64("when", movements.timestamp); + message->AddInt32("be:device_subtype", B_MOUSE_DEVICE_SUBTYPE); message->AddInt32("buttons", movements.buttons); message->AddInt32("x", xdelta); message->AddInt32("y", ydelta); @@ -345,6 +347,7 @@ MouseInputDevice::DeviceWatcher(void* arg) message = new BMessage(B_MOUSE_WHEEL_CHANGED); if (message) { message->AddInt64("when", movements.timestamp); + message->AddInt32("be:device_subtype", B_MOUSE_DEVICE_SUBTYPE); message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta); message->AddFloat("be:wheel_delta_y", movements.wheel_ydelta); diff --git a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp index 403d50c87d..31ae1a2a76 100644 --- a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp +++ b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp @@ -381,7 +381,9 @@ TabletDevice::_ControlThread() && message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta) == B_OK && message->AddFloat("be:wheel_delta_y", - movements.wheel_ydelta) == B_OK) + movements.wheel_ydelta) == B_OK + && message->AddInt32("be:device_subtype", + B_TABLET_DEVICE_SUBTYPE) == B_OK) fTarget.EnqueueMessage(message); else delete message; @@ -433,7 +435,9 @@ TabletDevice::_BuildMouseMessage(uint32 what, uint64 when, uint32 buttons, if (message->AddInt64("when", when) < B_OK || message->AddInt32("buttons", buttons) < B_OK || message->AddFloat("x", xPosition) < B_OK - || message->AddFloat("y", yPosition) < B_OK) { + || message->AddFloat("y", yPosition) < B_OK + || message->AddInt32("be:device_subtype", + B_TABLET_DEVICE_SUBTYPE) < B_OK) { delete message; return NULL; } diff --git a/src/add-ons/input_server/filters/padblocker/PadBlocker.cpp b/src/add-ons/input_server/filters/padblocker/PadBlocker.cpp index 000b7efa47..3416f72f78 100644 --- a/src/add-ons/input_server/filters/padblocker/PadBlocker.cpp +++ b/src/add-ons/input_server/filters/padblocker/PadBlocker.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #if DEBUG @@ -162,10 +163,16 @@ filter_result PadBlocker::Filter(BMessage *message, BList *outList) case B_MOUSE_DOWN: { + int32 device; // do nothing if disabled if (_threshold == 0) break; + // only block touchpad devices + if (message->FindInt32("be:device_subtype", &device) != B_OK + || device != B_TOUCHPAD_DEVICE_SUBTYPE) + break; + bigtime_t now = system_time(); // if less than the threshold has passed, tell input server // to ignore this message diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 33e5972d0f..336b7b17a1 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -1681,13 +1681,24 @@ InputServer::_SanitizeEvents(EventList& events) for (int32 index = 0; BMessage* event = (BMessage*)events.ItemAt(index); index++) { switch (event->what) { + case B_MOUSE_WHEEL_CHANGED: + { + int32 device; + if (event->FindInt32("be:device_subtype", &device) != B_OK) + event->AddInt32("be:device_subtype", B_UNKNOWN_DEVICE_SUBTYPE); + + break; + } case B_MOUSE_MOVED: case B_MOUSE_DOWN: { - int32 buttons; + int32 buttons, device; if (event->FindInt32("buttons", &buttons) != B_OK) event->AddInt32("buttons", 0); + if (event->FindInt32("be:device_subtype", &device) != B_OK) + event->AddInt32("be:device_subtype", B_UNKNOWN_DEVICE_SUBTYPE); + // supposed to fall through } case B_MOUSE_UP: