mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
input: fix name/manufacturer/serial fetching for some evdev devices
This commit is contained in:
parent
712b246dd6
commit
f189b817c6
@ -572,8 +572,14 @@ init_device() {
|
|||||||
|
|
||||||
char path[64];
|
char path[64];
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
const char *parent = "";
|
||||||
sprintf(path, "/sys/class/input/event%d/device/device/../product", _index);
|
sprintf(path, "/sys/class/input/event%d/device/device/../product", _index);
|
||||||
FILE *f = fopen(path, "r");
|
FILE *f = fopen(path, "r");
|
||||||
|
if (!f) {
|
||||||
|
parent = "../";
|
||||||
|
sprintf(path, "/sys/class/input/event%d/device/device/%s../product", _index, parent);
|
||||||
|
f = fopen(path, "r");
|
||||||
|
}
|
||||||
if (f) {
|
if (f) {
|
||||||
if (fgets(buffer, sizeof(buffer), f) != NULL) {
|
if (fgets(buffer, sizeof(buffer), f) != NULL) {
|
||||||
buffer[strcspn(buffer, "\r\n")] = 0;
|
buffer[strcspn(buffer, "\r\n")] = 0;
|
||||||
@ -583,7 +589,7 @@ init_device() {
|
|||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
sprintf(path, "/sys/class/input/event%d/device/device/../manufacturer", _index);
|
sprintf(path, "/sys/class/input/event%d/device/device/%s../manufacturer", _index, parent);
|
||||||
f = fopen(path, "r");
|
f = fopen(path, "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
if (fgets(buffer, sizeof(buffer), f) != NULL) {
|
if (fgets(buffer, sizeof(buffer), f) != NULL) {
|
||||||
@ -592,7 +598,7 @@ init_device() {
|
|||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
sprintf(path, "/sys/class/input/event%d/device/device/../serial", _index);
|
sprintf(path, "/sys/class/input/event%d/device/device/%s../serial", _index, parent);
|
||||||
f = fopen(path, "r");
|
f = fopen(path, "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
if (fgets(buffer, sizeof(buffer), f) != NULL) {
|
if (fgets(buffer, sizeof(buffer), f) != NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user