Search Unity

PC like Keyboard & Mouse Input for Mobile platforms

Discussion in 'Assets and Asset Store' started by zezba9000, May 31, 2022.

  1. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
  2. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
  3. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
    Running on Samsung Galaxy S9 + DeX Dock


    Running on x64 Chromebook
     
  4. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
  5. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    I see that there is InputCapture.GetMouseVelocity and InputCapture.GetMouseScroll but there is no GetMousePosition.
    Is there a way to get the mouse position?
     
  6. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
    Mobile devices do not give you back the cursors position only the velocity.
    You just use this to create your own virtual cursor if you need.

    I may just add this virtual position for you as many people are confused as to why this doesn't exist.
     
  7. Inter-Illusion

    Inter-Illusion

    Joined:
    Jan 5, 2014
    Posts:
    598
    Oh, I was under the impression that when an iPad had a keyboard with touch pad attached, the
    NSEvent mouseLocation returned the actual mouse position for that device.
    I will have to check a bit into that to see how other apps get that position.
     
  8. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
    iOS may provide a little more information in its API (can't remember off the top of my head atm) but Android 100% does not support this & thus not the correct way to model a cursor position thats portable for mobile platforms. Simulation is the only portable way here. This also applies to WASM if not mistaken.
     
  9. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
    Working on a update but you can add these fixes if you're running into them.

    In the "AndroidCapture.cs" file "unityPlayer" field need to be changed from a "AndroidJavaObject" to a "AndroidJavaClass" or it will fail on some devices.
    upload_2022-10-16_20-39-8.png

    If you're using ProGuard R8 & Release you need to add this line in your "proguard-user.txt" file to prevent stripping.
    upload_2022-10-16_20-36-58.png
     

    Attached Files:

  10. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    992
    2.0.4 has been submitted for Asset Store review and will include the fixes mentioned above for Android.