Need Help On Touchscreen dos driver

The intent of this forum is to discuss my DOS TSR programs (available at http://bretjohnson.us), how they work and don't work, new/missing features, status of updates, and anything else related to them that may need to be discussed.

Need Help On Touchscreen dos driver

Postby xceedsys » Mon May 06, 2013 5:08 pm

Hi,
I'm trying to use USBUHCI.COM and usbmouse.com for my egalax touch screen,
and found out from this forum that the mouse driver needs modification inorder
to work with touch screen. I have already have these info :

1. USBUHCI.COM is running see uhciRun.jpg
2. usb Device 0xeef is found
uhciRun.JPG
uhciRun.JPG (44 KiB) Viewed 63776 times

3. usbmouse.com says the device is bad
usbmouse.JPG
usbmouse.JPG (27.04 KiB) Viewed 63776 times

4. I already be able to read the touch screen data using a c program under dos and reading
from the usb returns 5 bytes of data, 1byte=touch, 2byte=X, 2byte=Y absolute location

from your usbmouse.a86, where can can I modify the codes and read these data, then send
to the mouse.sys /ctmouse.com driver ?

thanks
LIM
Attachments
usbDeviceFound.JPG
usbDeviceFound.JPG (43.82 KiB) Viewed 63776 times
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Tue May 07, 2013 4:29 am

After you've tried installing the drivers, do a:

Code: Select all
usbmouse /r > xceedsys.txt


and upload or attach the xceedsys.txt file that was created. There's something in the report descriptor that USBMOUSE doesn't like so it thinks your device isn't a "real" mouse.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Tue May 07, 2013 11:05 am

sir,
message return usbmouse /r was : There is no Descriptor Data to write

thanks
LIM
Attachments
r.JPG
r.JPG (39.25 KiB) Viewed 63769 times
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Tue May 07, 2013 11:14 am

Let's try this instead, then:

Code: Select all
USBUHCI /R 2 0 > xceedsys.txt
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Tue May 07, 2013 11:32 am

Device Address #2, Interface #0 does not exist or is not a Human Interface device
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Tue May 07, 2013 11:44 am

this is a output from a C program compiled using TurbC
code is taken from http://code.google.com/p/usb-driver-und ... vn%2Ftrunk

I was able to read the data when I touch and move on the screen.
Attachments
usbData.jpg
usbData.jpg (26.86 KiB) Viewed 63767 times
usbdeviceInfo.JPG
usbdeviceInfo.JPG (26.81 KiB) Viewed 63767 times
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Wed May 08, 2013 8:20 am

According to usbDeviceFound.JPG, there is an HID at address 2, interface 0. It looks like it's on host controller index 2 (can't tell for sure, though, since the top of the picture is cut off), so you'll probably need to add a /I:2 switch to the command-line.

BTW, it's much more efficient, in more ways than one, to redirect the output of DOS programs to a file (with a > on the command-line) instead of taking pictures of the screen with a camera.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Wed May 08, 2013 11:22 am

sorry, i was using a usb thumb drive to do the testing, so every time the usb driver starts, it cuts
off access to the drive and can not write to drive.
here is the data I got off from windows

Device Descriptor:
bcdUSB: 0x0110
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x08 (8)
idVendor: 0x0EEF
idProduct: 0x0001
bcdDevice: 0x0100
iManufacturer: 0x01
0x0409: "eGalax Inc."
iProduct: 0x02
0x0409: "Touch"
iSerialNumber: 0x00
bNumConfigurations: 0x01

ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: Low
Device Address: 0x01
Open Pipes: 1

Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0008 (8)
bInterval: 0x0A

Configuration Descriptor:
wTotalLength: 0x0022
bNumInterfaces: 0x01
bConfigurationValue: 0x01
iConfiguration: 0x04
0x0409: "HID-USB Touchscreen"
bmAttributes: 0xA0 (Bus Powered Remote Wakeup)
MaxPower: 0x16 (44 Ma)

Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x01
bInterfaceClass: 0x03 (HID)
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x00

HID Descriptor:
bcdHID: 0x0112
bCountryCode: 0x00
bNumDescriptors: 0x01
bDescriptorType: 0x22
wDescriptorLength: 0x008D

Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0008 (8)
bInterval: 0x0A
Attachments
win_info.JPG
win_info.JPG (47.44 KiB) Viewed 63748 times
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Wed May 08, 2013 11:40 am

Unfortunately, that's not the information I need. Those are the "general" descriptors that all devices have, whether they are HID or not. I need to see the HID report descriptor, which I don't think you can get from Windows.

Can you write to another disk (a floppy or RAM disk or a different USB drive or another partition on the hard drive or ...)? Screen picture(s) could also work, but would be more of a hassle to create a set of test data from.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Wed May 08, 2013 9:41 pm

attached is the data log in zip which I execute
- usbuhci /I:2 /Host
- usbuhci /I:2 /Descr :2
- usbuhci /I:2 /AD
- usbuhci /I:2 /TD

hope that is correct, else please show me the correct command.

regards
LIM
Attachments
DATA.zip
(2.5 KiB) Downloaded 4280 times
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Thu May 09, 2013 4:22 am

Much closer now, but still not quite there. Try this:

Code: Select all
usbuhci /i:2 /r:2 0
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Thu May 09, 2013 4:37 am

Hi Bret

please see attached

thanks
Attachments
I2R20.zip
(990 Bytes) Downloaded 2579 times
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Thu May 09, 2013 7:41 am

I'll take a look over the weekend and see what I can figure out.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby Bret » Fri May 10, 2013 10:46 am

I had a little bit of time today to look this over, and I have some questions.

In your C program output (usbData.jpg), is the first byte received ever a 1 instead of a 2?

Also, in the C program output, how are you calculating the X and Y values? They don't match the data coming from the USB device. Also, what are the t and r supposed to mean?
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Fri May 10, 2013 3:30 pm

Hi Bret,

the Calculation for x,y is wrong, but t=touch, r= result from reading usb, 0=scucess, below is the c code.

I got the maunal from http://www.disign-store.com/file/manual ... uide02.pdf

When the touch screen is touched it will read the following
02 03 27 07 10 07 00 00
when release
02 02 27 07 10 07 00 00
when not touched
00 00 00 00 00 00 00 00

1st byte is always 02 when touch and release, 00 when no touch
2nd byte 03 when touch 02 when release
3/4 byte x location
5/6 byte y location


void HID()
{
BYTE data[512];
WORD length=0;
cleanBuffer(data, 512);
BYTE Res=0;
if (pDIfound==0) ////hid not found
{
return;
}
BYTE (*pInt)(DeviceInfoPtr , BYTE , BYTE * ,WORD ,WORD * )= \
pDIfound->pHCStrucPtr->pHCDPointer->interruptTransfer;

Res=(*pInt)(pDIfound,0x80,data,8,&length);
dump(data, 8); //// show 8 byte data

if (data[0]>0)
{
// cal here is wrong
// touch_x = 2047-(data[3] *0xff) +(data[2]);
// touch_y = ((data[5] *0xff) +data[4]);

}

touch_t = data[1] & 0x01;
printf("x=%d, y=%d, t=%d, r=%d\n",touch_x,touch_y,touch_t,Res);


return;
}
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Sun May 12, 2013 3:15 pm

If you want other USB and PS/2 mice to work at the same time as the touch screen, you'll need to change DecipherReportDescr so that it recognizes your touch screen device correctly. Right now, it only looks for and recognizes devices that call themselves mice.

If you don't care about other devices, you can change LookForNewDevice so that it only looks for your specific Vendor and Product ID. If you do that, you won't even need to download any of the descriptors, since you'll already "know" everything you need to know (end point numbers, data formats and sizes, etc.).

You'll also need to change how the data gets sent to CTMOUSE. Regular mice use serial data streams, and report relative movement changes. Touch screens report absolute location, not relative movement. Instead of reporting the mouse movement data to CTMOUSE through an IRQ process, it is probably best to report it though INT 33.0004. You can use INT 33.0026 to determine the current screen size (needed to scale things appropriately). You will still need to report the button presses and releases through the IRQ process, though.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Sun May 12, 2013 3:25 pm

Hi Bret,
thanks for the info,
I'll try to modify the program, the setup does not require any ps/2 mouse, or keyboard
only touch screen. So I can take out ctmouse.
In your usbmouse.a26 program, where is the part that does the reading of the 8 byte data from the usb ?
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Sun May 12, 2013 7:06 pm

You actually still need CTMOUSE -- it's what responds to the INT 33h calls. In fact, you need to make sure it's installed before issuing INT 33h, or you could crash.

DeviceChangeCode is what is called by the USB IRQ handler immediately after the USB hardware has downloaded and stored the data in the buffer. This in turn calls DeviceChangeMouse, which processes and combines and formats the data and informs CTMOUSE of the status. Note that this code is all processed inside an IRQ handler, so it's important not to "mess around" too long, or do anything that could create a reentrancy problem. I'm assuming that CTMOUSE is reentrant, at least for the INT 33.0004 and INT 33.0026 calls -- if not, you'll need to figure out another way to inform CTMOUSE of the touch location.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Mon May 13, 2013 2:02 am

