IR Touch screen

Anything related to hardware, devices, drivers and how to use them with Ultibo.
User avatar
Rassamaha78
Posts: 44
Joined: Wed Dec 20, 2017 1:09 am
Location: Russia

IR Touch screen

Postby Rassamaha78 » Fri Jun 01, 2018 7:25 pm

I have Infrared touch screen panel with USB interface.

ir-touch-screen-panel_resize.jpg
ir-touch-screen-panel_resize.jpg (52.02 KiB) Viewed 365 times


it works fine with PC( Windows ) and Raspberry Pi 3 ( Raspbian stretch ) without any additional drivers. The panel is defined in devices as a standard HID Mouse device, but when I use the example "15-MouseCursor" the panel does not work like a mouse, just nothing happens.

How can I get it to work with Ultibo ?
User avatar
Ultibo
Site Admin
Posts: 1895
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: IR Touch screen

Postby Ultibo » Sun Jun 03, 2018 12:31 am

Rassamaha78 wrote:How can I get it to work with Ultibo ?

The most likely reason why it doesn't work is because the Ultibo USB mouse driver currently only supports the HID boot protocol and not the HID report protocol.

If it is a HID mouse class device then it should be relatively easy to get working by creating your own modified version of the USB mouse driver which recognizes it and understands the report format it uses.

We'd also like to make it possible for the standard driver to support devices like this (ones that use a common report format) so if you can provide some information about the device we can help you get it working and that will also help us to improve the Ultibo driver.

First thing is to obtain a decode of the USB descriptors for the device, the easiest way to do this is using lsusb in Linux, if you type lsusb by itself it will give you a list of USB devices. Then you can use lsusb -v -d xxxx:xxxx (where xxxx:xxxx is the device and vendor ID of the device as shown in the list) to obtain a decode of the USB descriptors, this will tell us a lot of the details of the device and what it is reporting as.

The next thing to get is a copy of the HID report descriptor for the device, you can do this using Ultibo (you could probably do it in Linux as well) by sending a control request to the device and asking for the USB_HID_DESCRIPTOR_TYPE_REPORT. Let us know if you can't work out how to do that and well provide a simple function for it.

Once we have the report descriptor then we can compare it against other mice and see if it could be supported by the standard driver, we can also tell you how make your own modified driver and read the reports the device sends.
Ultibo.org | Make something amazing
https://ultibo.org
User avatar
Rassamaha78
Posts: 44
Joined: Wed Dec 20, 2017 1:09 am
Location: Russia

Re: IR Touch screen

Postby Rassamaha78 » Sun Jun 03, 2018 6:06 am

This is listing for lsusb -v -d :

Code: Select all

pi@raspberrypi:~ $ lsusb -v -d aaec:0922

Bus 001 Device 006: ID aaec:0922 
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0xaaec
  idProduct          0x0922
  bcdDevice            2.00
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           66
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     490
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      65
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              10


How can I get USB_HID_DESCRIPTOR_TYPE_REPORT for you ?
I can give you remote access to my Raspberry P by SSH or VNC, if that's more convenient.
pik33
Posts: 704
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: IR Touch screen

Postby pik33 » Sun Jun 03, 2018 7:12 am

the Ultibo USB mouse driver currently only supports the HID boot protocol and not the HID report protocol.


You can try if the screen "mouse" can work here: https://github.com/pik33/ultibo_retro_gui
This program switches the mouse driver to HID report protocol.
User avatar
Rassamaha78
Posts: 44
Joined: Wed Dec 20, 2017 1:09 am
Location: Russia

Re: IR Touch screen

Postby Rassamaha78 » Sun Jun 03, 2018 7:56 am

I try run your project. Copy this files to SDCard:

    Colors (folder)
    kernel7.img
    libdrflac.a
    libFLAC.a
    libm.a
    libmad.a
    libxmp-lite.a

and get this screen:
DSC09639_resize.JPG
DSC09639_resize.JPG (46.9 KiB) Viewed 319 times

My config.txt is:

Code: Select all

max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 1280 720 60 6 0 0 0
hdmi_drive=1
gpu_mem=128
pik33
Posts: 704
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: IR Touch screen

Postby pik33 » Sun Jun 03, 2018 9:01 am

(1) There was a bug which caused (at the 1280x720 resolution which was never tested before) unnecessary doubling the framebuffer size to 2560x1440. Fixed. Committed. Get a new kernel7.img.
(2) The program will not run when gpu_mem=128. Set gpu_mem=64
User avatar
Ultibo
Site Admin
Posts: 1895
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: IR Touch screen

Postby Ultibo » Mon Jun 04, 2018 2:11 am

