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 <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2024-12-11 19:11:45 +00:00
committed by waddlesplash
parent 254894210c
commit 27e83b8be8
7 changed files with 17 additions and 28 deletions
+4 -4
View File
@@ -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
};
@@ -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);
@@ -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;
}
@@ -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);
@@ -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;
}
@@ -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();
+1 -12
View File
@@ -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: