Using GetRawInputDeviceList lazarus / 34-Windows ---------------------------------------------------------------------- dmudie · 2016-11-07 18:48 Good Afternoon, I would like to use an transcriber's foot pedal (Infinity Brand) with an application I am writing.  What I have been able to find through research is that this device can be read as a Human Interface Device using RegisterRawInputDevices and GetRawInputData.  In order to get started, I am trying to get a list of devices on the Windows machine using GetRawInputDeviceList.  Unfortunately, I'm not getting it working - either when trying to return the number of devices (does not update the value), or when trying to populate an array of RAWINPUTDEVICELIST.  Since I could not get a valid value when trying to get the device count, I hard coded 20 devices just to try and get some values into the array.  I was a C programmer years ago... then did a lot of Delphi work.  It's been 14 or so years since I've done any work in object pascal.   With that in mind, I think the problem may have to do with pointers.  I believe that I don't have to use a pointer explicitly for iNumDevices because the function declaration looks after it with the 'var' modifier.  Please correct me if I'm wrong.  The code is very simple because I'm simply trying to test one function. Thank you, David Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  unit uMain; {$mode delphi}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, jwawinuser; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Memo1: TMemo;    procedure Button1Click(Sender: TObject);  private    { private declarations }   public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var      iNumDevices: LongWord;       DeviceList : array [0..19] of RAWINPUTDEVICELIST;     DeviceCounter:integer;begin  // get the number of devices and display them  iNumDevices := GetRawInputDeviceList(DeviceList,iNumDevices,sizeof(DeviceList));  ShowMessage(IntToStr(iNumDevices));   // doesn't work, so I hard coded it to 20 for now  iNumDevices := 20;  iNumDevices := GetRawInputDeviceList(DeviceList,iNumDevices,sizeof(DeviceList));  ShowMessage(IntToStr(iNumDevices));   // the contents of the array is meaningless  for DeviceCounter := 0 to 19 do     begin       Memo1.Lines.Add('Device:'+IntToStr(DeviceCounter));       Memo1.Lines.Add(IntToStr(DeviceList[DeviceCounter].dwType));       Memo1.Lines.Add(' ');     end;end; end. ---------------------------------------------------------------------- molly · 2016-11-07 19:33 Example in Free Pascal, inspired on the msdn example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program test; {$MODE OBJFPC}{$H+} uses  jwawinuser; procedure GetList;var  nDevices    : LongWord;  listentries : Array of RAWINPUTDEVICELIST;  i           : integer;begin  WriteLn('get information about list');  if (GetRawInputDeviceList(nil, nDevices, sizeof(RAWINPUTDEVICELIST)) = 0) then  begin    WriteLn('found ', nDevices, ' devices');     Writeln('Set size of list');    SetLength(listentries, nDevices);     if (GetRawInputDeviceList(@ListEntries[0], nDevices, sizeof(RAWINPUTDEVICELIST)) <> LongWord(-1) ) then    begin      for i := low(ListEntries) to High(ListEntries) do      begin        WriteLn('handle = ', listentries[i].hDevice, '  Type = ', listentries[i].dwType);      end;    end    else WriteLn('error retreiving the list');     SetLength(listentries, 0);  end  else WriteLn('error');end; begin  GetList;end. ---------------------------------------------------------------------- dmudie · 2016-11-07 20:37 Molly: That worked perfectly.  Thank you for your help. David ---------------------------------------------------------------------- DonAlfredo · 2016-11-09 21:34 You could use this lib, for HID: https://github.com/LongDirtyAnimAlf/FPC-USB-HID Both Windows and Linux.