mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
android: handle right mouse button, more external keyboard keys
This commit is contained in:
parent
0fa8980be2
commit
18afcdbd0a
@ -44,7 +44,8 @@ AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
int flags,
|
int flags,
|
||||||
GraphicsStateGuardian *gsg,
|
GraphicsStateGuardian *gsg,
|
||||||
GraphicsOutput *host) :
|
GraphicsOutput *host) :
|
||||||
GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
|
GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host),
|
||||||
|
_mouse_button_state(0)
|
||||||
{
|
{
|
||||||
AndroidGraphicsPipe *android_pipe;
|
AndroidGraphicsPipe *android_pipe;
|
||||||
DCAST_INTO_V(android_pipe, _pipe);
|
DCAST_INTO_V(android_pipe, _pipe);
|
||||||
@ -533,10 +534,29 @@ handle_motion_event(const AInputEvent *event) {
|
|||||||
int32_t action = AMotionEvent_getAction(event);
|
int32_t action = AMotionEvent_getAction(event);
|
||||||
action &= AMOTION_EVENT_ACTION_MASK;
|
action &= AMOTION_EVENT_ACTION_MASK;
|
||||||
|
|
||||||
if (action == AMOTION_EVENT_ACTION_DOWN) {
|
if (action == AMOTION_EVENT_ACTION_DOWN ||
|
||||||
_input_devices[0].button_down(MouseButton::one());
|
action == AMOTION_EVENT_ACTION_UP) {
|
||||||
} else if (action == AMOTION_EVENT_ACTION_UP) {
|
// The up event doesn't let us know which button is up, so we need to
|
||||||
_input_devices[0].button_up(MouseButton::one());
|
// keep track of the button state ourselves.
|
||||||
|
int32_t button_state = AMotionEvent_getButtonState(event);
|
||||||
|
int32_t changed = _mouse_button_state ^ button_state;
|
||||||
|
if (changed != 0) {
|
||||||
|
if (changed & AMOTION_EVENT_BUTTON_PRIMARY) {
|
||||||
|
if (button_state & AMOTION_EVENT_BUTTON_PRIMARY) {
|
||||||
|
_input_devices[0].button_down(MouseButton::one());
|
||||||
|
} else {
|
||||||
|
_input_devices[0].button_up(MouseButton::one());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed & AMOTION_EVENT_BUTTON_SECONDARY) {
|
||||||
|
if (button_state & AMOTION_EVENT_BUTTON_SECONDARY) {
|
||||||
|
_input_devices[0].button_down(MouseButton::three());
|
||||||
|
} else {
|
||||||
|
_input_devices[0].button_up(MouseButton::three());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_mouse_button_state = button_state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float x = AMotionEvent_getX(event, 0) - _app->contentRect.left;
|
float x = AMotionEvent_getX(event, 0) - _app->contentRect.left;
|
||||||
@ -675,7 +695,7 @@ map_button(int32_t keycode) {
|
|||||||
case AKEYCODE_ENTER:
|
case AKEYCODE_ENTER:
|
||||||
return KeyboardButton::enter();
|
return KeyboardButton::enter();
|
||||||
case AKEYCODE_DEL:
|
case AKEYCODE_DEL:
|
||||||
return KeyboardButton::del();
|
return KeyboardButton::backspace();
|
||||||
case AKEYCODE_GRAVE:
|
case AKEYCODE_GRAVE:
|
||||||
return KeyboardButton::ascii_key('`');
|
return KeyboardButton::ascii_key('`');
|
||||||
case AKEYCODE_MINUS:
|
case AKEYCODE_MINUS:
|
||||||
@ -703,6 +723,7 @@ map_button(int32_t keycode) {
|
|||||||
case AKEYCODE_PLUS:
|
case AKEYCODE_PLUS:
|
||||||
return KeyboardButton::ascii_key('+');
|
return KeyboardButton::ascii_key('+');
|
||||||
case AKEYCODE_MENU:
|
case AKEYCODE_MENU:
|
||||||
|
return KeyboardButton::menu();
|
||||||
case AKEYCODE_NOTIFICATION:
|
case AKEYCODE_NOTIFICATION:
|
||||||
case AKEYCODE_SEARCH:
|
case AKEYCODE_SEARCH:
|
||||||
case AKEYCODE_MEDIA_PLAY_PAUSE:
|
case AKEYCODE_MEDIA_PLAY_PAUSE:
|
||||||
@ -734,6 +755,61 @@ map_button(int32_t keycode) {
|
|||||||
case AKEYCODE_BUTTON_START:
|
case AKEYCODE_BUTTON_START:
|
||||||
case AKEYCODE_BUTTON_SELECT:
|
case AKEYCODE_BUTTON_SELECT:
|
||||||
case AKEYCODE_BUTTON_MODE:
|
case AKEYCODE_BUTTON_MODE:
|
||||||
|
break;
|
||||||
|
case AKEYCODE_ESCAPE:
|
||||||
|
return KeyboardButton::escape();
|
||||||
|
case AKEYCODE_FORWARD_DEL:
|
||||||
|
return KeyboardButton::del();
|
||||||
|
case AKEYCODE_CTRL_LEFT:
|
||||||
|
return KeyboardButton::lcontrol();
|
||||||
|
case AKEYCODE_CTRL_RIGHT:
|
||||||
|
return KeyboardButton::rcontrol();
|
||||||
|
case AKEYCODE_CAPS_LOCK:
|
||||||
|
return KeyboardButton::caps_lock();
|
||||||
|
case AKEYCODE_SCROLL_LOCK:
|
||||||
|
return KeyboardButton::scroll_lock();
|
||||||
|
case AKEYCODE_META_LEFT:
|
||||||
|
return KeyboardButton::lmeta();
|
||||||
|
case AKEYCODE_META_RIGHT:
|
||||||
|
return KeyboardButton::rmeta();
|
||||||
|
case AKEYCODE_FUNCTION:
|
||||||
|
break;
|
||||||
|
case AKEYCODE_SYSRQ:
|
||||||
|
return KeyboardButton::print_screen();
|
||||||
|
case AKEYCODE_BREAK:
|
||||||
|
return KeyboardButton::pause();
|
||||||
|
case AKEYCODE_MOVE_HOME:
|
||||||
|
return KeyboardButton::home();
|
||||||
|
case AKEYCODE_MOVE_END:
|
||||||
|
return KeyboardButton::end();
|
||||||
|
case AKEYCODE_INSERT:
|
||||||
|
return KeyboardButton::insert();
|
||||||
|
case AKEYCODE_F1:
|
||||||
|
return KeyboardButton::f1();
|
||||||
|
case AKEYCODE_F2:
|
||||||
|
return KeyboardButton::f2();
|
||||||
|
case AKEYCODE_F3:
|
||||||
|
return KeyboardButton::f3();
|
||||||
|
case AKEYCODE_F4:
|
||||||
|
return KeyboardButton::f4();
|
||||||
|
case AKEYCODE_F5:
|
||||||
|
return KeyboardButton::f5();
|
||||||
|
case AKEYCODE_F6:
|
||||||
|
return KeyboardButton::f6();
|
||||||
|
case AKEYCODE_F7:
|
||||||
|
return KeyboardButton::f7();
|
||||||
|
case AKEYCODE_F8:
|
||||||
|
return KeyboardButton::f8();
|
||||||
|
case AKEYCODE_F9:
|
||||||
|
return KeyboardButton::f9();
|
||||||
|
case AKEYCODE_F10:
|
||||||
|
return KeyboardButton::f10();
|
||||||
|
case AKEYCODE_F11:
|
||||||
|
return KeyboardButton::f11();
|
||||||
|
case AKEYCODE_F12:
|
||||||
|
return KeyboardButton::f12();
|
||||||
|
case AKEYCODE_NUM_LOCK:
|
||||||
|
return KeyboardButton::num_lock();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,8 @@ private:
|
|||||||
EGLDisplay _egl_display;
|
EGLDisplay _egl_display;
|
||||||
EGLSurface _egl_surface;
|
EGLSurface _egl_surface;
|
||||||
|
|
||||||
|
int32_t _mouse_button_state;
|
||||||
|
|
||||||
const ARect *rect;
|
const ARect *rect;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user