Skip to content

Commit a7a97dd

Browse files
authored
Merge pull request #18 from ProjectLighthouseCAU/movement
Extend MouseEvent with fields for movement and pointer lock
2 parents 77db0a0 + bb4eda7 commit a7a97dd

File tree

1 file changed

+11
-2
lines changed
  • src/common/protocol/input

1 file changed

+11
-2
lines changed

src/common/protocol/input/new.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,24 @@ export interface KeyModifiers {
3434
export interface MouseEvent extends BaseInputEvent<'mouse'> {
3535
/** Whether the button was pressed. */
3636
down: boolean;
37+
/** Whether the mouse pointer was locked (e.g. to the frontend's canvas). */
38+
pointerLocked: boolean;
3739
/** The mouse button. */
3840
button: 'left' | 'middle' | 'right'; // TODO: Support more buttons
3941
/** The position. */
4042
pos: {
41-
/** The x-coordinate in range 0-28. */
43+
/** The x-coordinate in terms of lighthouse columns, i.e. in the range 0-28. */
4244
x: number;
43-
/** The y-coordinate in range 0-14. */
45+
/** The y-coordinate in terms of lighthouse rows, i.e. in the range 0-14. */
4446
y: number;
4547
};
48+
/** The movement of the mouse position. Useful e.g. for pointer-locked apps like games. */
49+
movement: {
50+
/** The movement on the x-axis. Expressed in terms of lighthouse columns, but may be negative. */
51+
x: number;
52+
/** The movement on the y-axis. Expressed in terms of lighthouse rows, but may be negative. */
53+
y: number;
54+
},
4655
}
4756

4857
/** Base type for gamepad/controller payloads. */

0 commit comments

Comments
 (0)