aboutsummaryrefslogtreecommitdiffstats
path: root/drv_vnc.c
diff options
context:
space:
mode:
authormichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2009-03-25 22:56:29 +0000
committermichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2009-03-25 22:56:29 +0000
commitec8146e93a99ceedb276cee31c631d378a94b9ff (patch)
treee22bb3fd92e2b8f44ff216e753e14ac9b174b846 /drv_vnc.c
parentc23b97451192e0c86cf97ed498642ea82b7ca9d6 (diff)
downloadlcd4linux-ec8146e93a99ceedb276cee31c631d378a94b9ff.tar.gz
more vnc driver stuff...
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@998 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'drv_vnc.c')
-rw-r--r--drv_vnc.c95
1 files changed, 57 insertions, 38 deletions
diff --git a/drv_vnc.c b/drv_vnc.c
index a8bbbc8..1ed4019 100644
--- a/drv_vnc.c
+++ b/drv_vnc.c
@@ -42,7 +42,7 @@
#include <string.h>
#include <errno.h>
-#include <rfb/rfb.h>
+#include <rfb/rfb.h>
#include "debug.h"
#include "cfg.h"
@@ -57,10 +57,11 @@
#include "drv_generic_graphic.h"
-
+//todo: fps limiter
+// key widget
/* 15 frames per second (if we can) */
-#define PICTURE_TIMEOUT (1.0/15.0)
+#define PICTURE_TIMEOUT (1.0/15.0)
static char Name[] = "VNC";
@@ -69,17 +70,49 @@ static int xres = 320;
static int yres = 200;
static int BPP = 4;
+static int clientCount = 0;
+static int oldClientCount = 0;
+
+static void clientgone(rfbClientPtr cl)
+{
+ if (clientCount > 0)
+ clientCount--;
+ debug("%d clients connected\n", clientCount);
+}
+
+static enum rfbNewClientAction newclient(rfbClientPtr cl)
+{
+ cl->clientGoneHook = clientgone;
+ clientCount++;
+ debug("%d clients connected\n", clientCount);
+ return RFB_CLIENT_ACCEPT;
+}
+
+static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
+{
+ //printf("doptr\n");
+// ClientData* cd=cl->clientData;
+
+ if (x >= 0 && y >= 0 && x < xres && y < yres) {
+ if (buttonMask) {
+ printf("btn:%d, x:%d, y:%d\n", buttonMask, x, y);
+ }
+ }
+
+ rfbDefaultPtrAddEvent(buttonMask, x, y, cl);
+}
+
static int drv_vnc_open(const char *Section)
{
if (cfg_number(Section, "xres", 320, 32, 2048, &xres) < 1) {
- info("[DRV_VNC] no '%s.xres' entry from %s using default %d", Section, cfg_source(), xres);
- }
+ info("[DRV_VNC] no '%s.xres' entry from %s using default %d", Section, cfg_source(), xres);
+ }
if (cfg_number(Section, "yres", 200, 32, 2048, &yres) < 1) {
- info("[DRV_VNC] no '%s.yres' entry from %s using default %d", Section, cfg_source(), yres);
+ info("[DRV_VNC] no '%s.yres' entry from %s using default %d", Section, cfg_source(), yres);
}
if (cfg_number(Section, "bpp", 4, 1, 4, &BPP) < 1) {
- info("[DRV_VNC] no '%s.bpp' entry from %s using default %d", Section, cfg_source(), BPP);
+ info("[DRV_VNC] no '%s.bpp' entry from %s using default %d", Section, cfg_source(), BPP);
}
return 0;
}
@@ -92,11 +125,11 @@ static int drv_vnc_close(void)
return 0;
}
-static void drv_vnc_blit_it(const int row, const int col, const int height, const int width, unsigned char* buffer)
+static void drv_vnc_blit_it(const int row, const int col, const int height, const int width, unsigned char *buffer)
{
int r, c, ofs;
RGBA p;
-
+
for (r = row; r < row + height; r++) {
for (c = col; c < col + width; c++) {
p = drv_generic_graphic_rgb(r, c);
@@ -104,7 +137,7 @@ static void drv_vnc_blit_it(const int row, const int col, const int height, cons
buffer[ofs++] = p.R;
buffer[ofs++] = p.G;
buffer[ofs++] = p.B;
- buffer[ofs ] = 255;
+ buffer[ofs] = 255;
}
}
}
@@ -112,32 +145,17 @@ static void drv_vnc_blit_it(const int row, const int col, const int height, cons
static void drv_vnc_blit(const int row, const int col, const int height, const int width)
{
if (rfbIsActive(server)) {
- //todo blit only if client are connected...
- drv_vnc_blit_it(row, col, height, width, (unsigned char *)server->frameBuffer);
- rfbMarkRectAsModified(server, 0, 0, xres, yres);
- rfbProcessEvents(server, server->deferUpdateTime*1000);
+ //todo blit only if client are connected...
+
+// if (clientCount > 0) {
+ drv_vnc_blit_it(row, col, height, width, (unsigned char *) server->frameBuffer);
+ rfbMarkRectAsModified(server, 0, 0, xres, yres);
+// }
+ oldClientCount = clientCount;
+ rfbProcessEvents(server, server->deferUpdateTime * 1000);
}
}
-static void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
-{
- //printf("doptr\n");
-// ClientData* cd=cl->clientData;
-
- if(x>=0 && y>=0 && x<xres && y<yres) {
- if(buttonMask) {
- printf("btn:%d, x:%d, y:%d\n", buttonMask, x, y);
- }
- }
-
- rfbDefaultPtrAddEvent(buttonMask,x,y,cl);
-}
-
-static void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
-{
- printf("dokey\n");
-}
-
/* start graphic display */
static int drv_vnc_start(const char *section)
{
@@ -168,16 +186,17 @@ static int drv_vnc_start(const char *section)
}
/* you surely want to allocate a framebuffer or something... */
- server=rfbGetScreen(0, NULL, xres, yres, 8, 3, BPP);
+ server = rfbGetScreen(0, NULL, xres, yres, 8, 3, BPP);
server->desktopName = "LCD4Linux VNC Driver";
- server->frameBuffer=(char*)malloc(xres*yres*BPP);
- server->alwaysShared=(1==1);
+ server->frameBuffer = (char *) malloc(xres * yres * BPP);
+ server->alwaysShared = (1 == 1);
server->ptrAddEvent = doptr;
// server->kbdAddEvent = dokey;
-
+ server->newClientHook = newclient;
+
/* Initialize the server */
rfbInitServer(server);
-
+
/* set width/height */
DROWS = yres;
DCOLS = xres;