On Thu, May 07, 2009 at 01:14:48PM +0200, Sven Neumann wrote: > Hi, > > attached is a patch that implements driver_get_axis_info() for the > linux-input driver. If we can reach consensus that this is a good thing > to do, then I'd like to push this change to the git repository. > > > Sven > >
> From 970ebffa842e598257945e922a544406a80431dd Mon Sep 17 00:00:00 2001 > From: Sven Neumann <s.neum...@raumfeld.com> > Date: Thu, 7 May 2009 11:34:52 +0200 > Subject: [PATCH] input: Implement driver_get_axis_info() in the linux-input > driver > > --- > inputdrivers/linux_input/linux_input.c | 47 > +++++++++++++++++++++++++++++++- > 1 files changed, 46 insertions(+), 1 deletions(-) > > diff --git a/inputdrivers/linux_input/linux_input.c > b/inputdrivers/linux_input/linux_input.c > index 1e9d761..7415cfb 100644 > --- a/inputdrivers/linux_input/linux_input.c > +++ b/inputdrivers/linux_input/linux_input.c > @@ -85,6 +85,7 @@ typedef unsigned long kernel_ulong_t; > #include <sys/kd.h> > #include <stdlib.h> > > +#define DFB_INPUTDRIVER_HAS_AXIS_INFO > > #include <directfb.h> > #include <directfb_keyboard.h> > @@ -1217,7 +1218,7 @@ driver_open_device( CoreInputDevice *device, > ret = ioctl( fd, EVIOCGRAB, 1 ); > /* 2.4 kernels don't have EVIOCGRAB so ignore EINVAL */ > if (ret && errno != EINVAL) { > - D_PERROR( "Direc tFB/linux_input: could not grab device" > ); > + D_PERROR( "DirectFB/linux_input: could not grab device" ); > close( fd ); > return DFB_INIT; > } > @@ -1278,6 +1279,50 @@ driver_open_device( CoreInputDevice *device, > return DFB_OK; > } > > +/* > + * Obtain information about an axis (only absolute axis so far). > + */ > +static DFBResult > +driver_get_axis_info( CoreInputDevice *device, > + void *driver_data, > + DFBInputDeviceAxisIdentifier axis, > + DFBInputDeviceAxisInfo *ret_info ) > +{ > + LinuxInputData *data = (LinuxInputData*) driver_data; > + > + if (data->touchpad) { > + /* for the touchpad, events are normalized to 0..511 */ > + switch (axis) { > + case DIAI_X: > + case DIAI_Y: > + ret_info->flags |= DIAIF_ABS_MIN | DIAIF_ABS_MAX; > + ret_info->abs_min = 0; > + ret_info->abs_max = (1 << 9) - 1; > + break; > + default: > + break; > + } We don't report absolute events for touchpads so this bit is not really needed. > + } else { > + if (axis <= ABS_PRESSURE && axis < DIAI_LAST) { > + unsigned long absbit[NBITS(ABS_CNT)]; > + > + /* check if we have an absolute axes */ > + ioctl( data->fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit ); > + > + if (test_bit (axis, absbit)) { > + struct input_absinfo absinfo; > + > + ioctl( data->fd, EVIOCGABS(axis), &absinfo ); > + > + ret_info->flags |= DIAIF_ABS_MIN | DIAIF_ABS_MAX; > + ret_info->abs_min = absinfo.minimum; > + ret_info->abs_max = absinfo.maximum; > + } > + } > + } > + > + return DFB_OK; > +} > > /* > * Fetch one entry from the kernel keymap. > -- > 1.5.6.3 > -- Ville Syrjälä syrj...@sci.fi http://www.sci.fi/~syrjala/ _______________________________________________ directfb-dev mailing list directfb-dev@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev