mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 00:29:50 -04:00
Change the mouse handler
This commit is contained in:
parent
2ce3bb4b76
commit
dd02868155
@ -755,9 +755,9 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
return super.dispatchKeyEvent(event);
|
return super.dispatchKeyEvent(event);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchGenericMotionEvent(MotionEvent ev) {
|
public boolean dispatchGenericMotionEvent(MotionEvent ev) {
|
||||||
|
boolean isDown = false;
|
||||||
if(ev.getSource() == InputDevice.SOURCE_CLASS_JOYSTICK) {
|
if(ev.getSource() == InputDevice.SOURCE_CLASS_JOYSTICK) {
|
||||||
CallbackBridge.nativePutControllerAxes((FloatBuffer)FloatBuffer.allocate(8)
|
CallbackBridge.nativePutControllerAxes((FloatBuffer)FloatBuffer.allocate(8)
|
||||||
.put(ev.getAxisValue(MotionEvent.AXIS_X))
|
.put(ev.getAxisValue(MotionEvent.AXIS_X))
|
||||||
@ -770,9 +770,33 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
.put(ev.getAxisValue(MotionEvent.AXIS_HAT_Y))
|
.put(ev.getAxisValue(MotionEvent.AXIS_HAT_Y))
|
||||||
.flip());
|
.flip());
|
||||||
return true;//consume the cum chalice
|
return true;//consume the cum chalice
|
||||||
}else{
|
}else if(ev.getSource() == InputDevice.SOURCE_MOUSE){
|
||||||
return false;
|
switch(ev.getActionMasked()) {
|
||||||
}
|
case MotionEvent.ACTION_DOWN: // 0
|
||||||
|
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
||||||
|
isDown = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MotionEvent.ACTION_UP: // 1
|
||||||
|
case MotionEvent.ACTION_CANCEL: // 3
|
||||||
|
case MotionEvent.ACTION_POINTER_UP: // 6
|
||||||
|
isDown = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
CallbackBridge.sendCursorPos((int)ev.getX(), (int)ev.getY());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MotionEvent.ACTION_BUTTON_PRESS:
|
||||||
|
sendMouseButtonUnconverted(ev.getActionButton(),isDown);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MotionEvent.ACTION_SCROLL:
|
||||||
|
CallbackBridge.sendScroll(ev.getAxisValue(MotionEvent.AXIS_HSCROLL), ev.getAxisValue(MotionEvent.AXIS_VSCROLL));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else return false;
|
||||||
}
|
}
|
||||||
byte[] kevArray = new byte[8];
|
byte[] kevArray = new byte[8];
|
||||||
@Override
|
@Override
|
||||||
@ -801,18 +825,6 @@ public class BaseMainActivity extends LoggableActivity {
|
|||||||
}else if(event.getSource() == InputDevice.SOURCE_KEYBOARD) {
|
}else if(event.getSource() == InputDevice.SOURCE_KEYBOARD) {
|
||||||
AndroidLWJGLKeycode.execKey(event,event.getKeyCode(),event.getAction() == KeyEvent.ACTION_DOWN);
|
AndroidLWJGLKeycode.execKey(event,event.getKeyCode(),event.getAction() == KeyEvent.ACTION_DOWN);
|
||||||
return true;
|
return true;
|
||||||
}else if(event.getSource() == InputDevice.SOURCE_MOUSE) {
|
|
||||||
int glfwCurrentMouse = LWJGLGLFWKeycode.GLFW_KEY_UNKNOWN;
|
|
||||||
switch(event.getKeyCode()) {
|
|
||||||
case 1:
|
|
||||||
glfwCurrentMouse = LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
glfwCurrentMouse = LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_RIGHT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sendMouseButton(glfwCurrentMouse,event.getAction() == KeyEvent.ACTION_DOWN);
|
|
||||||
return true;
|
|
||||||
}else return false;
|
}else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user