Cleanup title processing a bit.

This commit is contained in:
Unknown W. Brackets 2015-12-20 23:03:34 -08:00
parent 57b588456b
commit a89245a387
3 changed files with 32 additions and 29 deletions

View file

@ -892,20 +892,7 @@ bool NativeAxis(const AxisInput &axis) {
//now transform out current tilt to the calibrated coordinate system
Tilt trueTilt = GenTilt(baseTilt, currentTilt, g_Config.bInvertTiltX, g_Config.bInvertTiltY, g_Config.fDeadzoneRadius, xSensitivity, ySensitivity);
//now send the appropriate tilt event
switch (g_Config.iTiltInputType) {
case TILT_ANALOG:
GenerateAnalogStickEvent(trueTilt);
break;
case TILT_DPAD:
GenerateDPadEvent(trueTilt);
break;
case TILT_ACTION_BUTTON:
GenerateActionButtonEvent(trueTilt);
break;
}
TranslateTiltToInput(trueTilt);
return true;
}

View file

@ -1,6 +1,7 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include "TiltEventProcessor.h"
#include "UI/TiltEventProcessor.h"
#include "Core/Config.h"
#include "Core/HLE/sceCtrl.h"
#include "math.h"
#include "base/logging.h"
@ -72,6 +73,25 @@ Tilt TiltEventProcessor::GenTilt(const Tilt &baseTilt, const Tilt &currentTilt,
return dampTilt(transformedTilt, deadzone, xSensitivity, ySensitivity);
}
void TiltEventProcessor::TranslateTiltToInput(const Tilt &tilt) {
switch (g_Config.iTiltInputType) {
case TILT_NULL:
break;
case TILT_ANALOG:
GenerateAnalogStickEvent(tilt);
break;
case TILT_DPAD:
GenerateDPadEvent(tilt);
break;
case TILT_ACTION_BUTTON:
GenerateActionButtonEvent(tilt);
break;
}
}
void TiltEventProcessor::GenerateAnalogStickEvent(const Tilt &tilt) {
__CtrlSetAnalogX(clamp(tilt.x_), CTRL_STICK_LEFT);
__CtrlSetAnalogY(clamp(tilt.y_), CTRL_STICK_LEFT);
@ -82,14 +102,12 @@ void TiltEventProcessor::GenerateDPadEvent(const Tilt &tilt) {
static const int dir[4] = {CTRL_RIGHT, CTRL_DOWN, CTRL_LEFT, CTRL_UP};
if (tilt.x_ == 0) {
__CtrlButtonUp(CTRL_RIGHT);
__CtrlButtonUp(CTRL_LEFT);
__CtrlButtonUp(CTRL_RIGHT | CTRL_LEFT);
tiltButtonsDown &= ~(CTRL_LEFT | CTRL_RIGHT);
}
if (tilt.y_ == 0) {
__CtrlButtonUp(CTRL_UP);
__CtrlButtonUp(CTRL_DOWN);
__CtrlButtonUp(CTRL_UP | CTRL_DOWN);
tiltButtonsDown &= ~(CTRL_UP | CTRL_DOWN);
}
@ -118,14 +136,12 @@ void TiltEventProcessor::GenerateActionButtonEvent(const Tilt &tilt) {
static const int buttons[4] = {CTRL_CIRCLE, CTRL_CROSS, CTRL_SQUARE, CTRL_TRIANGLE};
if (tilt.x_ == 0) {
__CtrlButtonUp(CTRL_SQUARE);
__CtrlButtonUp(CTRL_CIRCLE);
__CtrlButtonUp(CTRL_SQUARE | CTRL_CIRCLE);
tiltButtonsDown &= ~(CTRL_SQUARE | CTRL_CIRCLE);
}
if (tilt.y_ == 0) {
__CtrlButtonUp(CTRL_TRIANGLE);
__CtrlButtonUp(CTRL_CROSS);
__CtrlButtonUp(CTRL_TRIANGLE | CTRL_CROSS);
tiltButtonsDown &= ~(CTRL_TRIANGLE | CTRL_CROSS);
}

View file

@ -11,12 +11,11 @@ namespace TiltEventProcessor {
//Represents a generic Tilt event
struct Tilt{
struct Tilt {
Tilt() : x_(0), y_(0) {}
Tilt(const float x, const float y) : x_(x), y_(y) {}
float x_, y_;
Tilt () : x_(0), y_(0) {};
Tilt (const float x, const float y) : x_(x), y_(y){}
};
@ -28,9 +27,10 @@ namespace TiltEventProcessor {
//NOTE- both base and current tilt *MUST BE NORMALIZED* by calling the NormalizeTilt() function.
Tilt GenTilt(const Tilt &baseTilt, const Tilt &currentTilt, bool invertX, bool invertY, float deadzone, float xSensitivity, float ySensitivity);
void TranslateTiltToInput(const Tilt &tilt);
//the next 3 functions generate tilt events given the current Tilt amount,
//and the deadzone radius.
//the next functions generate tilt events given the current Tilt amount,
//and the deadzone radius.
void GenerateAnalogStickEvent(const Tilt &tilt);
void GenerateDPadEvent(const Tilt &tilt);
void GenerateActionButtonEvent(const Tilt &tilt);