initial version
This commit is contained in:
commit
6cdb039c6c
9 changed files with 556 additions and 0 deletions
38
tvtswitch.c
Normal file
38
tvtswitch.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include <sys/time.h>
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int fd, vtnum;
|
||||
struct wsdisplay_addscreendata screendata;
|
||||
struct timeval t0, t1, dt;
|
||||
|
||||
fd = open("/dev/ttyC0", O_RDWR);
|
||||
if (fd < 0)
|
||||
err(2, "open /dev/ttyC0");
|
||||
|
||||
if (argc == 2) {
|
||||
vtnum = atoi(argv[1]);
|
||||
gettimeofday(&t0, NULL);
|
||||
if (ioctl(fd, WSDISPLAYIO_SETSCREEN, &vtnum) < 0)
|
||||
err(2, "SETSCREEN");
|
||||
gettimeofday(&t1, NULL);
|
||||
timersub(&t1, &t0, &dt);
|
||||
printf("vt switch took %lu %ld %lf ms\n",
|
||||
(unsigned long)dt.tv_sec, (long)dt.tv_usec,
|
||||
dt.tv_usec/1000.0);
|
||||
}
|
||||
screendata.idx = -1;
|
||||
if (ioctl(fd, WSDISPLAYIO_GETSCREEN, &screendata) < 0)
|
||||
err(2, "GETSCREEN");
|
||||
printf("Current VT: %d %s %s\n", screendata.idx,
|
||||
screendata.screentype, screendata.emul);
|
||||
exit(0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue