Updated some documentation.
This commit is contained in:
1 parent
0e50de4c76
commit
4f5a875d0e
17 files changed
+2416
-6207
No files matched your search
@@ -25,6 +25,7 @@ package console
|
||||
#include <libevdev/libevdev.h>
|
||||
#include <libevdev/libevdev-uinput.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/vt.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
@@ -36,6 +37,13 @@ static int console_state(int fd, int *mode, unsigned char *leds) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int console_usage(int fd, unsigned short *mask) {
|
||||
struct vt_stat state;
|
||||
if (ioctl(fd, VT_GETSTATE, &state) < 0) return -errno;
|
||||
*mask = state.v_state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_feedback(const struct libevdev_uinput *device, struct input_event *event) {
|
||||
ssize_t count = read(libevdev_uinput_get_fd(device), event, sizeof(*event));
|
||||
if (count < 0) return -errno;
|
||||
@@ -69,6 +77,19 @@ func kernel_error(code C.int) error {
|
||||
return syscall.Errno(-code)
|
||||
}
|
||||
|
||||
func query_usage(path string) (uint16, error) {
|
||||
file, err := os.OpenFile(path, os.O_RDONLY|syscall.O_NOCTTY, 0)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer file.Close()
|
||||
var mask C.ushort
|
||||
if err := kernel_error(C.console_usage(C.int(file.Fd()), &mask)); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint16(mask), nil
|
||||
}
|
||||
|
||||
func query_state(path string) (bool, bool, bool, error) {
|
||||
file, err := os.OpenFile(path, os.O_RDONLY|syscall.O_NOCTTY, 0)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user