mirror of
https://github.com/netfun2000/lcd4linux.git
synced 2026-02-27 09:44:34 +08:00
some more keypad stuff for vnc driver...
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1010 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
@@ -69,51 +69,75 @@
|
||||
|
||||
static char Name[] = "VNC";
|
||||
|
||||
static rfbScreenInfoPtr server; /* vnc device */
|
||||
static int xres = 320; /* screen settings */
|
||||
static int yres = 200;
|
||||
static int BPP = 4;
|
||||
static int max_clients = 2; /* max connected clients */
|
||||
static int buttons = 2; /* number of keypad buttons */
|
||||
|
||||
static int show_keypad_osd = 0; /* is the osd active? */
|
||||
static int osd_showtime = 2000; /* time to display the osd in ms */
|
||||
static struct timeval osd_timestamp;
|
||||
static int buttons = 2; /* number of keypad buttons */
|
||||
static int buttonsize = 50; /* size of keypad buttons */
|
||||
|
||||
static rfbScreenInfoPtr server; /* vnc device */
|
||||
static struct timeval osd_timestamp;
|
||||
static int show_keypad_osd = 0; /* is the osd active? */
|
||||
static int clientCount = 0; /* currently connected clients */
|
||||
static int mouse_x = 0;
|
||||
static int mouse_y = 0;
|
||||
|
||||
/* draws a simple rect, used to display keypad */
|
||||
void draw_rect(int x, int y, int size, unsigned char col, unsigned char *buffer)
|
||||
{
|
||||
int ofs, i;
|
||||
// unsigned char col = 0;
|
||||
unsigned char colr = col;
|
||||
|
||||
if (mouse_x > x && mouse_x < (x + size))
|
||||
if (mouse_y > y && mouse_y < (y + size))
|
||||
colr = 128;
|
||||
|
||||
for (i = x; i < x + size; i++) {
|
||||
ofs = (i + xres * y) * BPP;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = colr;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = col;
|
||||
|
||||
ofs = (i + xres * (y + size)) * BPP;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = colr;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = col;
|
||||
}
|
||||
|
||||
for (i = y; i <= y + size; i++) {
|
||||
ofs = (i * xres + x) * BPP;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = colr;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = col;
|
||||
|
||||
ofs = (i * xres + x + size) * BPP;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = colr;
|
||||
buffer[ofs++] = col;
|
||||
buffer[ofs++] = col;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void display_keypad()
|
||||
{
|
||||
int i, rectx, recty;
|
||||
int kp_xpos = 20;
|
||||
int kp_ypos = 80;
|
||||
int gap = 10;
|
||||
for (i = 0; i < buttons; i++) {
|
||||
rectx = kp_xpos + (i * (buttonsize + gap));
|
||||
recty = kp_ypos /*+ (i*(buttonsize+gap)) */ ;
|
||||
draw_rect(rectx, recty, buttonsize, 0, server->frameBuffer);
|
||||
|
||||
if (mouse_x > rectx && mouse_x < (rectx + buttonsize))
|
||||
if (mouse_y > recty && mouse_y < (recty + buttonsize))
|
||||
debug("mouse in keypad nr %d", i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* called if a vnc client disconnects */
|
||||
static void clientgone(rfbClientPtr cl)
|
||||
{
|
||||
@@ -143,14 +167,19 @@ static void hook_mouseaction(int buttonMask, int x, int y, rfbClientPtr cl)
|
||||
|
||||
/* we check only, if the left mousebutton is pressed */
|
||||
if (buttonMask == 1) {
|
||||
gettimeofday(&osd_timestamp, NULL);
|
||||
debug("button %d pressed", buttonMask);
|
||||
|
||||
if (show_keypad_osd == 0) {
|
||||
/* no osd until yet, activate osd keypad ... */
|
||||
show_keypad_osd = 1;
|
||||
gettimeofday(&osd_timestamp, NULL);
|
||||
} else {
|
||||
/* TODO: handle button stuff... */
|
||||
mouse_x = x;
|
||||
mouse_y = y;
|
||||
debug("mouse: %d,%d", x, y);
|
||||
drv_generic_keypad_press(2);
|
||||
}
|
||||
drv_generic_keypad_press(buttonMask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +235,12 @@ static int drv_vnc_open(const char *Section)
|
||||
if (cfg_number(Section, "osd_showtime", 2000, 500, 60000, &osd_showtime) < 1) {
|
||||
info("[DRV_VNC] no '%s.osd_showtime' entry from %s using default %d", Section, cfg_source(), osd_showtime);
|
||||
}
|
||||
if (cfg_number(Section, "buttons", 2, 0, 6, &buttons) < 1) {
|
||||
info("[DRV_VNC] no '%s.buttons' entry from %s using default %d", Section, cfg_source(), buttons);
|
||||
}
|
||||
if (cfg_number(Section, "buttonsize", 50, 8, 256, &buttonsize) < 1) {
|
||||
info("[DRV_VNC] no '%s.buttonsize' entry from %s using default %d", Section, cfg_source(), buttonsize);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
@@ -220,14 +255,6 @@ static int drv_vnc_close(void)
|
||||
}
|
||||
|
||||
|
||||
static void display_keypad()
|
||||
{
|
||||
draw_rect(30, 30, 50, 255, server->frameBuffer);
|
||||
draw_rect(40, 40, 20, 0, server->frameBuffer);
|
||||
|
||||
//rfbDrawString(server, &default8x16Font,10, yres-16, line, 0x01);
|
||||
}
|
||||
|
||||
/* actual blitting method */
|
||||
static void drv_vnc_blit_it(const int row, const int col, const int height, const int width, unsigned char *buffer)
|
||||
{
|
||||
|
||||
@@ -33,19 +33,18 @@
|
||||
#ifdef __CYGWIN__
|
||||
|
||||
#ifndef HAVE_UNION_SEMUN
|
||||
union semun
|
||||
{
|
||||
int val;
|
||||
union semun {
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
unsigned short *array;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef SHM_R
|
||||
#define SHM_R 0400
|
||||
#define SHM_R 0400
|
||||
#endif
|
||||
#ifndef SHM_W
|
||||
#define SHM_W 0660
|
||||
#define SHM_W 0660
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user