X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fengine%2Fe_input.pas;h=0baad37ff55abaea386a336cfe7008aeed982f5c;hb=fb8592aa898a8da05a47bfe50ff8272de4fdc995;hp=5cf17a788264ffc00dde1b8f1e524135680878a0;hpb=d7d166dc3cd287276202e862746208892c4cc89f;p=d2df-sdl.git diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas index 5cf17a7..0baad37 100644 --- a/src/engine/e_input.pas +++ b/src/engine/e_input.pas @@ -1,4 +1,4 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,7 +94,8 @@ const function e_InitInput(): Boolean; procedure e_ReleaseInput(); procedure e_ClearInputBuffer(); -function e_PollInput(): Boolean; +//function e_PollInput(): Boolean; +procedure e_PollJoysticks(); // call this from message loop to update joysticks function e_KeyPressed(Key: Word): Boolean; function e_AnyKeyPressed(): Boolean; function e_GetFirstKeyPressed(): Word; @@ -226,21 +227,20 @@ begin } end; -function PollJoysticks(): Boolean; +procedure e_PollJoysticks(); var i, j: Word; hat: Byte; begin - Result := False; + //Result := False; if (Joysticks = nil) or (e_JoysticksAvailable = 0) then Exit; SDL_JoystickUpdate(); for j := Low(Joysticks) to High(Joysticks) do + begin with Joysticks[j] do begin - for i := 0 to Buttons do - ButtBuf[i] := SDL_JoystickGetButton(Handle, i) <> 0; - for i := 0 to Axes do - AxisBuf[i] := SDL_JoystickGetAxis(Handle, i); + for i := 0 to Buttons do ButtBuf[i] := SDL_JoystickGetButton(Handle, i) <> 0; + for i := 0 to Axes do AxisBuf[i] := SDL_JoystickGetAxis(Handle, i); for i := 0 to Hats do begin hat := SDL_JoystickGetHat(Handle, i); @@ -250,6 +250,7 @@ begin HatBuf[i, HAT_RIGHT] := LongBool(hat and SDL_HAT_RIGHT); end; end; + end; end; procedure GenerateKeyNames(); @@ -322,15 +323,17 @@ begin end; end; +{ function e_PollInput(): Boolean; var kb, js: Boolean; begin kb := PollKeyboard(); - js := PollJoysticks(); + js := e_PollJoysticks(); Result := kb or js; end; +} function e_KeyPressed(Key: Word): Boolean; var