.[ ČeskéHry.cz ].

Laboratoř ČeskýchHer.cz - PasteBin

Vložit nový kód

ČeskéHry.cz - KOMUNITA HERNÍCH VÝVOJÁŘŮ

  1. Mega teen leaks young paradise t33n folders
    12 hod
  2. Mega teen leaks young paradise t33n folders
    12 hod
  3. Mega teen leaks young paradise t33n folders
    12 hod
  4. Mega teen leaks young paradise t33n folders
    12 hod
  5. Mega teen leaks young paradise t33n folders
    12 hod
  6. Mega teen leaks young paradise t33n folders
    12 hod
  7. Mega teen leaks young paradise t33n folders
    12 hod
  8. Mega teen leaks young paradise t33n folders
    12 hod
  9. Mega teen leaks young paradise t33n folders
    12 hod
  10. Mega teen leaks young paradise t33n folders
    12 hod
Link: http://nopaste.ceske-hry.cz/subdom/nopaste222793
Zaslal: posila
Popis: DirectInput v Delphi
Jazyk: Delphi
Vloženo: 7.12.2009, 22:25
Stáhnout jako soubor
  1. TDX8Application = class(TObject)
  2. ...
  3. function InitDirectInput: Boolean;
  4. ...
  5. property DirectInput8: IDirectInput8 read FDirectInput8;
  6. ...
  7. end;
  8.  
  9. TDirectInput8Keyboard = class(TObject)
  10. private
  11. FApplication : TDX8Application;
  12. FKeyboard : IDIRECTINPUTDEVICE8;
  13. FKeyState : array [0..255] of Byte;
  14. FOldKeyState : array [0..255] of Byte;
  15. FTimeKeyState : array [0..255] of Byte;
  16. FDoTimeKeys : boolean;
  17. protected
  18. function GetKeyDown(index: byte): boolean;
  19. function GetOldKeyDown(index: byte): boolean;
  20. function GetTimeKey(index: byte): byte;
  21. procedure SetTimeKey(index, value: byte);
  22. public
  23. constructor Create(App: TDX8Application); virtual;
  24. destructor Destroy; override;
  25. procedure UpDate;
  26. property Keys[index: byte] : Boolean read GetKeyDown;
  27. property OldKeys[index: byte]: boolean read GetOldKeyDown;
  28. property TimeKeys[index: byte]: byte read GetTimeKey write SetTimeKey;
  29. property DoTimeKeys : boolean read FDoTimeKeys write FDoTimeKeys;
  30. end;
  31.  
  32. { TDX8Application }
  33.  
  34. function TDX8Application.InitDirectInput: Boolean;
  35. begin
  36. Result := False;
  37. if Failed(DirectInput8Create(GetModuleHandle(nil), DIRECTINPUT_VERSION,IID_IDirectInput8,FDirectInput8,nil)) then
  38. begin
  39. {$ifdef sg3d_engine_debug}Writeln(logfile,'End initializing DirectInpu...Error');{$endif}
  40. exit;
  41. end
  42. else
  43. begin
  44. {$ifdef sg3d_engine_debug}Writeln(logfile,'End initializing DirectInpu...OK');{$endif}
  45. end;
  46. Result := True;
  47. end;
  48.  
  49. {TDirectInput8Keyboard}
  50.  
  51. constructor TDirectInput8Keyboard.Create(App: TDX8Application);
  52. begin
  53. {$ifdef sg3d_engine_debug}App.Writeln(App.logfile,'Creating Keyboard');{$endif}
  54. FApplication := App;
  55. if App.DirectInput8 <> nil then
  56. begin
  57. if (FAILED(App.DirectInput8.CreateDevice(GUID_SysKeyboard, FKeyboard, nil))) then
  58. begin
  59. {$ifdef sg3d_engine_debug}
  60. FApplication.Writeln(FApplication.logfile,'Keyboard: Error CreateDevice');
  61. {$endif}
  62. App.Terminate;
  63. end;
  64. if (FAILED(FKeyboard.SetDataFormat(@c_dfDIKeyboard))) then
  65. begin
  66. {$ifdef sg3d_engine_debug}
  67. FApplication.Writeln(FApplication.logfile,'Keyboard: Error SetDataFormat');
  68. {$endif}
  69. App.Terminate;
  70. end;
  71. if (FAILED(FKeyboard.SetCooperativeLevel(App.WindowHandle, DISCL_BACKGROUND or
  72. DISCL_NONEXCLUSIVE))) then
  73. begin
  74. {$ifdef sg3d_engine_debug}
  75. FApplication.Writeln(FApplication.logfile,'Keyboard: Error SetCooperativeLevel');
  76. {$endif}
  77. App.Terminate;
  78. end;
  79. if (FAILED(FKeyboard.Acquire)) then
  80. begin
  81. {$ifdef sg3d_engine_debug}
  82. App.Writeln(FApplication.logfile,'Keyboard: Error Acquire');
  83. {$endif}
  84. App.Terminate;
  85. end;
  86. end;
  87. {$ifdef sg3d_engine_debug}App.Writeln(FApplication.logfile,'Creating Keyboard...OK');{$endif}
  88. FDoTimeKeys := False;
  89. end;
  90.  
  91. destructor TDirectInput8Keyboard.Destroy;
  92. begin
  93. if FKeyboard <> nil then begin
  94. FKeyboard.Unacquire();
  95. // FKeyboard._Release();
  96. FKeyboard := nil; end;
  97. inherited Destroy;
  98. end;
  99.  
  100. procedure TDirectInput8Keyboard.UpDate;
  101. var i : integer;
  102. begin
  103. fillChar(FOldKeyState,sizeof(FOldKeyState),0);
  104. Move(FKeyState,FOldKeyState,sizeof(FKeyState));
  105. if (FAILED(FKeyboard.GetDeviceState(sizeof(FKeyState), @FKeyState))) then
  106. exit;
  107. if FDoTimeKeys then
  108. for i := 0 to 255 do
  109. if Keys[i] then Inc(FTimeKeyState[i]) else FTimeKeyState[i] := 0;
  110.  
  111. end;
  112.  
  113. function TDirectInput8Keyboard.GetKeyDown(index: byte): boolean;
  114. begin
  115. Result := (FKeyState[index] and $80 = $80);
  116. end;
  117. function TDirectInput8Keyboard.GetOldKeyDown(index: byte): boolean;
  118. begin
  119. Result := (FOldKeyState[index] and $80 = $80);
  120. end;
  121. function TDirectInput8Keyboard.GetTimeKey(index: byte): byte;
  122. begin
  123. Result := FTimeKeyState[index];
  124. end;
  125. procedure TDirectInput8Keyboard.SetTimeKey(index, value: byte);
  126. begin
  127. FTimeKeyState[index] := value;
  128. end;
  129.