关于作者

evtouch触摸屏九点校正笔记

上一篇 / 下一篇  2012-01-31 11:37:08

$ cat /proc/bus/input/devices
$ lshal
$ hal-find-by-property --key info.product --string 'HID TOUCH HID Touch Panel'
/org/freedesktop/Hal/devices/usb_device_1ddb_1_noserial_2_if0_logicaldev_input
/org/freedesktop/Hal/devices/usb_device_1ddb_1_noserial_1_if0_logicaldev_input
/org/freedesktop/Hal/devices/usb_device_1ddb_1_noserial_0_if0_logicaldev_input
/org/freedesktop/Hal/devices/usb_device_1ddb_1_noserial_if0_logicaldev_input
$ cat calibrate.sh
#!/bin/bash
UDI=$(hal-find-by-property --key info.product --string 'HID TOUCH HID Touch Panel')
#UDI=$(hal-find-by-property --key input.x11_driver --string evtouch)
MYDPY=":1.1"
#MYDPY=":1.0"
$ pwd
/usr/lib/xf86-input-evtouch
$ sudo ./calibrate.sh
$ sed -e 's/^\(.*\)=/\tOption \"\1\" /g' -e 's/MIN/Min/g' -e 's/MAX/Max/g' -e 's/X\([0-9]\)/x\1/g' -e 's/Y\([0-9]\)/y\1/g' /etc/evtouch/config
$ cat /etc/X11/xorg.conf
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 285.05.09  (buildmeister@swio-display-x86-rhel47-02.nvidia.com)  Fri Sep 23 19:18:04 PDT 2011

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    Screen      1  "Screen1" RightOf "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
#    InputDevice    "Mouse0" "SendCoreEvents"
    InputDevice    "Touch0" "SendCoreEvents"
    InputDevice    "Touch1" "SendCoreEvents"
    Option       "AllowMouseOpenFail" "true"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Idek Iiyama AS4637"
    HorizSync       24.0 - 80.0
    VertRefresh     56.0 - 85.0
    Option         "DPMS"
EndSection

Section "Monitor"
    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "DVI"
    HorizSync       31.5 - 80.0
    VertRefresh     56.0 - 75.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 380"
    BusID          "PCI:1:0:0"
    Screen          0
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 380"
    BusID          "PCI:1:0:0"
    Screen          1
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "DFP-0: 800x512 +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "DFP-1: 1280x1024 +0+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

$ cat /etc/X11/xorg.conf.d/00-touch.conf
Section "InputDevice"
        Identifier  "Touch0"  # FIXME
        Driver "evtouch"
        Option "Device" "/dev/input/event4"  # FIXME
        Option "ScreenNumber" "0"  # FIXME
        Option "MinX" "27"
        Option "MinY" "1"
        Option "MaxX" "3987"
        Option "MaxY" "4072"
        Option "SwapX" "true"
        Option "SwapY" "true"
        Option "Calibrate" "0"
        Option "ReportingMode" "Raw"
        Option "Emulate3Buttons" "true"
        Option "Emulate3Timeout" "50"
        Option "SendCoreEvents" "On"
EndSection

Section "InputDevice"
        Identifier  "Touch1"  # FIXME
        Driver "evtouch"
        Option "Device" "/dev/input/event5"  # FIXME
        Option "ScreenNumber" "1"  # FIXME
    Option "MinX" "98"
    Option "MinY" "133"
    Option "MaxX" "3913"
    Option "MaxY" "3877"
    Option "x0" "-8"
    Option "y0" "-13"
    Option "x1" "40"
    Option "y1" "-5"
    Option "x2" "-2"
    Option "y2" "5"
    Option "x3" "5"
    Option "y3" "24"
    Option "x4" "-7"
    Option "y4" "6"
    Option "x5" "-5"
    Option "y5" "-56"
    Option "x6" "-14"
    Option "y6" "-2"
    Option "x7" "-16"
    Option "y7" "-4"
    Option "x8" "-1"
    Option "y8" "-5"
    Option "SwapX" "false"
        Option "SwapY" "false"
        Option "Calibrate" "0"
        Option "ReportingMode" "Raw"
        Option "Emulate3Buttons" "true"
        Option "Emulate3Timeout" "50"
        Option "SendCoreEvents" "On"
EndSection
$
还是很不准啊- -
另赠小程序一个:
$ cat input.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <poll.h>
#include <signal.h>

#define DEVNAME "/dev/input/event4"

static struct input_event rec;
static int min_x = 0x7fff, min_y = 0x7fff, max_x = 0, max_y = 0;
static int fd;

static int get_packet(int fd)
{
  /* struct pollfd fds; */
  int total = sizeof(rec);
  int ret;

  memset(&rec, 0, total);

  /* fds.fd = fd; */
  /* fds.events = POLLIN; */
  /* fds.revents = 0; */

  /* poll(&fds, 1, -1); */
  /* if (fds.revents & POLLHUP) { */
  /*   fprintf(stderr, "HUP\n"); */
  /*   return 0; */
  /* } */
  /* if (!(fds.revents & POLLIN)) { */
  /*   fprintf(stderr, "!IN\n"); */
  /*   return 0; */
  /* } */
  ret = read(fd, &rec, total);
  if (ret <= 0) {
    return 0;
  }

  return 1;
}

