aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ivypointer.c70
1 files changed, 63 insertions, 7 deletions
diff --git a/src/ivypointer.c b/src/ivypointer.c
index ec5919b..dbc9c72 100644
--- a/src/ivypointer.c
+++ b/src/ivypointer.c
@@ -90,9 +90,23 @@
#define CHAMP_X_WACOM_PREDICTIVE_BUTTON 9
#define CHAMP_Y_WACOM_PREDICTIVE_BUTTON 10
+#define REGEXP_POINTER_2 "^InputMoveEvent %s Abs_X=(.*) Abs_Y=(.*).*(unknown=.*)? time=(.*)"
+#define REGEXP_BUTTON_WACOM_2 "^InputButtonEvent %s num=(.*) state=(.*) Abs_X=(.*) Abs_Y=(.*).*(unknown=.*)? time=(.*)"
+
+#define CHAMP_X_WACOM_2 1
+#define CHAMP_Y_WACOM_2 2
+
+#define CHAMP_X_WACOM_BUTTON_2 1
+#define CHAMP_Y_WACOM_BUTTON_2 2
+
#define TIME_CLICK 200
#define TIME_BETWEEN_CLICK 200
+enum input_type {
+ WACOM,
+ TELEPOINTER,
+ XINPUT2
+};
static void printHelpMsg(const char *name);
@@ -462,6 +476,22 @@ static void CallbackButtonWacom (IvyClientPtr app, void *user_data, int argc, ch
fakeMouseButton(b,press,0,0);
}
+static void CallbackButtonXInput2 (IvyClientPtr app, void *user_data, int argc, char *argv[]) {
+// char *id = argv[0];
+ int b = atoi(argv[1-device_input_id_given]);
+ if (b == 1 && relative) // gestion propre du bouton 1
+ return;
+ int press = !!strcmp(argv[2-device_input_id_given],"released");
+ float x = atof(argv[champXButton]);
+ float y = atof(argv[champYButton]);
+ if (!valid(x,y)){
+ // ignore outside events
+ return;
+ }
+
+ fakeMouseButton(b,press,0,0);
+}
+
static int extractValues(char optarg[], float* output, const char name[]){
int i = 0;
int j = 0;
@@ -498,6 +528,7 @@ static int extractValues(char optarg[], float* output, const char name[]){
static 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-2\t\tuse data from xinput2 instead of xinput_wacom\n"
"\t-t\t\tuse data from ModeManager instead of xinput_wacom\n"
"\t-C x0,y0,x1,y1\tspecify the coords of the screen used\n"
"\t-d device\tuse \"device\" as the source of the events\n"
@@ -518,12 +549,12 @@ int main(int argc, char *argv[]) {
char busbuf [1024] = "";
char device_input_id [1024] = "(.*)";
char ivyName [1024] = "IvyPointer";
- int wacom = 1;
+ enum input_type input_type = WACOM;
float user_coordsO = 0;
float coordsO[4] = {0,0,0,0};
int c;
int id = -1;
- while ((c = getopt(argc, argv, "vb:td:C:rpi:sc:")) != EOF)
+ while ((c = getopt(argc, argv, "vb:2td:C:rpi:sc:")) != EOF)
switch (c) {
case 'b':
strcpy (busbuf, optarg);
@@ -539,8 +570,11 @@ int main(int argc, char *argv[]) {
strcpy (device_input_id, optarg);
device_input_id_given = 1;
break;
+ case '2':
+ input_type = XINPUT2;
+ break;
case 't':
- wacom = 0;
+ input_type = TELEPOINTER;
break;
case 'p':
predictive_mode = 1;
@@ -597,7 +631,8 @@ int main(int argc, char *argv[]) {
exit(1);
}
- if (wacom) {
+ switch (input_type) {
+ case WACOM:
if (predictive_mode){
coords_input[2] = width;
coords_input[3] = height;
@@ -617,7 +652,16 @@ int main(int argc, char *argv[]) {
champXButton = CHAMP_X_WACOM_PREDICTIVE_BUTTON;
champYButton = CHAMP_Y_WACOM_PREDICTIVE_BUTTON;
}
- } else {
+ break;
+ case XINPUT2:
+ coords_input[2] = 104480.0;
+ coords_input[3] = 65600.0;
+ champX = CHAMP_X_WACOM_2;
+ champY = CHAMP_Y_WACOM_2;
+ champXButton = CHAMP_X_WACOM_BUTTON_2;
+ champYButton = CHAMP_Y_WACOM_BUTTON_2;
+ break;
+ default:
champX = CHAMP_X_TELEPOINTEUR;
champY = CHAMP_Y_TELEPOINTEUR;
}
@@ -642,7 +686,8 @@ int main(int argc, char *argv[]) {
IvyInit(ivyName,"IvyPointer Ready",NULL,NULL,NULL,NULL);
char regexp[2048] = "";
- if (!wacom) {
+ switch (input_type) {
+ case TELEPOINTER:
// telepointer callbacks
sprintf(regexp, REGEXP_MOVE, device_input_id);
@@ -660,7 +705,8 @@ int main(int argc, char *argv[]) {
sprintf(regexp, REGEXP_BUTTON, device_input_id);
ptrMove=IvyBindMsg(CallbackButton,&ptrButton, REGEXP_BUTTON, device_input_id);
printf("bound to %s\n",regexp);
- } else {
+ break;
+ case WACOM:
//wacom callbacks
sprintf(regexp, REGEXP_POINTER, device_input_id);
ptrMove=IvyBindMsg(CallbackPointer,&ptrMove, REGEXP_POINTER, device_input_id);
@@ -676,6 +722,16 @@ int main(int argc, char *argv[]) {
sprintf(regexp, REGEXP_BUTTON_WACOM, device_input_id);
ptrMove=IvyBindMsg(CallbackButtonWacom,&ptrButton, REGEXP_BUTTON_WACOM, device_input_id);
printf("bound to %s\n",regexp);
+ break;
+ case XINPUT2:
+ sprintf(regexp, REGEXP_POINTER_2, device_input_id);
+ ptrMove=IvyBindMsg(CallbackPointer,&ptrMove, REGEXP_POINTER_2, device_input_id);
+ printf("bound to %s\n",regexp);
+
+ sprintf(regexp, REGEXP_BUTTON_WACOM_2, device_input_id);
+ ptrMove=IvyBindMsg(CallbackButtonXInput2,&ptrButton, REGEXP_BUTTON_WACOM_2, device_input_id);
+ printf("bound to %s\n",regexp);
+ break;
}
if (!predictive_mode) {