Skip to content
This repository was archived by the owner on Apr 28, 2021. It is now read-only.

Commit 0ac193e

Browse files
committed
Added termfix
1 parent 82276e6 commit 0ac193e

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ TOOLS_CFLAGS := -Wall -std=c99 -D _DEFAULT_SOURCE
22
#
33
# Programs
44
#
5-
all: funkey_gpio_management
5+
all: funkey_gpio_management termfix
66

7-
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
7+
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
88
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
99

10+
termfix: termfix.o
11+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
1012

1113
#
1214
# Objects

termfix.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <sys/ioctl.h>
2+
#include <errno.h>
3+
#include <string.h>
4+
#include <stdio.h>
5+
#include <linux/vt.h>
6+
#include <sys/types.h>
7+
#include <sys/stat.h>
8+
#include <fcntl.h>
9+
#include <linux/kd.h>
10+
#include <linux/keyboard.h>
11+
12+
int main(int argc, char** argv) {
13+
if (argc != 2) {
14+
printf("usage: termfix /dev/ttyX\n");
15+
return 2;
16+
}
17+
18+
int fd = open(argv[1], O_RDWR, 0);
19+
int res = ioctl(fd, VT_UNLOCKSWITCH, 1);
20+
21+
if (res != 0) {
22+
perror("ioctl VT_UNLOCKSWITCH failed");
23+
return 3;
24+
}
25+
26+
ioctl(fd, KDSETMODE, KD_TEXT);
27+
28+
if (res != 0) {
29+
perror("ioctl KDSETMODE failed");
30+
return 3;
31+
}
32+
33+
printf("Success\n");
34+
35+
return res;
36+
}

0 commit comments

Comments
 (0)