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
This commit is contained in:
Jordan Woyak
2010-08-10 04:12:32 +00:00
parent a1daa636c2
commit 2b45e87b3e
9 changed files with 603 additions and 417 deletions

View File

@ -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);
}
void Pop()
{
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
}
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;
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
t = Front();
Pop();
return true;
}
bool Peek(T& t)
// not thread-safe
void Clear()
{
// 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;
return true;
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;
};
}