2021-03-29 08:10:55 +00:00
|
|
|
#include <Arduino.h>
|
2019-05-10 05:17:29 +00:00
|
|
|
#include "./Input.h"
|
|
|
|
#include "./MainLoop.h"
|
|
|
|
|
2021-03-29 08:10:55 +00:00
|
|
|
CRGB
|
2019-05-10 05:17:29 +00:00
|
|
|
Variant::asRGB() const
|
|
|
|
{
|
2021-03-29 08:10:55 +00:00
|
|
|
return CRGB(m_value.asRGB[0], m_value.asRGB[1], m_value.asRGB[2]);
|
2019-05-10 05:17:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
Variant::asString() const
|
|
|
|
{
|
|
|
|
return m_value.asString;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Variant::asInt() const
|
|
|
|
{
|
|
|
|
return m_value.asInt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
InputSource::loop()
|
|
|
|
{
|
|
|
|
MainLoop::instance()->dispatch(read());
|
|
|
|
}
|
|
|
|
|
|
|
|
InputEvent
|
|
|
|
BufferedInputSource::read()
|
|
|
|
{
|
2021-03-28 21:50:31 +00:00
|
|
|
InputEvent ret;
|
|
|
|
m_eventQueue.take(ret);
|
2019-05-10 05:17:29 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BufferedInputSource::setEvent(InputEvent &&evt)
|
|
|
|
{
|
2021-03-28 21:50:31 +00:00
|
|
|
m_eventQueue.insert(std::move(evt));
|
2019-05-10 05:17:29 +00:00
|
|
|
}
|
2021-03-28 01:19:55 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
BufferedInputSource::setEvent(InputEvent::Intent intent, Variant &&v)
|
|
|
|
{
|
2021-03-28 21:50:31 +00:00
|
|
|
m_eventQueue.insert(InputEvent{intent, std::move(v)});
|
2021-03-28 01:19:55 +00:00
|
|
|
}
|