Fix bluetooth reconnection events
This commit is contained in:
parent
ac414bf33e
commit
0002d9f536
|
@ -193,9 +193,15 @@ void Device::set_dpi(int dpi)
|
||||||
void Device::start()
|
void Device::start()
|
||||||
{
|
{
|
||||||
configure();
|
configure();
|
||||||
listener->addEventHandler( std::make_unique<ButtonHandler>(hidpp_dev, this) );
|
try { listener->addEventHandler(std::make_unique<ButtonHandler>(this)); }
|
||||||
|
catch(HIDPP20::UnsupportedFeature &e) { }
|
||||||
if(index != HIDPP::DefaultDevice && index != HIDPP::CordedDevice)
|
if(index != HIDPP::DefaultDevice && index != HIDPP::CordedDevice)
|
||||||
listener->addEventHandler( std::make_unique<ReceiverHandler>(this) );
|
listener->addEventHandler( std::make_unique<ReceiverHandler>(this) );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try { listener->addEventHandler( std::make_unique<WirelessStatusHandler>(this) ); }
|
||||||
|
catch(HIDPP20::UnsupportedFeature &e) { }
|
||||||
|
}
|
||||||
listener->start();
|
listener->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +280,25 @@ void ReceiverHandler::handleEvent(const HIDPP::Report &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WirelessStatusHandler::handleEvent(const HIDPP::Report &event)
|
||||||
|
{
|
||||||
|
switch(event.function())
|
||||||
|
{
|
||||||
|
case HIDPP20::IWirelessDeviceStatus::StatusBroadcast:
|
||||||
|
{
|
||||||
|
auto status = HIDPP20::IWirelessDeviceStatus::statusBroadcastEvent(event);
|
||||||
|
if(status.ReconfNeeded)
|
||||||
|
dev->configure();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
log_printf(DEBUG, "Undocumented event %02x from WirelessDeviceStatus", event.function());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EventListener::removeEventHandlers ()
|
void EventListener::removeEventHandlers ()
|
||||||
{
|
{
|
||||||
for (const auto &p: iterators)
|
for (const auto &p: iterators)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <hidpp/Dispatcher.h>
|
#include <hidpp/Dispatcher.h>
|
||||||
#include <hidpp/SimpleDispatcher.h>
|
#include <hidpp/SimpleDispatcher.h>
|
||||||
#include <hidpp10/IReceiver.h>
|
#include <hidpp10/IReceiver.h>
|
||||||
|
#include <hidpp20/IWirelessDeviceStatus.h>
|
||||||
|
|
||||||
class EventListener;
|
class EventListener;
|
||||||
class DeviceConfig;
|
class DeviceConfig;
|
||||||
|
@ -68,15 +69,15 @@ public:
|
||||||
class ButtonHandler : public EventHandler
|
class ButtonHandler : public EventHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ButtonHandler (HIDPP20::Device *hidppdev, Device *d) : _irc (HIDPP20::IReprogControls::auto_version(hidppdev)), dev (d) { }
|
ButtonHandler (Device *d) : dev (d), _irc (HIDPP20::IReprogControls::auto_version(d->hidpp_dev)) { }
|
||||||
const HIDPP20::FeatureInterface *feature () const
|
const HIDPP20::FeatureInterface *feature () const
|
||||||
{
|
{
|
||||||
return &_irc;
|
return &_irc;
|
||||||
}
|
}
|
||||||
void handleEvent (const HIDPP::Report &event);
|
void handleEvent (const HIDPP::Report &event);
|
||||||
protected:
|
protected:
|
||||||
HIDPP20::IReprogControls _irc;
|
|
||||||
Device* dev;
|
Device* dev;
|
||||||
|
HIDPP20::IReprogControls _irc;
|
||||||
std::vector<uint16_t> states;
|
std::vector<uint16_t> states;
|
||||||
std::vector<uint16_t> new_states;
|
std::vector<uint16_t> new_states;
|
||||||
};
|
};
|
||||||
|
@ -96,6 +97,19 @@ public:
|
||||||
protected:
|
protected:
|
||||||
Device* dev;
|
Device* dev;
|
||||||
};
|
};
|
||||||
|
class WirelessStatusHandler : public EventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WirelessStatusHandler (Device *d) : dev (d), _iws (d->hidpp_dev) { }
|
||||||
|
const HIDPP20::FeatureInterface *feature () const
|
||||||
|
{
|
||||||
|
return &_iws;
|
||||||
|
}
|
||||||
|
void handleEvent (const HIDPP::Report &event);
|
||||||
|
protected:
|
||||||
|
Device* dev;
|
||||||
|
HIDPP20::IWirelessDeviceStatus _iws;
|
||||||
|
};
|
||||||
|
|
||||||
class EventListener
|
class EventListener
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user