r5362 vince - in /branches/vince/netsurf-fb/framebuffer: fb_cursor.c fb_init_linux.c

netsurf at semichrome.net netsurf at semichrome.net
Wed Sep 17 13:56:48 BST 2008


Author: vince
Date: Wed Sep 17 07:56:47 2008
New Revision: 5362

URL: http://source.netsurf-browser.org?rev=5362&view=rev
Log:
add mouse handling

Modified:
    branches/vince/netsurf-fb/framebuffer/fb_cursor.c
    branches/vince/netsurf-fb/framebuffer/fb_init_linux.c

Modified: branches/vince/netsurf-fb/framebuffer/fb_cursor.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_cursor.c?rev=5362&r1=5361&r2=5362&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_cursor.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_cursor.c Wed Sep 17 07:56:47 2008
@@ -31,6 +31,15 @@
 {
         fb->cursor->x += x;
         fb->cursor->y += y;
+        if (fb->cursor->x < 0)
+                fb->cursor->x = 0;
+        if (fb->cursor->y < 0)
+                fb->cursor->y = 0;
+        if (fb->cursor->x > fb->width)
+                fb->cursor->x = fb->width;
+        if (fb->cursor->y > fb->height)
+                fb->cursor->y = fb->height;
+
 }
 
 void 

Modified: branches/vince/netsurf-fb/framebuffer/fb_init_linux.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_init_linux.c?rev=5362&r1=5361&r2=5362&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_init_linux.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_init_linux.c Wed Sep 17 07:56:47 2008
@@ -25,6 +25,7 @@
 #include "framebuffer/fb_gui.h"
 #include "framebuffer/fb_plotters.h"
 #include "framebuffer/fb_schedule.h"
+#include "framebuffer/fb_cursor.h"
 
 #include "utils/log.h"
 
@@ -52,7 +53,8 @@
 static unsigned short            ored[256], ogreen[256], oblue[256], otransp[256];
 static struct fb_cmap            ocmap = { 0, 256, ored, ogreen, oblue, otransp };
 
-int inputfd;
+int keyboardfd;
+int mousefd;
 
 /* -------------------------------------------------------------------- */
 /* devices                                                              */
@@ -527,10 +529,14 @@
 
 
 
-        inputfd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK);
-        if (inputfd < 0) {
+        keyboardfd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK);
+        if (keyboardfd < 0) {
                 fprintf(stderr, "Unable to open /dev/input/event0 no keyboard\n");                
         } 
+        mousefd = open("/dev/input/event2", O_RDONLY | O_NONBLOCK);
+        if (mousefd < 0) {
+                fprintf(stderr, "Unable to open /dev/input/event2 no mouse\n");                
+        } 
         return newfb;
 }
 
@@ -544,54 +550,68 @@
         ssize_t amt;
         struct input_event event;       
 
-        if (inputfd < 0)
-                return;
-
-        amt = read(inputfd, &event, sizeof(struct input_event));
-
-        if (amt > 0) {
-                if (event.type != EV_KEY)
-                        return;
-
-                if (event.value == 0)
-                        return;
-
-                switch (event.code) {
-                case KEY_J:
-                        g->scrolly +=100;
-                        gui_window_redraw_window(g);
-                        break;
-
-                case KEY_K:
-                        g->scrolly -=100;
-                        if (g->scrolly < 0)
-                                g->scrolly = 0;
-                        gui_window_redraw_window(g);
-                        break;
-
-                case KEY_Q:
-                        browser_window_destroy(g->bw);
-                        break;
-
-                case KEY_D:
-                        list_schedule();
-                        break;
-
-                case KEY_UP:
-                        fb_cursor_move(0, -1);
-                        break;
-
-                case KEY_DOWN:
-                        fb_cursor_move(0, 1);
-                        break;
-
-                case KEY_LEFT:
-                        fb_cursor_move(-1, 0);
-                        break;
-
-                case KEY_RIGHT:
-                        fb_cursor_move(1, 0);
-                        break;
+        if (keyboardfd >= 0) {
+
+                amt = read(keyboardfd, &event, sizeof(struct input_event));
+
+                if (amt > 0) {
+                        if (event.type != EV_KEY)
+                                return;
+
+                        if (event.value == 0)
+                                return;
+
+                        switch (event.code) {
+                        case KEY_J:
+                                g->scrolly +=100;
+                                gui_window_redraw_window(g);
+                                break;
+
+                        case KEY_K:
+                                g->scrolly -=100;
+                                if (g->scrolly < 0)
+                                        g->scrolly = 0;
+                                gui_window_redraw_window(g);
+                                break;
+
+                        case KEY_Q:
+                                browser_window_destroy(g->bw);
+                                break;
+
+                        case KEY_D:
+                                list_schedule();
+                                break;
+
+                        case KEY_UP:
+                                fb_cursor_move(framebuffer, 0, -1);
+                                break;
+
+                        case KEY_DOWN:
+                                fb_cursor_move(framebuffer, 0, 1);
+                                break;
+
+                        case KEY_LEFT:
+                                fb_cursor_move(framebuffer, -1, 0);
+                                break;
+
+                        case KEY_RIGHT:
+                                fb_cursor_move(framebuffer, 1, 0);
+                                break;
+                        }
+                }
+        }
+
+        if (mousefd >= 0) {
+
+                while((amt = read(mousefd, &event, sizeof(struct input_event))) > 0) {
+                        if (event.type != EV_REL)
+                                return;
+
+                        if (event.code == 0) {
+                                fb_cursor_move(framebuffer, 0, event.value);
+                        } else { 
+                                fb_cursor_move(framebuffer, event.value, 0);
+                        }
                 }
         }
 




More information about the netsurf-commits mailing list