refactor: use ANSI C

This commit is contained in:
rick 2022-12-05 03:07:23 +01:00
parent bc999e3218
commit a9fdae695a
Signed by: Rick
GPG key ID: 4A6223D66294EB20
4 changed files with 16 additions and 13 deletions

View file

@ -5,7 +5,7 @@ SRCS := main.c event.c read_events.c read_file.c
OBJS := main.o event.o read_events.o read_file.o
CC := gcc
CFLAGS := -Wall -g -I.
CFLAGS := -ansi -pedantic -Wall -Wextra -g -I.
#CFLAGS := -Wall -ansi -g -I.
LDLIBS := -lxdo -lX11

View file

@ -147,10 +147,11 @@ void readfile() {
int main()
{
int t;
FILE *file = fopen("t", "w+");
if (file == NULL) return -1;
int t = listen(file);
t = listen(file);
if (t) return t;
printf("Fin\n");

View file

@ -26,6 +26,11 @@ int listen(FILE *file)
unsigned char data[3];
const char *pDevice = "/dev/input/mice";
int left = 0;
int right = 0;
int middle = 0;
signed char x, y;
int fd = open(pDevice, O_RDWR);
if (fd == -1)
{
@ -33,14 +38,9 @@ int listen(FILE *file)
return -1;
}
int left = 0;
int right = 0;
int middle = 0;
signed char x, y;
while (!(left && right))
{
// Read Mouse
/* Read Mouse */
bytes = read(fd, data, sizeof(data));
if (bytes > 0)
@ -61,7 +61,7 @@ int listen(FILE *file)
&event.xbutton.state
);
//printf("%d - %d\n", event.xmotion.x, event.xmotion.y);
/* printf("%d - %d\n", event.xmotion.x, event.xmotion.y); */
if ((left || right) && !(left && right)) {
mouse_button type_button;
@ -83,6 +83,8 @@ int listen(FILE *file)
close(fd);
XCloseDisplay(display);
return 0;
// TODO on ecoute la souris
// TODO on repete ce qu'on a entre
/*
TODO on ecoute la souris
TODO on repete ce qu'on a entre
*/
}

View file

@ -1,4 +1,3 @@
//#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <xdo.h>
@ -6,7 +5,8 @@
#include "event.h"
#include "read_file.h"
void readfile(FILE *file) {
void readfile(FILE *file)
{
xdo_t *x_t = xdo_new(NULL);
event *current_event = new_event();