Created
August 9, 2020 20:17
-
-
Save slavapestov/6f894594db02c580b3203ee8be5d66a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <termios.h> | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <sys/termios.h> | |
#include <sys/types.h> | |
int main() { | |
int fd; | |
struct termios termios_p; | |
int status; | |
speed_t speed; | |
fd = open("/dev/mouse", O_RDWR); | |
if (fd < 0) { perror("open"); return 1; } | |
status = tcgetattr(fd, &termios_p); | |
if (status < 0) { perror("tcgetattr"); return 1; } | |
speed = cfgetispeed(&termios_p); | |
printf("%x\n", speed); | |
status = cfsetispeed(&termios_p, B4800); | |
if (status) { perror("cfsetispeed\n"); return 1; } | |
speed = cfgetospeed(&termios_p); | |
printf("%x\n", speed); | |
status = cfsetospeed(&termios_p, B4800); | |
if (status) { perror("cfsetospeed\n"); return 1; } | |
status = tcsetattr(fd, TCSANOW, &termios_p); | |
if (status) { perror("tcsetattr"); return 1; } | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment