Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate the class given in class if not explicitly given #792

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion data/wacom-cintiq-24hd-touch.tablet
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Name=Wacom Cintiq 24HD touch
ModelName=DTH-2400
DeviceMatch=usb|056a|00f8
PairedID=usb|056a|00f6
Class=Cintiq
Width=21
Height=13
Layout=wacom-cintiq-24hd.svg
Expand Down
1 change: 0 additions & 1 deletion data/wacom-cintiq-27hdt.tablet
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Name=Wacom Cintiq 27QHD touch
ModelName=DTH-2700
DeviceMatch=usb|056a|032b
PairedID=usb|056a|032c
Class=Cintiq
Width=24
Height=12
Styli=@intuos5;@propengen2;
Expand Down
12 changes: 11 additions & 1 deletion libwacom/libwacom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,17 @@ libwacom_get_height(const WacomDevice *device)
LIBWACOM_EXPORT WacomClass
libwacom_get_class(const WacomDevice *device)
{
return device->cls;
if (device->cls != WCLASS_UNKNOWN) {
return device->cls;
}
if (device->integration_flags & WACOM_DEVICE_INTEGRATED_DISPLAY &&
device->integration_flags & WACOM_DEVICE_INTEGRATED_SYSTEM) {
return WCLASS_ISDV4;
}
if (device->integration_flags & WACOM_DEVICE_INTEGRATED_DISPLAY) {
return WCLASS_CINTIQ;
}
Comment on lines +1368 to +1374
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (device->integration_flags & WACOM_DEVICE_INTEGRATED_DISPLAY &&
device->integration_flags & WACOM_DEVICE_INTEGRATED_SYSTEM) {
return WCLASS_ISDV4;
}
if (device->integration_flags & WACOM_DEVICE_INTEGRATED_DISPLAY) {
return WCLASS_CINTIQ;
}
unsigned int flags = device->integration_flags & (WACOM_DEVICE_INTEGRATED_DISPLAY|WACOM_DEVICE_INTEGRATED_SYSTEM);
if (flags == (WACOM_DEVICE_INTEGRATED_DISPLAY|WACOM_DEVICE_INTEGRATED_SYSTEM)) {
return WCLASS_ISDV4;
}
if (flags == WACOM_DEVICE_INTEGRATED_DISPLAY) {
return WCLASS_CINTIQ;
}

is i think a bit more readable.

(oh, and I always like to have () around any bitwise operations, it makes the code a bit more readable)

return WCLASS_BAMBOO;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Remote class is missing here, that will need handling, could go together with #779.

Then again there's so few of them that we can mark those in the .tablet file...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, come to think of it: this is better as WCLASS_INTUOS5 - that's the most recent class and most devices are more like that than whatever the latest bamboo was like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the archives: WCLASS_BAMBOO is better here because bamboos arent' expected to have stylus ids/serials.

}

LIBWACOM_EXPORT int
Expand Down
4 changes: 4 additions & 0 deletions test/test-load.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ test_cintiq24hdt(struct fixture *f, gconstpointer user_data)
const WacomMatch *match;

g_assert_nonnull(device);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
g_assert_cmpint(libwacom_get_class(device), ==, WCLASS_CINTIQ);
#pragma GCC diagnostic pop

/* 24HDT has one paired device */
match = libwacom_get_paired_device(device);
Expand Down