Hi Bret,
Finally I can get the touchscreen recognized,
DeviceChangeCode is firing constantly,
when I place my finger on the screen, data is displayed
so how can I put the absolute reading into ctmouse ?
Attachments
touched.JPG
touched.JPG (45.33 KiB) Viewed 63674 times
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Mon May 13, 2013 3:57 am

Use INT 33.0026 to determine the current screen resolution (at least what CTMOUSE thinks the current resolution is), and then INT 33.0004 to tell CTMOUSE where to put the mouse cursor.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby xceedsys » Mon May 13, 2013 4:52 am

thanks,
my asm is very bad, may take a few days, I'll try
xceedsys
 
Posts: 11
Joined: Mon May 06, 2013 4:23 pm

Re: Need Help On Touchscreen dos driver

Postby Bret » Mon May 13, 2013 5:37 am

OK. A couple of things you may want to keep in mind, though.

Based on the screen display, it looks like you're not compensating for the Report ID. For your device, there are two possible Report ID's (1 & 2, study the I2R20 output). If a device uses Report ID's (some do and some don't), the first byte of data returned is the Report ID, not the actual data from the device. USBMOUSE adjusts for this automatically, and changes the offset of the data buffer by one byte based on whether or not there is a Report ID. It looks like you're bypassing this part of the code in USBMOUSE when you shouldn't be.

You say you've never seen a 1 returned in the first byte of the data (Report ID 1), but you shouldn't ignore the possibility that it could happen, and should essentially ignore the returned data if it does happen. That's part of what DeviceChangeCode does -- it will only call DeviceChangeMouse if the data has the correct Report ID. I'm still not sure what the purpose of Report ID 1 is, but think it may actually contain some calibration data in the logical limits (e.g., the bottom left corner of the screen is not actually 0,0). If it is some sort of calibration data, you may want to use it as your limits instead of 0,2047.

Also, you may not need to poll the device 100 times a second, but may only need to do it a few times a second (I imagine 10 times a second or so would be more than enough). You shouldn't need the same kind of response times from a touch screen than you do from a mouse, and it's better not to waste resources when you don't actually need to.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby Pierre-Marie Baty » Thu Nov 17, 2016 11:46 am

Hello

Sorry for bumping this 3 years old thread. I have the same eGalax Touch screen and I'm struggling to achieve the same goal.

First all, thank you Bret for this excellent, extensive work on USB drivers for DOS. The documentation is impressive (I dare to say intimidating).

If xceedsys reads this post (I hope he gets notified when someone replies to this topic) I'd really appreciate his help.

I'm an experienced C coder but I know very little in assembly and low level programming for DOS. I know the protocol of those eGalax touch screens (http://www.eeti.com/pdf/Software%20Prog ... e_v2.0.pdf), what I don't know is the USB protocol. So far what I've done is, I've taken the C source code of "usbdevic.cpp" and started modifying it. I can enumerate the hosts and devices until it finds my touch screen, and I successfully registered myself as the interface owner for it. But I have several problems now.

- Starting from here, I don't know what to do next. I'd like to send and receive data packets to the device, but I haven't found any concise howto do that in the documentation. Please don't advise me to read the 600 pages of the USB specifications...

