Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
added config flag EnableXRControllerInput for enabling/disabling XR c…
Browse files Browse the repository at this point in the history
…ontroller messages
  • Loading branch information
hmuurine committed Mar 3, 2023
1 parent 64b564d commit 71daadf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
12 changes: 12 additions & 0 deletions Frontend/library/src/Config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Flags {
static EnableMouseInput = 'EnableMouseInput' as const;
static EnableTouchInput = 'EnableTouchInput' as const;
static EnableGamePadInput = 'EnableGamePadInput' as const;
static EnableXRControllerInput = 'EnableXRControllerInput' as const;
}

export type FlagsKeys = Exclude<keyof typeof Flags, 'prototype'>;
Expand Down Expand Up @@ -446,6 +447,17 @@ export class Config {
)
);

this.flags.set(
Flags.EnableXRControllerInput,
new SettingFlag(
Flags.EnableXRControllerInput,
'Enable XR controller input',
'If enabled, send XR controller events to streamer',
true,
useUrlParams
)
);

/**
* Numeric parameters
*/
Expand Down
23 changes: 13 additions & 10 deletions Frontend/library/src/WebXR/WebXRController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { WebGLUtils } from '../Util/WebGLUtils';
import { Controller } from '../Inputs/GamepadTypes';
import { XRGamepadController } from '../Inputs/XRGamepadController';
import { XrFrameEvent } from '../Util/EventEmitter'
import { Flags } from '../pixelstreamingfrontend';

export class WebXRController {
private xrSession: XRSession;
Expand Down Expand Up @@ -190,16 +191,18 @@ export class WebXRController {
this.render(this.webRtcController.videoPlayer.getVideoElement());
}

this.xrSession.inputSources.forEach(
(source: XRInputSource, index: number, array: XRInputSource[]) => {
this.xrGamepadController.updateStatus(
source,
frame,
this.xrRefSpace
);
},
this
);
if (this.webRtcController.config.isFlagEnabled(Flags.EnableXRControllerInput)) {
this.xrSession.inputSources.forEach(
(source: XRInputSource, index: number, array: XRInputSource[]) => {
this.xrGamepadController.updateStatus(
source,
frame,
this.xrRefSpace
);
},
this
);
}

this.xrSession.requestAnimationFrame(
(time: DOMHighResTimeStamp, frame: XRFrame) =>
Expand Down
5 changes: 5 additions & 0 deletions Frontend/ui-library/src/Config/ConfigUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ export class ConfigUI {
this.flagsUi.get(Flags.EnableGamePadInput)
);

this.addSettingFlag(
viewSettingsSection,
this.flagsUi.get(Flags.EnableXRControllerInput)
);

this.addSettingFlag(viewSettingsSection, this.flagsUi.get(LightMode));

/* Setup all encoder related settings under this section */
Expand Down

0 comments on commit 71daadf

Please sign in to comment.