1 #ifndef NACRO_H 2 #define NACRO_H 3 4 #ifdef SWIG 5 %module nacro 6 7 %{ 8 9 /* types used */ 10 11 /* 0=false, every other value=true */ 12 typedef int bool_t; 13 14 /* a keysym: identical with ASCII for values between 0-127 */ 15 typedef int keysym_t; 16 17 /* this can be negative, because of a new origin set via visual grep */ 18 typedef int coordinate_t; 19 20 /* left button is 1<<0, middle button is 1<<1, right button is 1<<2 */ 21 typedef unsigned char buttons_t; 22 23 /* this is sort of a "file descriptor" for the proxy */ 24 typedef int resource_t; 25 26 /* the timeout, specified in microseconds, for process() and friends */ 27 typedef double timeout_t; 28 29 /* the return values of process() and friends */ 30 typedef int result_t; 31 /* 32 %constant int RESULT_TIMEOUT=1; 33 %constant int RESULT_KEY=2; 34 %constant int RESULT_MOUSE=4; 35 %constant int RESULT_TEXT_CLIENT=8; 36 %constant int RESULT_TEXT_CLIENT=16; 37 %constant int RESULT_SCREEN=32; 38 %constant int RESULT_FOUNDIMAGE=64; 39 %constant int RESULT_SHUTDOWN=128; 40 */ 41 42 %} 43 44 #endif // SWIG 45 46 typedef int bool_t; 47 typedef int keysym_t; 48 typedef int coordinate_t; 49 typedef unsigned char buttons_t; 50 typedef int resource_t; 51 typedef double timeout_t; 52 typedef int result_t; 53 #define RESULT_TIMEOUT 1 54 #define RESULT_KEY 2 55 #define RESULT_MOUSE 4 56 #define RESULT_TEXT_CLIENT 8 57 #define RESULT_TEXT_SERVER 16 58 #define RESULT_SCREEN 32 59 #define RESULT_FOUNDIMAGE 64 60 #define RESULT_SHUTDOWN 128 61 62 /* init/shutdown */ 63 64 resource_t initvnc(const char* server,int serverPort,int listenPort); 65 void closevnc(resource_t res); 66 67 /* run the event loop for a while: process() and friends: 68 * process() returns only on timeout, 69 * waitforanything returns on any event (input, output or timeout), 70 * waitforupdate() returns only on timeout or screen update, 71 * waitforinput() returns only on timeout or user input, 72 * visualgrep() returns only on timeout or if the specified PNM was found 73 * (in that case, x_origin and y_origin are set to the upper left 74 * corner of the matched image). */ 75 76 result_t process(resource_t res,timeout_t seconds); 77 result_t waitforanything(resource_t res,timeout_t seconds); 78 result_t waitforupdate(resource_t res,timeout_t seconds); 79 result_t waitforinput(resource_t res,timeout_t seconds); 80 result_t visualgrep(resource_t res,const char* filename,timeout_t seconds); 81 82 /* inspect last events */ 83 84 keysym_t getkeysym(resource_t res); 85 bool_t getkeydown(resource_t res); 86 87 coordinate_t getx(resource_t res); 88 coordinate_t gety(resource_t res); 89 buttons_t getbuttons(resource_t res); 90 91 const char *gettext_client(resource_t res); 92 const char *gettext_server(resource_t res); 93 94 /* send events to the server */ 95 96 bool_t sendkey(resource_t res,keysym_t keysym,bool_t keydown); 97 bool_t sendascii(resource_t res,const char *string); 98 bool_t sendmouse(resource_t res,coordinate_t x,coordinate_t y,buttons_t buttons); 99 bool_t sendtext(resource_t res, const char *string); 100 bool_t sendtext_to_server(resource_t res, const char *string); 101 102 /* for visual grepping */ 103 104 coordinate_t getxorigin(resource_t res); 105 coordinate_t getyorigin(resource_t res); 106 107 bool_t savepnm(resource_t res,const char* filename,coordinate_t x1, coordinate_t y1, coordinate_t x2, coordinate_t y2); 108 109 result_t displaypnm(resource_t res, const char *filename, coordinate_t x, coordinate_t y, bool_t border, timeout_t timeout); 110 111 /* this displays an overlay which is shown for a certain time */ 112 113 result_t alert(resource_t res,const char* message,timeout_t timeout); 114 115 /* display a rectangular rubber band between (x0, y0) and the current 116 mouse pointer, as long as a button us pressed. */ 117 118 result_t rubberband(resource_t res, coordinate_t x0, coordinate_t y0); 119 120 #endif 121