2008/9/29 Peter Hutterer <[EMAIL PROTECTED]>:
> Søren:
>
> On Mon, Sep 29, 2008 at 01:29:35PM +0200, Søren Hauberg wrote:
>> > Sorry, I wanted to suggest that in reply but missed it. Anyway, be aware
>> > that as your patch is now, you're also triggering on absolute axes you 
>> > can't
>> > handle/don't know. I'd consider that a regression.
>>
>> Ahh, I (think I) see. The attached patch should handle this.
>
> a few comments to your patch:

Okay, so I'm attaching my latest patch. This should handle everything
except setting/getting calibration parameters. I'll look into this
after lunch today. I'd love some feedback on the patch, as I think
this is the best structure, but since I'm a newbie I just might be
mistaken.

Also, I should mention that this is my last day where I have easy
access to a touch screen. I can get access later on, but it'll be some
work.

Thanks,
Søren

Attachment: evdev.c.patch5
Description: Binary data

Attachment: evdev.h.patch0
Description: Binary data

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <xf86.h>
#include <xf86Xinput.h>
#include <X11/Xatom.h>
#include <exevents.h>

#include <evdev-properties.h>
#include "evdev.h"

void EvdevInitTouchscreen(InputInfoPtr pInfo)
{
    EvdevPtr pEvdev;
    pEvdev = pInfo->private;
    
    /* Calibration parameters. I'm setting them to the ones I need for ease of debugging */
    pEvdev->touchscreen.flip_x = TRUE;
    pEvdev->touchscreen.flip_y = TRUE;
    pEvdev->touchscreen.swap_xy = TRUE;
    pEvdev->touchscreen.min_x = 46;
    pEvdev->touchscreen.max_x = 1000;
    pEvdev->touchscreen.min_y = 61;
    pEvdev->touchscreen.max_y = 969;
    /* end calibration parameters */
}

#define TRANSFORM(X, MIN_X, MAX_X, RANGE_X) \
        ((RANGE_X * (X - MIN_X))/(MAX_X-MIN_X))

int EvdevTransformTouchX(EvdevPtr pEvdev, int value)
{
  int abs_x;
  abs_x = TRANSFORM(value, pEvdev->touchscreen.min_x, pEvdev->touchscreen.max_x,
                    pEvdev->max_x);

  if (pEvdev->touchscreen.flip_x)
      abs_x = pEvdev->max_x - abs_x;
  
  return abs_x;
}

int EvdevTransformTouchY(EvdevPtr pEvdev, int value)
{
  int abs_y;
  abs_y = TRANSFORM(value, pEvdev->touchscreen.min_y, pEvdev->touchscreen.max_y,
                    pEvdev->max_y);

  if (pEvdev->touchscreen.flip_y)
      abs_y = pEvdev->max_y - abs_y;
  
  return abs_y;
}

_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg

Reply via email to