Merge pull request #7751 from zackhow/motefix

Android: Don't grab wiimote report if size is < 1
This commit is contained in:
JMC47 2019-01-28 19:53:04 -05:00 committed by GitHub
commit cf8da56297
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -95,10 +95,13 @@ bool WiimoteAndroid::IsConnected() const
int WiimoteAndroid::IORead(u8* buf)
{
int read_size = m_env->CallStaticIntMethod(s_adapter_class, m_input_func, m_mayflash_index);
if (read_size > 0)
{
jbyte* java_data = m_env->GetByteArrayElements(m_java_wiimote_payload, nullptr);
memcpy(buf + 1, java_data, std::min(MAX_PAYLOAD - 1, read_size));
buf[0] = 0xA1;
m_env->ReleaseByteArrayElements(m_java_wiimote_payload, java_data, 0);
}
return read_size <= 0 ? read_size : read_size + 1;
}