internal static void NativeTouchFullCallback(NativeTouchDataFull ntd) { switch (ntd.CallbackType) { case TouchPhase.Began: fullCallbacksBegan.Invoke(ntd); break; case TouchPhase.Ended: fullCallbacksEnded.Invoke(ntd); break; case TouchPhase.Canceled: fullCallbacksCancelled.Invoke(ntd); break; case TouchPhase.Moved: fullCallbacksMoved.Invoke(ntd); break; } }
/// <summary> /// Read the data at current cursor on the ring buffer then move forward by 1. /// /// If too many touches had passed that it loops over the ring buffer and overwritten your current cursor position, /// this read automatically change the cursor to be the earliest touch and start from there. /// </summary> /// <param name="ntdf">When returning `false`, this is a `default` value and should not be used.</param> /// <returns>`true` when there is a remaining touch to get. This is to be used with `while` loop.</returns> /// <exception cref="InvalidOperationException">Thrown when you use this while not in <see cref="NativeTouch.StartOption.fullMode">.</exception> public bool TryGetAndMoveNextFull(out NativeTouchDataFull ntdf) { if (NativeTouch.IsFullMode == false) { throw new InvalidOperationException("You cannot TryGetAndMoveNextFull() while Native Touch is in minimal mode. Use TryGetAndMoveNext() instead."); } EnterCriticalSection(); CatchUpIfRequired(); if (currentCursor < NativeTouch.finalCursor) { int getIndex = currentCursor % NativeTouch.activeRingBufferSize; ntdf = NativeTouch.ntdFullRingBuffer[getIndex]; ExitCriticalSection(); currentCursor++; return(true); } else { ExitCriticalSection(); ntdf = default(NativeTouchDataFull); return(false); } }
internal static void NativeTouchFullCallbackRingBuffer(int start, int count) { int currentIndex = start; do { //No mutex is required for this read, since this continues immediately after the native side itself writes. No one else could be writing at this moment. NativeTouchDataFull ntd = NativeTouch.ntdFullRingBuffer[currentIndex]; switch (ntd.CallbackType) { case TouchPhase.Began: fullCallbacksBegan.Invoke(ntd); break; case TouchPhase.Ended: fullCallbacksEnded.Invoke(ntd); break; case TouchPhase.Canceled: fullCallbacksCancelled.Invoke(ntd); break; case TouchPhase.Moved: fullCallbacksMoved.Invoke(ntd); break; } currentIndex = (currentIndex + 1) % NativeTouch.activeRingBufferSize; count--; }while (count > 0); }