Skip to content

Commit

Permalink
ANDROID: Enter main menu on middle mouse press
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldin committed Aug 8, 2013
1 parent a50ede2 commit bb39cbc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions backends/platform/android/events.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ enum {
JE_MOUSE_MOVE = 13, JE_MOUSE_MOVE = 13,
JE_GAMEPAD = 14, JE_GAMEPAD = 14,
JE_JOYSTICK = 15, JE_JOYSTICK = 15,
JE_MMB_DOWN = 16,
JE_MMB_UP = 17,
JE_QUIT = 0x1000 JE_QUIT = 0x1000
}; };


Expand Down Expand Up @@ -922,6 +924,20 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,


return; return;


case JE_MMB_DOWN:
e.type = Common::EVENT_MAINMENU;

lockMutex(_event_queue_lock);
_event_queue.push(e);
unlockMutex(_event_queue_lock);

return;

case JE_MMB_UP:
// No action

return;

case JE_QUIT: case JE_QUIT:
e.type = Common::EVENT_QUIT; e.type = Common::EVENT_QUIT;


Expand Down
18 changes: 18 additions & 0 deletions backends/platform/android/org/scummvm/scummvm/MouseHelper.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class MouseHelper {
private long _rmbGuardTime; private long _rmbGuardTime;
private boolean _rmbPressed; private boolean _rmbPressed;
private boolean _lmbPressed; private boolean _lmbPressed;
private boolean _mmbPressed;


/** /**
* Class initialization fails when this throws an exception. * Class initialization fails when this throws an exception.
Expand Down Expand Up @@ -114,6 +115,23 @@ public boolean onMouseEvent(MotionEvent e, boolean hover) {
_rmbPressed = false; _rmbPressed = false;
} }


boolean mmbDown = (buttonState & MotionEvent.BUTTON_TERTIARY) == MotionEvent.BUTTON_TERTIARY;
if (mmbDown) {
if (!_mmbPressed) {
// middle mouse button was pressed just now
_scummvm.pushEvent(ScummVMEvents.JE_MMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0);
}

_mmbPressed = true;
} else {
if (_mmbPressed) {
// middle mouse button was released just now
_scummvm.pushEvent(ScummVMEvents.JE_MMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0);
}

_mmbPressed = false;
}

return true; return true;
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ScummVMEvents implements
public static final int JE_MOUSE_MOVE = 13; public static final int JE_MOUSE_MOVE = 13;
public static final int JE_GAMEPAD = 14; public static final int JE_GAMEPAD = 14;
public static final int JE_JOYSTICK = 15; public static final int JE_JOYSTICK = 15;
public static final int JE_MMB_DOWN = 16;
public static final int JE_MMB_UP = 17;
public static final int JE_QUIT = 0x1000; public static final int JE_QUIT = 0x1000;


final protected Context _context; final protected Context _context;
Expand Down

0 comments on commit bb39cbc

Please sign in to comment.