initial commit
This commit is contained in:
commit
4de9088898
13 changed files with 610 additions and 0 deletions
46
main.c
Normal file
46
main.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Copyright (c) 2025 favewa
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "hidpp20.h"
|
||||
#include "ratazana.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ratazana_hid_device_t hid_device;
|
||||
ratazana_result_t result;
|
||||
|
||||
result = ratazana_hid_enumerate(&hid_device, hidpp_match_logitech_mouse);
|
||||
if (result != RATAZANA_OK) {
|
||||
ratazana_fatal("failed to locate a logitech mouse: %s",
|
||||
ratazana_strerror(result));
|
||||
}
|
||||
|
||||
printf("Found device: %s [%04X:%04X]\n", hid_device.name,
|
||||
hid_device.vendor_id, hid_device.product_id);
|
||||
|
||||
ratazana_device_t device = {.fd = -1};
|
||||
result = ratazana_device_open(&device, hid_device.path, HIDPP_DEVICE_WIRED);
|
||||
if (result != RATAZANA_OK)
|
||||
ratazana_fatal("failed to open device: %s", ratazana_strerror(result));
|
||||
|
||||
hidpp_version_t version;
|
||||
result = hidpp_detect_protocol(&device, &version);
|
||||
if (result != RATAZANA_OK) {
|
||||
ratazana_device_close(&device);
|
||||
ratazana_fatal("Failed to detect HID++ protocol: %s",
|
||||
ratazana_strerror(result));
|
||||
}
|
||||
|
||||
printf("Successfully initialized HID++ %u.%u protocol\n", version.major,
|
||||
version.minor);
|
||||
|
||||
ratazana_device_close(&device);
|
||||
printf("Device closed successfully\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue