///////////////////////////////////////////////////////
| 193 | |
| 194 | //////////////////////////////////////////////////////////// |
| 195 | std::optional<JniInputDevice> JniInputDeviceClass::getDevice(jint idx) |
| 196 | { |
| 197 | jmethodID getNameMethod = m_env.GetMethodID(m_inputDeviceClass, "getName", "()Ljava/lang/String;"); |
| 198 | jmethodID getVendorIdMethod = m_env.GetMethodID(m_inputDeviceClass, "getVendorId", "()I"); |
| 199 | jmethodID getProductIdMethod = m_env.GetMethodID(m_inputDeviceClass, "getProductId", "()I"); |
| 200 | jmethodID supportsSourceMethod = m_env.GetMethodID(m_inputDeviceClass, "supportsSource", "(I)Z"); |
| 201 | jmethodID getMotionRangesMethod = m_env.GetMethodID(m_inputDeviceClass, "getMotionRanges", "()Ljava/util/List;"); |
| 202 | |
| 203 | if (!getNameMethod || !getVendorIdMethod || !getProductIdMethod || !supportsSourceMethod || !getMotionRangesMethod) |
| 204 | { |
| 205 | err() << "Could not locate required InputDevice methods" << std::endl; |
| 206 | return std::nullopt; |
| 207 | } |
| 208 | |
| 209 | jobject inputDevice = m_env.CallStaticObjectMethod(m_inputDeviceClass, m_getDeviceMethod, idx); |
| 210 | if (!inputDevice) |
| 211 | { |
| 212 | // Can happen normally, no log needed |
| 213 | return std::nullopt; |
| 214 | } |
| 215 | |
| 216 | return JniInputDevice(m_env, inputDevice, getNameMethod, getVendorIdMethod, getProductIdMethod, supportsSourceMethod, getMotionRangesMethod); |
| 217 | } |
| 218 | |
| 219 | |
| 220 | //////////////////////////////////////////////////////////// |
no test coverage detected