diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2010-08-10 04:12:32 +0000 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2010-08-10 04:12:32 +0000 |
| commit | 2b45e87b3ed270f130dc3263b009af6df9cb0e90 (patch) | |
| tree | de1b6b3d1bcb5799c864c3925d045c6088455137 /Source/Core | |
| parent | a1daa636c267eceba1c0d4ea199f72ab4a455f81 (diff) | |
New Wiimote Plugin: Added a "Hybrid Wiimote" input source type. This allows a real wiimote to be used with an emulated extension.(and in the future, real wiimote with emulated motion plus) If the emulated extension is set to "None", a real extension can be used. Real/Emulated buttons are combined. Real acceleration data is used. Currently, emulated IR data is used.(might change this to allow both) Switching between an emulated and a real extension in-game is a bit testy right now, but if you switch the emu-extension to "None" before connecting a real extension, it usually works.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6082 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/Src/FifoQueue.h | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/Source/Core/Common/Src/FifoQueue.h b/Source/Core/Common/Src/FifoQueue.h index 380f4f6da4..2060ceee92 100644 --- a/Source/Core/Common/Src/FifoQueue.h +++ b/Source/Core/Common/Src/FifoQueue.h @@ -5,6 +5,8 @@ // a simple lockless thread-safe, // single reader, single writer queue +#include "Atomic.h" + namespace Common { @@ -12,7 +14,7 @@ template <typename T> class FifoQueue { public: - FifoQueue() + FifoQueue() : m_size(0) { m_write_ptr = m_read_ptr = new ElementPtr(); } @@ -23,9 +25,20 @@ public: delete m_read_ptr; } - bool Empty() const // true if the queue is empty + u32 Size() const { - return (m_read_ptr == m_write_ptr); + return m_size; + } + + bool Empty() const + { + //return (m_read_ptr == m_write_ptr); + return (0 == m_size); + } + + const T& Front() const + { + return *m_read_ptr->current; } void Push(const T& t) @@ -35,42 +48,41 @@ public: // set the next pointer to a new element ptr // then advance the write pointer m_write_ptr = m_write_ptr->next = new ElementPtr(); + Common::AtomicIncrement(m_size); } - bool Pop(T& t) + void Pop() { - // if write pointer points to the same element, queue is empty - if (m_read_ptr == m_write_ptr) - return false; - - // get the element from out of the queue - t = *m_read_ptr->current; - + Common::AtomicDecrement(m_size); ElementPtr *const tmpptr = m_read_ptr; // advance the read pointer m_read_ptr = m_read_ptr->next; - // set the next element to NULL to stop the recursive deletion tmpptr->next = NULL; delete tmpptr; // this also deletes the element - - return true; } - bool Peek(T& t) + bool Pop(T& t) { - // if write pointer points to the same element, queue is empty - if (m_read_ptr == m_write_ptr) + if (Empty()) return false; - // get the element from out of the queue - t = *m_read_ptr->current; + t = Front(); + Pop(); return true; } + // not thread-safe + void Clear() + { + m_size = 0; + delete m_read_ptr; + m_write_ptr = m_read_ptr = new ElementPtr(); + } + private: - // stores a pointer to element at front of queue + // stores a pointer to element // and a pointer to the next ElementPtr class ElementPtr { @@ -94,6 +106,7 @@ private: ElementPtr *volatile m_write_ptr; ElementPtr *volatile m_read_ptr; + volatile u32 m_size; }; } |
