| 8 | } |
| 9 | |
| 10 | void HapticsBuffer::AddSamples(const ovrHapticsBuffer* buffer) |
| 11 | { |
| 12 | // Force constant vibration off |
| 13 | m_ConstantTimeout = 0; |
| 14 | |
| 15 | uint8_t* samples = (uint8_t*)buffer->Samples; |
| 16 | |
| 17 | for (int i = 0; i < buffer->SamplesCount; i++) |
| 18 | { |
| 19 | if (m_WriteIndex == m_ReadIndex) |
| 20 | return; |
| 21 | |
| 22 | m_Buffer[m_WriteIndex] = samples[i]; |
| 23 | |
| 24 | // We increment the atomic here as a memory barrier |
| 25 | // Index will overflow correctly, so no need for a modulo operator |
| 26 | m_WriteIndex++; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | void HapticsBuffer::SetConstant(float frequency, float amplitude) |
| 31 | { |