Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller support #416

Draft
wants to merge 56 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f34a14b
feat: joystick aim and movement
Arman-AIi Nov 15, 2024
29c3904
refactor: removed unnecessary activePlayer const
Arman-AIi Nov 15, 2024
78dabad
refactor: named axe variables + one less indent
Arman-AIi Nov 15, 2024
dfd54b8
feat: added joystick sensitivity slider for people with stick drift
Arman-AIi Nov 16, 2024
0effb6d
fix: hide controller tab content by default
Arman-AIi Nov 16, 2024
78cc4f5
feat: allow players to switch joystick functions
Arman-AIi Nov 16, 2024
748da8a
feat: hide controller tab when controller isn't detected
Arman-AIi Nov 16, 2024
f3bc168
feat: separate sliders for left and right joystick sensitivity
Arman-AIi Nov 16, 2024
6206403
fix: only start ticker if controller connects, and kill ticker if it …
Arman-AIi Nov 16, 2024
70b757e
slightly adjust mp40 loot+kf
ei-pi Nov 14, 2024
f10a3fc
fix: glitched river generation
hsanger Nov 15, 2024
6b04ff8
feat: update outdated airdrop winter reskins
1092384 Nov 15, 2024
696f78f
feat: update airdrop winter reskin particles
1092384 Nov 15, 2024
30f4e99
feat: oak tree + box 3 updated winter reskins
1092384 Nov 15, 2024
c135992
feat: new emote
1092384 Nov 15, 2024
56ac855
fix: c4 exploding when destroyed
pap-24 Nov 15, 2024
001b79b
perf/refactor: combine ceilingHitbox + scopeHitbox
pap-24 Nov 15, 2024
b518ba0
feat: winter reskins for flint, aegis, normal crates and oil tank
1092384 Nov 16, 2024
b9914b3
feat: sandbags winter reskin
1092384 Nov 16, 2024
12e50c2
feat: refinery ceiling winter reskin
1092384 Nov 16, 2024
a2af537
feat: cooler winter reskin
1092384 Nov 16, 2024
0ffd77c
fix: throwable collisions not having layer checks 💀
pap-24 Nov 16, 2024
03137c5
enhance: dont stop piano hit sounds
pap-24 Nov 16, 2024
b0ccbdb
refactor/perf/fix: metal detector walls
pap-24 Nov 16, 2024
fd2cc74
wip: initial work on improving teammate indicators + colored/tinted c4s
pap-24 Nov 16, 2024
b6e0f25
fix: remove useless element attribute
pap-24 Nov 16, 2024
82dfef6
feat: colored teammate c4s
pap-24 Nov 16, 2024
b6778db
fix: cleanup code with a new method/function ig
pap-24 Nov 16, 2024
03487ae
fix: handle solo case where there are no colors
pap-24 Nov 16, 2024
3551e18
feat: strict checks for color indexing on teams
pap-24 Nov 16, 2024
f91d79f
fix: remove testing stuff
pap-24 Nov 16, 2024
6ef7f6d
fix: only tint c4s and not other throwables
pap-24 Nov 16, 2024
76135f5
enhance: Updated names of VSS Vintorez and PP-19 Vityaz
SolsticeUnlimitd Nov 16, 2024
d8032c5
wip: snow variant generating function
1092384 Nov 16, 2024
6885cea
fix: some template type issues + winter variation
ei-pi Nov 16, 2024
6d768a6
fix: server crash + add winter variants code
1092384 Nov 17, 2024
6b8b15d
feat: barrel, super barrel, grenade crate, flint stone winter reskins
1092384 Nov 17, 2024
fe8d3c8
fix: average 109 fuckup
1092384 Nov 17, 2024
40f01e4
feat: grenade crate, tear gas crate, grenade box winter variations
1092384 Nov 17, 2024
c072ba8
enhance: border standardization for winter variants
1092384 Nov 17, 2024
4215c58
feat: birch tree, dumpster, trash bag winter variants
1092384 Nov 17, 2024
8b62d3b
fix: remove c4 synced particle (lmao)
pap-24 Nov 17, 2024
a2b1f7d
chore: lint + dv
pap-24 Nov 17, 2024
a135d94
perf: minor optimizations
hsanger Nov 17, 2024
c9bfde5
chore: bump deps
hsanger Nov 17, 2024
3a1754a
fix: downgrade eslint to 9.14.0
hsanger Nov 17, 2024
ff4057b
fix: better fix for river gen glitch
hsanger Nov 17, 2024
2d706a4
feat: update changelog
hsanger Nov 17, 2024
15e9c52
chore: bump versions
hsanger Nov 17, 2024
60cf8cd
feat: vibration and a few buttons
Arman-AIi Nov 17, 2024
5433661
feat: added info for current joystick functions
Arman-AIi Nov 19, 2024
f381a85
feat: selecting controllers
Arman-AIi Nov 25, 2024
341ac6d
feat: vibrate selected controller (I love vibrations!)
Arman-AIi Nov 25, 2024
0c76016
fix: don't vibrate controller if it's already selected
Arman-AIi Nov 26, 2024
d1f8545
enhance: hide buttons that don't have a corresponding controller conn…
Arman-AIi Nov 26, 2024
6bbad7d
feat: name of the controller is now taken from controller.id, and use…
Arman-AIi Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions client/src/scripts/managers/inputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ItemType, type ItemDefinition } from "@common/utils/objectDefinitions";
import { Vec } from "@common/utils/vector";
import $ from "jquery";
import nipplejs, { type JoystickOutputData } from "nipplejs";
import * as PIXI from "pixi.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not import everything from pixijs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, now it only imports ticker

