acquire method

VrInputEvent acquire({
  1. required VrInputType type,
  2. required VrInputSource source,
  3. required int timestampMicrosecondsSinceEpoch,
  4. String? targetId,
  5. Map<String, dynamic>? data,
  6. bool active = true,
})

Implementation

VrInputEvent acquire({
  required VrInputType type,
  required VrInputSource source,
  required int timestampMicrosecondsSinceEpoch,
  String? targetId,
  Map<String, dynamic>? data,
  bool active = true,
}) {
  if (_freeSlots.isEmpty) {
    throw StateError(
      'VrInputEventPool exhausted ($capacity events are already in use).',
    );
  }

  final slot = _freeSlots.removeLast();
  final event = _events[slot];
  event._checkedOut = true;
  event.resetForReuse(
    type: type,
    source: source,
    targetId: targetId,
    data: data,
    active: active,
    timestampMicrosecondsSinceEpoch: timestampMicrosecondsSinceEpoch,
  );

  _inUseCount++;
  _totalAcquisitions++;
  if (_inUseCount > _peakInUse) _peakInUse = _inUseCount;
  return event;
}