Thanks for the information from lsusb, from that I can see that the device also reports a keyboard. The keyboard is a USB HID boot device so it should be working already but the touch screen does not have boot protocol support so it won't work without a modified driver.

Rassamaha78 wrote:How can I get USB_HID_DESCRIPTOR_TYPE_REPORT for you ?

I've created a simple Ultibo program to extract the HID report descriptors from all HID devices attached to the Pi, if you copy this into a new project, compile and run it on the Pi it should create a file for each HID interface on each device.

If you zip the ones for the touch screen device and attached them to this post we can take a look at what it reports.

Code: Select all

program HIDDescriptor;

{$mode delphi}
{$H+}

uses
  RaspberryPi2,
  GlobalConst,
  GlobalTypes,
  Platform,
  Threads,
  Console,
  Framebuffer,
  SysUtils,
  Classes,
  USB,
  Mouse,
   
  HTTP,
  WebStatus,
 
  RemoteShell,
  ShellFilesystem,
  ShellUpdate;

var
 WindowHandle:TWindowHandle;
 HTTPListener:THTTPListener;

type
 THIDDeviceDescriptor = packed record
  bLength:Byte;
  bDescriptorType:Byte;
  bcdHID:Word;
  bCountryCode:Byte;
  bNumDescriptors:Byte;
  bHIDDescriptorType:Byte;
  wHIDDescriptorLength:Word;
  {Note: Up to two optional bHIDDescriptorType/wHIDDescriptorLength pairs after the Report descriptor details}
 end;
 
function HIDDeviceGetDescriptor(Device:PUSBDevice;Data:Pointer):LongWord;
var
 Count:Integer;
 Filename:String;
 USBInterface:PUSBInterface;
 MemoryStream:TMemoryStream;
 HIDDeviceDescriptor:THIDDeviceDescriptor;
begin
 {}
 Result:=ERROR_SUCCESS;
 
 {Check Device}
 if Device = nil then Exit;
 if Device.Descriptor = nil then Exit;
 if Device.Configuration = nil then Exit;
 
 {Check Device Class}
 if Device.Descriptor.bDeviceClass <> USB_CLASS_CODE_INTERFACE_SPECIFIC then Exit;
 
 {Find Interfaces}
 for Count:=0 to Device.Configuration.Descriptor.bNumInterfaces - 1 do
  begin
   USBInterface:=USBDeviceFindInterfaceByIndex(Device,Count);
   if USBInterface <> nil then
    begin
     ConsoleWindowWriteLn(WindowHandle,'Checking Interface ' + IntToStr(USBInterface.Descriptor.bInterfaceNumber) + ' for device ' + IntToHex(Device.Descriptor.idVendor,4) + ':' + IntToHex(Device.Descriptor.idProduct,4) + ' (' + Device.Product + ')');
     
     if USBInterface.Descriptor.bInterfaceClass = USB_CLASS_CODE_HID then
      begin
       ConsoleWindowWriteLn(WindowHandle,'Getting report descriptor for HID device ' + IntToHex(Device.Descriptor.idVendor,4) + ':' + IntToHex(Device.Descriptor.idProduct,4) + ' (' + Device.Product + ')');   
       
       {Get the HID descriptor}
       if USBControlRequest(Device,nil,USB_DEVICE_REQUEST_GET_DESCRIPTOR,USB_BMREQUESTTYPE_DIR_IN or USB_BMREQUESTTYPE_TYPE_STANDARD or USB_BMREQUESTTYPE_RECIPIENT_INTERFACE,(USB_HID_DESCRIPTOR_TYPE_HID shl 8),USBInterface.Descriptor.bInterfaceNumber,@HIDDeviceDescriptor,SizeOf(THIDDeviceDescriptor)) = ERROR_SUCCESS then
        begin
         ConsoleWindowWriteLn(WindowHandle,' HID Descriptor bLength = ' + IntToStr(HIDDeviceDescriptor.bLength));
         ConsoleWindowWriteLn(WindowHandle,'                bDescriptorType = ' + IntToStr(HIDDeviceDescriptor.bDescriptorType));
         ConsoleWindowWriteLn(WindowHandle,'                bcdHID = ' + USBBCDVersionToString(HIDDeviceDescriptor.bcdHID));
         ConsoleWindowWriteLn(WindowHandle,'                bCountryCode = ' + IntToStr(HIDDeviceDescriptor.bCountryCode));
         ConsoleWindowWriteLn(WindowHandle,'                bNumDescriptors = ' + IntToStr(HIDDeviceDescriptor.bNumDescriptors));
         ConsoleWindowWriteLn(WindowHandle,'                bHIDDescriptorType = ' + IntToStr(HIDDeviceDescriptor.bHIDDescriptorType));
         ConsoleWindowWriteLn(WindowHandle,'                wHIDDescriptorLength = ' + IntToStr(HIDDeviceDescriptor.wHIDDescriptorLength));
         
         {Get the Report descriptor}
         MemoryStream:=TMemoryStream.Create;
         try
          MemoryStream.Size:=HIDDeviceDescriptor.wHIDDescriptorLength;
         
          if USBControlRequest(Device,nil,USB_DEVICE_REQUEST_GET_DESCRIPTOR,USB_BMREQUESTTYPE_DIR_IN or USB_BMREQUESTTYPE_TYPE_STANDARD or USB_BMREQUESTTYPE_RECIPIENT_INTERFACE,(USB_HID_DESCRIPTOR_TYPE_REPORT shl 8),USBInterface.Descriptor.bInterfaceNumber,MemoryStream.Memory,MemoryStream.Size) = ERROR_SUCCESS then
           begin
            Filename:='HID_Report_' + IntToHex(Device.Descriptor.idVendor,4) + '_' + IntToHex(Device.Descriptor.idProduct,4) + '_' + IntToStr(USBInterface.Descriptor.bInterfaceNumber) + '.dat';
            ConsoleWindowWriteLn(WindowHandle,' Saving ' + IntToStr(HIDDeviceDescriptor.wHIDDescriptorLength) + ' byte HID report descriptor to file ' + Filename);
           
            if FileExists(Filename) then
             begin
              DeleteFile(Filename);
             end;
           
            MemoryStream.SaveToFile(Filename);
           end;
         finally
          MemoryStream.Free;
         end;
        end;
       
       ConsoleWindowWriteLn(WindowHandle,'');
      end;
    end;
  end;
