Exemple #1
0
void
libwacom_print_device_description(int fd, const WacomDevice *device)
{
	const WacomMatch **match;
	WacomClass class;
	const char *class_name;

	class  = libwacom_get_class(device);
	switch(class) {
		case WCLASS_UNKNOWN:	class_name = "Unknown";	break;
		case WCLASS_INTUOS3:	class_name = "Intuos3";	break;
		case WCLASS_INTUOS4:	class_name = "Intuos4";	break;
		case WCLASS_INTUOS5:	class_name = "Intuos5";	break;
		case WCLASS_CINTIQ:	class_name = "Cintiq";	break;
		case WCLASS_BAMBOO:	class_name = "Bamboo";	break;
		case WCLASS_GRAPHIRE:	class_name = "Graphire";break;
		case WCLASS_ISDV4:	class_name = "ISDV4";	break;
		case WCLASS_INTUOS:	class_name = "Intuos";	break;
		case WCLASS_INTUOS2:	class_name = "Intuos2";	break;
		case WCLASS_PEN_DISPLAYS:	class_name = "PenDisplay";	break;
		case WCLASS_REMOTE:	class_name = "Remote";	break;
		default:		g_assert_not_reached(); break;
	}

	dprintf(fd, "[Device]\n");
	dprintf(fd, "Name=%s\n", libwacom_get_name(device));
	dprintf(fd, "DeviceMatch=");
	for (match = libwacom_get_matches(device); *match; match++)
		print_match(fd, *match);
	dprintf(fd, "\n");

	if (libwacom_get_paired_device(device)) {
		dprintf(fd, "PairedID=");
		print_match(fd, libwacom_get_paired_device(device));
		dprintf(fd, "\n");
	}

	dprintf(fd, "Class=%s\n",		class_name);
	dprintf(fd, "Width=%d\n",		libwacom_get_width(device));
	dprintf(fd, "Height=%d\n",		libwacom_get_height(device));
	print_integrated_flags_for_device(fd, device);
	print_layout_for_device(fd, device);
	print_styli_for_device(fd, device);
	dprintf(fd, "\n");

	dprintf(fd, "[Features]\n");
	dprintf(fd, "Reversible=%s\n", libwacom_is_reversible(device)	? "true" : "false");
	dprintf(fd, "Stylus=%s\n",	 libwacom_has_stylus(device)	? "true" : "false");
	dprintf(fd, "Ring=%s\n",	 libwacom_has_ring(device)	? "true" : "false");
	dprintf(fd, "Ring2=%s\n",	 libwacom_has_ring2(device)	? "true" : "false");
	dprintf(fd, "Touch=%s\n",	 libwacom_has_touch(device)	? "true" : "false");
	dprintf(fd, "TouchSwitch=%s\n",	libwacom_has_touchswitch(device)? "true" : "false");
	print_supported_leds(fd, device);

	dprintf(fd, "NumStrips=%d\n",	libwacom_get_num_strips(device));
	dprintf(fd, "Buttons=%d\n",		libwacom_get_num_buttons(device));

	print_buttons_for_device(fd, device);
}
Exemple #2
0
static void print_styli_for_device (int fd, const WacomDevice *device)
{
	int nstyli;
	const int *styli;
	int i;

	if (!libwacom_has_stylus(device))
		return;

	styli = libwacom_get_supported_styli(device, &nstyli);

	dprintf(fd, "Styli=");
	for (i = 0; i < nstyli; i++)
		dprintf(fd, "%#x;", styli[i]);
	dprintf(fd, "\n");
}
Exemple #3
0
int main(int argc, char **argv)
{
	WacomDeviceDatabase *db;
	WacomDevice *device;
	const WacomMatch *match;
	const char *str;

	db = libwacom_database_new_for_path(TOPSRCDIR"/data");
	if (!db)
		printf("Failed to load data from %s", TOPSRCDIR"/data");
	assert(db);

	device = libwacom_new_from_usbid(db, 0, 0, NULL);
	assert(!device);

	device = libwacom_new_from_usbid(db, 0x56a, 0x00bc, NULL);
	assert(device);

	str = libwacom_get_name(device);
	assert(strcmp(str, "Wacom Intuos4 WL") == 0);
	assert(libwacom_get_class(device) == WCLASS_INTUOS4);
	assert(libwacom_get_vendor_id(device) == 0x56a);
	assert(libwacom_get_product_id(device) == 0xbc);
	assert(libwacom_get_bustype(device) == WBUSTYPE_USB);
	assert(libwacom_get_num_buttons(device) == 9);
	assert(libwacom_has_stylus(device));
	assert(libwacom_is_reversible(device));
	assert(!libwacom_has_touch(device));
	assert(libwacom_has_ring(device));
	assert(!libwacom_has_ring2(device));
	assert(!libwacom_has_touchswitch(device));
	assert(libwacom_get_num_strips(device) == 0);
	assert(libwacom_get_integration_flags (device) == WACOM_DEVICE_INTEGRATED_NONE);
	assert(libwacom_get_width(device) == 8);
	assert(libwacom_get_height(device) == 5);

	/* I4 WL has two matches */
	check_multiple_match(device);

	libwacom_destroy(device);

	device = libwacom_new_from_usbid(db, 0x56a, 0x00b9, NULL);
	assert(device);

	assert(libwacom_get_button_flag(device, 'A') & WACOM_BUTTON_RING_MODESWITCH);
	assert(libwacom_get_button_flag(device, 'I') & WACOM_BUTTON_OLED);
	/*
	 * I4 WL has only 9 buttons, asking for a 10th button will raise a warning
	 * in libwacom_get_button_flag() which is expected.
	 */
	printf("Following critical warning in libwacom_get_button_flag() is expected\n");
	assert(libwacom_get_button_flag(device, 'J') == WACOM_BUTTON_NONE);
	assert(libwacom_get_ring_num_modes(device) == 4);

	libwacom_destroy(device);

	device = libwacom_new_from_usbid(db, 0x56a, 0x00f4, NULL);
	assert(device);

	assert(libwacom_get_ring_num_modes(device) == 3);
	assert(libwacom_get_ring2_num_modes(device) == 3);

	libwacom_destroy(device);

	device = libwacom_new_from_usbid(db, 0x056a, 0x00cc, NULL);
	assert(libwacom_get_num_strips(device) == 2);
	libwacom_destroy(device);

	device = libwacom_new_from_name(db, "Wacom Serial Tablet WACf004", NULL);
	assert(device);
	assert(libwacom_get_integration_flags (device) & WACOM_DEVICE_INTEGRATED_DISPLAY);
	assert(libwacom_get_integration_flags (device) & WACOM_DEVICE_INTEGRATED_SYSTEM);
	libwacom_destroy(device);

	/* 24HDT has one paired device */
	device = libwacom_new_from_usbid(db, 0x56a, 0x00f8, NULL);
	assert(device);

	match = libwacom_get_paired_device(device);
	assert(match != NULL);
	assert(libwacom_match_get_vendor_id(match) == 0x56a);
	assert(libwacom_match_get_product_id(match) == 0xf6);
	assert(libwacom_match_get_bustype(match) == WBUSTYPE_USB);

	libwacom_database_destroy (db);
	return 0;
}