Use identity transform for Joystick MotionEvent

The SyntheticJoystickHandler makes key events
according to the axis values of MotionEvent.

If there is a Window which has transformed,
the axis values are going to be bigger or smaller than
SyntheticJoystickHandler's threshold and the generating
events never stop because JoystickHandler thinks that
the user is controlling Joystick continuously.

This makes Joystick's MotionEvent has identity transform
so that its aix values are not depending on the window but
display.

Test: atest inputflinger_tests:InputDispatcherTest\
        #NonPointerMotionEvent_JoystickNotTransformed
Bug: 158802274
Change-Id: Ib1c12c773a604c74807033819b8d1e1032913c98
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 5832109..dcac786 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -321,6 +321,17 @@
 static std::unique_ptr<DispatchEntry> createDispatchEntry(const InputTarget& inputTarget,
                                                           std::shared_ptr<EventEntry> eventEntry,
                                                           int32_t inputTargetFlags) {
+    if (eventEntry->type == EventEntry::Type::MOTION) {
+        const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*eventEntry);
+        if (motionEntry.source & AINPUT_SOURCE_CLASS_JOYSTICK) {
+            const ui::Transform identityTransform;
+            // Use identity transform for joystick events events because they don't depend on
+            // the window info
+            return std::make_unique<DispatchEntry>(eventEntry, inputTargetFlags, identityTransform,
+                                                   1.0f /*globalScaleFactor*/);
+        }
+    }
+
     if (inputTarget.useDefaultPointerTransform()) {
         const ui::Transform& transform = inputTarget.getDefaultPointerTransform();
         return std::make_unique<DispatchEntry>(eventEntry, inputTargetFlags, transform,