static void
sig(int id)
{
  FILE *fp;

  ioctl(fd, EVIOCGRAB, (void *)0);
  close(fd);

  fp = fopen("log", "w");
  if (!fp) {
    fp = stderr;
    return;
  }

  fprintf(fp, "Section \"InputDevice\"\n");
  fprintf(fp, "        Identifier  \"Touch0\"  # FIXME\n");
  fprintf(fp, "        Driver \"evtouch\"\n");
  fprintf(fp, "        Option \"Device\" \"%s\"\n", DEVNAME);
  fprintf(fp, "        Option \"ScreenNumber\" \"\"  # FIXME\n");
  fprintf(fp, "        Option \"MinX\" \"%d\"\n", min_x);
  fprintf(fp, "        Option \"MinY\" \"%d\"\n", min_y);
  fprintf(fp, "        Option \"MaxX\" \"%d\"\n", max_x);
  fprintf(fp, "        Option \"MaxY\" \"%d\"\n", max_y);
  fprintf(fp, "        Option \"SwapX\" \"true\" # FIXME\n");
  fprintf(fp, "        Option \"SwapY\" \"true\" # FIXME\n");
  fprintf(fp, "        Option \"Calibrate\" \"0\"\n");
  fprintf(fp, "        Option \"ReportingMode\" \"Raw\"\n");
  fprintf(fp, "        Option \"Emulate3Buttons\" \"true\"\n");
  fprintf(fp, "        Option \"Emulate3Timeout\" \"50\"\n");
  fprintf(fp, "        Option \"SendCoreEvents\" \"On\"\n");
  fprintf(fp, "EndSection\n");
  if (fp != stderr) {
    fclose(fp);
  }
  printf("logs save to ./log\n");

  exit(EXIT_SUCCESS);
}

int main(int argc, char *argv[])
{
  struct input_event *input;
  int x, y;

  fd = open(DEVNAME, O_RDONLY);
  if (fd < 0) {
    fprintf(stderr, "%s open fail\n", DEVNAME);
    exit(EXIT_FAILURE);
  }

  if (ioctl(fd, EVIOCGRAB, (void *)1)) {
    fprintf(stderr, "unable to grab device\n");
  }

  signal(SIGINT, sig);

  puts("Press touch screen please");
  while (get_packet(fd)) {
    input = &rec;
#if 0
    printf("%ld.%ld, type %04x, code %04x, value %08x\n", input->time.tv_sec, input->time.tv_usec, input->type, input->code, input->value);
#endif
    if (input->type == EV_ABS && input->code == ABS_Z) {
      x = input->value;
      printf("cur(%d, ", x);
      if (x > max_x) {
    max_x = x;
      }
      if (x < min_x) {
    min_x = x;
      }
    }
    if (input->type == EV_ABS && input->code == ABS_RX) {
      y = input->value;
      printf("%d) ", y);
      if (y > max_y) {
    max_y = y;
      }
      if (y < min_y) {
    min_y = y;
      }
      printf(" min(%d, %d), max(%d, %d)\n", min_x, min_y, max_x, max_y);
    }
  }

  ioctl(fd, EVIOCGRAB, (void *)0);
  close(fd);
  exit(EXIT_SUCCESS);
}
$ cat README
$ lshal
udi = '/org/freedesktop/Hal/devices/usb_device_1ddb_1_noserial'
  info.linux.driver = 'usb'  (string)
  info.parent = '/org/freedesktop/Hal/devices/usb_device_8087_24_noserial'  (string)
  info.product = 'HID Touch Panel'  (string)
  info.subsystem = 'usb_device'  (string)
  info.udi = '/org/freedesktop/Hal/devices/usb_device_1ddb_1_noserial'  (string)
  info.vendor = 'HID TOUCH'  (string)
  linux.device_file = '/dev/bus/usb/001/003'  (string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'usb'  (string)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2'  (string)
  usb_device.bus_number = 1  (0x1)  (int)
  usb_device.can_wake_up = true  (bool)
  usb_device.configuration_value = 1  (0x1)  (int)
  usb_device.device_class = 0  (0x0)  (int)
  usb_device.device_protocol = 0  (0x0)  (int)
  usb_device.device_revision_bcd = 0  (0x0)  (int)
  usb_device.device_subclass = 0  (0x0)  (int)
  usb_device.is_self_powered = false  (bool)
  usb_device.linux.device_number = 3  (0x3)  (int)
  usb_device.linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2'  (string)
  usb_device.max_power = 100  (0x64)  (int)
  usb_device.num_configurations = 1  (0x1)  (int)
  usb_device.num_interfaces = 1  (0x1)  (int)
  usb_device.num_ports = 0  (0x0)  (int)
  usb_device.product = 'HID Touch Panel'  (string)
  usb_device.product_id = 1  (0x1)  (int)
  usb_device.speed = 12.0 (12) (double)
  usb_device.vendor = 'HID TOUCH'  (string)
  usb_device.vendor_id = 7643  (0x1ddb)  (int)
  usb_device.version = 1.1 (1.1) (double)
$
---
# apt-get install xfonts-wqy
$ xset fp rehash
$ xlsfonts | grep wenquanyi
---
/usr/bin/xinit ./calibrate -- /usr/bin/X ":1.1" -auth /dev/null
---
~/source/linux/linux-2.6.36/drivers/input/evdev.c
~/source/xf86-input-evtouch/xf86-input-evtouch-0.8.8/evtouch.c:790 ReadInput
~/source/linux-2.6.36/drivers/hid/hid-input.c
---
EV_MSC - MSC_SCAN - 0x090001 (HID_UP_BUTTON | )
EV_KEY - BTN_LEFT - 1 (press)
EV_ABS - ABS_Z - 0x04c1
EV_ABS - ABS_RX - 0x086b
EV_SYN - SYN_REPORT - 0
EV_ABS - ABS_Z - 0x04b4
EV_ABS - ABS_RX - 0x0867
EV_SYN - SYN_REPORT - 0
EV_MSC - MSC_SCAN - 0x090001 (HID_UP_BUTTON | )
EV_KEY - BTN_LEFT - 0 (release)
EV_SYN - SYN_REPORT - 0
$


TAG: 九点 校正

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)