-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtester.c
executable file
·70 lines (60 loc) · 2.13 KB
/
tester.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <SDL2/SDL.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <linux/fs.h>
#include <fcntl.h>
int main()
{
bool quit = false;
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("Mouse Events", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, 0);
char buffer[10];
int fp = open("/dev/mbdriver", O_RDWR);
SDL_Event event;
while(!quit)
{
while (SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
quit = true;
break;
case SDL_MOUSEBUTTONDOWN:
switch (event.button.button)
{
case SDL_BUTTON_LEFT:
printf("Left button was pressed!");
SDL_ShowSimpleMessageBox(0, "Click", "Left button was pressed!", window);
break;
case SDL_BUTTON_RIGHT:
printf("Right button was pressed!");
SDL_ShowSimpleMessageBox(0, "Click", "Right button was pressed!", window);
break;
}
break;
case SDL_MOUSEWHEEL:
if(event.wheel.y == -1)
{
printf("You scored down!\n");
buffer[0] = '1';
write(fp,buffer,1);
SDL_ShowSimpleMessageBox(0, "Wheel Event", "Scroll down!", window);
} else if (event.wheel.y == 1)
{
printf("You scored up!\n");
buffer[0] = '0';
write(fp,buffer,1);
SDL_ShowSimpleMessageBox(0, "Wheel Event", "Scroll up!", window);
}
}
}
SDL_Rect dstrect = { 288, 208, 64, 64 };
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
}