# HG changeset patch # User John Tsiombikas # Date 1360245812 -7200 # Node ID 2471e9b6343287ea8746096be87bdf69de7f67d2 # Parent 88a2049be27bce48e985941e1f067689bad9648f foo diff -r 88a2049be27b -r 2471e9b63432 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Feb 07 16:03:32 2013 +0200 @@ -0,0 +1,4 @@ +\.o$ +\.swp$ +\.d$ +^libfbee.a$ diff -r 88a2049be27b -r 2471e9b63432 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Feb 07 16:03:32 2013 +0200 @@ -0,0 +1,25 @@ +gfxsys_cflags = `sdl-config --cflags` +gfxsys_ldflags = `sdl-config --libs` + +src = $(wildcard src/*.c) +obj = $(src:.c=.o) +lib_a = libfbee.a +bin = fbee_test + +inc = -Iinclude -Isrc + +CFLAGS = -pedantic -Wall -g $(inc) $(gfxsys_cflags) +LDFLAGS = $(gfxsys_ldflags) + +$(bin): test.o $(lib_a) + $(CC) -o $@ test.o $(lib_a) $(LDFLAGS) + +$(lib_a): $(obj) + $(AR) rcs $@ $(obj) + +%.d: %.c + @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ + +.PHONY: clean +clean: + rm -f $(obj) $(bin) test.o $(lib_a) diff -r 88a2049be27b -r 2471e9b63432 src/sys_linuxfb.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sys_linuxfb.c Thu Feb 07 16:03:32 2013 +0200 @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +static int fbfd; +static void *framebuf; + +static int width, height, bpp; +static int dirty; + +int fbee_sys_init(void) +{ + struct fb_var_screeninfo sinf; + struct termios termios; + + /* open framebuffer device */ + if((fbfd = open("/dev/fb0", O_RDWR)) == -1) { + fprintf(stderr, "failed to open /dev/fb0: %s\n", strerror(errno)); + return -1; + } + + if(ioctl(fbfd, FBIOGET_VSCREENINFO, &sinf) == -1) { + fprintf(stderr, "failed to retreive screen information for fb0: %s\n", strerror(errno)); + close(fbfd); + fbfd = -1; + return -1; + } + width = sinf.width; + height = sinf.height; + bpp = sinf.bits_per_pixel; + + if((framebuf = mmap(0, width * height * bpp / 8, PROT_READ | PROT_WRITE, + MAP_SHARED, fbfd, 0)) == (void*)-1) { + fprintf(stderr, "failed to map framebuffer: %s\n", strerror(errno)); + return -1; + } + + + /* set terminal in raw mode */ + if(tcgetattr(0, &termios) == -1) { + fprintf(stderr, "failed to get terminal information: %s\n", strerror(errno)); + munmap(framebuf, width * height * bpp / 8); + return -1; + } + + /* open /dev/psaux for mouse input */ + if((mousefd = open("/dev/psaux", O_RDONLY | O_NONBLOCK)) == -1) { + fprintf(stderr, "Failed to open the mouse device: %s, mouse will be unavailable.\n", strerror(errno)); + } + + return 0; +}