![]()
Benutzerinformationen überspringen
Dabei seit: 10. April 2010
Wohnort: Welt://Europa/Deutschland/NRW/Ich.Mensch
Benutzerinformationen überspringen
Dabei seit: 10. April 2010
Wohnort: Welt://Europa/Deutschland/NRW/Ich.Mensch
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Leseratte« (11. April 2010, 07:07) aus folgendem Grund: Anhang hinzugefügt
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
//--WriteReport-------------------------------------
procedure WriteReport;
var
NumberOfBytesWritten: DWORD;
SendBuffer: array [0..2] of Byte;
begin
//Send data to the device.
//******************************************************************************
//WriteFile
//Sends a report to the device.
//Returns: success or failure.
//Requires: the handle returned by CreateFile and
//The output report byte length returned by HidP_GetCaps
//******************************************************************************
//The first byte is the Report ID
SendBuffer[0] := 2;
SendBuffer[1] := trkRumble[0].Position;
SendBuffer[2] := trkRumble[1].Position;
NumberOfBytesWritten := 0;
WriteFile(HIDHandle, SendBuffer, sizeof(SendBuffer), NumberOfBytesWritten, nil);
If frmMain.chkRawData.Checked = True Then
begin
frmMain.txtBytesSent.Text := IntToHex(SendBuffer[1], 2) + ' ' + IntToHex(SendBuffer[2], 2);
end
Else
frmMain.txtBytesSent.Text := '';
end;
//--WriteReport-------------------------------------
|
|
|
Quellcode |
1 2 3 4 5 6 7 |
HIDHandle := CreateFile(PChar(strDevicePath[frmMain.cmbDevices.ItemIndex]),
GENERIC_WRITE,
FILE_SHARE_READ Or FILE_SHARE_WRITE,
nil,//Addr(Security),
OPEN_EXISTING,
0,
0);
|
|
|
Quellcode |
1 2 3 4 5 6 7 |
function EnumCallback(EnumDevice: PXBCD_Device): Integer;
// ...
strUSBDevicePath[intUSBCount] := EnumDevice.USBPath;
strDevicePath[intUSBCount] := EnumDevice.HIDPath;
// ...
Result := 0;
end;
|
|
|
Quellcode |
1 2 3 4 5 6 7 |
Type
PXBCD_Device = ^TXBCD_Device;
TXBCD_Device = packed record
Index: Integer;
HIDPath: PChar;
USBPath: PChar;
end;
|
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »Mad Andy« (11. April 2010, 18:33)
Benutzerinformationen überspringen
Dabei seit: 10. April 2010
Wohnort: Welt://Europa/Deutschland/NRW/Ich.Mensch
|
|
Visual Basic Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
Public Class Form1 '--WriteReport------------------------------------- Private Declare Function WriteFile Lib "kernel32" ( _ ByVal hFile As Long, ByVal lpBuffer As String, _ ByVal nNumberOfBytesToWrite As Long, _ ByVal lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long Private Function WriteReport() Dim NumberOfBytesWritten As Integer Dim SendBuffer(2) As Byte 'Send data to the device. '****************************************************************************** 'WriteFile 'Sends a report to the device. 'Returns: success or failure. 'Requires: the handle returned by CreateFile and 'The output report byte length returned by HidP_GetCaps '****************************************************************************** 'The first byte is the Report ID SendBuffer(0) = 2 SendBuffer(1) = 255 SendBuffer(2) = 255 NumberOfBytesWritten = 0 WriteFile(HIDHandle, SendBuffer, Len(SendBuffer), NumberOfBytesWritten, 0)'In diesem Teil will VB HIDhandle deklariert haben '--WriteReport------------------------------------- End Function End Class |
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »Leseratte« (11. April 2010, 20:05)
Benutzerinformationen überspringen
Dabei seit: 10. April 2010
Wohnort: Welt://Europa/Deutschland/NRW/Ich.Mensch