summaryrefslogtreecommitdiff
path: root/gdk/linux-fb/gdkinput-ps2.c
diff options
context:
space:
mode:
authorElliot Lee <sopwith@src.gnome.org>2000-08-07 18:19:43 +0000
committerElliot Lee <sopwith@src.gnome.org>2000-08-07 18:19:43 +0000
commit73f441ccbbd79dc91238cf7ebe8f59b6e9188029 (patch)
treece0e8e55750a6da08bb5a7aabafb13277fc0c414 /gdk/linux-fb/gdkinput-ps2.c
parent10ce43ece56ad76d8ddac3b01d9ae98701b921f8 (diff)
downloadgtk+-73f441ccbbd79dc91238cf7ebe8f59b6e9188029.tar.gz
Works.
Diffstat (limited to 'gdk/linux-fb/gdkinput-ps2.c')
-rw-r--r--gdk/linux-fb/gdkinput-ps2.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/gdk/linux-fb/gdkinput-ps2.c b/gdk/linux-fb/gdkinput-ps2.c
index 451dfb094a..bfce523819 100644
--- a/gdk/linux-fb/gdkinput-ps2.c
+++ b/gdk/linux-fb/gdkinput-ps2.c
@@ -33,7 +33,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
-
+#include <math.h>
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
@@ -571,7 +571,7 @@ handle_mouse_input(MouseDevice *mouse, gboolean got_motion)
}
static gboolean
-pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, int *x, int *y)
+pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, gdouble *x, gdouble *y)
{
gboolean keep_reading = TRUE;
@@ -613,7 +613,7 @@ pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, int *x, int *y)
}
else if(mouse->fidmour_nbytes == 5)
{
- switch(mouse->fidmour_bytes[0] & 0x80)
+ switch(mouse->fidmour_bytes[0] & 0xF)
{
case 2:
*btn_down = 0;
@@ -622,9 +622,20 @@ pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, int *x, int *y)
case 0:
*btn_down = 1;
break;
+ default:
+ g_assert_not_reached();
+ break;
}
- *x = (mouse->fidmour_bytes[1] << 1) + (mouse->fidmour_bytes[2] << 7);
- *y = (mouse->fidmour_bytes[3] << 1) + (mouse->fidmour_bytes[4] << 7);
+
+ *x = mouse->fidmour_bytes[1] + (mouse->fidmour_bytes[2] << 7);
+ if(*x > 8192)
+ *x -= 16384;
+ *y = mouse->fidmour_bytes[3] + (mouse->fidmour_bytes[4] << 7);
+ if(*y > 8192)
+ *y -= 16384;
+ /* Now map touchscreen coords to screen coords */
+ *x *= ((double)gdk_display->modeinfo.xres)/4096.0;
+ *y *= ((double)gdk_display->modeinfo.yres)/4096.0;
n = 5;
keep_reading = FALSE;
}
@@ -643,7 +654,7 @@ static gboolean
handle_input_fidmour(GIOChannel *gioc, GIOCondition cond, gpointer data)
{
MouseDevice *mouse = data;
- int x, y;
+ gdouble x, y, oldx, oldy;
gboolean got_motion = FALSE;
gboolean btn_down;
time_t the_time;
@@ -651,21 +662,17 @@ handle_input_fidmour(GIOChannel *gioc, GIOCondition cond, gpointer data)
g_get_current_time(&tv);
the_time = tv.tv_sec;
-
+ oldx = mouse->x;
+ oldy = mouse->y;
while(pull_fidmour_packet(mouse, &btn_down, &x, &y))
{
-#if 0
- if(x != mouse->x
- || y != mouse->y)
- got_motion = TRUE;
- mouse->x = x;
- mouse->y = y;
-#else
- g_print("%d at %dx%d\n",
- btn_down, x, y);
- continue;
-#endif
-
+ if(fabs(x - mouse->x) >= 1.0
+ || fabs(x - mouse->y) >= 1.0)
+ {
+ got_motion = TRUE;
+ mouse->x = x;
+ mouse->y = y;
+ }
if(btn_down != mouse->button1_pressed)
{
@@ -844,8 +851,11 @@ mouse_open(void)
break;
case FIDMOUR_MOUSE:
+ fcntl(retval->fd, F_SETFL, O_RDONLY|O_NONBLOCK);
gioc = g_io_channel_unix_new(retval->fd);
- retval->fd_tag = g_io_add_watch(gioc, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, handle_input_fidmour, retval);
+ /* We set the priority lower here because otherwise it will flood out all the other stuff */
+ retval->fd_tag = g_io_add_watch_full(gioc, G_PRIORITY_DEFAULT, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL,
+ handle_input_fidmour, retval, NULL);
break;
default:
g_assert_not_reached();