| 38 | } |
| 39 | |
| 40 | float HapticsBuffer::GetSample() |
| 41 | { |
| 42 | if (m_ConstantTimeout > 0) |
| 43 | { |
| 44 | m_ConstantMutex.lock(); |
| 45 | float sample = m_Amplitude; |
| 46 | if (m_Frequency <= 0.5f && m_ConstantTimeout % 2 == 0) |
| 47 | sample = 0.0f; |
| 48 | m_ConstantMutex.unlock(); |
| 49 | |
| 50 | m_ConstantTimeout--; |
| 51 | return sample; |
| 52 | } |
| 53 | |
| 54 | // We can't pass the write index, so the buffer is now empty |
| 55 | if (m_ReadIndex + 1 == m_WriteIndex) |
| 56 | return 0.0f; |
| 57 | |
| 58 | // Index will overflow correctly, so no need for a modulo operator |
| 59 | uint8_t sample = m_Buffer[++m_ReadIndex]; |
| 60 | |
| 61 | return sample / 255.0f; |
| 62 | } |
| 63 | |
| 64 | ovrHapticsPlaybackState HapticsBuffer::GetState() |
| 65 | { |