- Are there constraints to obey when programming in C ? I have two compilers at hand, either Borland Turbo C++ 3.0 (TCC) or Microsoft C/C++ Optimizing Compiler 7.00 (CL). The latter one requires 386MAX to simply run (but the binary format I target doesn't require an extender. It produces 16-bit code).

- I can't seem to be able to use the callbacks feature of the driver (tested with the interface registration). Each time my callback is supposed to be called (for example, if I unplug the cord) the computer freezes and a reboot is required. My callback is defined as "void interrupt USBNotification (void)". I pass it as such :

// prepare request structure
usb_request.I14RRequestType = I14RRTRegIntfOwner;
usb_request.I14RHostIndex = host_index;
usb_request.I14RDeviceAddress = device_address;
usb_request.I14RInterfaceNum = device_interface;
usb_request.I14RCallBackAddrSeg = FP_SEG (callback_address);
usb_request.I14RCallBackAddrOff = FP_OFF (callback_address);
usb_request.I14RUserPktID = callback_arg;

usb_request being a global instance of the int14h structure that I reuse across calls, and callback_address being a void * pointer that points to USBNotification. What am I doing incorrectly ?

Obviously, I'd love if xceedsys accepted to share his driver code with me - that would save me days ;), but any sort of helpful feedback will be appreciated. An answer to my first question would be a great relief already.
Pierre-Marie Baty
 
Posts: 6
Joined: Thu Nov 17, 2016 11:05 am

Re: Need Help On Touchscreen dos driver

Postby Bret » Fri Nov 18, 2016 5:33 am

Hi, Pierre.

Glad you contacted me through the forum.

Just as an FYI, I now have a Lenovo touch-screen and have been experimenting with it some. I am adding support for "generic" touch-screen devices to USBMOUSE. I still have lots of work to do on the USB drivers before the next release, and have very limited spare time to work on it. It's still a long time away before anything new comes out from me, I'm afraid. Even when USBMOUSE comes out, though, it still may not work out-of-the-box with your particular touch-screen -- it depends on how "generic" it really is.

Regarding your specific questions for now, though, I think you did the correct thing by starting with USBDEVIC.CPP and modifying it. Since you're able to register as the interface owner, it means you're communicating with the USB subsystem appropriately., so you're already a good portion of the way there. I don't know if your application actually requires a TSR or not, but if so I probably can't provide much beneficial advice. I've never written a TSR in anything other than ASM.

I think I see two questions you're asking. The first is how to "talk" to your particular device. Unfortunately, the documentation you linked to doesn't help all that much. You actually need to know where to send the packets to/from. Specifically, you need to know the End Point number and/or the Control Packet (Setup) Header information that needs to be used to send data to the device. A control packet would get sent to End Point 0, but has to have special "codes" in the 8-byte Control Setup Packet (SRRequestType, SRRequest, SRValue, SRIndex, & SRLength), and the documentation you provided doesn't give any details about what those 8 bytes should look like. There could also be an OUT endpoint for the touch-screen that lets you send packets of data directly to it that doesn't use the Control mechanism. If so, your device would probably have Bulk Out End Point defined, though it could also be an Interrupt Out End Point. If there is no Out End Point defined, then you would have to somehow issue commands to the Device with Control packets.

A normal mouse doesn't have any special commands that get sent to it. Everything the driver needs to know about the device (the precise format of the data that the mouse sends) is defined in the "generic" USB descriptors, and all that the driver needs to do is periodically poll the mouse for that data. Since your touch-screen isn't "generic" (there are specific/custom commands that can/must be sent to it), you need to know which "path" to send those commands to and which "path" to use to receive the responses. Based on what the document says, it emulates a Microsoft device of some sort, so you may need to look there.

Your second question is how to get C to respond to a call-back. Again, I'm not very good with C, but it looks like you have it setup as an Interrupt call, when it should be a Far Call. An interrupt call pushes three items on the stack (Flags, Segment, Offset), a Far Call pushes two (Segment & Offset), and a Near Call only pushes one (Offset).
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Re: Need Help On Touchscreen dos driver

Postby Pierre-Marie Baty » Sat Nov 19, 2016 5:27 am

Thanks Bret for your informative reply. I put "interrupt" in the callback prototype because I thought it made sense, since the callback would be called from an interrupt handler. But I was wrong, the callback is not the interrupt handler itself, so there's no point in declaring it as such, and your reply makes perfect sense.

About how to set up the device and communicate with it, I found the Linux kernel driver source code for this screen, here : http://lxr.free-electrons.com/source/dr ... chscreen.c

Unfortunately I'm no more experienced with the Linux kernel (I'm more a BSD guy) than with DOS. Do you see any interesting information in it that could tell me how to craft that special setup packet and how/where to send it ?

The eGalax touch screen controller is widely used on low-cost chinese touch screens. It handles USB and RS232. Unfortunately the binary DOS driver they provide for it fails miserably to detect anything and there's no way to get any support from them regarding it (I tried, they were clueless all our exchange long and at some point they simply stopped replying. I tried to buy their source code from them but no reply either). The screen works out of the box on Linux and Windows though. Promised, if I manage to come out with a working DOS driver for this touch screen in C I'll make it open source and post a link to it here.

*edit*: corrected the link. What I found in the first place was the I2C version of the Linux driver. Here's the USB version.

*edit 2* Let me start another post instead of cluttering this one
Pierre-Marie Baty
 
Posts: 6
Joined: Thu Nov 17, 2016 11:05 am

Next

Return to Programs

Who is online

Users browsing this forum: No registered users and 4 guests

cron