Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  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.  
  12. struct kolibri_button *kolibri_new_button(unsigned int tlx, unsigned int tly, unsigned int sizex, unsigned int sizey,
  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;
  21. }
  22.  
  23. void draw_button(struct kolibri_button *some_button)
  24. {
  25.   define_button(some_button -> x65536sizex, some_button -> y65536sizey, some_button -> identifier, some_button -> color);
  26. }
  27.  
  28. unsigned int kolibri_button_get_identifier(void)
  29. {
  30.   unsigned int identifier;
  31.  
  32.   __asm__ __volatile__(
  33.                        "int $0x40"
  34.                        :"=a"(identifier)
  35.                        :"a"(17)
  36.                        );
  37.   /* If no button pressed, returns 1 */
  38.   /* Otherwise, returns identifier of button */
  39.  
  40.   if(identifier != 1) /* Button was detected indeed */
  41.     return identifier>>8;
  42.   else
  43.     return identifier; /* No button detected */
  44. }
  45.  
  46. #endif /* KOLIBRI_BUTTON_H */
  47.