Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
6 changes: 6 additions & 0 deletions src/deprecated/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { AssetRegistry } from '../framework/asset/asset-registry.js';
import { XrInputSource } from '../framework/xr/xr-input-source.js';

import { ElementInput } from '../framework/input/element-input.js';
import { MouseButton } from '../platform/input/mouse-button.js';
import { MouseEvent } from '../platform/input/mouse-event.js';

import { AppBase } from '../framework/app-base.js';
Expand Down Expand Up @@ -771,6 +772,11 @@ export const EVENT_SELECT = 'select';
export const EVENT_SELECTSTART = 'selectstart';
export const EVENT_SELECTEND = 'selectend';

export const MOUSEBUTTON_NONE = MouseButton.None;
export const MOUSEBUTTON_LEFT = MouseButton.Left;
export const MOUSEBUTTON_MIDDLE = MouseButton.Middle;
export const MOUSEBUTTON_RIGHT = MouseButton.Right;

Object.defineProperty(ElementInput.prototype, 'wheel', {
get: function () {
return this.wheelDelta * -2;
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export { GamePads } from './platform/input/game-pads.js';
export { Keyboard } from './platform/input/keyboard.js';
export { KeyboardEvent } from './platform/input/keyboard-event.js';
export { Mouse } from './platform/input/mouse.js';
export { MouseButton } from './platform/input/mouse-button.js';
export { MouseEvent } from './platform/input/mouse-event.js';
export { TouchDevice } from './platform/input/touch-device.js';
export { getTouchTargetCoords, Touch, TouchEvent } from './platform/input/touch-event.js';
Expand Down
28 changes: 0 additions & 28 deletions src/platform/input/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,34 +592,6 @@ export const KEY_CLOSE_BRACKET = 221;
*/
export const KEY_META = 224;

/**
* No mouse buttons pressed.
*
* @category Input
*/
export const MOUSEBUTTON_NONE = -1;

/**
* The left mouse button.
*
* @category Input
*/
export const MOUSEBUTTON_LEFT = 0;

/**
* The middle mouse button.
*
* @category Input
*/
export const MOUSEBUTTON_MIDDLE = 1;

/**
* The right mouse button.
*
* @category Input
*/
export const MOUSEBUTTON_RIGHT = 2;

/**
* Index for pad 1.
*
Expand Down
2 changes: 1 addition & 1 deletion src/platform/input/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Controller {
* @param {object} action - An action object to add.
* @param {ACTION_KEYBOARD | ACTION_MOUSE | ACTION_GAMEPAD} action.type - The name of the action.
* @param {number[]} [action.keys] - Keyboard: A list of keycodes e.g. `[pc.KEY_A, pc.KEY_ENTER]`.
* @param {number} [action.button] - Mouse: e.g. `pc.MOUSEBUTTON_LEFT` - Gamepad: e.g. `pc.PAD_FACE_1`
* @param {number} [action.button] - Mouse: e.g. `pc.MouseButton.LEFT` - Gamepad: e.g. `pc.PAD_FACE_1`
* @param {number} [action.pad] - Gamepad: An index of the pad to register (use {@link PAD_1}, etc).
*/
appendAction(action_name, action) {
Expand Down
12 changes: 3 additions & 9 deletions src/platform/input/mouse-event.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { MOUSEBUTTON_NONE } from './constants.js';

/**
* @import { Mouse } from './mouse.js'
*/
Expand Down Expand Up @@ -54,15 +52,11 @@ class MouseEvent {
dy = 0;

/**
* The mouse button associated with this event. Can be:
*
* - {@link MOUSEBUTTON_LEFT}
* - {@link MOUSEBUTTON_MIDDLE}
* - {@link MOUSEBUTTON_RIGHT}
* The mouse button associated with this event.
*
* @type {number}
* @type {MouseButton}
*/
button = MOUSEBUTTON_NONE;
button = MouseButton.NONE;

/**
* A value representing the amount the mouse wheel has moved, only valid for
Expand Down
25 changes: 7 additions & 18 deletions src/platform/input/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { EventHandler } from '../../core/event-handler.js';

import { isMousePointerLocked, MouseEvent } from './mouse-event.js';

/**
* @import { MouseButton } from './mouse-button.js';
*/

/**
* @callback LockMouseCallback
* Callback used by {@link Mouse#enablePointerLock} and {@link Mouse#disablePointerLock}.
Expand Down Expand Up @@ -245,12 +249,7 @@ class Mouse extends EventHandler {
/**
* Returns true if the mouse button is currently pressed.
*
* @param {number} button - The mouse button to test. Can be:
*
* - {@link MOUSEBUTTON_LEFT}
* - {@link MOUSEBUTTON_MIDDLE}
* - {@link MOUSEBUTTON_RIGHT}
*
* @param {MouseButton} button - The mouse button to test.
* @returns {boolean} True if the mouse button is current pressed.
*/
isPressed(button) {
Expand All @@ -260,12 +259,7 @@ class Mouse extends EventHandler {
/**
* Returns true if the mouse button was pressed this frame (since the last call to update).
*
* @param {number} button - The mouse button to test. Can be:
*
* - {@link MOUSEBUTTON_LEFT}
* - {@link MOUSEBUTTON_MIDDLE}
* - {@link MOUSEBUTTON_RIGHT}
*
* @param {MouseButton} button - The mouse button to test.
* @returns {boolean} True if the mouse button was pressed since the last update.
*/
wasPressed(button) {
Expand All @@ -275,12 +269,7 @@ class Mouse extends EventHandler {
/**
* Returns true if the mouse button was released this frame (since the last call to update).
*
* @param {number} button - The mouse button to test. Can be:
*
* - {@link MOUSEBUTTON_LEFT}
* - {@link MOUSEBUTTON_MIDDLE}
* - {@link MOUSEBUTTON_RIGHT}
*
* @param {MouseButton} button - The mouse button to test.
* @returns {boolean} True if the mouse button was released since the last update.
*/
wasReleased(button) {
Expand Down
Loading