mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Change ControlState typedef to double, and change all related floats/doubles to use it.
Fixes an off by 1 issue related to double->float->double conversion, and eliminates numerous warnings.
This commit is contained in:
parent
64575d565a
commit
5adbc83453
@ -92,7 +92,7 @@ std::string GCPad::GetName() const
|
||||
|
||||
void GCPad::GetInput(GCPadStatus* const pad)
|
||||
{
|
||||
double x, y, triggers[2];
|
||||
ControlState x, y, triggers[2];
|
||||
|
||||
// buttons
|
||||
m_buttons->GetState(&pad->button, button_bitmasks);
|
||||
@ -121,8 +121,8 @@ void GCPad::GetInput(GCPadStatus* const pad)
|
||||
|
||||
void GCPad::SetMotor(const u8 on)
|
||||
{
|
||||
float state = static_cast<float>(on) / 255;
|
||||
float force = abs(state - 0.5f) * 2;
|
||||
ControlState state = static_cast<ControlState>(on) / 255;
|
||||
ControlState force = abs(state - 0.5) * 2;
|
||||
if (state < 0.5)
|
||||
force = -force;
|
||||
|
||||
|
@ -89,7 +89,7 @@ void Classic::GetState(u8* const data)
|
||||
|
||||
// left stick
|
||||
{
|
||||
double x, y;
|
||||
ControlState x, y;
|
||||
m_left_stick->GetState(&x, &y);
|
||||
|
||||
ccdata->lx = static_cast<u8>(Classic::LEFT_STICK_CENTER_X + (x * Classic::LEFT_STICK_RADIUS));
|
||||
@ -98,7 +98,7 @@ void Classic::GetState(u8* const data)
|
||||
|
||||
// right stick
|
||||
{
|
||||
double x, y;
|
||||
ControlState x, y;
|
||||
u8 x_, y_;
|
||||
m_right_stick->GetState(&x, &y);
|
||||
|
||||
@ -113,7 +113,7 @@ void Classic::GetState(u8* const data)
|
||||
|
||||
//triggers
|
||||
{
|
||||
double trigs[2] = { 0, 0 };
|
||||
ControlState trigs[2] = { 0, 0 };
|
||||
u8 lt, rt;
|
||||
m_triggers->GetState(&ccdata->bt, classic_trigger_bitmasks, trigs);
|
||||
|
||||
|
@ -60,7 +60,7 @@ void Drums::GetState(u8* const data)
|
||||
|
||||
// stick
|
||||
{
|
||||
double x, y;
|
||||
ControlState x, y;
|
||||
m_stick->GetState(&x, &y);
|
||||
|
||||
ddata->sx = static_cast<u8>((x * 0x1F) + 0x20);
|
||||
|
@ -73,7 +73,7 @@ void Guitar::GetState(u8* const data)
|
||||
|
||||
// stick
|
||||
{
|
||||
double x, y;
|
||||
ControlState x, y;
|
||||
m_stick->GetState(&x, &y);
|
||||
|
||||
gdata->sx = static_cast<u8>((x * 0x1F) + 0x20);
|
||||
@ -84,7 +84,7 @@ void Guitar::GetState(u8* const data)
|
||||
gdata->tb = 0x0F; // not touched
|
||||
|
||||
// whammy bar
|
||||
double whammy;
|
||||
ControlState whammy;
|
||||
m_whammy->GetState(&whammy);
|
||||
gdata->whammy = static_cast<u8>(whammy * 0x1F);
|
||||
|
||||
|
@ -62,7 +62,7 @@ void Turntable::GetState(u8* const data)
|
||||
|
||||
// stick
|
||||
{
|
||||
double x, y;
|
||||
ControlState x, y;
|
||||
m_stick->GetState(&x, &y);
|
||||
|
||||
ttdata->sx = static_cast<u8>((x * 0x1F) + 0x20);
|
||||
@ -71,7 +71,7 @@ void Turntable::GetState(u8* const data)
|
||||
|
||||
// left table
|
||||
{
|
||||
double tt;
|
||||
ControlState tt;
|
||||
s8 tt_;
|
||||
m_left_table->GetState(&tt);
|
||||
|
||||
@ -83,7 +83,7 @@ void Turntable::GetState(u8* const data)
|
||||
|
||||
// right table
|
||||
{
|
||||
double tt;
|
||||
ControlState tt;
|
||||
s8 tt_;
|
||||
m_right_table->GetState(&tt);
|
||||
|
||||
@ -97,7 +97,7 @@ void Turntable::GetState(u8* const data)
|
||||
|
||||
// effect dial
|
||||
{
|
||||
double dial;
|
||||
ControlState dial;
|
||||
u8 dial_;
|
||||
m_effect_dial->GetState(&dial);
|
||||
|
||||
@ -109,7 +109,7 @@ void Turntable::GetState(u8* const data)
|
||||
|
||||
// crossfade slider
|
||||
{
|
||||
double cfs;
|
||||
ControlState cfs;
|
||||
m_crossfade->GetState(&cfs);
|
||||
|
||||
ttdata->slider = static_cast<u8>((cfs * 0x07) + 0x08);
|
||||
|
@ -97,7 +97,7 @@ void EmulateShake(AccelData* const accel
|
||||
auto const shake_step_max = 15;
|
||||
|
||||
// peak G-force
|
||||
auto const shake_intensity = 3.f;
|
||||
auto const shake_intensity = 3.0;
|
||||
|
||||
// shake is a bitfield of X,Y,Z shake button states
|
||||
static const unsigned int btns[] = { 0x01, 0x02, 0x04 };
|
||||
@ -120,7 +120,7 @@ void EmulateTilt(AccelData* const accel
|
||||
, ControllerEmu::Tilt* const tilt_group
|
||||
, const bool sideways, const bool upright)
|
||||
{
|
||||
double roll, pitch;
|
||||
ControlState roll, pitch;
|
||||
// 180 degrees
|
||||
tilt_group->GetState(&roll, &pitch);
|
||||
|
||||
@ -152,13 +152,13 @@ void EmulateTilt(AccelData* const accel
|
||||
(&accel->x)[fb] = sin(pitch)*sgn[fb];
|
||||
}
|
||||
|
||||
#define SWING_INTENSITY 2.5f//-uncalibrated(aprox) 0x40-calibrated
|
||||
#define SWING_INTENSITY 2.5//-uncalibrated(aprox) 0x40-calibrated
|
||||
|
||||
void EmulateSwing(AccelData* const accel
|
||||
, ControllerEmu::Force* const swing_group
|
||||
, const bool sideways, const bool upright)
|
||||
{
|
||||
double swing[3];
|
||||
ControlState swing[3];
|
||||
swing_group->GetState(swing);
|
||||
|
||||
s8 g_dir[3] = {-1, -1, -1};
|
||||
@ -176,7 +176,7 @@ void EmulateSwing(AccelData* const accel
|
||||
if (!sideways && upright)
|
||||
g_dir[axis_map[0]] *= -1;
|
||||
|
||||
for (unsigned int i=0; i<3; ++i)
|
||||
for (unsigned int i = 0; i < 3; ++i)
|
||||
(&accel->x)[axis_map[i]] += swing[i] * g_dir[i] * SWING_INTENSITY;
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ void Wiimote::GetAccelData(u8* const data)
|
||||
|
||||
FillRawAccelFromGForceData(*(wm_accel*)data, *(accel_cal*)&m_eeprom[0x16], m_accel);
|
||||
}
|
||||
#define kCutoffFreq 5.0f
|
||||
#define kCutoffFreq 5.0
|
||||
inline void LowPassFilter(double & var, double newval, double period)
|
||||
{
|
||||
double RC=1.0/kCutoffFreq;
|
||||
@ -419,15 +419,15 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
|
||||
u16 x[4], y[4];
|
||||
memset(x, 0xFF, sizeof(x));
|
||||
|
||||
double xx = 10000, yy = 0, zz = 0;
|
||||
ControlState xx = 10000, yy = 0, zz = 0;
|
||||
double nsin,ncos;
|
||||
|
||||
if (use_accel)
|
||||
{
|
||||
double ax,az,len;
|
||||
ax=m_accel.x;
|
||||
az=m_accel.z;
|
||||
len=sqrt(ax*ax+az*az);
|
||||
ax = m_accel.x;
|
||||
az = m_accel.z;
|
||||
len = sqrt(ax*ax+az*az);
|
||||
if (len)
|
||||
{
|
||||
ax/=len;
|
||||
@ -449,8 +449,8 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
|
||||
ncos=1;
|
||||
}
|
||||
|
||||
LowPassFilter(ir_sin,nsin,1.0f/60);
|
||||
LowPassFilter(ir_cos,ncos,1.0f/60);
|
||||
LowPassFilter(ir_sin,nsin,1.0/60);
|
||||
LowPassFilter(ir_cos,ncos,1.0/60);
|
||||
|
||||
m_ir->GetState(&xx, &yy, &zz, true);
|
||||
|
||||
@ -462,14 +462,16 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
|
||||
static const double bnddown=0.85;
|
||||
static const double bndleft=0.443364;
|
||||
static const double bndright=-0.443364;
|
||||
static const double dist1=100.f/camWidth; //this seems the optimal distance for zelda
|
||||
static const double dist2=1.2f*dist1;
|
||||
static const double dist1=100.0/camWidth; //this seems the optimal distance for zelda
|
||||
static const double dist2=1.2*dist1;
|
||||
|
||||
for (auto& vtx : v)
|
||||
{
|
||||
vtx.x=xx*(bndright-bndleft)/2+(bndleft+bndright)/2;
|
||||
if (m_sensor_bar_on_top) vtx.y=yy*(bndup-bnddown)/2+(bndup+bnddown)/2;
|
||||
else vtx.y=yy*(bndup-bnddown)/2-(bndup+bnddown)/2;
|
||||
vtx.x = xx * (bndright - bndleft) / 2 + (bndleft + bndright) / 2;
|
||||
if (m_sensor_bar_on_top)
|
||||
vtx.y = yy * (bndup - bnddown) / 2 + (bndup + bnddown) / 2;
|
||||
else
|
||||
vtx.y = yy * (bndup - bnddown) / 2 - (bndup + bnddown) / 2;
|
||||
vtx.z=0;
|
||||
}
|
||||
|
||||
@ -487,7 +489,7 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
|
||||
//MatrixIdentity(rot);
|
||||
MatrixMultiply(tot,scale,rot);
|
||||
|
||||
for (int i=0; i<4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
MatrixTransformVertex(tot,v[i]);
|
||||
if ((v[i].x<-1)||(v[i].x>1)||(v[i].y<-1)||(v[i].y>1))
|
||||
@ -535,7 +537,7 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
|
||||
{
|
||||
memset(data, 0xFF, 12);
|
||||
wm_ir_extended* const irdata = (wm_ir_extended*)data;
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
if (x[i] < 1024 && y[i] < 768)
|
||||
{
|
||||
irdata[i].x = u8(x[i]);
|
||||
|
@ -43,7 +43,7 @@ static void DrawCenteredRectangle(wxDC &dc, int x, int y, int w, int h)
|
||||
|
||||
#define COORD_VIS_SIZE 4
|
||||
|
||||
static void DrawCoordinate(wxDC &dc, double x, double y)
|
||||
static void DrawCoordinate(wxDC &dc, ControlState x, ControlState y)
|
||||
{
|
||||
int xc = VIS_COORD(x);
|
||||
int yc = VIS_COORD(y);
|
||||
@ -60,7 +60,7 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
{
|
||||
// this is starting to be a mess combining all these in one case
|
||||
|
||||
double x = 0, y = 0, z = 0;
|
||||
ControlState x = 0, y = 0, z = 0;
|
||||
|
||||
switch (g->control_group->type)
|
||||
{
|
||||
@ -103,7 +103,7 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
dc.SetPen(LightGrayPen);
|
||||
|
||||
// polygon offset
|
||||
float max
|
||||
ControlState max
|
||||
, diagonal
|
||||
, box = 64
|
||||
, d_of = box / 256.0
|
||||
@ -111,18 +111,18 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
|
||||
if (g->control_group->name == "Main Stick")
|
||||
{
|
||||
max = (87.0f / 127.0f) * 100;
|
||||
diagonal = (55.0f / 127.0f) * 100;
|
||||
max = (87.0 / 127.0) * 100;
|
||||
diagonal = (55.0 / 127.0) * 100;
|
||||
}
|
||||
else if (g->control_group->name == "C-Stick")
|
||||
{
|
||||
max = (74.0f / 127.0f) * 100;
|
||||
diagonal = (46.0f / 127.0f) * 100;
|
||||
max = (74.0 / 127.0) * 100;
|
||||
diagonal = (46.0 / 127.0) * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
max = (82.0f / 127.0f) * 100;
|
||||
diagonal = (58.0f / 127.0f) * 100;
|
||||
max = (82.0 / 127.0) * 100;
|
||||
diagonal = (58.0 / 127.0) * 100;
|
||||
}
|
||||
|
||||
// polygon corners
|
||||
@ -153,7 +153,7 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
|
||||
// raw dot
|
||||
{
|
||||
float xx, yy;
|
||||
ControlState xx, yy;
|
||||
xx = g->control_group->controls[3]->control_ref->State();
|
||||
xx -= g->control_group->controls[2]->control_ref->State();
|
||||
yy = g->control_group->controls[1]->control_ref->State();
|
||||
@ -177,9 +177,9 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
break;
|
||||
case GROUP_TYPE_FORCE :
|
||||
{
|
||||
double raw_dot[3];
|
||||
double adj_dot[3];
|
||||
const float deadzone = g->control_group->settings[0]->value;
|
||||
ControlState raw_dot[3];
|
||||
ControlState adj_dot[3];
|
||||
const ControlState deadzone = g->control_group->settings[0]->value;
|
||||
|
||||
// adjusted
|
||||
((ControllerEmu::Force*)g->control_group)->GetState(adj_dot);
|
||||
@ -287,7 +287,7 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
ControlState deadzone = g->control_group->settings[0]->value;
|
||||
|
||||
double* const trigs = new double[trigger_count];
|
||||
ControlState* const trigs = new ControlState[trigger_count];
|
||||
((ControllerEmu::Triggers*)g->control_group)->GetState(trigs);
|
||||
|
||||
for (unsigned int n = 0; n < trigger_count; ++n)
|
||||
@ -363,7 +363,7 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
dc.DrawRectangle(31 + state * 30, 0, 2, 14);
|
||||
|
||||
double adj_state;
|
||||
ControlState adj_state;
|
||||
((ControllerEmu::Slider*)g->control_group)->GetState(&adj_state);
|
||||
if (state)
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::s
|
||||
{
|
||||
if (s->is_virtual)
|
||||
continue;
|
||||
sec->Set(group + s->name, s->value*100.0f, s->default_value*100.0f);
|
||||
sec->Set(group + s->name, (float)s->value * 100.0f, (float)s->default_value * 100.0f);
|
||||
}
|
||||
|
||||
for (auto& c : controls)
|
||||
@ -113,7 +113,7 @@ void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::s
|
||||
sec->Set(group + c->name, c->control_ref->expression, "");
|
||||
|
||||
// range
|
||||
sec->Set(group + c->name + "/Range", c->control_ref->range*100.0f, 100.0f);
|
||||
sec->Set(group + c->name + "/Range", (float) (c->control_ref->range*100.0, 100.0));
|
||||
}
|
||||
|
||||
// extensions
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
// The GameCube controller and Wiimote attachments have a different default radius
|
||||
AnalogStick(const char* const _name, ControlState default_radius);
|
||||
|
||||
void GetState(double* const x, double* const y)
|
||||
void GetState(ControlState* const x, ControlState* const y)
|
||||
{
|
||||
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
@ -167,7 +167,7 @@ public:
|
||||
ControlState dist = sqrt(xx*xx + yy*yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max(0.0f, dist - deadzone);
|
||||
dist = std::max(0.0, dist - deadzone);
|
||||
dist /= (1 - deadzone);
|
||||
|
||||
// radius
|
||||
@ -178,8 +178,8 @@ public:
|
||||
if (m)
|
||||
dist *= 0.5;
|
||||
|
||||
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
|
||||
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));
|
||||
yy = std::max(-1.0, std::min(1.0, ang_sin * dist));
|
||||
xx = std::max(-1.0, std::min(1.0, ang_cos * dist));
|
||||
|
||||
*y = yy;
|
||||
*x = xx;
|
||||
@ -210,7 +210,7 @@ public:
|
||||
public:
|
||||
MixedTriggers(const std::string& _name);
|
||||
|
||||
void GetState(u16 *const digital, const u16* bitmasks, double* analog)
|
||||
void GetState(u16 *const digital, const u16* bitmasks, ControlState* analog)
|
||||
{
|
||||
const unsigned int trig_count = ((unsigned int) (controls.size() / 2));
|
||||
for (unsigned int i=0; i<trig_count; ++i,++bitmasks,++analog)
|
||||
@ -233,12 +233,12 @@ public:
|
||||
public:
|
||||
Triggers(const std::string& _name);
|
||||
|
||||
void GetState(double* analog)
|
||||
void GetState(ControlState* analog)
|
||||
{
|
||||
const unsigned int trig_count = ((unsigned int) (controls.size()));
|
||||
const ControlState deadzone = settings[0]->value;
|
||||
for (unsigned int i=0; i<trig_count; ++i,++analog)
|
||||
*analog = std::max(controls[i]->control_ref->State() - deadzone, 0.0f) / (1 - deadzone);
|
||||
*analog = std::max(controls[i]->control_ref->State() - deadzone, 0.0) / (1 - deadzone);
|
||||
}
|
||||
};
|
||||
|
||||
@ -247,12 +247,12 @@ public:
|
||||
public:
|
||||
Slider(const std::string& _name);
|
||||
|
||||
void GetState(double* const slider)
|
||||
void GetState(ControlState* const slider)
|
||||
{
|
||||
const float deadzone = settings[0]->value;
|
||||
const float state = controls[1]->control_ref->State() - controls[0]->control_ref->State();
|
||||
const ControlState deadzone = settings[0]->value;
|
||||
const ControlState state = controls[1]->control_ref->State() - controls[0]->control_ref->State();
|
||||
|
||||
if (fabsf(state) > deadzone)
|
||||
if (fabs(state) > deadzone)
|
||||
*slider = (state - (deadzone * sign(state))) / (1 - deadzone);
|
||||
else
|
||||
*slider = 0;
|
||||
@ -264,24 +264,24 @@ public:
|
||||
public:
|
||||
Force(const std::string& _name);
|
||||
|
||||
void GetState(double* axis)
|
||||
void GetState(ControlState* axis)
|
||||
{
|
||||
const float deadzone = settings[0]->value;
|
||||
for (unsigned int i=0; i<6; i+=2)
|
||||
const ControlState deadzone = settings[0]->value;
|
||||
for (unsigned int i = 0; i < 6; i += 2)
|
||||
{
|
||||
float tmpf = 0;
|
||||
const float state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
|
||||
if (fabsf(state) > deadzone)
|
||||
ControlState tmpf = 0;
|
||||
const ControlState state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
|
||||
if (fabs(state) > deadzone)
|
||||
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
||||
|
||||
float &ax = m_swing[i >> 1];
|
||||
ControlState &ax = m_swing[i >> 1];
|
||||
*axis++ = (tmpf - ax);
|
||||
ax = tmpf;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
float m_swing[3];
|
||||
ControlState m_swing[3];
|
||||
};
|
||||
|
||||
class Tilt : public ControlGroup
|
||||
@ -289,7 +289,7 @@ public:
|
||||
public:
|
||||
Tilt(const std::string& _name);
|
||||
|
||||
void GetState(double* const x, double* const y, const bool step = true)
|
||||
void GetState(ControlState* const x, ControlState* const y, const bool step = true)
|
||||
{
|
||||
// this is all a mess
|
||||
|
||||
@ -298,7 +298,7 @@ public:
|
||||
|
||||
ControlState deadzone = settings[0]->value;
|
||||
ControlState circle = settings[1]->value;
|
||||
auto const angle = settings[2]->value / 1.8f;
|
||||
auto const angle = settings[2]->value / 1.8;
|
||||
ControlState m = controls[4]->control_ref->State();
|
||||
|
||||
// deadzone / circle stick code
|
||||
@ -309,7 +309,7 @@ public:
|
||||
ControlState ang_cos = cos(ang);
|
||||
|
||||
// the amt a full square stick would have at current angle
|
||||
ControlState square_full = std::min(ang_sin ? 1/fabsf(ang_sin) : 2, ang_cos ? 1/fabsf(ang_cos) : 2);
|
||||
ControlState square_full = std::min(ang_sin ? 1/fabs(ang_sin) : 2, ang_cos ? 1/fabs(ang_cos) : 2);
|
||||
|
||||
// the amt a full stick would have that was (user setting circular) at current angle
|
||||
// I think this is more like a pointed circle rather than a rounded square like it should be
|
||||
@ -318,7 +318,7 @@ public:
|
||||
ControlState dist = sqrt(xx*xx + yy*yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max(0.0f, dist - deadzone * stick_full);
|
||||
dist = std::max(0.0, dist - deadzone * stick_full);
|
||||
dist /= (1 - deadzone);
|
||||
|
||||
// circle stick code
|
||||
@ -328,8 +328,8 @@ public:
|
||||
if (m)
|
||||
dist *= 0.5;
|
||||
|
||||
yy = std::max(-1.0f, std::min(1.0f, ang_sin * dist));
|
||||
xx = std::max(-1.0f, std::min(1.0f, ang_cos * dist));
|
||||
yy = std::max(-1.0, std::min(1.0, ang_sin * dist));
|
||||
xx = std::max(-1.0, std::min(1.0, ang_cos * dist));
|
||||
|
||||
// this is kinda silly here
|
||||
// gui being open will make this happen 2x as fast, o well
|
||||
@ -338,14 +338,14 @@ public:
|
||||
if (step)
|
||||
{
|
||||
if (xx > m_tilt[0])
|
||||
m_tilt[0] = std::min(m_tilt[0] + 0.1f, xx);
|
||||
m_tilt[0] = std::min(m_tilt[0] + 0.1, xx);
|
||||
else if (xx < m_tilt[0])
|
||||
m_tilt[0] = std::max(m_tilt[0] - 0.1f, xx);
|
||||
m_tilt[0] = std::max(m_tilt[0] - 0.1, xx);
|
||||
|
||||
if (yy > m_tilt[1])
|
||||
m_tilt[1] = std::min(m_tilt[1] + 0.1f, yy);
|
||||
m_tilt[1] = std::min(m_tilt[1] + 0.1, yy);
|
||||
else if (yy < m_tilt[1])
|
||||
m_tilt[1] = std::max(m_tilt[1] - 0.1f, yy);
|
||||
m_tilt[1] = std::max(m_tilt[1] - 0.1, yy);
|
||||
}
|
||||
|
||||
*y = m_tilt[1] * angle;
|
||||
@ -353,7 +353,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
float m_tilt[2];
|
||||
ControlState m_tilt[2];
|
||||
};
|
||||
|
||||
class Cursor : public ControlGroup
|
||||
@ -361,34 +361,34 @@ public:
|
||||
public:
|
||||
Cursor(const std::string& _name);
|
||||
|
||||
void GetState(double* const x, double* const y, double* const z, const bool adjusted = false)
|
||||
void GetState(ControlState* const x, ControlState* const y, ControlState* const z, const bool adjusted = false)
|
||||
{
|
||||
const float zz = controls[4]->control_ref->State() - controls[5]->control_ref->State();
|
||||
const ControlState zz = controls[4]->control_ref->State() - controls[5]->control_ref->State();
|
||||
|
||||
// silly being here
|
||||
if (zz > m_z)
|
||||
m_z = std::min(m_z + 0.1f, zz);
|
||||
m_z = std::min(m_z + 0.1, zz);
|
||||
else if (zz < m_z)
|
||||
m_z = std::max(m_z - 0.1f, zz);
|
||||
m_z = std::max(m_z - 0.1, zz);
|
||||
|
||||
*z = m_z;
|
||||
|
||||
// hide
|
||||
if (controls[6]->control_ref->State() > 0.5f)
|
||||
if (controls[6]->control_ref->State() > 0.5)
|
||||
{
|
||||
*x = 10000; *y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
float xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
|
||||
// adjust cursor according to settings
|
||||
if (adjusted)
|
||||
{
|
||||
xx *= (settings[1]->value * 2);
|
||||
yy *= (settings[2]->value * 2);
|
||||
yy += (settings[0]->value - 0.5f);
|
||||
yy += (settings[0]->value - 0.5);
|
||||
}
|
||||
|
||||
*x = xx;
|
||||
@ -396,7 +396,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
float m_z;
|
||||
ControlState m_z;
|
||||
};
|
||||
|
||||
class Extension : public ControlGroup
|
||||
|
@ -266,7 +266,7 @@ std::string Joystick::Hat::GetName() const
|
||||
|
||||
ControlState Joystick::Axis::GetState() const
|
||||
{
|
||||
return std::max(0.0f, ControlState(m_axis - m_base) / m_range);
|
||||
return std::max(0.0, ControlState(m_axis - m_base) / m_range);
|
||||
}
|
||||
|
||||
ControlState Joystick::Button::GetState() const
|
||||
|
@ -298,12 +298,12 @@ ControlState KeyboardMouse::Button::GetState() const
|
||||
|
||||
ControlState KeyboardMouse::Axis::GetState() const
|
||||
{
|
||||
return std::max(0.0f, ControlState(m_axis) / m_range);
|
||||
return std::max(0.0, ControlState(m_axis) / m_range);
|
||||
}
|
||||
|
||||
ControlState KeyboardMouse::Cursor::GetState() const
|
||||
{
|
||||
return std::max(0.0f, ControlState(m_axis) / (m_positive ? 1.0f : -1.0f));
|
||||
return std::max(0.0, ControlState(m_axis) / (m_positive ? 1.0 : -1.0));
|
||||
}
|
||||
|
||||
void KeyboardMouse::Light::SetState(const ControlState state)
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "Common/Common.h"
|
||||
|
||||
// idk in case I wanted to change it to double or something, idk what's best
|
||||
typedef float ControlState;
|
||||
typedef double ControlState;
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ public:
|
||||
case TOK_OR:
|
||||
return std::max(lhsValue, rhsValue);
|
||||
case TOK_ADD:
|
||||
return std::min(lhsValue + rhsValue, 1.0f);
|
||||
return std::min(lhsValue + rhsValue, 1.0);
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
|
@ -253,7 +253,7 @@ ControlState Keyboard::Key::GetState() const
|
||||
|
||||
ControlState Keyboard::Cursor::GetState() const
|
||||
{
|
||||
return std::max(0.0f, ControlState(m_axis) / (m_positive ? 1.0f : -1.0f));
|
||||
return std::max(0.0, ControlState(m_axis) / (m_positive ? 1.0 : -1.0));
|
||||
}
|
||||
|
||||
ControlState Keyboard::Button::GetState() const
|
||||
|
@ -407,7 +407,7 @@ ControlState Joystick::Button::GetState() const
|
||||
|
||||
ControlState Joystick::Axis::GetState() const
|
||||
{
|
||||
return std::max(0.0f, ControlState(SDL_JoystickGetAxis(m_js, m_index)) / m_range);
|
||||
return std::max(0.0, ControlState(SDL_JoystickGetAxis(m_js, m_index)) / m_range);
|
||||
}
|
||||
|
||||
ControlState Joystick::Hat::GetState() const
|
||||
|
@ -256,7 +256,7 @@ ControlState Device::Trigger::GetState() const
|
||||
|
||||
ControlState Device::Axis::GetState() const
|
||||
{
|
||||
return std::max( 0.0f, ControlState(m_axis) / m_range );
|
||||
return std::max( 0.0, ControlState(m_axis) / m_range );
|
||||
}
|
||||
|
||||
void Device::Motor::SetState(ControlState state)
|
||||
|
Loading…
Reference in New Issue
Block a user