Skip to content

Commit

Permalink
Generate the device class if not explicitly given in the tablet file
Browse files Browse the repository at this point in the history
libwacom_get_class() is deprecated but it's still a part of the API, and
thus have required even new .tablet files to fill this out even though
it's superseded by IntegratedIn. So let's generate them programmatically.

This turns devices that are IntegratedIn=Display to the Cintiq class,
IntegratedIn=Display;System into the ISDV4 class, and everything else
into the Bamboo class (because Bamboo is not expected to have tool
ids/serials).
  • Loading branch information
redstrate authored and whot committed Oct 29, 2024
1 parent 7531208 commit 5a7961f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
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
15 changes: 14 additions & 1 deletion libwacom/libwacom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,20 @@ 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;
}

switch (device->integration_flags) {
case WACOM_DEVICE_INTEGRATED_DISPLAY:
return WCLASS_CINTIQ;
case WACOM_DEVICE_INTEGRATED_DISPLAY|WACOM_DEVICE_INTEGRATED_SYSTEM:
return WCLASS_CINTIQ;
case WACOM_DEVICE_INTEGRATED_REMOTE:
return WCLASS_REMOTE;
}

return WCLASS_BAMBOO;
}

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

0 comments on commit 5a7961f

Please sign in to comment.