1 /* 2 * LOVE: Totally Awesome 2D Gaming. 3 * Website: http://love.sourceforge.net 4 * Licence: ZLIB/libpng 5 * Copyright (c) 2006-2008 LOVE Development Team 6 * 7 * This is a small interface to the mouse device 8 * via SDL. 9 * 10 * @author Anders Ruud 11 * @date 2008-03-16 12 */ 13 14 #ifndef LOVE_MOD_SDLMOUSE_H 15 #define LOVE_MOD_SDLMOUSE_H 16 17 // LOVE 18 #include <love/mod.h> 19 20 // Creating a separate namespace to avoid conflicts 21 // with standard library functions. 22 namespace love_sdlmouse 23 { 24 // Standard module functions. 25 bool module_init(int argc, char ** argv, love::Core * core); 26 bool module_quit(); 27 bool module_open(void * vm); 28 29 /** 30 * Gets current mouse position on x-axis. 31 **/ 32 float getX(); 33 34 /** 35 * Gets current mouse position on x-axis. 36 **/ 37 float getY(); 38 39 /** 40 * Sets the mouse position. 41 **/ 42 void setPosition(float x, float y); 43 44 /** 45 * Checks if a mouse button is pressed. 46 **/ 47 bool isDown(int button); 48 49 /** 50 * Changes cursor visibility. 51 * @param visible True = visible, false = invisible. 52 **/ 53 void setVisible(bool visible); 54 55 /** 56 * Returns true if the mouse is visible, false otherwise. 57 **/ 58 bool isVisible(); 59 60 /** 61 * Native function with two return values (x,y). The same 62 * can be achieved with separate calls to getX() and getY(), 63 * but getting the mouse position is common, and this 64 * will make the process prettier. 65 * Does not take any parameters, and returns two numbers. 66 **/ 67 int getPosition(lua_State * L); 68 69 70 } // love_sdlmouse 71 72 #endif // LOVE_MOD_SDLMOUSE_H 73