summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 386dec8)
raw | patch | inline | side by side (parent: 386dec8)
author | FGSFDSFGS <derp.primus@gmail.com> | |
Mon, 5 Jun 2017 19:00:19 +0000 (22:00 +0300) | ||
committer | FGSFDSFGS <derp.primus@gmail.com> | |
Mon, 5 Jun 2017 19:00:19 +0000 (22:00 +0300) |
src/engine/e_input.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history | |
src/game/g_netmsg.pas | patch | blob | history |
diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas
index 15cc2aa6ff3a348cf6271fb7b9d1023a668d53a6..d4081ee5615075eaa89c26fb80962c47e82e1dda 100644 (file)
--- a/src/engine/e_input.pas
+++ b/src/engine/e_input.pas
e_MaxKbdKeys = SDL_NUM_SCANCODES;
e_MaxJoys = 4;
e_MaxJoyBtns = 32;
- e_MaxJoyAxes = 4;
- e_MaxJoyHats = 4;
+ e_MaxJoyAxes = 8;
+ e_MaxJoyHats = 8;
e_MaxJoyKeys = e_MaxJoyBtns + e_MaxJoyAxes*2 + e_MaxJoyHats*4;
e_MaxInputKeys = e_MaxKbdKeys + e_MaxJoys*e_MaxJoyKeys - 1;
// $$$..$$$ - 321 Keyboard buttons/keys
// $$$..$$$ - 4*32 Joystick buttons
- // $$$..$$$ - 4*4 Joystick axes (- and +)
+ // $$$..$$$ - 8*2 Joystick axes (- and +)
// $$$..$$$ - 4*4 Joystick hats (L U R D)
// these are apparently used in g_gui and g_game and elsewhere
Hats: Byte;
ButtBuf: array [0..e_MaxJoyBtns] of Boolean;
AxisBuf: array [0..e_MaxJoyAxes] of Integer;
+ AxisZero: array [0..e_MaxJoyAxes] of Integer;
HatBuf: array [0..e_MaxJoyHats] of array [HAT_LEFT..HAT_DOWN] of Boolean;
end;
function OpenJoysticks(): Byte;
var
- i, k, c: Integer;
+ i, j, k, c: Integer;
joy: PSDL_Joystick;
begin
Result := 0;
if joy <> nil then
begin
Inc(c);
- e_WriteLog('Input: Opened SDL joystick ' + IntToStr(i) + ' as joystick ' + IntToStr(c) + ':', MSG_NOTIFY);
+ e_WriteLog('Input: Opened SDL joystick ' + IntToStr(i) + ' (' + SDL_JoystickName(joy) +
+ ') as joystick ' + IntToStr(c) + ':', MSG_NOTIFY);
SetLength(Joysticks, c);
with Joysticks[c-1] do
begin
Axes := Min(e_MaxJoyAxes, SDL_JoystickNumAxes(joy));
Buttons := Min(e_MaxJoyBtns, SDL_JoystickNumButtons(joy));
Hats := Min(e_MaxJoyHats, SDL_JoystickNumHats(joy));
+ // TODO: find proper solution for this xbox trigger shit
+ for j := 0 to Axes do AxisZero[j] := SDL_JoystickGetAxis(joy, j);
e_WriteLog(' ' + IntToStr(Axes) + ' axes, ' + IntToStr(Buttons) + ' buttons, ' +
IntToStr(Hats) + ' hats.', MSG_NOTIFY);
end;
Key := (Key - JOYA_BEG) mod (e_MaxJoyAxes*2);
dir := Key mod 2;
if dir = AX_MINUS then
- Result := Joysticks[JoyI].AxisBuf[Key div 2] < -e_JoystickDeadzones[JoyI]
+ Result := Joysticks[JoyI].AxisBuf[Key div 2] <
+ Joysticks[JoyI].AxisZero[Key div 2] - e_JoystickDeadzones[JoyI]
else
- Result := Joysticks[JoyI].AxisBuf[Key div 2] > e_JoystickDeadzones[JoyI]
+ Result := Joysticks[JoyI].AxisBuf[Key div 2] >
+ Joysticks[JoyI].AxisZero[Key div 2] + e_JoystickDeadzones[JoyI]
end;
end
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 110111e6ca492084d47e8488d0a32138a9c66359..4cfb4a2106b8f080662e8c8dffe66de05e87abaa 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
// now set direction according to strafe
if (strafeDir = 1) then plr.SetDirection(D_LEFT)
else if (strafeDir = 2) then plr.SetDirection(D_RIGHT)
- else plr.SetDirection(TDirection(MoveButton-1));
+ else if MoveButton <> 0 then plr.SetDirection(TDirection(MoveButton-1));
end
else
begin
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 1b80ddd13aba6f9a9d031aa5ff3a172ed3002c92..e5cd723488af9bec0802f13af252346ec73b9e6a 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
// now set direction according to strafe
if (strafeDir = 1) then gPlayer1.SetDirection(D_LEFT)
else if (strafeDir = 2) then gPlayer1.SetDirection(D_RIGHT)
- else gPlayer1.SetDirection(TDirection(P1MoveButton-1));
+ else if P1MoveButton <> 0 then gPlayer1.SetDirection(TDirection(P1MoveButton-1));
end
else
begin