/***************************************************************
                           mouse.h
 ***************************************************************/

module allegro.mouse;

import allegro.gfx;
import allegro.internal._export;
import allegro.internal._volatile;
import allegro.internal.dintern;


enum {
   MOUSEDRV_AUTODETECT  = -1,
   MOUSEDRV_NONE        =  0,
}


extern (C)
struct MOUSE_DRIVER
{
   int  id;
   const char *name;
   const char *desc;
   const char *ascii_name;
   int (*init) ();
   void (*exit) ();
   void (*poll) ();
   void (*timer_poll) ();
   void (*position) (int x, int y);
   void (*set_range) (int x1, int y_1, int x2, int y2);
   void (*set_speed) (int xspeed, int yspeed);
   void (*get_mickeys) (int *mickeyx, int *mickeyy);
   int (*analyse_data) (in char *buffer, int size);
   void (*enable_hardware_cursor) (int mode);
   int (*select_system_cursor) (int cursor);
}


// FIXME: remove?
//extern MOUSE_DRIVER mousedrv_none;
mixin(_export!("extern extern (C) MOUSE_DRIVER * mouse_driver;"));
//extern _DRIVER_INFO _mouse_driver_list[];

extern (C) {

int install_mouse ();
void remove_mouse ();

int poll_mouse ();
int mouse_needs_poll ();

void enable_hardware_cursor ();
void disable_hardware_cursor ();

} // extern (C)

/* Mouse cursors */
enum {
   MOUSE_CURSOR_NONE       = 0,
   MOUSE_CURSOR_ALLEGRO    = 1,
   MOUSE_CURSOR_ARROW      = 2,
   MOUSE_CURSOR_BUSY       = 3,
   MOUSE_CURSOR_QUESTION   = 4,
   MOUSE_CURSOR_EDIT       = 5,
   AL_NUM_MOUSE_CURSORS    = 6,
}

mixin(_export!(`
   extern (C) {
      extern BITMAP * mouse_sprite;
      extern int mouse_x_focus;
      extern int mouse_y_focus;
   }
`));

mixin(_volatile("int", "mouse_x"));
mixin(_volatile("int", "mouse_y"));
mixin(_volatile("int", "mouse_z"));
mixin(_volatile("int", "mouse_w"));
mixin(_volatile("int", "mouse_b"));
mixin(_volatile("int", "mouse_pos"));

mixin(_volatile("int", "freeze_mouse_flag"));
mixin(_volatile_setter("int", "freeze_mouse_flag"));

enum {
   MOUSE_FLAG_MOVE            = 1,
   MOUSE_FLAG_LEFT_DOWN       = 2,
   MOUSE_FLAG_LEFT_UP         = 4,
   MOUSE_FLAG_RIGHT_DOWN      = 8,
   MOUSE_FLAG_RIGHT_UP        = 16,
   MOUSE_FLAG_MIDDLE_DOWN     = 32,
   MOUSE_FLAG_MIDDLE_UP       = 64,
   MOUSE_FLAG_MOVE_Z          = 128,
   MOUSE_FLAG_MOVE_W          = 256,
}

mixin(_export!("extern extern (C) void (*mouse_callback) (int flags);"));

extern (C) {

void show_mouse (BITMAP *bmp);
void scare_mouse ();
void scare_mouse_area (int x, int y, int w, int h);
void unscare_mouse ();
void position_mouse (int x, int y);
void position_mouse_z (int z);
void position_mouse_w (int w);
void set_mouse_range (int x1, int y_1, int x2, int y2);
void set_mouse_speed (int xspeed, int yspeed);
void select_mouse_cursor (int cursor);
void set_mouse_cursor_bitmap (int cursor, BITMAP *bmp);
void set_mouse_sprite_focus (int x, int y);
void get_mouse_mickeys (int *mickeyx, int *mickeyy);
void set_mouse_sprite (BITMAP *sprite);
int show_os_cursor (int cursor);

}  // extern (C)
