mirror of
https://github.com/FunKey-Project/FunKey-GPIO-Mapping.git
synced 2025-12-12 09:48:51 +01:00
37 lines
689 B
C
37 lines
689 B
C
#include <sys/ioctl.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <linux/vt.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <linux/kd.h>
|
|
#include <linux/keyboard.h>
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc != 2) {
|
|
printf("usage: termfix /dev/ttyX\n");
|
|
return 2;
|
|
}
|
|
|
|
int fd = open(argv[1], O_RDWR, 0);
|
|
int res = ioctl(fd, VT_UNLOCKSWITCH, 1);
|
|
|
|
if (res != 0) {
|
|
perror("ioctl VT_UNLOCKSWITCH failed");
|
|
return 3;
|
|
}
|
|
|
|
ioctl(fd, KDSETMODE, KD_TEXT);
|
|
|
|
if (res != 0) {
|
|
perror("ioctl KDSETMODE failed");
|
|
return 3;
|
|
}
|
|
|
|
printf("Success\n");
|
|
|
|
return res;
|
|
}
|