###############################################################################
###       An XFree86 Input Driver To Read /dev/input/event* Devices         ###
###############################################################################

The official home page for this driver is:  http://opensource.idealcorp.com/

REQUIREMENTS

To use this driver, you must meet the following requirements:

  o You must run a 2.6 kernel
  o You must have the evdev module compiled in or loaded as a module
  o You must have enough /dev/input/event* device nodes to cover
    all the potential event generating devices

    # mknod /dev/input/event0 c 13 64
    # mknod /dev/input/event1 c 13 65
    # mknod /dev/input/event2 c 13 66
    # mknod /dev/input/event3 c 13 67
    # mknod /dev/input/event4 c 13 68
    # mknod /dev/input/event5 c 13 69

SHORT INSTALL INSTRUCTIONS

Start here if you are running Debian:

  1) Download the Debian package or build the package from source.
     To build from source, run 'dpkg-buildpackage -rfakeroot' or as root just
     run 'dpkg-buildpackage'

  2) Install the package and go to step 3 below.

Start here if you are not running Debian:

  1) Run 'make ; make install'

  2) Copy the findevdev to /etc/init.d/ and add it to your startup scripts.
     NOTE: Make certain it runs after the usb drivers are initialized.

  3) Modify the XF86Config-4 file to include an InputDevice section:

     Section "InputDevice"
	     Identifier   "Gunze Touchscreen"
	     Driver       "evdev"
	     Option       "SendCoreEvents"        "true"
	     Option       "Device"                "/dev/gunze"
	     Option       "MinX"                  "60"
	     Option       "MaxX"                  "960"
	     Option       "MinY"                  "70"
	     Option       "MaxY"                  "960"
     EndSection

     You will also have to make reference to the InputDevice in the ServerLayout
     section:

     Section "ServerLayout"
	     Identifier   "Default Layout"
	     Screen       "Default Screen"
	     InputDevice  "Generic Keyboard"
	     InputDevice  "Gunze Touchscreen"
	     InputDevice  "PSAUX Mouse"
	     InputDevice  "USB Mouse"
     EndSection

  4) Restart (or start) X. Touch your screen.
     NOTE: After you get the driver installed, you may have to adjust the MinX/Y
     and MaxX/Y values to adjust the calibration of your particular device.

BACKGROUND DRIVER NOTES

Certain USB HID devices can provide input to the /dev/input/event* stream
devices, even if they do not have a specific driver in the kernel. For
example, the Gunze AHL-61/62 Touchscreen controller is registered as a USB /
HID device and can generate raw input data without any specific driver based
only on the generic class driver. What is even better, is that it operates
by default in the 'absolute positioning' mode and delivers basic coordinate
and button events to the event stream device. I was unable to find a generic
event stream device driver for XFree86 so I researched and wrote this one.

The data from the /dev/input/event device is provided in this format:

+---------+--------------+-------+-------+-------+
| Seconds | Microseconds | Type  | Code  | Value |
+---------+--------------+-------+-------+-------+
| Int     | Int          | Short | Short | Int   |
+---------+--------------+-------+-------+-------+

The types can be one of the following:

+-------------------------+--------------+-------+
| Event Type Description  | Const        | Value |
+-------------------------+--------------+-------+
| Sync                    | EV_SYN       | 0x00  |
| Keypress                | EV_KEY       | 0x01  |
| Relative Position       | EV_REL       | 0x02  |
| Absolute Position       | EV_ABS       | 0x03  |
| Misc                    | EV_MSC       | 0x04  |
| LED Indicator           | EV_LED       | 0x11  |
| Sound                   | EV_SND       | 0x12  |
| Repeat                  | EV_REP       | 0x14  |
| Force Feedback          | EV_FF        | 0x15  |
| Power                   | EV_PWR       | 0x16  |
| Force Feedback Status   | EV_FF_STATUS | 0x17  |
| Upper limit placeholder | EV_MAX       | 0x1f  |
+-------------------------+--------------+-------+

The only events/codes/values that the current version of the evdev driver
passes to the X server are:

+------+------+-------+
| Type | Code | Value |
+------+------+-------+
|    3 |    0 |     * | = Mouse X absolute coordinate
+------+------+-------+
|    3 |    1 |     * | = Mouse Y absolute coordinate
+------+------+-------+
|    1 |  272 |     1 | = Left mouse button down
+------+------+-------+
|    1 |  272 |     0 | = Left mouse button up
+------+------+-------+

Other events can be trapped and reported to X in the ReadInput function of the
driver.

TROUBLESHOOTING

Use the evtest program to determine that your device is emitting packets when
you touch it:

  # evtest /dev/input/event2
    Input driver version is 1.0.0
    Input device ID: bus 0x11 vendor 0x2 product 0x1 version 0x0
    Input device name: "PS/2 Generic Mouse"
    Supported events:
      Event type 0 (SYN)
      Event type 1 (KEY)
        Event code 272 (LEFT)
        Event code 273 (RIGHT)
        Event code 274 (MIDDLE)
      Event type 2 (REL)
        Event code 0 (X)
        Event code 1 (Y)
    Testing ... (interrupt to exit)
    Event: time 1109627406.644838, type 1 (KEY), code 272 (LEFT), value 1
    Event: time 1109627406.644844, type 0 (SYN), code 0 (SYN), value 0
    Event: time 1109627406.644844, -------------- Report Sync ------------
    Event: time 1109627406.743881, type 1 (KEY), code 272 (LEFT), value 0
    Event: time 1109627406.743887, type 0 (SYN), code 0 (SYN), value 0
    Event: time 1109627406.743887, -------------- Report Sync ------------
    Event: time 1109627406.965388, type 1 (KEY), code 272 (LEFT), value 1
    Event: time 1109627406.965393, type 0 (SYN), code 0 (SYN), value 0
    Event: time 1109627406.965393, -------------- Report Sync ------------
    Event: time 1109627407.063477, type 1 (KEY), code 272 (LEFT), value 0
    Event: time 1109627407.063483, type 0 (SYN), code 0 (SYN), value 0
    Event: time 1109627407.063483, -------------- Report Sync ------------

You hit CTRL-C to exit the evtest program. The evstatus program can be used to
provide information about a particular device:

  # evstatus /dev/input/event3
    Input driver version is 1.0.0
    Input device ID: bus 0x3 vendor 0x46d product 0xc016 version 0x340
    Input device name: "Logitech Optical USB Mouse"
    Supported events:
      Event type 0 (SYN)
      Event type 1 (KEY)
        Event code 272 (LEFT)
        Event code 273 (RIGHT)
        Event code 274 (MIDDLE)
      Event type 2 (REL)
        Event code 0 (X)
        Event code 1 (Y)
        Event code 8 (WHEEL)
      Event type 3 (ABS)
        Event code 40 (MISC)
          Value      0
          Min        0
          Max        1

###############################################################################
###       An XFree86 Input Driver To Read /dev/input/event* Devices         ###
###############################################################################
