From: "Tamási János" <janusz@uhulinux.hu>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Alex Custov <alex.custov@gmail.com>,
linux-kernel@vger.kernel.org, janusz@uhulinux.hu
Subject: Re: touchscreen wirh 2.6.26
Date: Wed, 09 Dec 2009 22:21:34 +0100 [thread overview]
Message-ID: <4B2014DE.4040605@uhulinux.hu> (raw)
In-Reply-To: <alpine.LSU.2.00.0911280025460.6953@wotan.suse.de>
[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]
Hi!
I wrote a small (and really ugly) uinput driver to this device. I hope
this helps somebody to write a proper driver for this touchscreen.
2009-11-28 00:30 keltezéssel, Jiri Kosina írta:
> On Fri, 27 Nov 2009, Alex Custov wrote:
>
>
>> Bus 004 Device 002: ID 0408:3000 Quanta Computer, Inc.
>> Device Descriptor:
>> bLength 18
>> bDescriptorType 1
>> bcdUSB 1.10
>> bDeviceClass 0 (Defined at Interface level)
>> bDeviceSubClass 0
>> bDeviceProtocol 0
>> bMaxPacketSize0 64
>> idVendor 0x0408 Quanta Computer, Inc.
>> idProduct 0x3000
>>
> Unfortunately, this touchscreen is not (yet) neither supported by
> usbtouchscreen kernel driver, nor is it apparently HID standard compliant,
> so HID driver can't do much with it as well.
>
> You will have to reverse-engineer the data protocol the touchscreen is
> sending. It's usually quite easy, in cases in which the device doesn't
> require complex initialization before it can become functional.
>
>
[-- Attachment #2: acer-t230H.c --]
[-- Type: text/plain, Size: 3602 bytes --]
// uinput.c
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
/*
* Globals
*/
static int uinp_fd = -1;
struct uinput_user_dev uinp; // uInput device structure
struct input_event event; // Input device structure
/*
* Setup the uinput device
*/
int setup_uinput_device() {
// Temporary variable
int i = 0;
// Open the input device
uinp_fd = open("/dev/input/uinput", O_WRONLY | O_NDELAY);
if (&uinp_fd == NULL) {
printf("Unable to open /dev/input/uinput\n");
return -1;
}
memset(&uinp, 0, sizeof(uinp)); // Intialize the uInput device to NULL
strncpy(uinp.name, "Acer T230H", UINPUT_MAX_NAME_SIZE);
uinp.id.version = 4;
uinp.id.bustype = BUS_USB;
uinp.absmax[ABS_X] = 1920+1440; // i have another monitor connected;
uinp.absmin[ABS_X] = 0;
uinp.absfuzz[ABS_X] = 3;
uinp.absmin[ABS_X] = 0;
uinp.absmax[ABS_Y] = 1080;
uinp.absmin[ABS_Y] = 0;
uinp.absfuzz[ABS_Y] = 3;
uinp.absmin[ABS_Y] = 0;
// Setup the uinput device
ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
ioctl(uinp_fd, UI_SET_EVBIT, EV_ABS);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_X);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_Y);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_LEFT);
/*
* Create input device into input sub-system
*/
write(uinp_fd, &uinp, sizeof(uinp));
if (ioctl(uinp_fd, UI_DEV_CREATE)) {
printf("Unable to create UINPUT device.\n");
return -1;
}
return 1;
}
void pukk() {
int fd;
unsigned int x,
y,
xx,
yy;
unsigned char buf[30];
fd = open("/dev/hidraw6", O_RDONLY);
while (1) {
read(fd, buf, sizeof(buf));
x = buf[4] + (unsigned int) buf[5] * 256;
y = buf[6] + (unsigned int) buf[7] * 256;
xx = buf[10] + (unsigned int) buf[11] * 256;
yy = buf[12] + (unsigned int) buf[13] * 256;
// set x & y
memset(&event, 0, sizeof(event));
gettimeofday(&event.time, NULL);
event.type = EV_ABS;
event.code = ABS_X;
event.value = x + 1440; // a have another monitor connected :)
write(uinp_fd, &event, sizeof(event));
event.type = EV_ABS;
event.code = ABS_Y;
event.value = y;
write(uinp_fd, &event, sizeof(event));
event.type = EV_SYN;
event.code = SYN_REPORT;
event.value = 0;
write(uinp_fd, &event, sizeof(event));
if (buf[2] == 7) { // BTN1 pressed
memset(&event, 0, sizeof(event));
gettimeofday(&event.time, NULL);
event.type = EV_KEY;
event.code = BTN_LEFT;
event.value = 1;
write(uinp_fd, &event, sizeof(event));
event.type = EV_SYN;
event.code = SYN_REPORT;
event.value = 0;
write(uinp_fd, &event, sizeof(event));
}
if (buf[2] == 4) { // BTN1 released
memset(&event, 0, sizeof(event));
gettimeofday(&event.time, NULL);
event.type = EV_KEY;
event.code = BTN_LEFT;
event.value = 0;
write(uinp_fd, &event, sizeof(event));
event.type = EV_SYN;
event.code = SYN_REPORT;
event.value = 0;
write(uinp_fd, &event, sizeof(event));
}
printf("\n%ux%u %ux%u [%u]\n", x, y, xx, yy, buf[2]);
}
close(fd);
}
int main() {
// Return an error if device not found.
if (setup_uinput_device() < 0) {
printf("Unable to find uinput device\n");
return -1;
}
pukk();
ioctl(uinp_fd, UI_DEV_DESTROY);
close(uinp_fd);
return 0;
}
prev parent reply other threads:[~2009-12-09 21:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 3:57 Alex Custov
2009-11-27 10:59 ` Jiri Kosina
2009-11-27 12:03 ` Alex Custov
2009-11-27 12:10 ` Jiri Kosina
2009-11-27 17:36 ` Alex Custov
2009-11-27 23:30 ` Jiri Kosina
2009-12-09 21:21 ` Tamási János [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B2014DE.4040605@uhulinux.hu \
--to=janusz@uhulinux.hu \
--cc=alex.custov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®