Defines a set of haptic feedback patterns that can be requested.

const MotionControllerModule = require("LensStudio:MotionControllerModule")

@component
export class NewScript extends BaseScriptComponent {

private controller: MotionController
private feedbackId: number = 0

onAwake() {
var options = MotionController.Options.create()
options.motionType = MotionController.MotionType.SixDoF

this.controller = MotionControllerModule.getController(options)

this.controller.onTouchEvent.add(this.testHapticFeedback.bind(this));
}
testHapticFeedback(normalizedPosition, touchId, timestampMs, phase) {

if (phase != MotionController.TouchPhase.Began) {
//we only want to trigger the feedback on touch start
return;
}
this.feedbackId = (this.feedbackId + 1) % 8
var request = MotionController.HapticRequest.create()
switch (this.feedbackId) {
case 0:
request.hapticFeedback = MotionController.HapticFeedback.Default
print("Default")
break
case 1:
request.hapticFeedback = MotionController.HapticFeedback.Tick
print("Tick")
break
case 2:
request.hapticFeedback = MotionController.HapticFeedback.Select
print("Select")
break
case 3:
request.hapticFeedback = MotionController.HapticFeedback.Success
print("Success")
break
case 4:
request.hapticFeedback = MotionController.HapticFeedback.Error
print("Error")
break
case 5:
request.hapticFeedback = MotionController.HapticFeedback.VibrationLow
print("Vibration Low")
break
case 6:
request.hapticFeedback = MotionController.HapticFeedback.VibrationMedium
print("Vibration Medium")
break
case 7:
request.hapticFeedback = MotionController.HapticFeedback.VibrationHigh
print("Vibration High")
break
default:
print("Unknown feedbackId = " + this.feedbackId)
}
request.duration = 0.3
this.controller.invokeHaptic(request)
}
}

Enumeration Members

Default: number

Default value, same as Tick.

Error: number

A negative haptic pattern indicating that an action failed or encountered an issue.

Select: number

A subtle haptic effect used to confirm a selection or interaction.

Success: number

A positive haptic pattern indicating that an action was completed successfully.

Tick: number

A brief, single haptic effect that simulates a ticking or clicking sensation

VibrationHigh: number

A strong vibration for more pronounced feedback.

VibrationLow: number

A gentle vibration for less intense feedback.

VibrationMedium: number

A moderate vibration for standard feedback intensity.