Fix undetected CIDs
This commit is contained in:
		@@ -79,20 +79,23 @@ ReprogControls::ControlInfo ReprogControls::getControlInfo(uint8_t index)
 | 
			
		||||
    return info;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ReprogControls::initCidMap()
 | 
			
		||||
{
 | 
			
		||||
    std::unique_lock<std::mutex> lock(_cids_populating);
 | 
			
		||||
    if(_cids_initialized)
 | 
			
		||||
        return;
 | 
			
		||||
    uint8_t controls = getControlCount();
 | 
			
		||||
    for(uint8_t i = 0; i < controls; i++) {
 | 
			
		||||
        auto info = getControlInfo(i);
 | 
			
		||||
        _cids.emplace(info.controlID, info);
 | 
			
		||||
    }
 | 
			
		||||
    _cids_initialized = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ReprogControls::ControlInfo ReprogControls::getControlIdInfo(uint16_t cid)
 | 
			
		||||
{
 | 
			
		||||
    if(!_cids_initialized) {
 | 
			
		||||
        std::unique_lock<std::mutex> lock(_cids_populating);
 | 
			
		||||
        if(!_cids_initialized) {
 | 
			
		||||
            uint8_t controls = getControlCount();
 | 
			
		||||
            for(uint8_t i = 0; i < controls; i++) {
 | 
			
		||||
                auto info = getControlInfo(i);
 | 
			
		||||
                _cids.emplace(info.controlID, info);
 | 
			
		||||
            }
 | 
			
		||||
            _cids_populating.unlock();
 | 
			
		||||
            _cids_initialized = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if(!_cids_initialized)
 | 
			
		||||
        initCidMap();
 | 
			
		||||
 | 
			
		||||
    auto it = _cids.find(cid);
 | 
			
		||||
    if(it == _cids.end())
 | 
			
		||||
 
 | 
			
		||||
@@ -95,6 +95,8 @@ namespace hidpp20
 | 
			
		||||
 | 
			
		||||
        virtual ControlInfo getControlIdInfo(uint16_t cid);
 | 
			
		||||
 | 
			
		||||
        virtual void initCidMap();
 | 
			
		||||
 | 
			
		||||
        // Onlu controlId and flags will be set
 | 
			
		||||
        virtual ControlInfo getControlReporting(uint16_t cid);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,7 @@ using namespace logid::actions;
 | 
			
		||||
RemapButton::RemapButton(Device *dev): DeviceFeature(dev), _config (dev),
 | 
			
		||||
    _reprog_controls (hidpp20::ReprogControls::autoVersion(&dev->hidpp20()))
 | 
			
		||||
{
 | 
			
		||||
    _reprog_controls->initCidMap();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RemapButton::~RemapButton()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user