Update native with tilt Y/Z axis fix. Fix tilt in portrait mode.

This commit is contained in:
Henrik Rydgard 2014-07-20 18:30:43 +02:00
parent 1140bc7539
commit 93d1a0b175
2 changed files with 24 additions and 18 deletions

View File

@ -772,50 +772,56 @@ bool NativeKey(const KeyInput &key) {
return retval;
}
bool NativeAxis(const AxisInput &key) {
bool NativeAxis(const AxisInput &axis) {
using namespace TiltEventProcessor;
// only handle tilt events if tilt is enabled.
if (g_Config.iTiltInputType == TILT_NULL){
if (g_Config.iTiltInputType == TILT_NULL) {
// if tilt events are disabled, then run it through the usual way.
if (screenManager) {
screenManager->axis(key);
return true;
return screenManager->axis(axis);
} else {
return false;
}
}
//create the base coordinate tilt system from the calibration data.
//This is static for no particular reason, can be un-static'ed
// create the base coordinate tilt system from the calibration data.
// This is static for no particular reason, can be un-static'ed
static Tilt baseTilt;
baseTilt.x_ = g_Config.fTiltBaseX;
baseTilt.y_ = g_Config.fTiltBaseY;
//figure out what the current tilt orientation is by checking the axis event
//This is static, since we need to remember where we last were (in terms of orientation)
// figure out what the current tilt orientation is by checking the axis event
// This is static, since we need to remember where we last were (in terms of orientation)
static Tilt currentTilt;
switch (key.axisId) {
// x and y are flipped if we are in landscape orientation. The events are
// sent with respect to the portrait coordinate system, while we
// take all events in landscape.
// see [http://developer.android.com/guide/topics/sensors/sensors_overview.html] for details
bool portrait = dp_yres > dp_xres;
switch (axis.axisId) {
case JOYSTICK_AXIS_ACCELEROMETER_X:
//x and y are flipped due to landscape orientation. The events are
//sent with respect to the portrait coordinate system, while we
//take all events in landscape.
//see [http://developer.android.com/guide/topics/sensors/sensors_overview.html] for details
currentTilt.y_ = key.value;
if (portrait) {
currentTilt.x_ = axis.value;
} else {
currentTilt.y_ = axis.value;
}
break;
case JOYSTICK_AXIS_ACCELEROMETER_Y:
currentTilt.x_ = key.value;
if (portrait) {
currentTilt.y_ = axis.value;
} else {
currentTilt.x_ = axis.value;
}
break;
case JOYSTICK_AXIS_ACCELEROMETER_Z:
//don't handle this now as only landscape is enabled.
//TODO: make this generic.
return false;
case JOYSTICK_AXIS_OUYA_UNKNOWN1:
case JOYSTICK_AXIS_OUYA_UNKNOWN2:
case JOYSTICK_AXIS_OUYA_UNKNOWN3:

2
native

@ -1 +1 @@
Subproject commit a9ab9bcdca0c938e716d0d5d59a2676c3e2bf530
Subproject commit 1d77b9435562e67d2814db99c89a752febd6dbe4