Skip to content

Commit f7e84ad

Browse files
Actually use c_char instead of assuming it is the same as u8
Reported-By: Davide Cavalca <[email protected]>
1 parent 76456d5 commit f7e84ad

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

src/main.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use input::{
2222
keyboard::{KeyboardEvent, KeyboardEventTrait, KeyState}
2323
}
2424
};
25-
use libc::{O_RDONLY, O_RDWR, O_WRONLY};
25+
use libc::{O_RDONLY, O_RDWR, O_WRONLY, c_char};
2626
use input_linux::{uinput::UInputHandle, EventKind, Key, SynchronizeKind};
2727
use input_linux_sys::{uinput_setup, input_id, timeval, input_event};
2828
use nix::poll::{poll, PollFd, PollFlags};
@@ -259,6 +259,11 @@ fn main() {
259259
uinput.set_keybit(button.action).unwrap();
260260
}
261261
}
262+
let mut dev_name_c = [0 as c_char; 80];
263+
let dev_name = "Dynamic Function Row Virtual Input Device".as_bytes();
264+
for i in 0..dev_name.len() {
265+
dev_name_c[i] = dev_name[i] as c_char;
266+
}
262267
uinput.dev_setup(&uinput_setup {
263268
id: input_id {
264269
bustype: 0x19,
@@ -267,15 +272,7 @@ fn main() {
267272
version: 1
268273
},
269274
ff_effects_max: 0,
270-
name: [
271-
b'D', b'y', b'n', b'a', b'm', b'i', b'c', b' ',
272-
b'F', b'u', b'n', b'c', b't', b'i', b'o', b'n', b' ',
273-
b'R', b'o', b'w', b' ',
274-
b'V', b'i', b'r', b't', b'u', b'a', b'l', b' ',
275-
b'I', b'n', b'p', b'u', b't', b' ',
276-
b'D', b'e', b'v', b'i', b'c', b'e',
277-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
278-
]
275+
name: dev_name_c
279276
}).unwrap();
280277
uinput.dev_create().unwrap();
281278

0 commit comments

Comments
 (0)