コード例 #1
0
ファイル: driver-hidpp20.c プロジェクト: bentiss/libratbag
static void
hidpp20drv_remove(struct ratbag_device *device)
{
    struct hidpp20drv_data *drv_data = ratbag_get_drv_data(device);
    struct hidpp20_device *dev = drv_data->dev;

    if (!device)
        return;

    ratbag_close_hidraw(device);

    if (drv_data->profiles)
        hidpp20_onboard_profiles_destroy(dev, drv_data->profiles);
    free(drv_data->controls);
    free(drv_data->sensors);
    if (drv_data->dev)
        hidpp20_device_destroy(drv_data->dev);
    free(drv_data);
}
コード例 #2
0
ファイル: hidpp20-dump-page.c プロジェクト: elFarto/libratbag
int
main(int argc, char **argv)
{
	_cleanup_close_ int fd = 0;
	const char *path;
	size_t page = 0, offset = 0;
	struct hidpp20_device *dev = NULL;
	struct hidpp_device base;
	struct hidpp20_onboard_profiles_info info = { 0 };
	int rc;

	if (argc < 2 || argc > 4) {
		usage();
		return 1;
	}

	path = argv[argc - 1];
	fd = open(path, O_RDWR);
	if (fd < 0)
		error(1, errno, "Failed to open path %s", path);

	hidpp_device_init(&base, fd);
	dev = hidpp20_device_new(&base, 0xff);
	if (!dev)
		error(1, 0, "Failed to open %s as a HID++ 2.0 device", path);

	hidpp20_onboard_profiles_get_profiles_desc(dev, &info);

	if (argc == 2)
		rc = dump_everything(dev, info.sector_size);
	else {
		page = atoi(argv[1]);
		if (argc > 3)
			offset = atoi(argv[2]);
		rc = dump_page(dev, info.sector_size, 0, page, offset);
	}

	hidpp20_device_destroy(dev);

	return rc;
}