refactor: use ANSI C
This commit is contained in:
parent
bc999e3218
commit
a9fdae695a
4 changed files with 16 additions and 13 deletions
2
Makefile
2
Makefile
|
@ -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
|
OBJS := main.o event.o read_events.o read_file.o
|
||||||
|
|
||||||
CC := gcc
|
CC := gcc
|
||||||
CFLAGS := -Wall -g -I.
|
CFLAGS := -ansi -pedantic -Wall -Wextra -g -I.
|
||||||
#CFLAGS := -Wall -ansi -g -I.
|
#CFLAGS := -Wall -ansi -g -I.
|
||||||
LDLIBS := -lxdo -lX11
|
LDLIBS := -lxdo -lX11
|
||||||
|
|
||||||
|
|
|
@ -147,10 +147,11 @@ void readfile() {
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
int t;
|
||||||
FILE *file = fopen("t", "w+");
|
FILE *file = fopen("t", "w+");
|
||||||
if (file == NULL) return -1;
|
if (file == NULL) return -1;
|
||||||
|
|
||||||
int t = listen(file);
|
t = listen(file);
|
||||||
if (t) return t;
|
if (t) return t;
|
||||||
|
|
||||||
printf("Fin\n");
|
printf("Fin\n");
|
||||||
|
|
|
@ -26,6 +26,11 @@ int listen(FILE *file)
|
||||||
unsigned char data[3];
|
unsigned char data[3];
|
||||||
const char *pDevice = "/dev/input/mice";
|
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);
|
int fd = open(pDevice, O_RDWR);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
|
@ -33,14 +38,9 @@ int listen(FILE *file)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int left = 0;
|
|
||||||
int right = 0;
|
|
||||||
int middle = 0;
|
|
||||||
signed char x, y;
|
|
||||||
|
|
||||||
while (!(left && right))
|
while (!(left && right))
|
||||||
{
|
{
|
||||||
// Read Mouse
|
/* Read Mouse */
|
||||||
bytes = read(fd, data, sizeof(data));
|
bytes = read(fd, data, sizeof(data));
|
||||||
|
|
||||||
if (bytes > 0)
|
if (bytes > 0)
|
||||||
|
@ -61,7 +61,7 @@ int listen(FILE *file)
|
||||||
&event.xbutton.state
|
&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)) {
|
if ((left || right) && !(left && right)) {
|
||||||
mouse_button type_button;
|
mouse_button type_button;
|
||||||
|
@ -83,6 +83,8 @@ int listen(FILE *file)
|
||||||
close(fd);
|
close(fd);
|
||||||
XCloseDisplay(display);
|
XCloseDisplay(display);
|
||||||
return 0;
|
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
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
//#include <fcntl.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <xdo.h>
|
#include <xdo.h>
|
||||||
|
@ -6,7 +5,8 @@
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "read_file.h"
|
#include "read_file.h"
|
||||||
|
|
||||||
void readfile(FILE *file) {
|
void readfile(FILE *file)
|
||||||
|
{
|
||||||
xdo_t *x_t = xdo_new(NULL);
|
xdo_t *x_t = xdo_new(NULL);
|
||||||
|
|
||||||
event *current_event = new_event();
|
event *current_event = new_event();
|
||||||
|
|
Loading…
Reference in a new issue