ANDROID: Seperate DPAD codes
This commit is contained in:
parent
b721547213
commit
e056bfca9c
2 changed files with 93 additions and 78 deletions
|
@ -38,11 +38,12 @@
|
||||||
enum {
|
enum {
|
||||||
JE_SYS_KEY = 0,
|
JE_SYS_KEY = 0,
|
||||||
JE_KEY = 1,
|
JE_KEY = 1,
|
||||||
JE_DOWN = 2,
|
JE_DPAD = 2,
|
||||||
JE_SCROLL = 3,
|
JE_DOWN = 3,
|
||||||
JE_TAP = 4,
|
JE_SCROLL = 4,
|
||||||
JE_DOUBLE_TAP = 5,
|
JE_TAP = 5,
|
||||||
JE_BALL = 6,
|
JE_DOUBLE_TAP = 6,
|
||||||
|
JE_BALL = 7,
|
||||||
JE_QUIT = 0x1000
|
JE_QUIT = 0x1000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -338,74 +339,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JE_KEY:
|
case JE_KEY:
|
||||||
// five-way first
|
|
||||||
switch (arg2) {
|
|
||||||
case JKEYCODE_DPAD_UP:
|
|
||||||
case JKEYCODE_DPAD_DOWN:
|
|
||||||
case JKEYCODE_DPAD_LEFT:
|
|
||||||
case JKEYCODE_DPAD_RIGHT:
|
|
||||||
{
|
|
||||||
if (arg1 != JACTION_DOWN)
|
|
||||||
return;
|
|
||||||
|
|
||||||
e.type = Common::EVENT_MOUSEMOVE;
|
|
||||||
e.synthetic = true;
|
|
||||||
|
|
||||||
e.mouse = getEventManager()->getMousePos();
|
|
||||||
|
|
||||||
int16 *c;
|
|
||||||
int s;
|
|
||||||
|
|
||||||
if (arg2 == JKEYCODE_DPAD_UP || arg2 == JKEYCODE_DPAD_DOWN) {
|
|
||||||
c = &e.mouse.y;
|
|
||||||
s = _eventScaleY;
|
|
||||||
} else {
|
|
||||||
c = &e.mouse.x;
|
|
||||||
s = _eventScaleX;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the longer the button held, the faster the pointer is
|
|
||||||
// TODO put these values in some option dlg?
|
|
||||||
int f = CLIP(arg5, 1, 8) * _dpad_scale * 100 / s;
|
|
||||||
|
|
||||||
*c += ((arg2 == JKEYCODE_DPAD_UP ||
|
|
||||||
arg2 == JKEYCODE_DPAD_LEFT) ? -1 : 1) * f;
|
|
||||||
|
|
||||||
clipMouse(e.mouse);
|
|
||||||
|
|
||||||
lockMutex(_event_queue_lock);
|
|
||||||
_event_queue.push(e);
|
|
||||||
unlockMutex(_event_queue_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
case JKEYCODE_DPAD_CENTER:
|
|
||||||
switch (arg1) {
|
|
||||||
case JACTION_DOWN:
|
|
||||||
e.type = Common::EVENT_LBUTTONDOWN;
|
|
||||||
break;
|
|
||||||
case JACTION_UP:
|
|
||||||
e.type = Common::EVENT_LBUTTONUP;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOGE("unhandled jaction on dpad key: %d", arg1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const Common::Point &m = getEventManager()->getMousePos();
|
|
||||||
|
|
||||||
e.mouse = m;
|
|
||||||
|
|
||||||
lockMutex(_event_queue_lock);
|
|
||||||
_event_queue.push(e);
|
|
||||||
unlockMutex(_event_queue_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (arg1) {
|
switch (arg1) {
|
||||||
case JACTION_DOWN:
|
case JACTION_DOWN:
|
||||||
e.type = Common::EVENT_KEYDOWN;
|
e.type = Common::EVENT_KEYDOWN;
|
||||||
|
@ -442,6 +375,75 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case JE_DPAD:
|
||||||
|
switch (arg2) {
|
||||||
|
case JKEYCODE_DPAD_UP:
|
||||||
|
case JKEYCODE_DPAD_DOWN:
|
||||||
|
case JKEYCODE_DPAD_LEFT:
|
||||||
|
case JKEYCODE_DPAD_RIGHT:
|
||||||
|
{
|
||||||
|
if (arg1 != JACTION_DOWN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
e.type = Common::EVENT_MOUSEMOVE;
|
||||||
|
|
||||||
|
e.mouse = getEventManager()->getMousePos();
|
||||||
|
|
||||||
|
int16 *c;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
if (arg2 == JKEYCODE_DPAD_UP || arg2 == JKEYCODE_DPAD_DOWN) {
|
||||||
|
c = &e.mouse.y;
|
||||||
|
s = _eventScaleY;
|
||||||
|
} else {
|
||||||
|
c = &e.mouse.x;
|
||||||
|
s = _eventScaleX;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the longer the button held, the faster the pointer is
|
||||||
|
// TODO put these values in some option dlg?
|
||||||
|
int f = CLIP(arg4, 1, 8) * _dpad_scale * 100 / s;
|
||||||
|
|
||||||
|
if (arg2 == JKEYCODE_DPAD_UP || arg2 == JKEYCODE_DPAD_LEFT)
|
||||||
|
*c -= f;
|
||||||
|
else
|
||||||
|
*c += f;
|
||||||
|
|
||||||
|
clipMouse(e.mouse);
|
||||||
|
|
||||||
|
lockMutex(_event_queue_lock);
|
||||||
|
_event_queue.push(e);
|
||||||
|
unlockMutex(_event_queue_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
case JKEYCODE_DPAD_CENTER:
|
||||||
|
switch (arg1) {
|
||||||
|
case JACTION_DOWN:
|
||||||
|
e.type = Common::EVENT_LBUTTONDOWN;
|
||||||
|
break;
|
||||||
|
case JACTION_UP:
|
||||||
|
e.type = Common::EVENT_LBUTTONUP;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOGE("unhandled jaction on dpad key: %d", arg1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const Common::Point &m = getEventManager()->getMousePos();
|
||||||
|
|
||||||
|
e.mouse = m;
|
||||||
|
|
||||||
|
lockMutex(_event_queue_lock);
|
||||||
|
_event_queue.push(e);
|
||||||
|
unlockMutex(_event_queue_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
case JE_DOWN:
|
case JE_DOWN:
|
||||||
_touch_pt_down = getEventManager()->getMousePos();
|
_touch_pt_down = getEventManager()->getMousePos();
|
||||||
_touch_pt_scroll.x = -1;
|
_touch_pt_scroll.x = -1;
|
||||||
|
|
|
@ -20,11 +20,12 @@ public class ScummVMEvents implements
|
||||||
|
|
||||||
public static final int JE_SYS_KEY = 0;
|
public static final int JE_SYS_KEY = 0;
|
||||||
public static final int JE_KEY = 1;
|
public static final int JE_KEY = 1;
|
||||||
public static final int JE_DOWN = 2;
|
public static final int JE_DPAD = 2;
|
||||||
public static final int JE_SCROLL = 3;
|
public static final int JE_DOWN = 3;
|
||||||
public static final int JE_TAP = 4;
|
public static final int JE_SCROLL = 4;
|
||||||
public static final int JE_DOUBLE_TAP = 5;
|
public static final int JE_TAP = 5;
|
||||||
public static final int JE_BALL = 6;
|
public static final int JE_DOUBLE_TAP = 6;
|
||||||
|
public static final int JE_BALL = 7;
|
||||||
public static final int JE_QUIT = 0x1000;
|
public static final int JE_QUIT = 0x1000;
|
||||||
|
|
||||||
final protected Context _context;
|
final protected Context _context;
|
||||||
|
@ -136,6 +137,18 @@ public class ScummVMEvents implements
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (keyCode) {
|
||||||
|
case KeyEvent.KEYCODE_DPAD_UP:
|
||||||
|
case KeyEvent.KEYCODE_DPAD_DOWN:
|
||||||
|
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||||
|
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||||
|
case KeyEvent.KEYCODE_DPAD_CENTER:
|
||||||
|
_scummvm.pushEvent(JE_DPAD, action, keyCode,
|
||||||
|
(int)(e.getEventTime() - e.getDownTime()),
|
||||||
|
e.getRepeatCount(), 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_scummvm.pushEvent(JE_KEY, action, keyCode,
|
_scummvm.pushEvent(JE_KEY, action, keyCode,
|
||||||
e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
|
e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
|
||||||
e.getMetaState(), e.getRepeatCount());
|
e.getMetaState(), e.getRepeatCount());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue