Skip to content

Commit e3b47e2

Browse files
build
1 parent ed26a00 commit e3b47e2

6 files changed

Lines changed: 114 additions & 93 deletions

File tree

dist/littlejs.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,7 @@ declare module "littlejsengine" {
23672367
/** Screen-pixel mouse movement per frame that counts as "using the mouse"
23682368
* (so sub-pixel hand jitter doesn't steal focus from the keyboard/gamepad).
23692369
* @type {number}
2370-
* @default 2
2370+
* @default
23712371
* @memberof Input */
23722372
export let inputMouseMoveThreshold: number;
23732373
/** Prevents input continuing to the default browser handling (true by default)

dist/littlejs.esm.js

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5540,9 +5540,9 @@ let lastInputDevice = 'mouse';
55405540
/** Screen-pixel mouse movement per frame that counts as "using the mouse"
55415541
* (so sub-pixel hand jitter doesn't steal focus from the keyboard/gamepad).
55425542
* @type {number}
5543-
* @default 2
5543+
* @default
55445544
* @memberof Input */
5545-
let inputMouseMoveThreshold = 2;
5545+
let inputMouseMoveThreshold = 6;
55465546

55475547
/** Prevents input continuing to the default browser handling (true by default)
55485548
* @type {boolean}
@@ -6071,34 +6071,41 @@ function inputUpdate()
60716071
// update gamepads if enabled
60726072
gamepadsUpdate();
60736073

6074-
// ── most-recently-used input device (sticky while everything is idle) ──
6075-
// gamepad: any stick past a .2 magnitude (.04 = .2²), or any of the 17
6076-
// standard-mapping buttons (0..16) held
6077-
let gamepadActive = false;
6078-
for (let s = gamepadStickCount(); s-- && !gamepadActive;)
6079-
gamepadActive = gamepadStick(s).lengthSquared() > .04;
6080-
for (let b = 17; b-- && !gamepadActive;)
6081-
gamepadActive = gamepadIsDown(b);
6082-
6083-
// mouse: any button held, or moved past the jitter threshold (screen px)
6084-
const mouseActive = mouseIsDown(0) || mouseIsDown(1) || mouseIsDown(2) ||
6085-
mouseDeltaScreen.length() > inputMouseMoveThreshold;
6086-
6087-
// keyboard: any non-mouse key currently down. device 0 holds both keyboard
6088-
// codes (e.g. 'KeyA') and mouse buttons (numeric 0..4); skip the numeric
6089-
// ones with isNaN(+k) so keyboard detection is exact
6090-
let keyboardActive = false;
6091-
for (const k in inputData[0])
6092-
if (isNaN(+k) && (inputData[0][k] & 1)) { keyboardActive = true; break; }
6093-
6094-
// priority on a same-frame tie: gamepad > mouse > keyboard
6095-
if (gamepadActive) lastInputDevice = 'gamepad';
6096-
else if (mouseActive) lastInputDevice = 'mouse';
6097-
else if (keyboardActive) lastInputDevice = 'keyboard';
6098-
// else keep the previous value — the whole point (idle never reverts)
6099-
6100-
// keep the legacy flag as an accurate derived view (single source of truth)
6101-
isUsingGamepad = lastInputDevice === 'gamepad';
6074+
// update most recently used input device
6075+
updateLastInputDevice();
6076+
6077+
function updateLastInputDevice()
6078+
{
6079+
// mouse: any button held or moved
6080+
const mouseActive = mouseIsDown(0) || mouseIsDown(1) || mouseIsDown(2) || mouseDeltaScreen.length() > inputMouseMoveThreshold;
6081+
6082+
// gamepad: any button held or stick moved
6083+
let gamepadActive = false;
6084+
for (let s = gamepadStickCount(); s-- && !gamepadActive;)
6085+
gamepadActive = gamepadStick(s).lengthSquared() > .04;
6086+
for (let b = 17; b-- && !gamepadActive;)
6087+
gamepadActive = gamepadIsDown(b);
6088+
6089+
// keyboard: any non-mouse key down
6090+
let keyboardActive = false;
6091+
for (const k in inputData[0])
6092+
if (isNaN(+k) && (inputData[0][k] & 1))
6093+
{
6094+
keyboardActive = true;
6095+
break;
6096+
}
6097+
6098+
// update the last input
6099+
if (gamepadActive)
6100+
lastInputDevice = 'gamepad';
6101+
else if (mouseActive)
6102+
lastInputDevice = 'mouse';
6103+
else if (keyboardActive)
6104+
lastInputDevice = 'keyboard';
6105+
6106+
// set flag if gamepad is last device
6107+
isUsingGamepad = lastInputDevice === 'gamepad';
6108+
}
61026109

61036110
// gamepads are updated by engine every frame automatically
61046111
function gamepadsUpdate()

dist/littlejs.esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/littlejs.js

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5540,9 +5540,9 @@ let lastInputDevice = 'mouse';
55405540
/** Screen-pixel mouse movement per frame that counts as "using the mouse"
55415541
* (so sub-pixel hand jitter doesn't steal focus from the keyboard/gamepad).
55425542
* @type {number}
5543-
* @default 2
5543+
* @default
55445544
* @memberof Input */
5545-
let inputMouseMoveThreshold = 2;
5545+
let inputMouseMoveThreshold = 6;
55465546

55475547
/** Prevents input continuing to the default browser handling (true by default)
55485548
* @type {boolean}
@@ -6071,34 +6071,41 @@ function inputUpdate()
60716071
// update gamepads if enabled
60726072
gamepadsUpdate();
60736073

6074-
// ── most-recently-used input device (sticky while everything is idle) ──
6075-
// gamepad: any stick past a .2 magnitude (.04 = .2²), or any of the 17
6076-
// standard-mapping buttons (0..16) held
6077-
let gamepadActive = false;
6078-
for (let s = gamepadStickCount(); s-- && !gamepadActive;)
6079-
gamepadActive = gamepadStick(s).lengthSquared() > .04;
6080-
for (let b = 17; b-- && !gamepadActive;)
6081-
gamepadActive = gamepadIsDown(b);
6082-
6083-
// mouse: any button held, or moved past the jitter threshold (screen px)
6084-
const mouseActive = mouseIsDown(0) || mouseIsDown(1) || mouseIsDown(2) ||
6085-
mouseDeltaScreen.length() > inputMouseMoveThreshold;
6086-
6087-
// keyboard: any non-mouse key currently down. device 0 holds both keyboard
6088-
// codes (e.g. 'KeyA') and mouse buttons (numeric 0..4); skip the numeric
6089-
// ones with isNaN(+k) so keyboard detection is exact
6090-
let keyboardActive = false;
6091-
for (const k in inputData[0])
6092-
if (isNaN(+k) && (inputData[0][k] & 1)) { keyboardActive = true; break; }
6093-
6094-
// priority on a same-frame tie: gamepad > mouse > keyboard
6095-
if (gamepadActive) lastInputDevice = 'gamepad';
6096-
else if (mouseActive) lastInputDevice = 'mouse';
6097-
else if (keyboardActive) lastInputDevice = 'keyboard';
6098-
// else keep the previous value — the whole point (idle never reverts)
6099-
6100-
// keep the legacy flag as an accurate derived view (single source of truth)
6101-
isUsingGamepad = lastInputDevice === 'gamepad';
6074+
// update most recently used input device
6075+
updateLastInputDevice();
6076+
6077+
function updateLastInputDevice()
6078+
{
6079+
// mouse: any button held or moved
6080+
const mouseActive = mouseIsDown(0) || mouseIsDown(1) || mouseIsDown(2) || mouseDeltaScreen.length() > inputMouseMoveThreshold;
6081+
6082+
// gamepad: any button held or stick moved
6083+
let gamepadActive = false;
6084+
for (let s = gamepadStickCount(); s-- && !gamepadActive;)
6085+
gamepadActive = gamepadStick(s).lengthSquared() > .04;
6086+
for (let b = 17; b-- && !gamepadActive;)
6087+
gamepadActive = gamepadIsDown(b);
6088+
6089+
// keyboard: any non-mouse key down
6090+
let keyboardActive = false;
6091+
for (const k in inputData[0])
6092+
if (isNaN(+k) && (inputData[0][k] & 1))
6093+
{
6094+
keyboardActive = true;
6095+
break;
6096+
}
6097+
6098+
// update the last input
6099+
if (gamepadActive)
6100+
lastInputDevice = 'gamepad';
6101+
else if (mouseActive)
6102+
lastInputDevice = 'mouse';
6103+
else if (keyboardActive)
6104+
lastInputDevice = 'keyboard';
6105+
6106+
// set flag if gamepad is last device
6107+
isUsingGamepad = lastInputDevice === 'gamepad';
6108+
}
61026109

61036110
// gamepads are updated by engine every frame automatically
61046111
function gamepadsUpdate()

dist/littlejs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/littlejs.release.js

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4852,9 +4852,9 @@ let lastInputDevice = 'mouse';
48524852
/** Screen-pixel mouse movement per frame that counts as "using the mouse"
48534853
* (so sub-pixel hand jitter doesn't steal focus from the keyboard/gamepad).
48544854
* @type {number}
4855-
* @default 2
4855+
* @default
48564856
* @memberof Input */
4857-
let inputMouseMoveThreshold = 2;
4857+
let inputMouseMoveThreshold = 6;
48584858

48594859
/** Prevents input continuing to the default browser handling (true by default)
48604860
* @type {boolean}
@@ -5383,34 +5383,41 @@ function inputUpdate()
53835383
// update gamepads if enabled
53845384
gamepadsUpdate();
53855385

5386-
// ── most-recently-used input device (sticky while everything is idle) ──
5387-
// gamepad: any stick past a .2 magnitude (.04 = .2²), or any of the 17
5388-
// standard-mapping buttons (0..16) held
5389-
let gamepadActive = false;
5390-
for (let s = gamepadStickCount(); s-- && !gamepadActive;)
5391-
gamepadActive = gamepadStick(s).lengthSquared() > .04;
5392-
for (let b = 17; b-- && !gamepadActive;)
5393-
gamepadActive = gamepadIsDown(b);
5394-
5395-
// mouse: any button held, or moved past the jitter threshold (screen px)
5396-
const mouseActive = mouseIsDown(0) || mouseIsDown(1) || mouseIsDown(2) ||
5397-
mouseDeltaScreen.length() > inputMouseMoveThreshold;
5398-
5399-
// keyboard: any non-mouse key currently down. device 0 holds both keyboard
5400-
// codes (e.g. 'KeyA') and mouse buttons (numeric 0..4); skip the numeric
5401-
// ones with isNaN(+k) so keyboard detection is exact
5402-
let keyboardActive = false;
5403-
for (const k in inputData[0])
5404-
if (isNaN(+k) && (inputData[0][k] & 1)) { keyboardActive = true; break; }
5405-
5406-
// priority on a same-frame tie: gamepad > mouse > keyboard
5407-
if (gamepadActive) lastInputDevice = 'gamepad';
5408-
else if (mouseActive) lastInputDevice = 'mouse';
5409-
else if (keyboardActive) lastInputDevice = 'keyboard';
5410-
// else keep the previous value — the whole point (idle never reverts)
5411-
5412-
// keep the legacy flag as an accurate derived view (single source of truth)
5413-
isUsingGamepad = lastInputDevice === 'gamepad';
5386+
// update most recently used input device
5387+
updateLastInputDevice();
5388+
5389+
function updateLastInputDevice()
5390+
{
5391+
// mouse: any button held or moved
5392+
const mouseActive = mouseIsDown(0) || mouseIsDown(1) || mouseIsDown(2) || mouseDeltaScreen.length() > inputMouseMoveThreshold;
5393+
5394+
// gamepad: any button held or stick moved
5395+
let gamepadActive = false;
5396+
for (let s = gamepadStickCount(); s-- && !gamepadActive;)
5397+
gamepadActive = gamepadStick(s).lengthSquared() > .04;
5398+
for (let b = 17; b-- && !gamepadActive;)
5399+
gamepadActive = gamepadIsDown(b);
5400+
5401+
// keyboard: any non-mouse key down
5402+
let keyboardActive = false;
5403+
for (const k in inputData[0])
5404+
if (isNaN(+k) && (inputData[0][k] & 1))
5405+
{
5406+
keyboardActive = true;
5407+
break;
5408+
}
5409+
5410+
// update the last input
5411+
if (gamepadActive)
5412+
lastInputDevice = 'gamepad';
5413+
else if (mouseActive)
5414+
lastInputDevice = 'mouse';
5415+
else if (keyboardActive)
5416+
lastInputDevice = 'keyboard';
5417+
5418+
// set flag if gamepad is last device
5419+
isUsingGamepad = lastInputDevice === 'gamepad';
5420+
}
54145421

54155422
// gamepads are updated by engine every frame automatically
54165423
function gamepadsUpdate()

0 commit comments

Comments
 (0)