6,20 → 6,7 |
|
uses |
Windows, Messages, SysUtils, Classes, Controls, Forms, MMSystem, |
DXClass, {$IFDEF VER17UP} Types, {$ENDIF} |
{$IfDef StandardDX} |
{$IfDef DX9} |
DirectInput; |
{$Else} |
{$IfDef DX81} |
DirectInput8; |
{$Else} |
DirectInput; |
{$EndIf} |
{$EndIf} |
{$Else} |
DirectX; |
{$EndIf} |
DirectX, DXClass; |
|
type |
|
778,7 → 765,7 |
FFindEffectGUID := pdei.guid; |
end; |
|
Result := Integer(DIENUM_STOP); |
Result := DIENUM_STOP; |
end; |
|
procedure CreateIEffectGuid(const GUID: TGUID; |
787,7 → 774,7 |
if EffectObject.Feff.dwSize=0 then Exit; |
|
if FRoot.FInput.FDevice2<>nil then |
FRoot.FInput.FDevice2.CreateEffect(GUID, @EffectObject.Feff, EffectObject.FEffect, nil); |
FRoot.FInput.FDevice2.CreateEffect(GUID, EffectObject.Feff, EffectObject.FEffect, nil); |
end; |
|
procedure CreateIEffect(dwFlags: DWORD; |
1418,11 → 1405,11 |
|
if FDevice<>nil then |
begin |
hr := FDevice.GetDeviceState(dwSize, @Data); |
hr := FDevice.GetDeviceState(dwSize, Data); |
if (hr=DIERR_INPUTLOST) or (hr=DIERR_NOTACQUIRED) then |
begin |
FDevice.Acquire; |
hr := FDevice.GetDeviceState(dwSize, @Data); |
hr := FDevice.GetDeviceState(dwSize, Data); |
end; |
Result := hr=DI_OK; |
end else |
1434,7 → 1421,7 |
function DIEnumDeviceObjectsProc(const peff: TDIDeviceObjectInstanceA; |
pvRef: Pointer): HRESULT; stdcall; |
begin |
Result := Integer(DIENUM_CONTINUE); |
Result := DIENUM_CONTINUE; |
|
if CompareMem(@peff.guidType, @GUID_Unknown, SizeOf(TGUID)) then Exit; |
|
1659,10 → 1646,7 |
DIK_APPS : Result := VK_APPS; |
end; |
end; |
{$IFDEF StandardDX} |
type |
TDIKeyboardState = array[0..255] of Byte; |
{$ENDIF} |
|
var |
j: Integer; |
i: TDXInputState; |
1864,7 → 1848,7 |
function TJoystick_EnumJoysticksCallback(const lpddi: TDIDeviceInstanceA; |
pvRef: Pointer): HRESULT; stdcall; |
begin |
Result := Integer(DIENUM_CONTINUE); |
Result := DIENUM_CONTINUE; |
|
with TJoystick(pvRef) do |
begin |
1872,7 → 1856,7 |
begin |
FDeviceGUID := lpddi.guidInstance; |
FEnumFlag := True; |
Result := Integer(DIENUM_STOP); |
Result := DIENUM_STOP; |
Exit; |
end; |
Inc(FEnumIndex); |
1896,7 → 1880,7 |
FEnumFlag := False; |
FEnumIndex := 0; |
|
FDXInput.FDInput.EnumDevices({DIDEVTYPE_JOYSTICK}4, @TJoystick_EnumJoysticksCallback, |
FDXInput.FDInput.EnumDevices(DIDEVTYPE_JOYSTICK, @TJoystick_EnumJoysticksCallback, |
Self, DIEDFL_ATTACHEDONLY); |
|
if not FEnumFlag then Exit; |
1912,7 → 1896,7 |
FForceFeedbackDevice := True; |
end; |
|
//if FDXInput.FDInput.CreateDevice(GUID_Joystick, FDevice, nil)<>DI_OK then Exit; get out by Paul van Dinther |
if FDXInput.FDInput.CreateDevice(GUID_Joystick, FDevice, nil)<>DI_OK then Exit; |
|
{ Device data format (TDIDataFormat) making. } |
|
2138,12 → 2122,12 |
procedure InitDirectInput(out DI: IDirectInput); |
type |
TDirectInputCreate = function(hinst: THandle; dwVersion: DWORD; |
out ppDI: {$IFDEF UNICODE}IDirectInputW{$ELSE}IDirectInputA{$ENDIF}; punkOuter: IUnknown): HRESULT; stdcall; |
out ppDI: IDirectInputA; punkOuter: IUnknown): HRESULT; stdcall; |
begin |
if FDirectInput=nil then |
begin |
try |
TDirectInputCreate(DXLoadLibrary('DInput.dll', {$IFDEF UNICODE}'DirectInputCreateW'{$ELSE}'DirectInputCreateA'{$ENDIF})) |
TDirectInputCreate(DXLoadLibrary('DInput.dll', 'DirectInputCreateA')) |
(HInstance, DIRECTINPUT_VERSION, FDirectInput, nil); |
except |
FDirectInput := nil; |