mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Kill off some usages of c_str.
Also changes some function params, but this is ok. Some simplifications were also able to be made (ie. killing off strcmps with ==, etc).
This commit is contained in:
@ -148,22 +148,22 @@ ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup(
|
||||
|
||||
}
|
||||
|
||||
ControllerEmu::Buttons::Buttons(const char* const _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS)
|
||||
ControllerEmu::Buttons::Buttons(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS)
|
||||
{
|
||||
settings.emplace_back(new Setting(_trans("Threshold"), 0.5f));
|
||||
}
|
||||
|
||||
ControllerEmu::MixedTriggers::MixedTriggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS)
|
||||
ControllerEmu::MixedTriggers::MixedTriggers(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS)
|
||||
{
|
||||
settings.emplace_back(new Setting(_trans("Threshold"), 0.9f));
|
||||
}
|
||||
|
||||
ControllerEmu::Triggers::Triggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS)
|
||||
ControllerEmu::Triggers::Triggers(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS)
|
||||
{
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
|
||||
ControllerEmu::Slider::Slider(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
|
||||
{
|
||||
controls.emplace_back(new Input("Left"));
|
||||
controls.emplace_back(new Input("Right"));
|
||||
@ -171,7 +171,7 @@ ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GRO
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP_TYPE_FORCE)
|
||||
ControllerEmu::Force::Force(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_FORCE)
|
||||
{
|
||||
memset(m_swing, 0, sizeof(m_swing));
|
||||
|
||||
@ -185,7 +185,7 @@ ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP
|
||||
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||
}
|
||||
|
||||
ControllerEmu::Tilt::Tilt(const char* const _name)
|
||||
ControllerEmu::Tilt::Tilt(const std::string& _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_TILT)
|
||||
{
|
||||
memset(m_tilt, 0, sizeof(m_tilt));
|
||||
@ -202,7 +202,7 @@ ControllerEmu::Tilt::Tilt(const char* const _name)
|
||||
settings.emplace_back(new Setting(_trans("Angle"), 0.9f, 0, 180));
|
||||
}
|
||||
|
||||
ControllerEmu::Cursor::Cursor(const char* const _name)
|
||||
ControllerEmu::Cursor::Cursor(const std::string& _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_CURSOR)
|
||||
, m_z(0)
|
||||
{
|
||||
|
@ -60,13 +60,13 @@ public:
|
||||
class Control
|
||||
{
|
||||
protected:
|
||||
Control(ControllerInterface::ControlReference* const _ref, const char* const _name)
|
||||
Control(ControllerInterface::ControlReference* const _ref, const std::string& _name)
|
||||
: control_ref(_ref), name(_name) {}
|
||||
|
||||
public:
|
||||
virtual ~Control() {}
|
||||
std::unique_ptr<ControllerInterface::ControlReference> const control_ref;
|
||||
const char* const name;
|
||||
const std::string name;
|
||||
|
||||
};
|
||||
|
||||
@ -74,7 +74,7 @@ public:
|
||||
{
|
||||
public:
|
||||
|
||||
Input(const char* const _name)
|
||||
Input(const std::string& _name)
|
||||
: Control(new ControllerInterface::InputReference, _name) {}
|
||||
};
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
{
|
||||
public:
|
||||
|
||||
Output(const char* const _name)
|
||||
Output(const std::string& _name)
|
||||
: Control(new ControllerInterface::OutputReference, _name) {}
|
||||
};
|
||||
|
||||
@ -90,7 +90,7 @@ public:
|
||||
{
|
||||
public:
|
||||
|
||||
Setting(const char* const _name, const ControlState def_value
|
||||
Setting(const std::string& _name, const ControlState def_value
|
||||
, const unsigned int _low = 0, const unsigned int _high = 100)
|
||||
: name(_name)
|
||||
, value(def_value)
|
||||
@ -98,19 +98,19 @@ public:
|
||||
, low(_low)
|
||||
, high(_high){}
|
||||
|
||||
const char* const name;
|
||||
const std::string name;
|
||||
ControlState value;
|
||||
const ControlState default_value;
|
||||
const unsigned int low, high;
|
||||
};
|
||||
|
||||
ControlGroup(const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
|
||||
ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
|
||||
virtual ~ControlGroup() {}
|
||||
|
||||
virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||
virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||
|
||||
const char* const name;
|
||||
const std::string name;
|
||||
const unsigned int type;
|
||||
|
||||
std::vector<std::unique_ptr<Control>> controls;
|
||||
@ -186,7 +186,7 @@ public:
|
||||
class Buttons : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Buttons(const char* const _name);
|
||||
Buttons(const std::string& _name);
|
||||
|
||||
template <typename C>
|
||||
void GetState(C* const buttons, const C* bitmasks)
|
||||
@ -224,7 +224,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
MixedTriggers(const char* const _name);
|
||||
MixedTriggers(const std::string& _name);
|
||||
|
||||
};
|
||||
|
||||
@ -241,7 +241,7 @@ public:
|
||||
*analog = S(std::max(controls[i]->control_ref->State() - deadzone, 0.0f) / (1 - deadzone) * range);
|
||||
}
|
||||
|
||||
Triggers(const char* const _name);
|
||||
Triggers(const std::string& _name);
|
||||
|
||||
};
|
||||
|
||||
@ -261,14 +261,14 @@ public:
|
||||
*slider = 0;
|
||||
}
|
||||
|
||||
Slider(const char* const _name);
|
||||
Slider(const std::string& _name);
|
||||
|
||||
};
|
||||
|
||||
class Force : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Force(const char* const _name);
|
||||
Force(const std::string& _name);
|
||||
|
||||
template <typename C, typename R>
|
||||
void GetState(C* axis, const u8 base, const R range)
|
||||
@ -294,7 +294,7 @@ public:
|
||||
class Tilt : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Tilt(const char* const _name);
|
||||
Tilt(const std::string& _name);
|
||||
|
||||
template <typename C, typename R>
|
||||
void GetState(C* const x, C* const y, const unsigned int base, const R range, const bool step = true)
|
||||
@ -374,7 +374,7 @@ public:
|
||||
class Cursor : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Cursor(const char* const _name);
|
||||
Cursor(const std::string& _name);
|
||||
|
||||
template <typename C>
|
||||
void GetState(C* const x, C* const y, C* const z, const bool adjusted = false)
|
||||
@ -418,7 +418,7 @@ public:
|
||||
class Extension : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Extension(const char* const _name)
|
||||
Extension(const std::string& _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_EXTENSION)
|
||||
, switch_extension(0)
|
||||
, active_extension(0) {}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <string>
|
||||
#include "InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h"
|
||||
|
||||
namespace ciface
|
||||
@ -17,7 +18,7 @@ template class ForceFeedbackDevice::Force<DIPERIODIC>;
|
||||
typedef struct
|
||||
{
|
||||
GUID guid;
|
||||
const char* name;
|
||||
const std::string name;
|
||||
} ForceType;
|
||||
|
||||
static const ForceType force_type_names[] =
|
||||
@ -216,7 +217,7 @@ void ForceFeedbackDevice::ForcePeriodic::SetState(const ControlState state)
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
ForceFeedbackDevice::Force<P>::Force(const char* name, EffectState& state)
|
||||
ForceFeedbackDevice::Force<P>::Force(const std::string& name, EffectState& state)
|
||||
: m_name(name), m_state(state)
|
||||
{
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
|
||||
@ -41,10 +42,10 @@ private:
|
||||
{
|
||||
public:
|
||||
std::string GetName() const;
|
||||
Force(const char* name, EffectState& state);
|
||||
Force(const std::string& name, EffectState& state);
|
||||
void SetState(ControlState state);
|
||||
private:
|
||||
const char* m_name;
|
||||
const std::string m_name;
|
||||
EffectState& m_state;
|
||||
P params;
|
||||
};
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Thread.h"
|
||||
#include "Common/Timer.h"
|
||||
@ -63,10 +64,10 @@ struct UDPWiimote::_d
|
||||
|
||||
int UDPWiimote::noinst = 0;
|
||||
|
||||
UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
|
||||
UDPWiimote::UDPWiimote(const std::string& _port, const std::string& name, int _index) :
|
||||
port(_port), displayName(name),
|
||||
d(new _d) ,x(0),y(0),z(1.0f),naX(0),naY(0),naZ(-1.0f),nunX(0),nunY(0),
|
||||
pointerX(1001.0f/2),pointerY(0),nunMask(0),mask(0),index(_index), int_port(atoi(_port))
|
||||
d(new _d) ,x(0), y(0), z(1.0f), naX(0), naY(0), naZ(-1.0f), nunX(0), nunY(0),
|
||||
pointerX(1001.0f / 2), pointerY(0), nunMask(0), mask(0), index(_index), int_port(atoi(_port.c_str()))
|
||||
{
|
||||
|
||||
static bool sranded=false;
|
||||
@ -107,7 +108,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
|
||||
return;
|
||||
}
|
||||
|
||||
if ((rv = getaddrinfo(nullptr, _port, &hints, &servinfo)) != 0)
|
||||
if ((rv = getaddrinfo(nullptr, _port.c_str(), &hints, &servinfo)) != 0)
|
||||
{
|
||||
cleanup;
|
||||
err=-1;
|
||||
@ -403,7 +404,7 @@ u32 UDPWiimote::getButtons()
|
||||
return msk;
|
||||
}
|
||||
|
||||
void UDPWiimote::getIR(float &_x, float &_y)
|
||||
void UDPWiimote::getIR(float& _x, float& _y)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(d->mutex);
|
||||
_x=(float)pointerX;
|
||||
@ -418,21 +419,21 @@ void UDPWiimote::getNunchuck(float &_x, float &_y, u8 &_mask)
|
||||
_mask=nunMask;
|
||||
}
|
||||
|
||||
void UDPWiimote::getNunchuckAccel(float &_x, float &_y, float &_z)
|
||||
void UDPWiimote::getNunchuckAccel(float& _x, float& _y, float& _z)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(d->mutex);
|
||||
_x=(float)naX;
|
||||
_y=(float)naY;
|
||||
_z=(float)naZ;
|
||||
_x = (float)naX;
|
||||
_y = (float)naY;
|
||||
_z = (float)naZ;
|
||||
}
|
||||
|
||||
const char * UDPWiimote::getPort()
|
||||
const std::string& UDPWiimote::getPort()
|
||||
{
|
||||
return port.c_str();
|
||||
return port;
|
||||
}
|
||||
|
||||
void UDPWiimote::changeName(const char * name)
|
||||
void UDPWiimote::changeName(const std::string& name)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(d->nameMutex);
|
||||
displayName=name;
|
||||
displayName = name;
|
||||
}
|
||||
|
@ -25,23 +25,23 @@
|
||||
class UDPWiimote
|
||||
{
|
||||
public:
|
||||
UDPWiimote(const char * port, const char * name, int index);
|
||||
UDPWiimote(const std::string& port, const std::string& name, int index);
|
||||
virtual ~UDPWiimote();
|
||||
void getAccel(float &x, float &y, float &z);
|
||||
void getAccel(float& x, float& y, float& z);
|
||||
u32 getButtons();
|
||||
void getNunchuck(float &x, float &y, u8 &mask);
|
||||
void getIR(float &x, float &y);
|
||||
void getNunchuckAccel(float &x, float &y, float &z);
|
||||
int getErrNo() {return err;};
|
||||
const char * getPort();
|
||||
void changeName(const char * name);
|
||||
void getNunchuck(float& x, float& y, u8& mask);
|
||||
void getIR(float& x, float& y);
|
||||
void getNunchuckAccel(float& x, float& y, float& z);
|
||||
int getErrNo() { return err; }
|
||||
const std::string& getPort();
|
||||
void changeName(const std::string& name);
|
||||
|
||||
void mainThread();
|
||||
private:
|
||||
std::string port,displayName;
|
||||
int pharsePacket(u8 * data, size_t size);
|
||||
int pharsePacket(u8* data, size_t size);
|
||||
struct _d; //using pimpl because Winsock2.h doesn't have include guards -_-
|
||||
_d *d;
|
||||
_d* d;
|
||||
double x,y,z;
|
||||
double naX,naY,naZ;
|
||||
double nunX,nunY;
|
||||
@ -54,8 +54,8 @@ private:
|
||||
int int_port;
|
||||
static int noinst;
|
||||
void broadcastPresence();
|
||||
void broadcastIPv4(const void * data, size_t size);
|
||||
void broadcastIPv6(const void * data, size_t size);
|
||||
void broadcastIPv4(const void* data, size_t size);
|
||||
void broadcastIPv6(const void* data, size_t size);
|
||||
void initBroadcastIPv4();
|
||||
void initBroadcastIPv6();
|
||||
};
|
||||
|
@ -69,12 +69,12 @@ void UDPWrapper::SaveConfig(IniFile::Section *sec, const std::string& defdev, co
|
||||
void UDPWrapper::Refresh()
|
||||
{
|
||||
bool udpAEn=(inst!=nullptr);
|
||||
if (udpEn&&udpAEn)
|
||||
if (udpEn && udpAEn)
|
||||
{
|
||||
if (strcmp(inst->getPort(),port.c_str()))
|
||||
if (inst->getPort() == port)
|
||||
{
|
||||
delete inst;
|
||||
inst = new UDPWiimote(port.c_str(),"Dolphin-Emu",index); //TODO: Changeable display name
|
||||
inst = new UDPWiimote(port, "Dolphin-Emu", index); //TODO: Changeable display name
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -86,7 +86,7 @@ void UDPWrapper::Refresh()
|
||||
return;
|
||||
}
|
||||
//else
|
||||
inst = new UDPWiimote(port.c_str(),"Dolphin-Emu",index);
|
||||
inst = new UDPWiimote(port, "Dolphin-Emu", index);
|
||||
}
|
||||
|
||||
UDPWrapper::~UDPWrapper()
|
||||
|
Reference in New Issue
Block a user