Program WiiControlP;
Uses Windows, SysUtils, Forms, Generics.Collections, WiiControl;
Procedure OnRecive(Sender: THIDDevice;
Const Data; Len: Integer);
Var S:
String;
i: Integer;
Begin
WriteLn('
OnRecive');
WriteLn('
Instance ', Sender.DeviceInfo.Instance);
S := '
Data';
For i := 0
to Len - 1
do Begin
If i
mod 20 = 0
Then Begin
WriteLn(S);
S := '
';
End Else If i
mod 5 = 0
Then
S := S + '
';
S := Format('
%s %.2x', [S, PByte(@Data)[i]]);
End;
WriteLn(S);
WriteLn;
End;
Procedure OnError(Sender: TWiiRemoteController; ReportID, ErrorCode: Byte);
Begin
WriteLn('
OnReceptError');
WriteLn('
Instance ', Sender.DeviceInfo.Instance);
WriteLn('
ReportID ', Format('
$%.2x', [ReportID]));
WriteLn('
ErrorCode ', ErrorCode);
WriteLn;
End;
Procedure DeviceChange(Controler: THIDControler);
Begin
WriteLn('
DeviceChange');
WriteLn;
End;
Procedure DeviceArrival(Controler: THIDControler;
Const DeviceInfo: THIDDeviceInfo);
Var Device: THIDDevice;
Begin
WriteLn('
DeviceArrival');
WriteLn('
ClassGUID ', GUIDToString(DeviceInfo.ClassGUID));
WriteLn('
Instance ', DeviceInfo.Instance);
WriteLn('
Path ', DeviceInfo.Path);
WriteLn('
Description ', DeviceInfo.Description);
WriteLn('
PhysicalDeviceObject ', DeviceInfo.PhysicalDeviceObject);
If Controler.CompareByID(DeviceInfo, WIIMOTE_VENDOR_ID, WIIMOTE_PRODUCT_ID)
Then Begin
Device := Controler.Arrival(DeviceInfo, TWiiRemoteController);
Device.OnRecive := OnRecive;
TWiiRemoteController(Device).OnReceptError := OnError;
WriteLn('
Arrivaled');
WriteLn('
VendorID ', Format('
$%.4x', [Device.VendorID]));
WriteLn('
ProductID ', Format('
$%.4x', [Device.ProductID]));
WriteLn('
ProductStr ', Device.ProductStr);
WriteLn('
Version ', Device.Version);
WriteLn('
Manufacturer ', Device.Manufacturer);
WriteLn('
SerialNumber ', Device.SerialNumber);
WriteLn('
Identifier ', Device.Identifier);
End;
WriteLn;
End;
Procedure DeviceRemoval(Controler: THIDControler;
Const DeviceInfo: THIDDeviceInfo; DeviceObject: THIDDevice);
Begin
WriteLn('
DeviceRemoval');
WriteLn('
ClassGUID ', GUIDToString(DeviceInfo.ClassGUID));
WriteLn('
Instance ', DeviceInfo.Instance);
WriteLn('
Path ', DeviceInfo.Path);
WriteLn('
Description ', DeviceInfo.Description);
WriteLn('
PhysicalDeviceObject ', DeviceInfo.PhysicalDeviceObject);
If Assigned(DeviceObject)
Then Begin
WriteLn('
Arrivaled');
WriteLn('
SerialNumber ', DeviceObject.SerialNumber);
WriteLn('
Identifier ', DeviceObject.Identifier);
DeviceObject.Free;
End;
WriteLn;
End;
Var HIDControler: THIDControler;
Report: TWiiReport;
Begin
Try
AllocConsole;
Application.Initialize;
HIDControler := GlobalHIDControler;
HIDControler.RegisterDeviceChangeProc(DeviceChange);
HIDControler.RegisterDeviceArrivalProc(DeviceArrival);
HIDControler.RegisterDeviceRemovalProc(DeviceRemoval);
Repeat
Application.ProcessMessages;
Sleep(10);
TWiiRemoteController(HIDControler.ArrivaledDevice[0]).LEDs := [blRumble, blLED2];
Sleep(200);
TWiiRemoteController(HIDControler.ArrivaledDevice[0]).LEDs := [blLED1, blLED4];
Sleep(1000);
Report.Clear;
Report.ReportID := WII_RID_MODE;
Report.Continuous := True;
Report.RequestReportID := WII_RECEPT_STATUS;
HIDControler.ArrivaledDevice[0].Send(Report, WIIMOTE_BT_REPORT_LEN);
Until Application.Terminated;
While HIDControler.ArrivaledDeviceCount > 0
do
HIDControler.ArrivaledDevice[0].Free;
HIDControler.UnregisterDeviceChangeProc(DeviceChange);
HIDControler.UnregisterDeviceArrivalProc(DeviceArrival);
HIDControler.UnregisterDeviceRemovalProc(DeviceRemoval);
Except
On E:
Exception do WriteLn(E.ClassName, '
: ', E.
Message);
End;
End.