diff options
author | David Chiu <dchiu@synaptics.com> | 2022-02-23 15:33:10 +0800 |
---|---|---|
committer | Vincent Huang <vincenthsw@gmail.com> | 2022-03-01 10:02:08 +0800 |
commit | 115762374d337c515587a02a387a845a4d6bdb6b (patch) | |
tree | 7183ef72ca71ae52a7cddf1e4eef25a31d453d55 | |
parent | 8809cf56b01cf3c613bd631986945aba80a6aca1 (diff) | |
download | rmi4utils-115762374d337c515587a02a387a845a4d6bdb6b.tar.gz |
Use the feature of toggling interrupts if it exists this feature report.
-rwxr-xr-x | rmidevice/hiddevice.cpp | 22 | ||||
-rwxr-xr-x | rmidevice/hiddevice.h | 5 |
2 files changed, 20 insertions, 7 deletions
diff --git a/rmidevice/hiddevice.cpp b/rmidevice/hiddevice.cpp index f55dc3a..d5e5176 100755 --- a/rmidevice/hiddevice.cpp +++ b/rmidevice/hiddevice.cpp @@ -40,6 +40,8 @@ #define RMI_READ_DATA_REPORT_ID 0xb // Input Report #define RMI_ATTN_REPORT_ID 0xc // Input Report #define RMI_SET_RMI_MODE_REPORT_ID 0xf // Feature Report +#define RMI_SET_LID_MODE_REPORT_ID 0xe // Feature Report + enum hid_report_type { HID_REPORT_TYPE_UNKNOWN = 0x0, @@ -218,6 +220,10 @@ void HIDDevice::ParseReportDescriptor() continue; } + if (m_rptDesc.value[i] == RMI_SET_LID_MODE_REPORT_ID) { + hasVendorDefineLIDMode = true; + } + if (m_rptDesc.value[i] == HID_REPORT_TYPE_INPUT) hidReportType = HID_REPORT_TYPE_INPUT; @@ -421,7 +427,7 @@ int HIDDevice::SetMode(int mode) if (!m_deviceOpen) return -1; - buf[0] = 0xF; + buf[0] = RMI_SET_RMI_MODE_REPORT_ID; buf[1] = mode; rc = ioctl(m_fd, HIDIOCSFEATURE(2), buf); if (rc < 0) { @@ -437,19 +443,23 @@ int HIDDevice::ToggleInterruptMask(bool enable) int rc; char buf[2]; - // Not use this feature temporarily. Need more implementation to check whether it - // exists this feature in device. - return 0; - if (GetDeviceType() != RMI_DEVICE_TYPE_TOUCHPAD) { fprintf(stdout, "Not TP, skip toggle interrupts mask\n"); return 0; } + + // We can have information to see whether it exists this feature report currentlt. + // However, it might have no action even we set this feature with specific value. + // Need FW team's help to query more information about the existence of functions. + if (!hasVendorDefineLIDMode) { + fprintf(stdout, "no LID mode feature, return\n"); + return 0; + } if (!m_deviceOpen) return -1; - buf[0] = 0xE; + buf[0] = RMI_SET_LID_MODE_REPORT_ID; if (enable) { buf[1] = 0; } else { diff --git a/rmidevice/hiddevice.h b/rmidevice/hiddevice.h index 5a01edb..7ee5e1b 100755 --- a/rmidevice/hiddevice.h +++ b/rmidevice/hiddevice.h @@ -41,7 +41,8 @@ public: m_mode(HID_RMI4_MODE_ATTN_REPORTS), m_initialMode(HID_RMI4_MODE_MOUSE), m_transportDeviceName(""), - m_driverPath("") + m_driverPath(""), + hasVendorDefineLIDMode(false) {} virtual int Open(const char * filename); virtual int Read(unsigned short addr, unsigned char *buf, @@ -88,6 +89,8 @@ private: std::string m_transportDeviceName; std::string m_driverPath; + bool hasVendorDefineLIDMode; + int GetReport(int *reportId, struct timeval * timeout = NULL); void PrintReport(const unsigned char *report); void ParseReportDescriptor(); |