8. Mouse support
Display and hide the mouse cursor
By default, the mouse cursor in visible in windowed mode, hidden in fullscreen mode. You can change it with:
static void TCODMouse::showCursor (bool visible)
void TCOD_mouse_show_cursor (bool visible)
mouse_show_cursor (visible)
void TCODMouse::showCursor(bool visible)
| Parameter | Description |
|---|---|
| visible | If true, this function turns the mouse cursor on. Else it turns the mouse cursor off. |
Getting the cursor status
You can get the current cursor status (hidden or visible) with:
static bool TCODMouse::isCursorVisible (void)
bool TCOD_mouse_is_cursor_visible (void)
mouse_is_cursor_visible ()
bool TCODMouse::isCursorVisible()
Setting the mouse cursor's position
You can set the cursor position (in pixel coordinates, where [0,0] is the window's top left corner) with:
static void TCODMouse::move (int x, int y)
void TCOD_mouse_move (int x, int y)
mouse_move (x, y)
void TCODMouse::moveMouse(int x, int y)
| Parameter | Description |
|---|---|
| x,y | New coordinates of the mouse cursor in pixels. |
Getting the mouse status
You can read the current mouse status with:
typedef struct {
int x, y;
int dx, dy;
int cx, cy;
int dcx, dcy;
unsigned lbutton : 1;
unsigned rbutton : 1;
unsigned mbutton : 1;
unsigned lbutton_pressed : 1;
unsigned rbutton_pressed : 1;
unsigned mbutton_pressed : 1;
} TCOD_mouse_t;
static TCOD_mouse_t TCODMouse::getStatus (void)
TCOD_mouse_t TCOD_mouse_get_status (void)
mouse_get_status ()
TCODMouseData TCODMouse::getStatus()
| Parameter | Description |
|---|---|
| x, | y Absolute position of the mouse cursor in pixels relative to the window top-left corner. |
| dx, | dy Movement of the mouse cursor since the last call in pixels. |
| cx, | cy Coordinates of the console cell under the mouse cursor (pixel coordinates divided by the font size). |
| dcx, | dcy Movement of the mouse since the last call in console cells (pixel coordinates divided by the font size). |
| lbutton | true if the left button is pressed. |
| rbutton | true if the right button is pressed. |
| mbutton | true if the middle button (or the wheel) is pressed. |
| lbutton_pressed | true if the left button was pressed and released. |
| rbutton_pressed | true if the right button was pressed and released. |
| mbutton_pressed | true if the middle button was pressed and released. |