export type PointerInputMode = 'controller'; export type PointerInputModeCarrier = { controller?: { userData?: any; }; pointerInputMode?: PointerInputMode; }; export function rememberPointerInputMode( inputSource: PointerInputModeCarrier, event: any, fallbackMode: PointerInputMode ): void { const eventInputSource = event?.data?.inputSource || event?.inputSource || event?.data; const nextMode = getPointerInputMode(eventInputSource) || fallbackMode; inputSource.pointerInputMode = nextMode; if (!inputSource.controller) { return; } inputSource.controller.userData = { ...inputSource.controller.userData, vrwpInputSource: inputSource }; } export function getPointerInputMode(eventInputSource: any): PointerInputMode | null { if (!eventInputSource) { return null; } if (eventInputSource.gamepad || eventInputSource.targetRayMode === 'tracked-pointer') { return 'controller'; } return null; }