MCPcopy Create free account
hub / github.com/SFML/SFML / getDevice

Method getDevice

src/SFML/Window/Android/JniHelper.cpp:195–217  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

193
194////////////////////////////////////////////////////////////
195std::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////////////////////////////////////////////////////////////

Callers 2

openMethod · 0.45
updateMethod · 0.45

Calls 1

JniInputDeviceClass · 0.85

Tested by

no test coverage detected