Print CIDs on device connect
This commit is contained in:
		@@ -92,6 +92,12 @@ void ReprogControls::initCidMap()
 | 
				
			|||||||
    _cids_initialized = true;
 | 
					    _cids_initialized = true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const std::map<uint16_t, ReprogControls::ControlInfo>&
 | 
				
			||||||
 | 
					        ReprogControls::getControls() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return _cids;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ReprogControls::ControlInfo ReprogControls::getControlIdInfo(uint16_t cid)
 | 
					ReprogControls::ControlInfo ReprogControls::getControlIdInfo(uint16_t cid)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if(!_cids_initialized)
 | 
					    if(!_cids_initialized)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,6 +97,8 @@ namespace hidpp20
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        virtual void initCidMap();
 | 
					        virtual void initCidMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const std::map<uint16_t, ControlInfo>& getControls() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Onlu controlId and flags will be set
 | 
					        // Onlu controlId and flags will be set
 | 
				
			||||||
        virtual ControlInfo getControlReporting(uint16_t cid);
 | 
					        virtual ControlInfo getControlReporting(uint16_t cid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -311,7 +311,7 @@ std::vector<uint8_t> RawDevice::_respondToReport
 | 
				
			|||||||
int RawDevice::_sendReport(const std::vector<uint8_t>& report)
 | 
					int RawDevice::_sendReport(const std::vector<uint8_t>& report)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    std::lock_guard<std::mutex> lock(_dev_io);
 | 
					    std::lock_guard<std::mutex> lock(_dev_io);
 | 
				
			||||||
    if(logid::global_loglevel == LogLevel::RAWREPORT) {
 | 
					    if(logid::global_loglevel <= LogLevel::RAWREPORT) {
 | 
				
			||||||
        printf("[RAWREPORT] %s OUT: ", _path.c_str());
 | 
					        printf("[RAWREPORT] %s OUT: ", _path.c_str());
 | 
				
			||||||
        for(auto &i : report)
 | 
					        for(auto &i : report)
 | 
				
			||||||
            printf("%02x ", i);
 | 
					            printf("%02x ", i);
 | 
				
			||||||
@@ -389,7 +389,7 @@ int RawDevice::_readReport(std::vector<uint8_t> &report,
 | 
				
			|||||||
    if(0 == ret)
 | 
					    if(0 == ret)
 | 
				
			||||||
        throw backend::TimeoutError();
 | 
					        throw backend::TimeoutError();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(logid::global_loglevel == LogLevel::RAWREPORT) {
 | 
					    if(logid::global_loglevel <= LogLevel::RAWREPORT) {
 | 
				
			||||||
        printf("[RAWREPORT] %s IN:  ", _path.c_str());
 | 
					        printf("[RAWREPORT] %s IN:  ", _path.c_str());
 | 
				
			||||||
        for(auto &i : report)
 | 
					        for(auto &i : report)
 | 
				
			||||||
            printf("%02x ", i);
 | 
					            printf("%02x ", i);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,25 @@ RemapButton::RemapButton(Device *dev): DeviceFeature(dev), _config (dev),
 | 
				
			|||||||
    _reprog_controls (hidpp20::ReprogControls::autoVersion(&dev->hidpp20()))
 | 
					    _reprog_controls (hidpp20::ReprogControls::autoVersion(&dev->hidpp20()))
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    _reprog_controls->initCidMap();
 | 
					    _reprog_controls->initCidMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(global_loglevel <= DEBUG) {
 | 
				
			||||||
 | 
					        #define FLAG(x) control.second.flags & hidpp20::ReprogControls::x ? \
 | 
				
			||||||
 | 
					            "YES" : ""
 | 
				
			||||||
 | 
					        #define ADDITIONAL_FLAG(x) control.second.additionalFlags & \
 | 
				
			||||||
 | 
					            hidpp20::ReprogControls::x ? "YES" : ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Print CIDs, originally by zv0n
 | 
				
			||||||
 | 
					        logPrintf(DEBUG,  "%s:%d remappable buttons:",
 | 
				
			||||||
 | 
					                dev->hidpp20().devicePath().c_str(),
 | 
				
			||||||
 | 
					                dev->hidpp20().deviceIndex());
 | 
				
			||||||
 | 
					        logPrintf(DEBUG, "CID  | reprog? | fn key? | mouse key? | "
 | 
				
			||||||
 | 
					                         "gesture support?");
 | 
				
			||||||
 | 
					        for(const auto & control : _reprog_controls->getControls())
 | 
				
			||||||
 | 
					                logPrintf(DEBUG, "0x%02x | %-7s | %-7s | %-10s | %s",
 | 
				
			||||||
 | 
					                        control.first, FLAG(TemporaryDivertable), FLAG(FKey),
 | 
				
			||||||
 | 
					                        FLAG(MouseButton), ADDITIONAL_FLAG(RawXY));
 | 
				
			||||||
 | 
					        #undef FLAG
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RemapButton::~RemapButton()
 | 
					RemapButton::~RemapButton()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user