Added termfix

This commit is contained in:
Michel Stempin 2020-05-11 22:15:58 +02:00
parent 82276e6ebe
commit 0ac193e41e
2 changed files with 40 additions and 2 deletions

View File

@ -2,11 +2,13 @@ TOOLS_CFLAGS := -Wall -std=c99 -D _DEFAULT_SOURCE
#
# Programs
#
all: funkey_gpio_management
all: funkey_gpio_management termfix
funkey_gpio_management: funkey_gpio_management.o gpio-utils.o uinput.o gpio_mapping.o read_conf_file.o keydefs.o driver_pcal6416a.o driver_axp209.o smbus.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
termfix: termfix.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
#
# Objects

36
termfix.c Normal file
View File

@ -0,0 +1,36 @@
#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;
}