aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortissoire2008-04-08 14:56:38 +0000
committertissoire2008-04-08 14:56:38 +0000
commit6262e3fc64a95a34b9cb8c844f4e17f8e1720448 (patch)
tree23be7c6625c3612529d77cdaae8a5a8e20cd570a
parent422be6425b61457d8122b6e9ebe5e05ea241b380 (diff)
downloadivypointer-6262e3fc64a95a34b9cb8c844f4e17f8e1720448.zip
ivypointer-6262e3fc64a95a34b9cb8c844f4e17f8e1720448.tar.gz
ivypointer-6262e3fc64a95a34b9cb8c844f4e17f8e1720448.tar.bz2
ivypointer-6262e3fc64a95a34b9cb8c844f4e17f8e1720448.tar.xz
* Utilisation de l'information hires de xinput_wacom
* Utilisation des boutons du stylet * Utilisation par d~faut de xinput_wacom (et ajout du flag '-t' pour utiliser ModeManager ~ la place)
-rw-r--r--debian/changelog9
-rw-r--r--debian/control2
-rw-r--r--src/ivypointer.c203
3 files changed, 128 insertions, 86 deletions
diff --git a/debian/changelog b/debian/changelog
index 7c2f1bc..8e02c94 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+ivypointer (0.0.5) unstable; urgency=low
+
+ * Utilisation de l'information hires de xinput_wacom
+ * Utilisation des boutons du stylet
+ * Utilisation par défaut de xinput_wacom (et ajout du flag '-t' pour utiliser
+ ModeManager à la place)
+
+ -- Benjamin Tissoires <tissoire@cena.fr> Tue, 8 Apr 2008 16:49:51 +0200
+
ivypointer (0.0.4-1) unstable; urgency=low
* Inversion des évènements 'move' et 'click'
diff --git a/debian/control b/debian/control
index 14dd567..16a5e3c 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Priority: extra
Section: unknown
Maintainer: Benjamin Tissoires <tissoire@cena.fr>
Build-Depends: debhelper (>> 4.0.0), libc6-dev, xlibs-dev | libx11-dev | xorg-dev, ivy-c-dev
-Standards-Version: 0.0.4-1
+Standards-Version: 0.0.5
Package: ivypointer
Section: unknown
diff --git a/src/ivypointer.c b/src/ivypointer.c
index 55b9343..6f72a60 100644
--- a/src/ivypointer.c
+++ b/src/ivypointer.c
@@ -12,6 +12,8 @@
* copyright notice regarding this software
*/
+//#define _MPX_
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -68,26 +70,36 @@
#define REGEXP_REL_MOVE "^TelepointerRelativeMotion Id=(.*) X=(.*) Y=(.*)"
#define REGEXP_BUTTON "^TelepointerButton Id=(.*) Button=(.*) status=(.*)"
-#define REGEXP_POINTER "^pointer_event device_id=(.*) x=(.*) y=(.*) presure=(.*) tilt_x=(.*) tilt_y=(.*) wheel=(.*) predicted_x=(.*) predicted_y=(.*) type=(.*) serial_number=(.*) time=(.*)"
+#define REGEXP_POINTER "^pointer_event device_id=(.*) x=(.*) y=(.*) presure=(.*) tilt_x=(.*) tilt_y=(.*) wheel=(.*) predicted_x=(.*) predicted_y=(.*) type=(.*) serial_number=(.*) time=(.*) hires_x=(.*) hires_y=(.*) proximity=(.*)"
#define REGEXP_PAD "^pad_event device_id=(.*) button=(.*) status=(.*) time=(.*)"
#define REGEXP_SLIDER "^slider_event device_id=(.*) value=(.*) side=(.*) time=(.*)"
+#define REGEXP_BUTTON_WACOM "^button_event device_id=(.*) button=(.*) status=(.*) x=(.*) y=(.*) presure=(.*) tilt_x=(.*) tilt_y=(.*) wheel=(.*) predicted_x=(.*) predicted_y=(.*) type=(.*) serial_number=(.*) time=(.*) hires_x=(.*) hires_y=(.*) proximity=(.*)"
+
#define WIDTH_WACOM 1600.0
#define HEIGHT_WACOM 1200.0
+//#define WIDTH_WACOM 1.0
+//#define HEIGHT_WACOM 1.0
#define TIME_CLICK 200
#define TIME_BETWEEN_CLICK 200
Display* display = NULL;
-XDevice* device = NULL;
-int width,height;
+#ifdef _MPX_
+XDevice* dev = NULL;
+//#else
+//# error plop
+#endif
+float width,height;
float coords_input[4] = {0.0,0.0,100.0,100.0};
-int width_input,height_input, offsetx, offsety;
+float width_input,height_input, offsetx, offsety;
int dragged = 0;
int relative = 0;
-int champX = 1;
-int champY = 2;
+//int champX = 1;
+//int champY = 2;
+int champX = 12;
+int champY = 13;
Display*
openDisplay(const char* displayName)
@@ -137,50 +149,19 @@ openDisplay(const char* displayName)
}
#endif
-// XDeviceInfo* devices;
-// int devicecount;
-//
-// devices = XListInputDevices(display, &devicecount);
-//// printf("there are %d available devices :\n",devicecount);
-// while(devicecount)
-// {
-// XDeviceInfo* currDevice;
-//
-// currDevice = &devices[--devicecount];
-// switch(currDevice->use){
-// case IsXPointer:
-// printf("xpointer id=%d\n",(int)currDevice->id);
-// device = XOpenDevice(display, currDevice->id);
-// if (device == NULL) {
-// printf("EE : can't open device \"%d\"\n", (int)currDevice->id);
-// return NULL;
-// // throw XScreenUnavailable(60.0);
-// }
-// break;
-// case IsXKeyboard:
-// printf("xkeyboard id=%d\n",(int)currDevice->id);
-// break;
-// case IsXExtensionDevice:
-// printf("xextensiondevice id=%d\n",(int)currDevice->id);
-// break;
-// case IsXExtensionKeyboard:
-// printf("XExtensionKeyboard id=%d\n",(int)currDevice->id);
-// break;
-// case IsXExtensionPointer:
-// printf("XExtensionPointer id=%d\n",(int)currDevice->id);
-// break;
-// }
-// }
-
return display;
}
+XDevice *openDevice(Display * dpy, int id){
+ return XOpenDevice(dpy, id);
+}
+
// --------------------------------------------------------------------------
// tools
// --------------------------------------------------------------------------
void print_coords_input(void){
- printf("coords of input : %.0f,%.0f %.0f,%.0f\n", coords_input[0], coords_input[1], coords_input[2], coords_input[3]);
+ printf("coords of input : %.2f,%.2f %.2f,%.2f\n", coords_input[0], coords_input[1], coords_input[2], coords_input[3]);
}
int valid(float x, float y) {
@@ -208,10 +189,15 @@ int valid(float x, float y) {
// --------------------------------------------------------------------------
void
-fakeMouseButton(const unsigned int xButton, Bool press)
+fakeMouseButton(const unsigned int xButton, Bool press, int x, int y)
{
if (xButton != 0) {
- XTestFakeButtonEvent(display, xButton, press ? True : False, 0);
+#ifndef _MPX_
+ XTestFakeButtonEvent(display, xButton, press ? True : False, CurrentTime);
+#else
+ int axes[2] = {x,y};
+ XTestFakeDeviceButtonEvent(display, dev, xButton, press ? True : False, axes, 2, CurrentTime);
+#endif
XFlush(display);
}
}
@@ -219,7 +205,13 @@ fakeMouseButton(const unsigned int xButton, Bool press)
void
fakeMouseMove(int x, int y)
{
+// printf("x = %d,y = %d;\n ",x,y);
+#ifndef _MPX_
XTestFakeMotionEvent(display, DefaultScreen(display), x, y, CurrentTime);
+#else
+ int axes[2] = {x,y};
+ XTestFakeDeviceMotionEvent(display, dev, False, 0, axes, 2, CurrentTime);
+#endif
//XWarpPointer(display, None, RootWindow(display, 0), 0, 0, 0, 0, x, y);
XFlush(display);
}
@@ -227,7 +219,12 @@ fakeMouseMove(int x, int y)
void
fakeMouseRelativeMove(int dx, int dy)
{
+#ifndef _MPX_
XTestFakeRelativeMotionEvent(display, dx, dy, CurrentTime);
+#else
+ int axes[2] = {dx,dy};
+ XTestFakeDeviceMotionEvent(display, dev, True, 0, axes, 2, CurrentTime);
+#endif
//XWarpPointer(display, None, None, 0, 0, 0, 0, dx, dy);
XFlush(display);
}
@@ -265,9 +262,9 @@ void CallbackScreen(IvyClientPtr app, void *user_data, int argc, char *argv[]) {
offsety = y0;
width = x1-x0;
height = y1-y0;
- printf("screen : %d+%d x %d+%d\n",offsetx,width,offsety,height);
+ printf("screen : %f+%f x %f+%f\n",offsetx,width,offsety,height);
} else {
- printf("bad coords received : %.0f,%.0f %.0f,%.0f\n",x0,y0,x1,y1);
+ printf("bad coords received : %.2f,%.2f %.2f,%.2f\n",x0,y0,x1,y1);
}
}
@@ -279,36 +276,37 @@ void CallbackMove (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
// printf ("%s sent (size : %d)",IvyGetApplicationName(app),argc);
// for (i = 0; i < argc; i++)
// printf(" '%s'",argv[i]);
- if (dragged){
- fakeMouseButton(1,0);
- dragged = 0;
- }
-// char *id = argv[0];
float x = atof(argv[1]);
float y = atof(argv[2]);
-// printf("x = %f,y = %f; ",x,y);
x = x*width/100.0;
y = y*height/100.0;
+// char *id = argv[0];
+// printf("x = %f,y = %f; ",x,y);
// printf("x = %f,y = %f\n",x,y);
- if (valid(x,y))
- fakeMouseMove((int)x,(int)y);
-// IvyUnbindMsg(*ptr);
+ if (valid(x,y)){
+ fakeMouseMove((int)x,(int)y);
+ if (dragged){
+ fakeMouseButton(1,0,x,y);
+ dragged = 0;
+ }
+ }
}
void CallbackDrag (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
- if (!dragged){
- fakeMouseButton(1,1);
- dragged = 1;
- }
// char *id = argv[0];
float x = atof(argv[1]);
float y = atof(argv[2]);
x *= width/100.0;
y *= height/100.0;
// printf("x = %f,y = %f\n",x,y);
- if (valid(x,y))
- fakeMouseMove((int)x,(int)y);
+ if (valid(x,y)){
+ fakeMouseMove((int)x,(int)y);
+ if (!dragged){
+ fakeMouseButton(1,1,x,y);
+ dragged = 1;
+ }
+ }
}
void CallbackRelMove (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
@@ -326,7 +324,7 @@ void CallbackButton (IvyClientPtr app, void *user_data, int argc, char *argv[])
int press = atoi(argv[2]);
// if (!b)
// return
- fakeMouseButton(b,press);
+ fakeMouseButton(b,press,0,0);
}
// --------------------------------------------------------------------------
@@ -348,7 +346,7 @@ void CallbackPointer (IvyClientPtr app, void *user_data, int argc, char *argv[])
// ignore outside events
return;
}
- // printf("x = %f,y = %f; ",x,y);
+// printf("x = %f,y = %f;\n ",x,y);
x = offsetx + (x-coords_input[0])*width/width_input;
y = offsety + (y-coords_input[1])*height/height_input;
@@ -357,7 +355,7 @@ void CallbackPointer (IvyClientPtr app, void *user_data, int argc, char *argv[])
//absolute mode
fakeMouseMove((int)x,(int)y);
if (!dragged && presure>0){
- fakeMouseButton(1,1);
+ fakeMouseButton(1,1,x,y);
dragged = 1;
}
} else {
@@ -386,18 +384,18 @@ void CallbackPointer (IvyClientPtr app, void *user_data, int argc, char *argv[])
if (clicked) {
//double click
// printf("ck\n");
- fakeMouseButton(1,0);
+ fakeMouseButton(1,0,x,y);
}
// printf("cli\n");
clicked = 1;
old_time = time;
- fakeMouseButton(1,1);
+ fakeMouseButton(1,1,x,y);
}
should_click = 0;
if (clicked) {
if (dt > TIME_BETWEEN_CLICK){
// printf("ck\n");
- fakeMouseButton(1,0);
+ fakeMouseButton(1,0,x,y);
clicked = 0;
}
} else {
@@ -408,7 +406,7 @@ void CallbackPointer (IvyClientPtr app, void *user_data, int argc, char *argv[])
// release (common of both modes)
if (dragged && presure==0){
- fakeMouseButton(1,0);
+ fakeMouseButton(1,0,x,y);
dragged = 0;
}
@@ -430,7 +428,7 @@ void CallbackPad (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
//inversion du mode
relative = !relative;
} else {
- fakeMouseButton(b,press);
+ fakeMouseButton(b,press,0,0);
}
}
@@ -444,10 +442,20 @@ void CallbackSlider (IvyClientPtr app, void *user_data, int argc, char *argv[])
// fakeMouseButton(b,press);
}
+void CallbackButtonWacom (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
+// char *id = argv[0];
+ int b = atoi(argv[1]);
+ if (b == 1) // gestion propre du bouton 1
+ return;
+ int press = strcmp(argv[2],"up");
+ fakeMouseButton(b,press,0,0);
+}
+
+
void printHelpMsg(const char *name){
const char* helpmsg =
"[options] [regexps]\n\t-b bus\t\tdefines the Ivy bus to which to connect to, defaults to 127:2010\n"
- "\t-w\t\tuse data from xinput_wacom instead of ModeManager\n"
+ "\t-t\t\tuse data from ModeManager instead of xinput_wacom\n"
"\t-c x0,y0,x1,y1\tspecify the coords of the input used (only used with wacom)\n"
"\t-C x0,y0,x1,y1\tspecify the coords of the screen used\n"
"\t-r\tuse relative mode by default\n"
@@ -457,11 +465,11 @@ void printHelpMsg(const char *name){
printf("usage: %s %s",name,helpmsg);
}
-int extractValues(char optarg[], int* output, const char name[]){
+int extractValues(char optarg[], float* output, const char name[]){
int i = 0;
int j = 0;
int last = 0;
- int coupures[4] = {0,0,0,0};
+ float coupures[4] = {0,0,0,0};
while(optarg[i]){
if (optarg[i] == ','){
@@ -484,7 +492,7 @@ int extractValues(char optarg[], int* output, const char name[]){
for (k = 0; k < length; k++) {
buf[k] = optarg[last+k];
}
- output[i] = atoi(buf);
+ output[i] = atof(buf);
last = coupures[i]+1;
}
return 1;
@@ -497,13 +505,15 @@ int extractValues(char optarg[], int* output, const char name[]){
int main(int argc, char *argv[]) {
const char* bus = 0;
char busbuf [1024] = "";
- int wacom = 0;
- int user_coordsI = 0;
- int user_coordsO = 0;
- int coordsI[4] = {0,0,0,0};
- int coordsO[4] = {0,0,0,0};
+ int wacom = 1;
+ int predictive_mode = 0;
+ float user_coordsI = 0;
+ float user_coordsO = 0;
+ float coordsI[4] = {0,0,0,0};
+ float coordsO[4] = {0,0,0,0};
int c;
- while ((c = getopt(argc, argv, "vb:wc:C:rp")) != EOF)
+ int id = -1;
+ while ((c = getopt(argc, argv, "vb:twc:C:rpd:")) != EOF)
switch (c) {
case 'b':
strcpy (busbuf, optarg);
@@ -516,11 +526,14 @@ int main(int argc, char *argv[]) {
relative = 1;
break;
case 'w':
- wacom = 1;
+ break;
+ case 't':
+ wacom = 0;
break;
case 'p':
champX = 7;
champY = 8;
+ predictive_mode = 1;
break;
case 'c':
user_coordsI = extractValues(optarg, coordsI, argv[0]);
@@ -528,7 +541,11 @@ int main(int argc, char *argv[]) {
case 'C':
user_coordsO = extractValues(optarg, coordsO, argv[0]);
break;
+ case 'd':
+ id = atoi(optarg);
+ break;
default:
+ printf("bad option : %s\n",(char*)&c);
printHelpMsg(argv[0]);
exit(1);
}
@@ -536,6 +553,15 @@ int main(int argc, char *argv[]) {
if (!d){
return 1;
}
+#ifdef _MPX_
+ if (id >=0){
+ printf("opening device id=%d\n",id);
+ dev = openDevice(d,id);
+ if (!dev) {
+ printf("unable to open device id=%d\n",id);
+ }
+ }
+#endif
if (wacom) {
if (user_coordsI){
@@ -544,8 +570,13 @@ int main(int argc, char *argv[]) {
coords_input[i] = coordsI[i];
}
} else {
- coords_input[2] = WIDTH_WACOM;
- coords_input[3] = HEIGHT_WACOM;
+ if (predictive_mode){
+ coords_input[2] = WIDTH_WACOM;
+ coords_input[3] = HEIGHT_WACOM;
+ } else {
+ coords_input[2] = 1.0;
+ coords_input[3] = 1.0;
+ }
}
print_coords_input();
width_input = coords_input[2]-coords_input[0];
@@ -564,12 +595,12 @@ int main(int argc, char *argv[]) {
height = DisplayHeight(d, DefaultScreen(d));
}
- printf("screen : %d+%d x %d+%d\n",offsetx,width,offsety,height);
+ printf("screen : %.2f+%.2f x %.2f+%.2f\n",offsetx,width,offsety,height);
// verifications
- if (width < 2 || height < 2 || (wacom && (width_input < 2 || height_input < 2))){
+ if (width < 2 || height < 2 ){//|| (wacom && (width_input < || height_input < 2))){
print_coords_input();
- printf("%d %d %d %d\n",width,height,width_input,height_input);
+ printf("%.2f %.2f %.2f %.2f\n",width,height,width_input,height_input);
printHelpMsg(argv[0]);
exit(1);
}
@@ -597,6 +628,8 @@ int main(int argc, char *argv[]) {
// printf("bound to %s\n",REGEXP_SLIDER);
ptrMove=IvyBindMsg(CallbackPad,&ptrButton,REGEXP_PAD);
printf("bound to %s\n",REGEXP_PAD);
+ ptrMove=IvyBindMsg(CallbackButtonWacom,&ptrButton,REGEXP_BUTTON_WACOM);
+ printf("bound to %s\n",REGEXP_BUTTON_WACOM);
}
ptrMove=IvyBindMsg(CallbackScreen,&ptrMove,REGEXP_CHANGE_GEOMETRY_SCREEN);
printf("bound to %s\n",REGEXP_CHANGE_GEOMETRY_SCREEN);