import { isMobile } from "pixi.js";
import { getTranslatedString } from "../../translations";
import { type Game } from "../game";
Expand Down Expand Up @@ -342,6 +343,50 @@ export class InputManager {
shootOnRelease = false;
});
}
const ticker = new PIXI.Ticker();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Game class's pixi ticker

ticker.stop();
ticker.add(() => {
const gamepads = navigator.getGamepads();
Copy link
Contributor

@kenos1 kenos1 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use Game's pixi ticker, put this into its own method

Copy link
Contributor

@kenos1 kenos1 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need to call this method every frame, is it required?

if (gamepads[0]) {
Arman-AIi marked this conversation as resolved.
Show resolved Hide resolved
Arman-AIi marked this conversation as resolved.
Show resolved Hide resolved
const leftJoystickMoving = gamepads[0].axes[0] !== 0 || gamepads[0].axes[1] !== 0;
const rightJoystickMoving = gamepads[0].axes[2] !== 0 || gamepads[0].axes[3] !== 0;
Arman-AIi marked this conversation as resolved.
Show resolved Hide resolved
// const rightJoystickDistance = Math.sqrt(gamepads[0].axes[2] * gamepads[0].axes[2] + gamepads[0].axes[3] * gamepads[0].axes[3]);
// distance formula for stuff like throwables, USAS-12, and M590M
if (leftJoystickMoving) {
Arman-AIi marked this conversation as resolved.
Show resolved Hide resolved
const movementAngle = Math.atan2(gamepads[0].axes[1], gamepads[0].axes[0]);
Arman-AIi marked this conversation as resolved.
Show resolved Hide resolved
this.movementAngle = movementAngle;
this.movement.moving = true;
// note: movement.moving only works on mobile
if (!rightJoystickMoving) {
this.rotation = movementAngle;
this.turning = true;
const activePlayer = game.activePlayer;
if (game.console.getBuiltInCVar("cv_responsive_rotation") && !game.gameOver && game.activePlayer) {
game.activePlayer.container.rotation = this.rotation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't there a better way to do this in the Player class?

this.turning = true;
}
if (!activePlayer) return;
activePlayer.images.aimTrail.alpha = 0;
}
} else {
this.movement.moving = false;
}

if (rightJoystickMoving) {
this.rotation = Math.atan2(gamepads[0].axes[3], gamepads[0].axes[2]);
this.turning = true;
const activePlayer = game.activePlayer;

if (game.console.getBuiltInCVar("cv_responsive_rotation") && !game.gameOver && activePlayer) {
Arman-AIi marked this conversation as resolved.
Show resolved Hide resolved
game.activePlayer.container.rotation = this.rotation;
}

if (!activePlayer) return;
activePlayer.images.aimTrail.alpha = 1;
}
}
});
ticker.start();
}

private handleInputEvent(down: boolean, event: KeyboardEvent | MouseEvent | WheelEvent): void {
Expand Down