Subversion Repositories Kolibri OS

Rev

Rev 6457 | 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
 
6457 punk_joker 4
typedef struct {
6391 ashmew2 5
  unsigned int x65536sizex;
6
  unsigned int y65536sizey;
7
  unsigned int color;
8
  unsigned int identifier;
9
  unsigned int XY;
6457 punk_joker 10
}kolibri_button;
6391 ashmew2 11
 
6457 punk_joker 12
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
{
6457 punk_joker 15
  kolibri_button* new_button = (kolibri_button *)malloc(sizeof(kolibri_button));
6391 ashmew2 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
 
6612 siemargl 24
__attribute__((__stdcall__))
25
static inline void draw_button(kolibri_button *some_button)
6391 ashmew2 26
{
27
  define_button(some_button -> x65536sizex, some_button -> y65536sizey, some_button -> identifier, some_button -> color);
28
}
29
 
30
unsigned int kolibri_button_get_identifier(void)
31
{
32
  unsigned int identifier;
33
 
34
  __asm__ __volatile__(
35
		       "int $0x40"
36
		       :"=a"(identifier)
37
		       :"a"(17)
38
		       );
39
  /* If no button pressed, returns 1 */
40
  /* Otherwise, returns identifier of button */
41
 
42
  if(identifier != 1) /* Button was detected indeed */
43
    return identifier>>8;
44
  else
45
    return identifier; /* No button detected */
46
}
47
 
48
#endif /* KOLIBRI_BUTTON_H */