From f5c4e6f79d487075307c57f54b126463953c0c8c Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 21 Aug 2012 18:04:16 +0900 Subject: upload tizen2.0 source --- debian/changelog | 65 +++++- debian/rules | 3 +- debian/xserver-xorg-input-evdev.install | 1 - include/evdev-properties.h | 5 + packaging/xorg-x11-drv-evdev.spec | 19 +- src/evdev.c | 363 ++++++++++++++++++++++++++------ src/evdev.h | 9 + 7 files changed, 388 insertions(+), 77 deletions(-) mode change 100644 => 100755 src/evdev.h diff --git a/debian/changelog b/debian/changelog index fbe620d..9e32c91 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,64 @@ +xserver-xorg-input-evdev (2.3.2-5slp2+19) unstable; urgency=low + + * Fix CFLAGS in .spec file (add omitted MACRO defininitions) + * Git: slp/pkgs/xorg/driver/xserver-xorg-input-evdev + * Tag: xserver-xorg-input-evdev_2.3.2-5slp2+19 + + -- Sung-Jin Park Fri, 15 Jun 2012 14:29:27 +0900 + +xserver-xorg-input-evdev (2.3.2-5slp2+18) unstable; urgency=low + + * Modify pointer confine functions for to/not to warp pointer + * Git: slp/pkgs/xorg/driver/xserver-xorg-input-evdev + * Tag: xserver-xorg-input-evdev_2.3.2-5slp2+18 + + -- Sung-Jin Park Wed, 13 Jun 2012 21:44:52 +0900 + +xserver-xorg-input-evdev (2.3.2-5slp2+17) unstable; urgency=low + + * do not install libtool files + * Git: slp/pkgs/xorg/driver/xserver-xorg-input-evdev + * Tag: xserver-xorg-input-evdev_2.3.2-5slp2+17 + + -- SooChan Lim Fri, 18 May 2012 09:28:50 +0900 + +xserver-xorg-input-evdev (2.3.2-4slp2+17) unstable; urgency=low + + * Change global variable(s) to member variable(s) of EvdevRec + * Remove old unused function(s) + * Replace xcalloc() with calloc() : xcalloc() is depricated. + * Replace variable(s) declaration at the front of each function + * Git: 165.213.180.234:slp/pkgs/xorg/driver/xserver-xorg-input-evdev + * Tag: xserver-xorg-input-evdev_2.3.2-4slp2+17 + + -- Sung-Jin Park Sat, 12 May 2012 16:08:29 +0900 + +xserver-xorg-input-evdev (2.3.2-4slp2+16) unstable; urgency=low + + * Add overriding functions related to confining cursor + Add misc functions needed by confining function + Modify EvdevSetCursorLimits() for backingup/restoring function pointer(s) + * Git: 165.213.180.234:slp/pkgs/xorg/driver/xserver-xorg-input-evdev + * Tag: xserver-xorg-input-evdev_2.3.2-4slp2+16 + + -- Sung-Jin Park Thu, 10 May 2012 19:06:36 +0900 + +xserver-xorg-input-evdev (2.3.2-4slp2+15) unstable; urgency=low + + * Add _F_IGNORE_TSP_RESOLUTION_ to ignore TSP range information + * Git: 165.213.180.234:slp/pkgs/xorg/driver/xserver-xorg-input-evdev + * Tag: xserver-xorg-input-evdev_2.3.2-4slp2+15 + + -- Sung-Jin Park Tue, 17 Apr 2012 19:16:08 +0900 + +xserver-xorg-input-evdev (2.3.2-4slp2+14) unstable; urgency=low + + * Add a feature for confining input coordinates + * Git: 165.213.180.234:slp/pkgs/xorg/driver/xserver-xorg-input-evdev + * Tag: xserver-xorg-input-evdev_2.3.2-4slp2+14 + + -- Sung-Jin Park Thu, 29 Mar 2012 15:02:49 +0900 + xserver-xorg-input-evdev (2.3.2-4slp2+13) unstable; urgency=low * Remove log messages applied in previous version @@ -32,7 +93,7 @@ xserver-xorg-input-evdev (2.3.2-4slp2+10) unstable; urgency=low xserver-xorg-input-evdev (2.3.2-4slp2+9) unstable; urgency=low - * [X11R7.6] upgrade package + * [X11R7.6] upgrade package * Git: 165.213.180.234:slp/pkgs/xorg/driver/xserver-xorg-input-evdev * Tag: xserver-xorg-input-evdev_2.3.2-4slp2+9 @@ -94,7 +155,7 @@ xserver-xorg-input-evdev (2.3.2-4slp2+3) unstable; urgency=low xserver-xorg-input-evdev (2.3.2-4slp2+2) unstable; urgency=low - * Reupload for fixing the problem (ABI not matching with xorg-server) + * Reupload for fixing the problem (ABI not matching with xorg-server) * Git: 165.213.180.234:/git/slp/pkgs/xorg/driver/xserver-xorg-input-evdev * Tag: xserver-xorg-input-evdev_2.3.2-4slp2+2 diff --git a/debian/rules b/debian/rules index 360a704..dae954a 100755 --- a/debian/rules +++ b/debian/rules @@ -9,7 +9,7 @@ include debian/xsfbs/xsfbs.mk -CFLAGS = -Wall -g -D_F_INIT_ABS_ONLY_FOR_POINTER_ +CFLAGS = -Wall -g -D_F_INIT_ABS_ONLY_FOR_POINTER_ -D_F_EVDEV_CONFINE_REGION_ LDFLAGS += -Wl,--hash-style=both -Wl,--as-needed ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 @@ -28,7 +28,6 @@ ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) confflags += --build=$(DEB_HOST_GNU_TYPE) else confflags += --build=$(DEB_HOST_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) -# confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) endif # kbd_drv.a isn't phenomenally useful; kbd_drv.so more so diff --git a/debian/xserver-xorg-input-evdev.install b/debian/xserver-xorg-input-evdev.install index 1002d70..4ac2576 100644 --- a/debian/xserver-xorg-input-evdev.install +++ b/debian/xserver-xorg-input-evdev.install @@ -1,2 +1 @@ usr/lib/xorg/modules/input/*.so -usr/lib/xorg/modules/input/*.la diff --git a/include/evdev-properties.h b/include/evdev-properties.h index 3e3c194..4ba25f7 100755 --- a/include/evdev-properties.h +++ b/include/evdev-properties.h @@ -66,4 +66,9 @@ /* BOOL */ #define EVDEV_PROP_SWAP_AXES "Evdev Axes Swap" +#ifdef _F_EVDEV_CONFINE_REGION_ +/* Confine region in which relative and absolute devices can be moved */ +#define EVDEV_PROP_CONFINE_REGION "Evdev Confine Region" +#endif /* _F_EVDEV_CONFINE_REGION_ */ + #endif diff --git a/packaging/xorg-x11-drv-evdev.spec b/packaging/xorg-x11-drv-evdev.spec index 29edce8..7473235 100644 --- a/packaging/xorg-x11-drv-evdev.spec +++ b/packaging/xorg-x11-drv-evdev.spec @@ -1,20 +1,23 @@ -Name: xorg-x11-drv-evdev +#sbs-git:slp/pkgs/xorg/driver/xserver-xorg-input-evdev xserver-xorg-input-evdev 2.3.2 1bd95071427e460187b090bc5ff5a2d880fe156a +Name: xorg-x11-drv-evdev Summary: Xorg X11 evdev input driver -Version: 2.3.2 +Version: 2.3.2 Release: 4 Group: System/X Hardware Support License: MIT URL: http://www.x.org/ -Source0: http://xorg.freedesktop.org/releases/individual/driver/xf86-input-evdev-%{version}.tar.gz -Requires: xserver-xorg-core -BuildRequires: pkgconfig(xorg-server) +Source0: %{name}-%{version}.tar.gz +#Requires: xorg-server +Requires: xorg-x11-server-Xorg +BuildRequires: pkgconfig(xorg-macros) +BuildRequires: xorg-x11-server-devel +#BuildRequires: pkgconfig(xorg-server) BuildRequires: pkgconfig(xkbfile) BuildRequires: pkgconfig(xproto) BuildRequires: pkgconfig(inputproto) BuildRequires: pkgconfig(xrandr) BuildRequires: pkgconfig(randrproto) BuildRequires: pkgconfig(xextproto) -BuildRequires: pkgconfig(xorg-macros) %description @@ -31,11 +34,11 @@ This package contains xorg evdev development files %prep -%setup -q -n xf86-input-evdev-%{version} +%setup -q %build -%reconfigure --disable-static +%reconfigure --disable-static CFLAGS="$CFLAGS -Wall -g -D_F_INIT_ABS_ONLY_FOR_POINTER_ -D_F_EVDEV_CONFINE_REGION_" make %{?jobs:-j%jobs} %install diff --git a/src/evdev.c b/src/evdev.c index e86c6db..862e940 100755 --- a/src/evdev.c +++ b/src/evdev.c @@ -45,6 +45,15 @@ #include #include "evdev.h" +#ifdef _F_EVDEV_CONFINE_REGION_ +#include + +#define MIPOINTER(dev) \ + ((!IsMaster(dev) && !dev->master) ? \ + (miPointerPtr)dixLookupPrivate(&(dev)->devPrivates, miPointerPrivKey): \ + (miPointerPtr)dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates, miPointerPrivKey)) + +#endif /* _F_EVDEV_CONFINE_REGION_ */ #ifdef HAVE_PROPERTIES #include @@ -93,6 +102,9 @@ #define EVDEV_UNIGNORE_ABSOLUTE (1 << 9) /* explicitly unignore abs axes */ #define EVDEV_UNIGNORE_RELATIVE (1 << 10) /* explicitly unignore rel axes */ #define EVDEV_RESOLUTION (1 << 12) /* device looks like a multi-touch screen? */ +#ifdef _F_EVDEV_CONFINE_REGION_ +#define EVDEV_CONFINE_REGION (1 << 13) +#endif /* _F_EVDEV_CONFINE_REGION_ */ #define MIN_KEYCODE 8 #define GLYPHS_PER_KEY 2 @@ -127,8 +139,17 @@ static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms); static void EvdevInitProperty(DeviceIntPtr dev); static int EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, BOOL checkonly); -static void EvdevSetMouseExist(int value); -static void EvdevSetExtKeyboardExist(int value); +#ifdef _F_EVDEV_CONFINE_REGION_ +Bool IsMaster(DeviceIntPtr dev); +DeviceIntPtr GetPairedDevice(DeviceIntPtr dev); +DeviceIntPtr GetMaster(DeviceIntPtr dev, int which); +DeviceIntPtr GetMasterPointerFromId(int deviceid); +static void EvdevHookPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, BoxPtr pHotBox, BoxPtr pTopLeftBox); +static void EvdevHookPointerConstrainCursor (DeviceIntPtr pDev, ScreenPtr pScreen, BoxPtr pBox); +static void EvdevSetCursorLimits(InputInfoPtr pInfo, int region[5], int isSet); +static void EvdevSetConfineRegion(InputInfoPtr pInfo, int num_item, int region[5]); +static Atom prop_confine_region = 0; +#endif /* _F_EVDEV_CONFINE_REGION_ */ static Atom prop_invert = 0; static Atom prop_reopen = 0; static Atom prop_calibration = 0; @@ -142,7 +163,7 @@ static Atom prop_btn_label = 0; * cannot be used by evdev, leaving us with a space of 2 at the end. */ static EvdevPtr evdev_devices[MAXDEVICES] = {NULL}; -static size_t CountBits(unsigned long *array, size_t nlongs) +static size_t EvdevCountBits(unsigned long *array, size_t nlongs) { unsigned int i; size_t count = 0; @@ -680,9 +701,8 @@ EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v, * initialized to 1 so devices that doesn't use this scheme still * just works. */ - if (pEvdev->abs && pEvdev->tool) { + if (pEvdev->abs && pEvdev->tool) xf86PostMotionEventP(pInfo->dev, TRUE, *first_v, *num_v, v); - } } /** @@ -1190,8 +1210,6 @@ EvdevAddKeyClass(DeviceIntPtr device) #endif - pInfo->flags |= XI86_KEYBOARD_CAPABLE; - return Success; } @@ -1209,7 +1227,7 @@ EvdevAddAbsClass(DeviceIntPtr device) if (!TestBit(EV_ABS, pEvdev->bitmask)) return !Success; - num_axes = CountBits(pEvdev->abs_bitmask, NLONGS(ABS_MAX)); + num_axes = EvdevCountBits(pEvdev->abs_bitmask, NLONGS(ABS_MAX)); if (num_axes < 1) return !Success; pEvdev->num_vals = num_axes; @@ -1247,7 +1265,7 @@ EvdevAddAbsClass(DeviceIntPtr device) #endif pEvdev->absinfo[axis].minimum, pEvdev->absinfo[axis].maximum, - 10000, 0, 10000); + 10000, 0, 10000, Absolute); xf86InitValuatorDefaults(device, axnum); pEvdev->old_vals[axnum] = -1; } @@ -1257,22 +1275,6 @@ EvdevAddAbsClass(DeviceIntPtr device) if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc)) return !Success; - if ((TestBit(ABS_X, pEvdev->abs_bitmask) && - TestBit(ABS_Y, pEvdev->abs_bitmask)) || - (TestBit(ABS_RX, pEvdev->abs_bitmask) && - TestBit(ABS_RY, pEvdev->abs_bitmask)) || - (TestBit(ABS_HAT0X, pEvdev->abs_bitmask) && - TestBit(ABS_HAT0Y, pEvdev->abs_bitmask)) || - (TestBit(ABS_HAT1X, pEvdev->abs_bitmask) && - TestBit(ABS_HAT1Y, pEvdev->abs_bitmask)) || - (TestBit(ABS_HAT2X, pEvdev->abs_bitmask) && - TestBit(ABS_HAT2Y, pEvdev->abs_bitmask)) || - (TestBit(ABS_HAT3X, pEvdev->abs_bitmask) && - TestBit(ABS_HAT3Y, pEvdev->abs_bitmask)) || - (TestBit(ABS_TILT_X, pEvdev->abs_bitmask) && - TestBit(ABS_TILT_Y, pEvdev->abs_bitmask))) - pInfo->flags |= XI86_POINTER_CAPABLE; - return Success; } @@ -1290,7 +1292,7 @@ EvdevAddRelClass(DeviceIntPtr device) if (!TestBit(EV_REL, pEvdev->bitmask)) return !Success; - num_axes = CountBits(pEvdev->rel_bitmask, NLONGS(REL_MAX)); + num_axes = EvdevCountBits(pEvdev->rel_bitmask, NLONGS(REL_MAX)); if (num_axes < 1) return !Success; @@ -1344,7 +1346,7 @@ EvdevAddRelClass(DeviceIntPtr device) #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 atoms[axnum], #endif - -1, -1, 1, 0, 1); + -1, -1, 1, 0, 1, Relative); xf86InitValuatorDefaults(device, axnum); } @@ -1353,8 +1355,6 @@ EvdevAddRelClass(DeviceIntPtr device) if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc)) return !Success; - pInfo->flags |= XI86_POINTER_CAPABLE; - return Success; } @@ -1624,6 +1624,7 @@ EvdevProc(DeviceIntPtr device, int what) { InputInfoPtr pInfo; EvdevPtr pEvdev; + int region[4] = { 0, }; pInfo = device->public.devicePrivate; pEvdev = pInfo->private; @@ -1660,6 +1661,10 @@ EvdevProc(DeviceIntPtr device, int what) break; case DEVICE_CLOSE: +#ifdef _F_EVDEV_CONFINE_REGION_ + if( pEvdev->confined_id ) + EvdevSetConfineRegion(pInfo, 1, ®ion[0]); +#endif//_F_EVDEV_CONFINE_REGION_ xf86Msg(X_INFO, "%s: Close\n", pInfo->name); if (pInfo->fd != -1) { close(pInfo->fd); @@ -1972,8 +1977,6 @@ EvdevProbe(InputInfoPtr pInfo) } if (has_rel_axes || has_abs_axes || num_buttons) { - pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS | - XI86_CONFIGURED; if (pEvdev->flags & EVDEV_TOUCHPAD) { xf86Msg(X_INFO, "%s: Configuring as touchpad\n", pInfo->name); pInfo->type_name = XI_TOUCHPAD; @@ -1995,26 +1998,17 @@ EvdevProbe(InputInfoPtr pInfo) pInfo->name); } else { xf86Msg(X_INFO, "%s: Configuring as keyboard\n", pInfo->name); - pInfo->flags |= XI86_KEYBOARD_CAPABLE | XI86_CONFIGURED; pInfo->type_name = XI_KEYBOARD; } } - if (has_scroll && (pInfo->flags & XI86_CONFIGURED) && - (pInfo->flags & XI86_POINTER_CAPABLE) == 0) + if (has_scroll) { xf86Msg(X_INFO, "%s: Adding scrollwheel support\n", pInfo->name); - pInfo->flags |= XI86_POINTER_CAPABLE; pEvdev->flags |= EVDEV_BUTTON_EVENTS; pEvdev->flags |= EVDEV_RELATIVE_EVENTS; } - if ((pInfo->flags & XI86_CONFIGURED) == 0) { - xf86Msg(X_WARNING, "%s: Don't know how to use device\n", - pInfo->name); - return 1; - } - return 0; } @@ -2038,41 +2032,243 @@ EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]) } } -static InputInfoPtr -EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) +#ifdef _F_EVDEV_CONFINE_REGION_ +DeviceIntPtr +GetMasterPointerFromId(int deviceid) +{ + DeviceIntPtr pDev = inputInfo.devices; + while(pDev) + { + if( pDev->id == deviceid && pDev->master ) + { + return pDev->master; + } + pDev = pDev->next; + } + + return NULL; +} + +Bool +IsMaster(DeviceIntPtr dev) +{ + return dev->type == MASTER_POINTER || dev->type == MASTER_KEYBOARD; +} + +DeviceIntPtr +GetPairedDevice(DeviceIntPtr dev) +{ + if (!IsMaster(dev) && dev->master) + dev = dev->master; + + return dev->spriteInfo->paired; +} + +DeviceIntPtr +GetMaster(DeviceIntPtr dev, int which) +{ + DeviceIntPtr master; + + if (IsMaster(dev)) + master = dev; + else + master = dev->master; + + if (master) + { + if (which == MASTER_KEYBOARD) + { + if (master->type != MASTER_KEYBOARD) + master = GetPairedDevice(master); + } else + { + if (master->type != MASTER_POINTER) + master = GetPairedDevice(master); + } + } + + return master; +} + +static void +EvdevHookPointerCursorLimits(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, + BoxPtr pHotBox, BoxPtr pTopLeftBox) +{ + *pTopLeftBox = *pHotBox; +} + +static void +EvdevHookPointerConstrainCursor (DeviceIntPtr pDev, ScreenPtr pScreen, BoxPtr pBox) { InputInfoPtr pInfo; + EvdevPtr pEvdev; + + pInfo = pDev->public.devicePrivate; + if(!pInfo || !pInfo->private) return; + pEvdev = pInfo->private; + + miPointerPtr pPointer; + pPointer = MIPOINTER(pDev); + + if( IsMaster(pDev) && GetMasterPointerFromId(pEvdev->confined_id) == pDev ) + { + if( pBox->x1 < pEvdev->pointer_confine_region.x1 ) + pBox->x1 = pEvdev->pointer_confine_region.x1; + if( pBox->y1 < pEvdev->pointer_confine_region.y1 ) + pBox->y1 = pEvdev->pointer_confine_region.y1; + if( pBox->x2 > pEvdev->pointer_confine_region.x2 ) + pBox->x2 = pEvdev->pointer_confine_region.x2; + if( pBox->y2 > pEvdev->pointer_confine_region.y2 ) + pBox->y2 = pEvdev->pointer_confine_region.y2; + } + + pPointer->limits = *pBox; + pPointer->confined = PointerConfinedToScreen(pDev); +} + +static void +EvdevSetCursorLimits(InputInfoPtr pInfo, int region[5], int isSet) +{ + EvdevPtr pEvdev = pInfo->private; + int v[2]; + int x, y; + + ScreenPtr pCursorScreen = NULL; + + pCursorScreen = miPointerGetScreen(pInfo->dev); + + if( !pCursorScreen ) + { + xf86DrvMsg(-1, X_ERROR, "[X11][SetCursorLimits] Failed to get screen information for pointer !\n"); + return; + } + + if( isSet ) + { + //Clip confine region with screen's width/height + if( region[0] < 0 ) + region[0] = 0; + if( region[2] >= pCursorScreen->width ) + region[2] = pCursorScreen->width - 1; + if( region [1] < 0 ) + region[1] = 0; + if( region[3] >= pCursorScreen->height ) + region[3] = pCursorScreen->height - 1; + + pEvdev->pointer_confine_region.x1 = region[0]; + pEvdev->pointer_confine_region.y1 = region[1]; + pEvdev->pointer_confine_region.x2 = region[2]; + pEvdev->pointer_confine_region.y2 = region[3]; + pEvdev->confined_id = pInfo->dev->id; + + pCursorScreen->ConstrainCursor(inputInfo.pointer, pCursorScreen, &pEvdev->pointer_confine_region); + xf86DrvMsg(-1, X_INFO, "[X11][SetCursorLimits] Constrain information for cursor was set to TOPLEFT(%d, %d) BOTTOMRIGHT(%d, %d) !\n", + region[0], region[1], region[2], region[3]); + + if( pCursorScreen->ConstrainCursor != EvdevHookPointerCursorLimits && + pCursorScreen->ConstrainCursor != EvdevHookPointerConstrainCursor) + { + //Backup original function pointer(s) + pEvdev->pOrgConstrainCursor = pCursorScreen->ConstrainCursor; + pEvdev->pOrgCursorLimits = pCursorScreen->CursorLimits; + + //Overriding function pointer(s) + pCursorScreen->CursorLimits = EvdevHookPointerCursorLimits; + pCursorScreen->ConstrainCursor = EvdevHookPointerConstrainCursor; + } + + //Skip pointer warp if region[4] is zero + if(!region[4]) + return; + + v[0] = region[0] + (int)((float)(region[2]-region[0])/2); + v[1] = region[1] + (int)((float)(region[3]-region[1])/2); + + xf86PostMotionEventP(pInfo->dev, TRUE, REL_X, 2, v); + xf86DrvMsg(-1, X_INFO, "[X11][SetCursorLimits] Cursor was warped to (%d, %d) !\n", v[0], v[1]); + miPointerGetPosition(pInfo->dev, &x, &y); + xf86DrvMsg(-1, X_INFO, "[X11][SetCursorLimits] Cursor is located at (%d, %d) !\n", x, y); + } + else + { + pEvdev->pointer_confine_region.x1 = 0; + pEvdev->pointer_confine_region.y1 = 0; + pEvdev->pointer_confine_region.x2 = pCursorScreen->width - 1; + pEvdev->pointer_confine_region.y2 = pCursorScreen->height - 1; + pEvdev->confined_id = 0; + + pCursorScreen->ConstrainCursor(inputInfo.pointer, pCursorScreen, &pEvdev->pointer_confine_region); + xf86DrvMsg(-1, X_INFO, "[X11][SetCursorLimits] Constrain information for cursor was restored ! TOPLEFT(%d, %d) BOTTOMRIGHT(%d, %d) !\n", + pEvdev->pointer_confine_region.x1, pEvdev->pointer_confine_region.y1, + pEvdev->pointer_confine_region.x2, pEvdev->pointer_confine_region.y2); + + //Restore original function pointer(s) + pCursorScreen->CursorLimits = pEvdev->pOrgCursorLimits; + pCursorScreen->ConstrainCursor = pEvdev->pOrgConstrainCursor; + } +} + +static void +EvdevSetConfineRegion(InputInfoPtr pInfo, int num_item, int region[5]) +{ + EvdevPtr pEvdev = pInfo->private; + + if( num_item != 5 && num_item != 1 ) + return; + + if( num_item == 5 ) + { + if ( (region[2]-region[0]>0) && (region[3]-region[1]>0) ) + { + EvdevSetCursorLimits(pInfo, ®ion[0], 1); + xf86DrvMsg(-1, X_INFO, "[X11][SetConfineRegion] Confine region was set to TOPLEFT(%d, %d) BOTTOMRIGHT(%d, %d) pointerwarp=%d\n", + region[0], region[1], region[2], region[3], region[4]); + pEvdev->flags |= EVDEV_CONFINE_REGION; + } + } + else if( num_item == 1 ) + { + if( !region[0] && (pEvdev->flags & EVDEV_CONFINE_REGION) ) + { + EvdevSetCursorLimits(pInfo, ®ion[0], 0); + xf86DrvMsg(-1, X_INFO, "[X11][SetConfineRegion] Confine region was unset !\n"); + pEvdev->flags &= ~EVDEV_CONFINE_REGION; + } + } +} +#endif /* _F_EVDEV_CONFINE_REGION_ */ + +static int +EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) +{ + int rc = BadAlloc; const char *device, *str; int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 }; int num_resolution = 0, resolution[4] = { 0, 0, 0, 0 }; EvdevPtr pEvdev; - if (!(pInfo = xf86AllocateInput(drv, 0))) - return NULL; + if(!pInfo) + { + ErrorF("[X11][EvdevPreInit] pInfo is NULL !\n"); + goto error; + } + + ErrorF("[X11][EvdevPreInit] pInfo is NOT NULL !\n"); /* Initialise the InputInfoRec. */ - pInfo->name = dev->identifier; pInfo->flags = 0; pInfo->type_name = "UNKNOWN"; pInfo->device_control = EvdevProc; pInfo->read_input = EvdevReadInput; - pInfo->history_size = 0; - pInfo->control_proc = NULL; - pInfo->close_proc = NULL; pInfo->switch_mode = NULL; - pInfo->conversion_proc = NULL; - pInfo->reverse_conversion_proc = NULL; pInfo->dev = NULL; - pInfo->private_flags = 0; - pInfo->always_core_feedback = NULL; - pInfo->conf_idev = dev; - if (!(pEvdev = xcalloc(sizeof(EvdevRec), 1))) - return pInfo; + if (!(pEvdev = calloc(sizeof(EvdevRec), 1))) + goto error; pInfo->private = pEvdev; - xf86CollectInputOptions(pInfo, evdevDefaults, NULL); + xf86CollectInputOptions(pInfo, evdevDefaults); xf86ProcessCommonOptions(pInfo, pInfo->options); /* @@ -2081,11 +2277,12 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) */ pEvdev->tool = 1; - device = xf86CheckStrOption(dev->commonOptions, "Device", NULL); + device = xf86CheckStrOption(pInfo->options, "Device", NULL); if (!device) { xf86Msg(X_ERROR, "%s: No device specified.\n", pInfo->name); xf86DeleteInput(pInfo, 0); - return NULL; + rc = BadValue; + goto error; } pEvdev->device = device; @@ -2098,7 +2295,8 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) if (pInfo->fd < 0) { xf86Msg(X_ERROR, "Unable to open evdev device \"%s\".\n", device); xf86DeleteInput(pInfo, 0); - return NULL; + rc = BadValue; + goto error; } /* Check major/minor of device node to avoid adding duplicate devices. */ @@ -2109,7 +2307,8 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) pInfo->name); close(pInfo->fd); xf86DeleteInput(pInfo, 0); - return NULL; + rc = BadValue; + goto error; } pEvdev->reopen_attempts = xf86SetIntOption(pInfo->options, "ReopenAttempts", 10); @@ -2146,7 +2345,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) /* Grabbing the event device stops in-kernel event forwarding. In other words, it disables rfkill and the "Macintosh mouse button emulation". Note that this needs a server that sets the console to RAW mode. */ - pEvdev->grabDevice = xf86CheckBoolOption(dev->commonOptions, "GrabDevice", 0); + pEvdev->grabDevice = xf86CheckBoolOption(pInfo->options, "GrabDevice", 0); EvdevInitButtonMapping(pInfo); @@ -2154,13 +2353,15 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) EvdevProbe(pInfo)) { close(pInfo->fd); xf86DeleteInput(pInfo, 0); - return NULL; + rc = BadMatch; + goto error; } if(pEvdev->flags & EVDEV_RESOLUTION) { EvdevSwapAxes(pEvdev); } +#ifdef _F_IGNORE_TSP_RESOLUTION_ else { pEvdev->absinfo[ABS_X].maximum = 0; @@ -2168,6 +2369,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) pEvdev->absinfo[ABS_Y].maximum = 0; pEvdev->absinfo[ABS_Y].minimum = 0; } +#endif//_F_IGNORE_TSP_RESOLUTION_ EvdevAddDevice(pInfo); @@ -2178,7 +2380,14 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) EvdevDragLockPreInit(pInfo); } - return pInfo; + memset(&pEvdev->pointer_confine_region, 0, sizeof(pEvdev->pointer_confine_region)); + + return Success; + +error: + if (pInfo->fd >= 0) + close(pInfo->fd); + return rc; } _X_EXPORT InputDriverRec EVDEV = { @@ -2526,6 +2735,9 @@ EvdevInitProperty(DeviceIntPtr dev) int rc; BOOL invert[2]; char reopen; +#ifdef _F_EVDEV_CONFINE_REGION_ + int region[4] = { 0, }; +#endif//_F_EVDEV_CONFINE_REGION_ prop_reopen = MakeAtom(EVDEV_PROP_REOPEN, strlen(EVDEV_PROP_REOPEN), TRUE); @@ -2606,6 +2818,16 @@ EvdevInitProperty(DeviceIntPtr dev) XISetDevicePropertyDeletable(dev, prop_btn_label, FALSE); } #endif /* HAVE_LABELS */ + +#ifdef _F_EVDEV_CONFINE_REGION_ + prop_confine_region = MakeAtom(EVDEV_PROP_CONFINE_REGION, + strlen(EVDEV_PROP_CONFINE_REGION), TRUE); + rc = XIChangeDeviceProperty(dev, prop_confine_region, XA_INTEGER, + 32, PropModeReplace, 4, region, FALSE); + + if (rc != Success) + return; +#endif /* _F_EVDEV_CONFINE_REGION_ */ } } @@ -2693,7 +2915,20 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, EvdevSwapAxes(pEvdev); } else if (atom == prop_axis_label || atom == prop_btn_label) return BadAccess; /* Axis/Button labels can't be changed */ +#ifdef _F_EVDEV_CONFINE_REGION_ + else if (atom == prop_confine_region) + { + if (val->format != 32 || val->type != XA_INTEGER) + return BadMatch; + if (val->size != 1 && val->size != 5) + return BadMatch; + if (!checkonly) + EvdevSetConfineRegion(pInfo, val->size, val->data); + } +#endif /* _F_EVDEV_CONFINE_REGION_ */ return Success; } #endif + + diff --git a/src/evdev.h b/src/evdev.h old mode 100644 new mode 100755 index e702694..aadcf97 --- a/src/evdev.h +++ b/src/evdev.h @@ -170,6 +170,14 @@ typedef struct { int reopen_left; /* number of attempts left to re-open the device */ OsTimerPtr reopen_timer; + //Backup pointer(s) for cursor + CursorLimitsProcPtr pOrgCursorLimits; + ConstrainCursorProcPtr pOrgConstrainCursor; + + //Confining information + int confined_id; + BoxRec pointer_confine_region; + /* Cached info from device. */ char name[1024]; unsigned long bitmask[NLONGS(EV_CNT)]; @@ -223,3 +231,4 @@ void EvdevWheelEmuInitProperty(DeviceIntPtr); void EvdevDragLockInitProperty(DeviceIntPtr); #endif #endif + -- cgit v1.2.3