mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 07:05:40 -04:00
Kudos for touchpads declaring as styluses
This commit is contained in:
parent
9b3420fdb2
commit
dc80378cdd
@ -203,7 +203,7 @@ public class MinecraftGLSurface extends View {
|
|||||||
public boolean onTouchEvent(MotionEvent e) {
|
public boolean onTouchEvent(MotionEvent e) {
|
||||||
// Looking for a mouse to handle, won't have an effect if no mouse exists.
|
// Looking for a mouse to handle, won't have an effect if no mouse exists.
|
||||||
for (int i = 0; i < e.getPointerCount(); i++) {
|
for (int i = 0; i < e.getPointerCount(); i++) {
|
||||||
if (e.getToolType(i) != MotionEvent.TOOL_TYPE_MOUSE) continue;
|
if(e.getToolType(i) != MotionEvent.TOOL_TYPE_MOUSE && e.getToolType(i) != MotionEvent.TOOL_TYPE_STYLUS ) continue;
|
||||||
|
|
||||||
// Mouse found
|
// Mouse found
|
||||||
if(CallbackBridge.isGrabbing()) return false;
|
if(CallbackBridge.isGrabbing()) return false;
|
||||||
@ -391,7 +391,7 @@ public class MinecraftGLSurface extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < event.getPointerCount(); i++) {
|
for(int i = 0; i < event.getPointerCount(); i++) {
|
||||||
if(event.getToolType(i) != MotionEvent.TOOL_TYPE_MOUSE) continue;
|
if(event.getToolType(i) != MotionEvent.TOOL_TYPE_MOUSE && event.getToolType(i) != MotionEvent.TOOL_TYPE_STYLUS ) continue;
|
||||||
// Mouse found
|
// Mouse found
|
||||||
mouseCursorIndex = i;
|
mouseCursorIndex = i;
|
||||||
break;
|
break;
|
||||||
@ -493,8 +493,6 @@ public class MinecraftGLSurface extends View {
|
|||||||
if(event.getRepeatCount() != 0) return true;
|
if(event.getRepeatCount() != 0) return true;
|
||||||
if(event.getAction() == KeyEvent.ACTION_MULTIPLE) return true;
|
if(event.getAction() == KeyEvent.ACTION_MULTIPLE) return true;
|
||||||
|
|
||||||
//Toast.makeText(this, "FIRST VERIF PASSED", Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
//Sometimes, key events comes from SOME keys of the software keyboard
|
//Sometimes, key events comes from SOME keys of the software keyboard
|
||||||
//Even weirder, is is unknown why a key or another is selected to trigger a keyEvent
|
//Even weirder, is is unknown why a key or another is selected to trigger a keyEvent
|
||||||
if((event.getFlags() & KeyEvent.FLAG_SOFT_KEYBOARD) == KeyEvent.FLAG_SOFT_KEYBOARD){
|
if((event.getFlags() & KeyEvent.FLAG_SOFT_KEYBOARD) == KeyEvent.FLAG_SOFT_KEYBOARD){
|
||||||
@ -502,25 +500,19 @@ public class MinecraftGLSurface extends View {
|
|||||||
touchCharInput.dispatchKeyEvent(event);
|
touchCharInput.dispatchKeyEvent(event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//Toast.makeText(this, "SECOND VERIF PASSED", Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
|
|
||||||
//Sometimes, key events may come from the mouse
|
//Sometimes, key events may come from the mouse
|
||||||
if(event.getDevice() != null
|
if(event.getDevice() != null
|
||||||
&& ( (event.getSource() & InputDevice.SOURCE_MOUSE_RELATIVE) == InputDevice.SOURCE_MOUSE_RELATIVE
|
&& ( (event.getSource() & InputDevice.SOURCE_MOUSE_RELATIVE) == InputDevice.SOURCE_MOUSE_RELATIVE
|
||||||
|| (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) ){
|
|| (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) ){
|
||||||
//Toast.makeText(this, "THE EVENT COMES FROM A MOUSE", Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
|
|
||||||
if(eventKeycode == KeyEvent.KEYCODE_BACK){
|
if(eventKeycode == KeyEvent.KEYCODE_BACK){
|
||||||
sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, event.getAction() == KeyEvent.ACTION_DOWN);
|
sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, event.getAction() == KeyEvent.ACTION_DOWN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//System.out.println(event);
|
|
||||||
|
|
||||||
if(Gamepad.isGamepadEvent(event)){
|
if(Gamepad.isGamepadEvent(event)){
|
||||||
|
|
||||||
if(mGamepad == null){
|
if(mGamepad == null){
|
||||||
mGamepad = new Gamepad(this, event.getDevice());
|
mGamepad = new Gamepad(this, event.getDevice());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user