Rev 6395 | Rev 6457 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6391 | ashmew2 | 1 | #ifndef KOLIBRI_BUTTON_H |
2 | #define KOLIBRI_BUTTON_H |
||
3 | |||
4 | struct kolibri_button { |
||
5 | unsigned int x65536sizex; |
||
6 | unsigned int y65536sizey; |
||
7 | unsigned int color; |
||
8 | unsigned int identifier; |
||
9 | unsigned int XY; |
||
10 | }; |
||
11 | |||
6395 | siemargl | 12 | struct kolibri_button *kolibri_new_button(unsigned int tlx, unsigned int tly, unsigned int sizex, unsigned int sizey, |
6391 | ashmew2 | 13 | unsigned int identifier, unsigned int color) |
14 | { |
||
15 | struct kolibri_button* new_button = (struct kolibri_button *)malloc(sizeof(struct kolibri_button)); |
||
16 | new_button -> x65536sizex = (tlx << 16) + sizex; |
||
17 | new_button -> y65536sizey = (tly << 16) + sizey; |
||
18 | new_button -> color = color; |
||
19 | new_button -> identifier = identifier; |
||
20 | new_button -> XY = 0; |
||
6395 | siemargl | 21 | return new_button; |
6391 | ashmew2 | 22 | } |
23 | |||
24 | void draw_button(struct kolibri_button *some_button) |
||
25 | { |
||
26 | define_button(some_button -> x65536sizex, some_button -> y65536sizey, some_button -> identifier, some_button -> color); |
||
27 | } |
||
28 | |||
29 | unsigned int kolibri_button_get_identifier(void) |
||
30 | { |
||
31 | unsigned int identifier; |
||
32 | |||
33 | __asm__ __volatile__( |
||
34 | "int $0x40" |
||
35 | :"=a"(identifier) |
||
36 | :"a"(17) |
||
37 | ); |
||
38 | /* If no button pressed, returns 1 */ |
||
39 | /* Otherwise, returns identifier of button */ |
||
40 | |||
41 | if(identifier != 1) /* Button was detected indeed */ |
||
42 | return identifier>>8; |
||
43 | else |
||
44 | return identifier; /* No button detected */ |
||
45 | } |
||
46 | |||
47 | #endif /* KOLIBRI_BUTTON_H */><>><> |