Smart pointer usage for input device handle

This commit is contained in:
Jack Andersen 2017-05-08 09:13:18 -10:00
parent d584df8f5f
commit 98142731d8
2 changed files with 4 additions and 4 deletions

View File

@ -172,20 +172,20 @@ public:
* using the relevant OS API. This thread blocks in a loop until an event is
* received. Device pointers should only be manipulated by this thread using
* the deviceConnected() and deviceDisconnected() callbacks. */
std::unique_ptr<boo::DolphinSmashAdapter> smashAdapter = NULL;
std::shared_ptr<boo::DolphinSmashAdapter> smashAdapter;
void deviceConnected(boo::DeviceToken& tok)
{
/* Device listener thread */
if (!smashAdapter)
{
smashAdapter.reset(dynamic_cast<boo::DolphinSmashAdapter*>(tok.openAndGetDevice()));
smashAdapter = std::dynamic_pointer_cast<boo::DolphinSmashAdapter>(tok.openAndGetDevice());
smashAdapter->setCallback(&m_dolphinCb);
}
}
void deviceDisconnected(boo::DeviceToken&, boo::DeviceBase* device)
{
if (smashAdapter.get() == device)
smashAdapter.reset(nullptr);
smashAdapter.reset();
}
void SetMotorState(EIOPort port, EMotorState state)
{

2
hecl

@ -1 +1 @@
Subproject commit 1327e4b4e8da8275e5a765e9a49802669df36fd8
Subproject commit 2d12cfe0d870fa80345e27b9185bd19d3bce0cd8