From 27e83b8be872b4e0f3794a96312786c120a630dc Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 10 Dec 2024 23:26:59 -0500 Subject: [PATCH] input: Adjust input_pointing_device_subtype enumeration and usages. Follow input_device_type above: we don't have _TYPE or _SUBTYPE on the end, but _POINTING in the middle, because these aren't in a global "subtype" enumeration, but a B_POINTING_DEVICE-specific enumeration. Also don't bother adding the UNKNOWN type to messages that have no type; if it's not included, UNKNOWN is implied. Saves a few CPU cycles. Change-Id: I9088b9fcee63bf001b43febbe1e3ac17eb1792b4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8635 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- headers/os/interface/Input.h | 8 ++++---- .../devices/easypen/EasyPenInputDevice.cpp | 6 +++--- .../input_server/devices/mouse/MouseInputDevice.cpp | 6 +++--- .../devices/serial_mouse/MouseInputDevice.cpp | 6 +++--- .../devices/tablet/TabletInputDevice.cpp | 4 ++-- .../input_server/filters/padblocker/PadBlocker.cpp | 2 +- src/servers/input/InputServer.cpp | 13 +------------ 7 files changed, 17 insertions(+), 28 deletions(-) diff --git a/headers/os/interface/Input.h b/headers/os/interface/Input.h index ee03d577f7..8a84b1b730 100644 --- a/headers/os/interface/Input.h +++ b/headers/os/interface/Input.h @@ -26,10 +26,10 @@ 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 + B_UNKNOWN_POINTING_DEVICE = 0, + B_MOUSE_POINTING_DEVICE = 1, + B_TOUCHPAD_POINTING_DEVICE = 2, + B_TABLET_POINTING_DEVICE = 3 }; diff --git a/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp b/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp index f47afb1091..7515e963da 100644 --- a/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp +++ b/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp @@ -277,7 +277,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg) } message->AddInt64("when", movements.timestamp); - message->AddInt32("be:device_subtype", B_TABLET_DEVICE_SUBTYPE); + message->AddInt32("be:device_subtype", B_TABLET_POINTING_DEVICE); message->AddInt32("buttons", movements.buttons); message->AddFloat("x", movements.xpos); message->AddFloat("y", movements.ypos); @@ -288,7 +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("be:device_subtype", B_TABLET_POINTING_DEVICE); message->AddInt32("buttons", movements.buttons); message->AddFloat("x", movements.xpos); message->AddFloat("y", movements.ypos); @@ -309,7 +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->AddInt32("be:device_subtype", B_TABLET_POINTING_DEVICE); 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 b5e624b2c5..20cc1b93de 100644 --- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp @@ -520,8 +520,8 @@ MouseDevice::_ControlThread() movements.wheel_ydelta) == B_OK && message->AddInt32("be:device_subtype", fIsTouchpad - ? B_TOUCHPAD_DEVICE_SUBTYPE - : B_MOUSE_DEVICE_SUBTYPE) == B_OK) + ? B_TOUCHPAD_POINTING_DEVICE + : B_MOUSE_POINTING_DEVICE) == B_OK) fTarget.EnqueueMessage(message); else delete message; @@ -643,7 +643,7 @@ MouseDevice::_BuildMouseMessage(uint32 what, uint64 when, uint32 buttons, || message->AddInt32("x", deltaX) < B_OK || message->AddInt32("y", deltaY) < B_OK || message->AddInt32("be:device_subtype", - fIsTouchpad ? B_TOUCHPAD_DEVICE_SUBTYPE : B_MOUSE_DEVICE_SUBTYPE) < B_OK) { + fIsTouchpad ? B_TOUCHPAD_POINTING_DEVICE : B_MOUSE_POINTING_DEVICE) < 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 e153b2ec0e..5ee982c5d6 100644 --- a/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp @@ -276,7 +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("be:device_subtype", B_MOUSE_POINTING_DEVICE); message->AddInt32("buttons", movements.buttons); if ((buttons & movements.buttons) > 0) { @@ -334,7 +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("be:device_subtype", B_MOUSE_POINTING_DEVICE); message->AddInt32("buttons", movements.buttons); message->AddInt32("x", xdelta); message->AddInt32("y", ydelta); @@ -347,7 +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->AddInt32("be:device_subtype", B_MOUSE_POINTING_DEVICE); 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 31ae1a2a76..805c86e08d 100644 --- a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp +++ b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp @@ -383,7 +383,7 @@ TabletDevice::_ControlThread() && message->AddFloat("be:wheel_delta_y", movements.wheel_ydelta) == B_OK && message->AddInt32("be:device_subtype", - B_TABLET_DEVICE_SUBTYPE) == B_OK) + B_TABLET_POINTING_DEVICE) == B_OK) fTarget.EnqueueMessage(message); else delete message; @@ -437,7 +437,7 @@ TabletDevice::_BuildMouseMessage(uint32 what, uint64 when, uint32 buttons, || message->AddFloat("x", xPosition) < B_OK || message->AddFloat("y", yPosition) < B_OK || message->AddInt32("be:device_subtype", - B_TABLET_DEVICE_SUBTYPE) < B_OK) { + B_TABLET_POINTING_DEVICE) < 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 3416f72f78..4bb906b0c8 100644 --- a/src/add-ons/input_server/filters/padblocker/PadBlocker.cpp +++ b/src/add-ons/input_server/filters/padblocker/PadBlocker.cpp @@ -170,7 +170,7 @@ filter_result PadBlocker::Filter(BMessage *message, BList *outList) // only block touchpad devices if (message->FindInt32("be:device_subtype", &device) != B_OK - || device != B_TOUCHPAD_DEVICE_SUBTYPE) + || device != B_TOUCHPAD_POINTING_DEVICE) break; bigtime_t now = system_time(); diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 336b7b17a1..53f0f548bb 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -1681,24 +1681,13 @@ 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, device; + int32 buttons; 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: