mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 18:27:26 +00:00
ANDROID: Add support for joystick motion
This commit is contained in:
parent
1b69f8aede
commit
a50ede203b
@ -146,7 +146,8 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
|
|||||||
_touchpad_scale(66),
|
_touchpad_scale(66),
|
||||||
_dpad_scale(4),
|
_dpad_scale(4),
|
||||||
_fingersDown(0),
|
_fingersDown(0),
|
||||||
_trackball_scale(2) {
|
_trackball_scale(2),
|
||||||
|
_joystick_scale(10) {
|
||||||
|
|
||||||
_fsFactory = new POSIXFilesystemFactory();
|
_fsFactory = new POSIXFilesystemFactory();
|
||||||
|
|
||||||
|
@ -231,6 +231,7 @@ private:
|
|||||||
int _touchpad_scale;
|
int _touchpad_scale;
|
||||||
int _trackball_scale;
|
int _trackball_scale;
|
||||||
int _dpad_scale;
|
int _dpad_scale;
|
||||||
|
int _joystick_scale;
|
||||||
int _fingersDown;
|
int _fingersDown;
|
||||||
|
|
||||||
void clipMouse(Common::Point &p);
|
void clipMouse(Common::Point &p);
|
||||||
|
@ -65,6 +65,7 @@ enum {
|
|||||||
JE_RMB_UP = 12,
|
JE_RMB_UP = 12,
|
||||||
JE_MOUSE_MOVE = 13,
|
JE_MOUSE_MOVE = 13,
|
||||||
JE_GAMEPAD = 14,
|
JE_GAMEPAD = 14,
|
||||||
|
JE_JOYSTICK = 15,
|
||||||
JE_QUIT = 0x1000
|
JE_QUIT = 0x1000
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -896,6 +897,31 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case JE_JOYSTICK:
|
||||||
|
e.mouse = getEventManager()->getMousePos();
|
||||||
|
|
||||||
|
switch (arg1) {
|
||||||
|
case JACTION_MULTIPLE:
|
||||||
|
e.type = Common::EVENT_MOUSEMOVE;
|
||||||
|
|
||||||
|
// already multiplied by 100
|
||||||
|
e.mouse.x += arg2 * _joystick_scale / _eventScaleX;
|
||||||
|
e.mouse.y += arg3 * _joystick_scale / _eventScaleY;
|
||||||
|
|
||||||
|
clipMouse(e.mouse);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOGE("unhandled jaction on joystick: %d", arg1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lockMutex(_event_queue_lock);
|
||||||
|
_event_queue.push(e);
|
||||||
|
unlockMutex(_event_queue_lock);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
case JE_QUIT:
|
case JE_QUIT:
|
||||||
e.type = Common::EVENT_QUIT;
|
e.type = Common::EVENT_QUIT;
|
||||||
|
|
||||||
|
@ -240,6 +240,14 @@ public class ScummVMActivity extends Activity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onGenericMotionEvent(final MotionEvent e) {
|
||||||
|
if (_events != null)
|
||||||
|
return _events.onGenericMotionEvent(e);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void showKeyboard(boolean show) {
|
private void showKeyboard(boolean show) {
|
||||||
SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
|
SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface);
|
||||||
InputMethodManager imm = (InputMethodManager)
|
InputMethodManager imm = (InputMethodManager)
|
||||||
|
@ -9,6 +9,7 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
|
import android.view.InputDevice;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
public class ScummVMEvents implements
|
public class ScummVMEvents implements
|
||||||
@ -32,6 +33,7 @@ public class ScummVMEvents implements
|
|||||||
public static final int JE_RMB_UP = 12;
|
public static final int JE_RMB_UP = 12;
|
||||||
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_QUIT = 0x1000;
|
public static final int JE_QUIT = 0x1000;
|
||||||
|
|
||||||
final protected Context _context;
|
final protected Context _context;
|
||||||
@ -64,6 +66,18 @@ public class ScummVMEvents implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onGenericMotionEvent(final MotionEvent e) {
|
||||||
|
if((e.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||||
|
_scummvm.pushEvent(JE_JOYSTICK, e.getAction(),
|
||||||
|
(int)(e.getAxisValue(MotionEvent.AXIS_X)*100),
|
||||||
|
(int)(e.getAxisValue(MotionEvent.AXIS_Y)*100),
|
||||||
|
0, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final static int MSG_MENU_LONG_PRESS = 1;
|
final static int MSG_MENU_LONG_PRESS = 1;
|
||||||
|
|
||||||
final private Handler keyHandler = new Handler() {
|
final private Handler keyHandler = new Handler() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user