diff --git a/Common/Data/Convert/SmallDataConvert.h b/Common/Data/Convert/SmallDataConvert.h index cdbfc3c5b2..f628534b73 100644 --- a/Common/Data/Convert/SmallDataConvert.h +++ b/Common/Data/Convert/SmallDataConvert.h @@ -132,13 +132,6 @@ inline void Uint8x3ToInt4(int i[4], uint32_t u) { i[3] = 0; } -inline void Uint8x3ToInt4_Alpha(int i[4], uint32_t u, uint8_t alpha) { - i[0] = ((u >> 0) & 0xFF); - i[1] = ((u >> 8) & 0xFF); - i[2] = ((u >> 16) & 0xFF); - i[3] = alpha; -} - inline void Uint8x3ToFloat4_Alpha(float f[4], uint32_t u, float alpha) { f[0] = ((u >> 0) & 0xFF) * (1.0f / 255.0f); f[1] = ((u >> 8) & 0xFF) * (1.0f / 255.0f); @@ -146,13 +139,6 @@ inline void Uint8x3ToFloat4_Alpha(float f[4], uint32_t u, float alpha) { f[3] = alpha; } -inline void Uint8x1ToFloat4(float f[4], uint32_t u) { - f[0] = ((u >> 0) & 0xFF) * (1.0f / 255.0f); - f[1] = 0.0f; - f[2] = 0.0f; - f[3] = 0.0f; -} - // These are just for readability. inline void CopyFloat2(float dest[2], const float src[2]) { @@ -206,6 +192,7 @@ inline void CopyMatrix4x4(float dest[16], const float src[16]) { memcpy(dest, src, sizeof(float) * 16); } +// WARNING: This can quietly "over-load" src by 4 bytes. inline void ExpandFloat24x3ToFloat4(float dest[4], const uint32_t src[3]) { #ifdef _M_SSE __m128i values = _mm_slli_epi32(_mm_loadu_si128((const __m128i *)src), 8); diff --git a/Common/Math/fast/fast_matrix.h b/Common/Math/fast/fast_matrix.h index f6bfa69a6d..051c78199a 100644 --- a/Common/Math/fast/fast_matrix.h +++ b/Common/Math/fast/fast_matrix.h @@ -2,7 +2,6 @@ #include "ppsspp_config.h" - #include "Common/Math/SIMDHeaders.h" #include "Common/Common.h" diff --git a/Windows/HidInputDevice.cpp b/Windows/HidInputDevice.cpp index 8e97bb8951..07bc7f4ac3 100644 --- a/Windows/HidInputDevice.cpp +++ b/Windows/HidInputDevice.cpp @@ -188,14 +188,14 @@ static const HIDControllerInfo g_psInfos[] = { static const HIDControllerInfo *GetGamepadInfo(HANDLE handle) { HIDD_ATTRIBUTES attr{sizeof(HIDD_ATTRIBUTES)}; if (!HidD_GetAttributes(handle, &attr)) { - return false; + return nullptr; } for (const auto &info : g_psInfos) { if (attr.VendorID == info.vendorId && attr.ProductID == info.productId) { return &info; } } - return false; + return nullptr; } template diff --git a/android/src/org/ppsspp/ppsspp/InputDeviceState.java b/android/src/org/ppsspp/ppsspp/InputDeviceState.java index c42df7290c..aa70cea448 100644 --- a/android/src/org/ppsspp/ppsspp/InputDeviceState.java +++ b/android/src/org/ppsspp/ppsspp/InputDeviceState.java @@ -5,6 +5,7 @@ import android.view.InputDevice; import android.view.InputDevice.MotionRange; import android.view.KeyEvent; import android.view.MotionEvent; + import java.util.Set; import java.util.HashSet; @@ -108,7 +109,7 @@ public class InputDeviceState { (source & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD; } - public InputDeviceState(InputDevice device) { + public InputDeviceState(InputDevice device, boolean fromConnectedNotification) { sources = device.getSources(); // First, anything that's a gamepad is a gamepad, even if it has a keyboard or pointer. // We also don't bother supporting multiple gamepads, we send them all to PAD0. @@ -140,12 +141,16 @@ public class InputDeviceState { Log.i(TAG, "Registering input device with " + numAxes + " axes: " + device.getName()); logAdvanced(device); - NativeApp.sendMessageFromJava("inputDeviceConnectedID", String.valueOf(this.deviceId)); - NativeApp.sendMessageFromJava("inputDeviceConnected", device.getName()); + if (deviceId == NativeApp.DEVICE_ID_PAD_0 && fromConnectedNotification) { + NativeApp.sendMessageFromJava("inputDeviceConnectedID", String.valueOf(this.deviceId)); + NativeApp.sendMessageFromJava("inputDeviceConnected", device.getName()); + } } public void Disconnect() { - NativeApp.sendMessageFromJava("inputDeviceDisconnectedID", String.valueOf(this.deviceId)); + if (deviceId == NativeApp.DEVICE_ID_PAD_0) { + NativeApp.sendMessageFromJava("inputDeviceDisconnectedID", String.valueOf(this.deviceId)); + } // Also reset all the buttons and axes. for (int value : pressedKeys) { NativeApp.keyUp(deviceId, value); diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index de09f5c83f..50f7b64065 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -14,7 +14,6 @@ import android.app.UiModeManager; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; @@ -35,7 +34,6 @@ import android.os.Environment; import android.os.Looper; import android.os.PowerManager; import android.provider.MediaStore; -import android.renderscript.ScriptGroup; import android.text.InputType; import android.util.Log; import android.database.Cursor; @@ -786,7 +784,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList } // None was found, just add and return it. - InputDeviceState state = new InputDeviceState(device); + InputDeviceState state = new InputDeviceState(device, true); inputPlayers.add(state); Log.i(TAG, "Input player registered on connect: desc = " + device.getDescriptor()); } @@ -1144,7 +1142,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList } // None was found, just add and return it. - InputDeviceState state = new InputDeviceState(device); + InputDeviceState state = new InputDeviceState(device, false); inputPlayers.add(state); Log.i(TAG, "Input player post-registered: desc = " + device.getDescriptor()); return state; diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index e182d3fcfa..225dec102f 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -81,6 +81,7 @@ #include "Common/Data/Convert/ColorConv.h" #include "Common/File/VFS/VFS.h" #include "Common/File/VFS/DirectoryReader.h" +#include "Common/Math/fast/fast_matrix.h" #include "Core/FileSystems/ISOFileSystem.h" #include "Core/MemMap.h" #include "Core/KeyMap.h" @@ -88,6 +89,7 @@ #include "Core/MIPS/MIPSVFPUUtils.h" #include "GPU/Common/TextureDecoder.h" #include "GPU/Common/GPUStateUtils.h" +#include "GPU/Math3D.h" #include "Common/File/AndroidContentURI.h" @@ -1233,6 +1235,79 @@ bool TestVolumeFunc() { return true; } +bool TestLinAlg() { + static const float m1[16] = { + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + }; + static const float m2[16] = { + 56, 0, 24, 2, + 0.5f, 35, 2, 4, + 1, 6, 1, 2, + 4, 0, -1, -4 + }; + static const float correct[16] = { + 298.f, 380.f, 462.f, 544.f, + 245.5f, 287.f, 328.5f, 370.f, + 66.f, 76.f, 86.f, 96.f, + -57.f, -58.f, -59.f, -60.f, + }; + + float d[16]{}; + + fast_matrix_mul_4x4(d, m1, m2); + + for (int i = 0; i < 16; i += 4) { + // printf("%0.2f, %0.2f, %0.2f, %0.2f,\n", d[i], d[i + 1], d[i + 2], d[i + 3]); + } + + for (int i = 0; i < 16; i++) { + EXPECT_EQ_FLOAT(d[i], correct[i]); + } + + + // OK, now test 4x3 multiplication. + float a4x4[16]; + float b4x4[16]; + + ConvertMatrix4x3To4x4(a4x4, m1); + ConvertMatrix4x3To4x4(b4x4, m1); + Matrix4ByMatrix4(d, a4x4, b4x4); + + for (int i = 0; i < 16; i += 4) { + // printf("%0.2f, %0.2f, %0.2f, %0.2f,\n", d[i], d[i + 1], d[i + 2], d[i + 3]); + } + + static const float correct4x4[16] = { + 30.00, 36.00, 42.00, 0.00, + 66.00, 81.00, 96.00, 0.00, + 102.00, 126.00, 150.00, 0.00, + 148.00, 182.00, 216.00, 1.00, + }; + + for (int i = 0; i < 16; i++) { + EXPECT_EQ_FLOAT(d[i], correct4x4[i]); + } + + ConvertMatrix4x3To4x4Transposed(b4x4, m1); + Matrix4ByMatrix4(d, a4x4, b4x4); + + static const float correct4x4transposed[16] = { + 14.00, 32.00, 50.00, 68.00, + 32.00, 77.00, 122.00, 167.00, + 50.00, 122.00, 194.00, 266.00, + 68.00, 167.00, 266.00, 366.00, + }; + + for (int i = 0; i < 16; i++) { + EXPECT_EQ_FLOAT(d[i], correct4x4transposed[i]); + } + // TODO: Add direct 4x3 x 4x3 multiplication + return true; +} + bool TestSplitSearch() { std::string part1 = "The quick brown fox jumps"; std::string part2 = " over the lazy dog."; @@ -1329,6 +1404,7 @@ TestItem availableTests[] = { TEST_ITEM(VolumeFunc), TEST_ITEM(SplitSearch), TEST_ITEM(FriendlyPath), + TEST_ITEM(LinAlg), }; int main(int argc, const char *argv[]) {