Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of input on --display 2/DeX mode #1288

Closed
lovintoja opened this issue Apr 13, 2020 · 5 comments
Closed

Lack of input on --display 2/DeX mode #1288

lovintoja opened this issue Apr 13, 2020 · 5 comments

Comments

@lovintoja
Copy link

lovintoja commented Apr 13, 2020

  • OS: Windows
  • scrcpy version: 1.12.1
  • installation method: Windows release
  • device model: S8+
  • Android version: 9.0

So, I've just downloaded latest stable release, paste'd scrcpy and scrcpy-server from dev branch (as posted in another issue), and wanted to test it with my DeX, so basically hook my S8+ to the docking station and share input of my notebook to the desktop mode of my phone. Dumpsys shows 3 displays: 0 - internal, 2 - desktop mode (DeX), 10 - marked as HDMI output (shown only when hooked to docking station, has mHasContent=false).

Choosing --display 0 without any problems. When I write --display 2 and try to give any input, I get "CANNOT ASSOCIATE A DISPLAY ID TO THE INPUT EVENT". --display 10 shows nothing, as expected.

Untitled

@rom1v
Copy link
Collaborator

rom1v commented Apr 14, 2020

Réf: #1177 (comment)

@peanutwolf Since the setDisplayId() method is not available before Android 10:

public static boolean setDisplayId(InputEvent inputEvent, int displayId) {
try {
Method method = getSetDisplayIdMethod();
method.invoke(inputEvent, displayId);
return true;
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
// just a warning, it might happen on old devices
Ln.w("Cannot associate a display id to the input event");
return false;
}
}

I think that supportsInputEvents() should just just return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q (whatever the presentation flag):

public boolean supportsInputEvents() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
return true;
}
return !isPresentationDisplay;
}

What do you think?

Also, when not supported, I'm not sure we should disable "power mode":

case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
if (device.supportsInputEvents()) {
device.setScreenPowerMode(msg.getAction());
}
break;

@peanutwolf
Copy link
Contributor

@rom1v if supportsInputEvents() will return only Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q when on device with API lower then 29 and displays that has FLAG_PRESENTATION touch events will be forwarded on wrong display.
AOSP doc clearly states that input events can't be forwarded on external displays until API 29.

My guess that we should attempt to call setDisplayId only on SDK >= Q

@lovintoja

share input of my notebook to the desktop mode of my phone

I couldn't clearly understand how it works. Without scrcpy you connect some kind of touch screen to DeX?

rom1v added a commit that referenced this issue Apr 15, 2020
Disable input events on secondary displays before Android 10, even if
FLAG_PRESENTATION is not set.

Ref #1288 <#1288>
rom1v added a commit that referenced this issue Apr 15, 2020
Disable input events on secondary displays before Android 10, even if
FLAG_PRESENTATION is not set.

Ref #1288 <#1288>
@rom1v
Copy link
Collaborator

rom1v commented Apr 15, 2020

@peanutwolf What about something like 0e27256?

@peanutwolf
Copy link
Contributor

@peanutwolf What about something like 0e27256?

Yes, correct

rom1v added a commit that referenced this issue Apr 16, 2020
Disable input events on secondary displays before Android 10, even if
FLAG_PRESENTATION is not set.

Refs #1288 <#1288>
@rom1v
Copy link
Collaborator

rom1v commented Apr 16, 2020

Android version: 9.0

OK, so to summarize: input events on secondary displays may not work before Android 10.

However, they were not disabled explicitly in your case, this is fixed by 94a7f1a.

@rom1v rom1v closed this as completed Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants