// // Raspberry Pi VNC client module // xkozima@myu.ac.jp #ifndef VNC_H #define VNC_H // VNC サーバとの接続 #define VNC_ADDR "127.0.0.1" #define VNC_PORT 5901 // ピクセル形式 #define VNC_FMT_RGB16 1 // RGB=565 (16bpp) #define VNC_FMT_RGB24 2 // RGB=0888 (32bpp) // タッチの種類 #define VNC_TOUCH_NONE 0 // タッチなし #define VNC_TOUCH_1 1 // 左ボタン class VNC { public: VNC(); // VNC サーバの設定 void presetServer(const char *serverAddr, int serverPort); // 描画コールバック/タッチコールバックの設定 void presetDrawCB(void (*cb)(unsigned char *buf, int x, int y, int w, int h)); void presetTouchCB(void (*cb)(int *x, int *y, int *mode)); // VNC パスワードの設定 void presetPassword(const char *password); // 初期化(最初に一度だけ呼び出す) void init(int w, int h, int format); // 終了 void quit(); // 画面のタイトル(VNC サーバ側で設定; 例. "kozPi's X") char *getTitle(); // 画面更新(サーバへのリクエスト->描画コールバックの適用) void update(); // キーイベントの送信(keysym: X-Window の keysym) void sendKeyPressed(unsigned int keysym); void sendKeyReleassed(unsigned int keysym); // ポインタイベントの送信(button: 左=1, 中=2, 右=4, 上=8, 下=16) void sendPointerEvent(int x, int y, int buttons); private: const char *addr; int port; int sock; char *desKey; char *title; void (*drawCB)(unsigned char *buf, int x, int y, int w, int h); void (*touchCB)(int *x, int *y, int *mode); unsigned char *buffer; int bufferSize; int width, height, bytesPP; // 表示画面の大きさ・深さ int touchLastX, touchLastY, touchLastM; int secureRead(int s, unsigned char *data, int len); int secureWrite(int s, unsigned char *data, int len); }; #endif