2018-04-28 11:30:53 -04:00
|
|
|
#ifndef DGL_DGLMOUSE_H_INCLUDED
|
|
|
|
#define DGL_DGLMOUSE_H_INCLUDED
|
2017-11-26 13:18:33 -05:00
|
|
|
|
2018-04-28 11:30:53 -04:00
|
|
|
#include "dglcmn.h"
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
#define MOUSE_LEFTBUTTON 0x01
|
|
|
|
#define MOUSE_RIGHTBUTTON 0x02
|
|
|
|
#define MOUSE_CENTERBUTTON 0x04
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Current mouse cursor X position.
|
|
|
|
*/
|
2018-04-28 11:30:53 -04:00
|
|
|
extern volatile int mouse_x;
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Current mouse cursor Y position.
|
|
|
|
*/
|
2018-04-28 11:30:53 -04:00
|
|
|
extern volatile int mouse_y;
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Current state of mouse buttons.
|
|
|
|
*/
|
2018-04-28 11:30:53 -04:00
|
|
|
extern volatile int mouse_buttons;
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Amount the cursor moved along the X-axis since the last update.
|
|
|
|
*/
|
2018-04-28 11:30:53 -04:00
|
|
|
extern volatile int mouse_delta_x;
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Amount the cursor moved along the Y-axis since the last update.
|
|
|
|
*/
|
2018-04-28 11:30:53 -04:00
|
|
|
extern volatile int mouse_delta_y;
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Installs a custom mouse handler.
|
|
|
|
* @return TRUE on success
|
|
|
|
*/
|
|
|
|
boolean mouse_init(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Removes a previously installed mouse handler.
|
|
|
|
* @return TRUE on success
|
|
|
|
*/
|
|
|
|
boolean mouse_shutdown(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @return TRUE if the custom mouse handler is installed.
|
|
|
|
*/
|
|
|
|
boolean mouse_is_initialized(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @return TRUE if the user's computer has a (recognized) mouse connected.
|
|
|
|
*/
|
|
|
|
boolean mouse_is_present(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shows the mouse cursor. If the mouse cursor is currently shown, this does
|
|
|
|
* nothing.
|
|
|
|
*/
|
|
|
|
void mouse_show(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hides the mouse cursor. If the mouse cursor is not currently shown, this
|
|
|
|
* does nothing.
|
|
|
|
*/
|
|
|
|
void mouse_hide(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sets the pixel boundaries for the mouse cursor.
|
|
|
|
* @param min_x left coordinate
|
|
|
|
* @param max_x right coordinate
|
|
|
|
* @param min_y top coordinate
|
|
|
|
* @param max_y bottom coordinate
|
|
|
|
*/
|
|
|
|
void mouse_set_bounds(int min_x, int min_y, int max_x, int max_y);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the current status of the specified button.
|
|
|
|
* @param button The button to check the status of.
|
|
|
|
* @return TRUE if the button is pressed.
|
|
|
|
*/
|
2018-04-28 11:30:53 -04:00
|
|
|
static boolean mouse_button(int button);
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2018-04-28 11:30:53 -04:00
|
|
|
static boolean mouse_button(int button) {
|
2017-11-26 13:18:33 -05:00
|
|
|
return (mouse_buttons & button) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|