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
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.