简体   繁体   English

LibGDX-Android上的鼠标按钮

[英]LibGDX - Mouse buttons on Android

How can i differentiate the mouse button on Android using LibGDX? 如何使用LibGDX区分Android上的鼠标按钮?


I'm trying to add proper mouse support for my LibGDX app, but on Android every mouse click returns the a left button. 我正在尝试为我的LibGDX应用添加适当的鼠标支持,但是在Android上,每一次鼠标单击都会返回一个左键。 I tried it with the Emulator and a real device as well, with USB mouse. 我在模拟器和真实设备(以及USB鼠标)上进行了尝试。

Is It even possible with LibGDX, or with the Android API? LibGDX或Android API甚至可能吗? Is it supported only from some version of Android or it's device dependent? 它仅受某些版本的Android支持还是取决于设备?

It is not possible to have mouse buttons in Android at all. 完全不可能在Android中拥有鼠标按钮。 The only way to test "right click" is to test if the user is touching with two (or more) fingers. 测试“右键单击”的唯一方法是测试用户是否用两根(或更多根)手指触摸。 To do so you need to use touch count. 为此,您需要使用触摸计数。

Mouse buttons can be identified on touch events from Android 4.0 onwards. 从Android 4.0开始,可以在触摸事件中识别鼠标按钮。 However, some devices are hardwired to return back/home instead of the actual button press and they can't be correctly read. 但是,有些设备被硬连线以返回/返回原位,而不是实际按下按钮,因此无法正确读取它们。

libGDX has extended mouse support as of 1.4.1 and will return the mid and right buttons correctly on a compatible device. libGDX从1.4.1开始扩展了鼠标支持,并将在兼容设备上正确返回中键和右键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM