~mil/fbvncm

c4bf465ba8e7477fca007419c57e50f5efad3505 — Miles Alan 11 months ago 1212b61 master
Always reboot on failure until manual quit triggered; quit with ^C
3 files changed, 46 insertions(+), 23 deletions(-)

A .gitignore
M Makefile
R fbvnc.c => fbvncm.c
A .gitignore => .gitignore +2 -0
@@ 0,0 1,2 @@
*.o
fbvncm

M Makefile => Makefile +9 -3
@@ 2,10 2,16 @@ CC = cc
CFLAGS = -Wall -O2
LDFLAGS =

all: fbvnc
all: fbvncm
.c.o:
	$(CC) -c $(CFLAGS) $<
fbvnc: fbvnc.o draw.o
fbvncm: fbvncm.o draw.o
	$(CC) $(LDFLAGS) -o $@ $^
clean:
	rm -f *.o fbvnc
	rm -f *.o fbvncm
install: fbvncm
	cp fbvncm /usr/bin/
	
pp:
		rsync -v -a . m@pine64-pinephone:/home/m/fbvncm


R fbvnc.c => fbvncm.c +35 -20
@@ 43,6 43,7 @@
#define SCRSCRL		2
#define MAXRES		(1 << 16)

static int run = 1;
static int cols, rows;		/* framebuffer dimensions */
static int bpp;			/* bytes per pixel */
static int srv_cols, srv_rows;	/* server screen dimensions */


@@ 397,13 398,19 @@ static int kbd_event(int fd, int kbdfd)
			if (i + 1 < nr) {
				mod[nmod++] = 0xffe9;
				k = key[++i];
				if (k == 0x03)	/* esc-^C: quit */
				if (k == 0x03) {
					/* esc-^C: quit */
					run = 0; 
					return -1;
				}
			}
			break;
		case 0x0d:
			k = 0xff0d;
			break;
		case 0x03:
			run = 0;
			return -1;
		case 0x0:	/* c-space: stop/start drawing */
			if (!nodraw) {
				nodraw = 1;


@@ 500,27 507,35 @@ int main(int argc, char * argv[])
		host = argv[1];
	if (argc >= 3)
		port = argv[2];
	if ((vnc_fd = vnc_connect(host, port)) < 0) {
		fprintf(stderr, "fbvnc: could not connect!\n");
		return 1;
	}
	if (vnc_init(vnc_fd) < 0) {
		close(vnc_fd);
		fprintf(stderr, "fbvnc: vnc init failed!\n");
		return 1;
	}
	term_setup(&ti);

	/* entering intellimouse for using mouse wheel */
	rat_fd = open("/dev/input/mice", O_RDWR);
	write(rat_fd, "\xf3\xc8\xf3\x64\xf3\x50", 6);
	read(rat_fd, buf, 1);
	
	while (run) {
		if ((vnc_fd = vnc_connect(host, port)) < 0) {
			fprintf(stderr, "fbvnc: could not connect!\n");
			//return 1;
			continue;
		}

		if (vnc_init(vnc_fd) < 0) {
			close(vnc_fd);
			fprintf(stderr, "fbvnc: vnc init failed!\n");
			//return 1;
			continue;
		}
		term_setup(&ti);

		/* entering intellimouse for using mouse wheel */
		rat_fd = open("/dev/input/mice", O_RDWR);
		write(rat_fd, "\xf3\xc8\xf3\x64\xf3\x50", 6);
		read(rat_fd, buf, 1);

	mainloop(vnc_fd, 0, rat_fd);
		mainloop(vnc_fd, 0, rat_fd);

		term_cleanup(&ti);
		vnc_free();
		close(vnc_fd);
		close(rat_fd);
	}

	term_cleanup(&ti);
	vnc_free();
	close(vnc_fd);
	close(rat_fd);
	return 0;
}