Socket
Socket
Sign inDemoInstall

contro

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.2.1

22

dist/contro.esm.js

@@ -1,2 +0,1 @@

/** Representation of a two-dimensional vector. */
class Vector2 {

@@ -15,3 +14,2 @@ constructor(x = 0, y = 0) {

})(MouseButton || (MouseButton = {}));
/** Representation of the player's mouse. */
class Mouse {

@@ -45,8 +43,6 @@ constructor({ canvas, doc = document }) {

}
/** Returns whether the passed in button is currently pressed. */
isPressed(/* istanbul ignore next */ button = MouseButton.Left) {
isPressed(button = MouseButton.Left) {
return this.pressedButtons.has(button);
}
/** Returns whether the passed in mouse button was pressed. */
wasPressed(/* istanbul ignore next */ button = MouseButton.Left) {
wasPressed(button = MouseButton.Left) {
if (this.queuedButtons.has(button)) {

@@ -58,3 +54,2 @@ this.queuedButtons.delete(button);

}
/** Returns the movement since the last check. */
getPointerMovement() {

@@ -65,3 +60,2 @@ const movement = this.pointerMovement;

}
/** Returns the scroll distance since the last request. */
getScrollDistance() {

@@ -72,11 +66,8 @@ const distance = this.scrollDistance;

}
/** Requests pointer lock. */
lockPointer() {
this.canvas.requestPointerLock();
}
/** Exits the pointer lock. */
unlockPointer() {
this.document.exitPointerLock();
}
/** Returns whether the pointer is currently locked. */
isPointerLocked() {

@@ -93,3 +84,2 @@ return this.document.pointerLockElement === this.canvas;

constructor(
/* istanbul ignore next */
{ doc = document } = {}) {

@@ -147,3 +137,2 @@ this.pressedKeys = new Set();

constructor(
/* istanbul ignore next */
{ win = window, nav = navigator } = {}) {

@@ -154,3 +143,2 @@ this.pressedButtons = new Set();

this.window.addEventListener('gamepadconnected', ({ gamepad }) => {
/* istanbul ignore else */
if (!this.isConnected())

@@ -160,3 +148,2 @@ this.gamepadIndex = gamepad.index;

this.window.addEventListener('gamepaddisconnected', ({ gamepad }) => {
/* istanbul ignore else */
if (this.gamepadIndex === gamepad.index) {

@@ -173,17 +160,12 @@ const gamepads = this.navigator.getGamepads();

}
/** Returns whether a gamepad is currently connected. */
isConnected() {
return this.gamepadIndex !== undefined && this.gamepad.connected;
}
/** The current gamepad instance. */
get gamepad() {
return this.navigator.getGamepads()[this.gamepadIndex];
}
/** Returns whether the button is pressed. */
isPressed(button) {
return this.isConnected() && this.gamepad.buttons[button].pressed;
}
/** Returns whether the button was pressed. */
wasPressed(button) {
/* istanbul ignore else */
if (this.isConnected()) {

@@ -190,0 +172,0 @@ if (this.gamepad.buttons[button].pressed) {

@@ -7,3 +7,2 @@ (function (global, factory) {

/** Representation of a two-dimensional vector. */
class Vector2 {

@@ -21,3 +20,2 @@ constructor(x = 0, y = 0) {

})(exports.MouseButton || (exports.MouseButton = {}));
/** Representation of the player's mouse. */
class Mouse {

@@ -51,8 +49,6 @@ constructor({ canvas, doc = document }) {

}
/** Returns whether the passed in button is currently pressed. */
isPressed(/* istanbul ignore next */ button = exports.MouseButton.Left) {
isPressed(button = exports.MouseButton.Left) {
return this.pressedButtons.has(button);
}
/** Returns whether the passed in mouse button was pressed. */
wasPressed(/* istanbul ignore next */ button = exports.MouseButton.Left) {
wasPressed(button = exports.MouseButton.Left) {
if (this.queuedButtons.has(button)) {

@@ -64,3 +60,2 @@ this.queuedButtons.delete(button);

}
/** Returns the movement since the last check. */
getPointerMovement() {

@@ -71,3 +66,2 @@ const movement = this.pointerMovement;

}
/** Returns the scroll distance since the last request. */
getScrollDistance() {

@@ -78,11 +72,8 @@ const distance = this.scrollDistance;

}
/** Requests pointer lock. */
lockPointer() {
this.canvas.requestPointerLock();
}
/** Exits the pointer lock. */
unlockPointer() {
this.document.exitPointerLock();
}
/** Returns whether the pointer is currently locked. */
isPointerLocked() {

@@ -99,3 +90,2 @@ return this.document.pointerLockElement === this.canvas;

constructor(
/* istanbul ignore next */
{ doc = document } = {}) {

@@ -153,3 +143,2 @@ this.pressedKeys = new Set();

constructor(
/* istanbul ignore next */
{ win = window, nav = navigator } = {}) {

@@ -160,3 +149,2 @@ this.pressedButtons = new Set();

this.window.addEventListener('gamepadconnected', ({ gamepad }) => {
/* istanbul ignore else */
if (!this.isConnected())

@@ -166,3 +154,2 @@ this.gamepadIndex = gamepad.index;

this.window.addEventListener('gamepaddisconnected', ({ gamepad }) => {
/* istanbul ignore else */
if (this.gamepadIndex === gamepad.index) {

@@ -179,17 +166,12 @@ const gamepads = this.navigator.getGamepads();

}
/** Returns whether a gamepad is currently connected. */
isConnected() {
return this.gamepadIndex !== undefined && this.gamepad.connected;
}
/** The current gamepad instance. */
get gamepad() {
return this.navigator.getGamepads()[this.gamepadIndex];
}
/** Returns whether the button is pressed. */
isPressed(button) {
return this.isConnected() && this.gamepad.buttons[button].pressed;
}
/** Returns whether the button was pressed. */
wasPressed(button) {
/* istanbul ignore else */
if (this.isConnected()) {

@@ -196,0 +178,0 @@ if (this.gamepad.buttons[button].pressed) {

2

package.json
{
"name": "contro",
"version": "1.2.0",
"version": "1.2.1",
"description": "Game controls done right.",

@@ -5,0 +5,0 @@ "main": "dist/contro.esm.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc