From 55c93989b31d75cd8e6686791c6a3dd6d86e82fb Mon Sep 17 00:00:00 2001 From: LazyDog Date: Tue, 22 Sep 2015 22:50:29 -0700 Subject: [PATCH 1/2] changes to src/mice.c --- src/mice.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/mice.c b/src/mice.c index 6cbd491..dfb03cc 100644 --- a/src/mice.c +++ b/src/mice.c @@ -254,6 +254,43 @@ static int M_evdev (Gpm_Event * state, unsigned char *data) } return 0; } +static int M_vboxevdev (Gpm_Event * state, unsigned char *data) +{ + struct input_event thisevent; + (void) memcpy (&thisevent, data, sizeof (struct input_event)); + if (thisevent.type==EV_ABS) { + if (thisevent.code==ABS_X) { //X: + state->x = (thisevent.value * (win.ws_col+1) / 65535); + int myrealposx=thisevent.value/4; + realposx=myrealposx; + } else if (thisevent.code==ABS_Y) { //Y: + state->y = 1 + thisevent.value * (win.ws_row)/65535; + int myrealposy=thisevent.value/4; + realposy=myrealposy; + } + } + else if (thisevent.type==EV_KEY) { + unsigned char mybuttons=state->buttons; + if (thisevent.code==BTN_LEFT) { //Left-Button: + if (thisevent.value==1) { //Press: + mybuttons |= GPM_B_LEFT; + } else { + mybuttons &= ~(GPM_B_LEFT); + } + } else if (thisevent.code=BTN_RIGHT) { //Right-Button: + if (thisevent.value==1) { //Press: + mybuttons |= GPM_B_RIGHT; + } else { + mybuttons &= ~(GPM_B_RIGHT); + } + } + state->buttons = mybuttons; + } + + //printf("type=%d code=%d value=%d buttons=%d\n",thisevent.type,thisevent.code,thisevent.value,state->buttons); + + return 0; +} #endif /* HAVE_LINUX_INPUT_H */ static int M_ms(Gpm_Event *state, unsigned char *data) @@ -2404,6 +2441,9 @@ Gpm_Type mice[]={ {"evdev", "Linux Event Device", "", M_evdev, I_empty, STD_FLG, {0x00, 0x00, 0x00, 0x00} , 16, 16, 0, 0, NULL}, + {"vboxevdev", "Linux Event Device2", + "", M_vboxevdev, I_empty, STD_FLG, + {0x00, 0x00, 0x00, 0x00} , 24, 24, 0, 1, NULL}, #endif /* HAVE_LINUX_INPUT_H */ {"exps2", "IntelliMouse Explorer (ps2) - 3 buttons, wheel unused", "ExplorerPS/2", M_imps2, I_exps2, STD_FLG, From 235f60bf576161cf116321f6ad2ea4b63a5f41f1 Mon Sep 17 00:00:00 2001 From: LazyDog Date: Wed, 23 Sep 2015 22:12:05 -0700 Subject: [PATCH 2/2] adding runner script for virtualbox evdev --- contrib/scripts/gpm-vboxevdev.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 contrib/scripts/gpm-vboxevdev.sh diff --git a/contrib/scripts/gpm-vboxevdev.sh b/contrib/scripts/gpm-vboxevdev.sh new file mode 100755 index 0000000..c5b249d --- /dev/null +++ b/contrib/scripts/gpm-vboxevdev.sh @@ -0,0 +1,6 @@ +#!/bin/bash +DEV1=/dev/$(grep 'ImExPS/2' /sys/class/input/event*/device/name|cut -d/ -f4,5) +DEV2=/dev/$(grep 'VirtualBox mouse' /sys/class/input/event*/device/name|cut -d/ -f4,5) +GPM=../../src/gpm +#echo $DEV1 $DEV2 +cat <(cat $DEV1 & cat $DEV2) | $GPM -m - -t vboxevdev -D > /dev/null 2>/dev/null