end;

begin
 HTTPListener:=THTTPListener.Create;
 HTTPListener.Active:=True;
 WebStatusRegister(HTTPListener,'','',True);

 {Create a console window at full size}
 WindowHandle:=ConsoleWindowCreate(ConsoleDeviceGetDefault,CONSOLE_POSITION_FULL,True);

 {Output some welcome text on the console window}
 ConsoleWindowWriteLn(WindowHandle,'HID Descriptor Extraction');

 {Wait a few seconds for everything to be ready}
 Sleep(3000);
 
 {Call USB Enumerate Devices}
 ConsoleWindowWriteLn(WindowHandle,'Enumerating Devices');
 USBDeviceEnumerate(HIDDeviceGetDescriptor,nil);
 
 {Halt the thread}
 ThreadHalt(0);
end.

Note this is for a Pi 2B but will also work on a Pi 3B or Pi 3B+, you can also modify it easily by changing the uses clause at the top.
Ultibo.org | Make something amazing
https://ultibo.org
User avatar
Rassamaha78
Posts: 44
Joined: Wed Dec 20, 2017 1:09 am
Location: Russia

Re: IR Touch screen

Postby Rassamaha78 » Mon Jun 04, 2018 8:51 am

I run your code on my Raspberry Pi 3, i noticed that if only the infrared panel is connected, then the program does not produce any results. After that, I connected the USB Keyboard + Infrared Panel, the result in the picture:

DSC09640_resize.JPG
DSC09640_resize.JPG (219.52 KiB) Viewed 281 times


I also received 3 HID_Report files, I added them to attachments.

HID_Reports.zip
(655 Bytes) Downloaded 5 times


HID_Report_AAEC_0922_0.dat - this is panel data file.

I would also like to add that the panel size is 32" and it supports 2 simultaneous touches.
I hope all this information will help in the development of the driver for this panel.

If you need any more information, I'm ready to participate.
User avatar
Ultibo
Site Admin
Posts: 1895
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: IR Touch screen

Postby Ultibo » Mon Jun 04, 2018 11:06 am

Rassamaha78 wrote:HID_Report_AAEC_0922_0.dat - this is panel data file.

Thanks for that, give us a couple of days to look at the information and we'll work out the quickest way for you to get this working.
Ultibo.org | Make something amazing
https://ultibo.org
User avatar
Ultibo
Site Admin
Posts: 1895
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: IR Touch screen

Postby Ultibo » Thu Jun 07, 2018 11:05 am

Rassamaha78 wrote:I would also like to add that the panel size is 32" and it supports 2 simultaneous touches.
I hope all this information will help in the development of the driver for this panel.

Just a quick question, from the HID descriptors your device seems to support operating either as a multi point touch device or as a simple mouse device.

For your purpose is the simple mouse mode useful for getting started with?

The multi point touch should also be able to be implemented (Ultibo has a touch API that supports multiple points) but the mouse mode is easier to explain as a starting point.
Ultibo.org | Make something amazing
https://ultibo.org

Return to “General”

Who is online

Users browsing this forum: No registered users and 0 guests