mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Turn some non-const refs into pointers
This commit is contained in:
@ -114,7 +114,7 @@ bool IniFile::Section::Get(const std::string& key, std::string* value, const std
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, std::vector<std::string>& out)
|
bool IniFile::Section::Get(const std::string& key, std::vector<std::string>* out)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp);
|
bool retval = Get(key, &temp);
|
||||||
@ -132,7 +132,7 @@ bool IniFile::Section::Get(const std::string& key, std::vector<std::string>& out
|
|||||||
size_t subEnd = temp.find_first_of(",", subStart);
|
size_t subEnd = temp.find_first_of(",", subStart);
|
||||||
if (subStart != subEnd)
|
if (subStart != subEnd)
|
||||||
// take from first char until next ,
|
// take from first char until next ,
|
||||||
out.push_back(StripSpaces(temp.substr(subStart, subEnd - subStart)));
|
out->push_back(StripSpaces(temp.substr(subStart, subEnd - subStart)));
|
||||||
// Find the next non , char
|
// Find the next non , char
|
||||||
subStart = temp.find_first_not_of(",", subEnd);
|
subStart = temp.find_first_not_of(",", subEnd);
|
||||||
}
|
}
|
||||||
@ -273,23 +273,25 @@ bool IniFile::DeleteKey(const std::string& sectionName, const std::string& key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of all keys in a section
|
// Return a list of all keys in a section
|
||||||
bool IniFile::GetKeys(const std::string& sectionName, std::vector<std::string>& keys) const
|
bool IniFile::GetKeys(const std::string& sectionName, std::vector<std::string>* keys) const
|
||||||
{
|
{
|
||||||
const Section* section = GetSection(sectionName);
|
const Section* section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
keys = section->keys_order;
|
}
|
||||||
|
*keys = section->keys_order;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of all lines in a section
|
// Return a list of all lines in a section
|
||||||
bool IniFile::GetLines(const std::string& sectionName, std::vector<std::string>& lines, const bool remove_comments) const
|
bool IniFile::GetLines(const std::string& sectionName, std::vector<std::string>* lines, const bool remove_comments) const
|
||||||
{
|
{
|
||||||
const Section* section = GetSection(sectionName);
|
const Section* section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
lines.clear();
|
lines->clear();
|
||||||
for (std::string line : section->lines)
|
for (std::string line : section->lines)
|
||||||
{
|
{
|
||||||
line = StripSpaces(line);
|
line = StripSpaces(line);
|
||||||
@ -308,7 +310,7 @@ bool IniFile::GetLines(const std::string& sectionName, std::vector<std::string>&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.push_back(line);
|
lines->push_back(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -426,7 +428,7 @@ bool IniFile::Save(const std::string& filename)
|
|||||||
return File::RenameSync(temp, filename);
|
return File::RenameSync(temp, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Get(const std::string& sectionName, const std::string& key, std::vector<std::string>& values)
|
bool IniFile::Get(const std::string& sectionName, const std::string& key, std::vector<std::string>* values)
|
||||||
{
|
{
|
||||||
Section *section = GetSection(sectionName);
|
Section *section = GetSection(sectionName);
|
||||||
if (!section)
|
if (!section)
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
bool Get(const std::string& key, bool* value, bool defaultValue = false);
|
bool Get(const std::string& key, bool* value, bool defaultValue = false);
|
||||||
bool Get(const std::string& key, float* value, float defaultValue = false);
|
bool Get(const std::string& key, float* value, float defaultValue = false);
|
||||||
bool Get(const std::string& key, double* value, double defaultValue = false);
|
bool Get(const std::string& key, double* value, double defaultValue = false);
|
||||||
bool Get(const std::string& key, std::vector<std::string>& values);
|
bool Get(const std::string& key, std::vector<std::string>* values);
|
||||||
|
|
||||||
bool operator < (const Section& other) const {
|
bool operator < (const Section& other) const {
|
||||||
return name < other.name;
|
return name < other.name;
|
||||||
@ -116,7 +116,7 @@ public:
|
|||||||
bool Get(const std::string& sectionName, const std::string& key, int* value, int defaultValue = 0);
|
bool Get(const std::string& sectionName, const std::string& key, int* value, int defaultValue = 0);
|
||||||
bool Get(const std::string& sectionName, const std::string& key, u32* value, u32 defaultValue = 0);
|
bool Get(const std::string& sectionName, const std::string& key, u32* value, u32 defaultValue = 0);
|
||||||
bool Get(const std::string& sectionName, const std::string& key, bool* value, bool defaultValue = false);
|
bool Get(const std::string& sectionName, const std::string& key, bool* value, bool defaultValue = false);
|
||||||
bool Get(const std::string& sectionName, const std::string& key, std::vector<std::string>& values);
|
bool Get(const std::string& sectionName, const std::string& key, std::vector<std::string>* values);
|
||||||
bool Get(const std::string& sectionName, const std::string& key, std::string* value, const std::string& defaultValue = NULL_STRING);
|
bool Get(const std::string& sectionName, const std::string& key, std::string* value, const std::string& defaultValue = NULL_STRING);
|
||||||
|
|
||||||
template<typename T> bool GetIfExists(const std::string& sectionName, const std::string& key, T value)
|
template<typename T> bool GetIfExists(const std::string& sectionName, const std::string& key, T value)
|
||||||
@ -126,10 +126,10 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetKeys(const std::string& sectionName, std::vector<std::string>& keys) const;
|
bool GetKeys(const std::string& sectionName, std::vector<std::string>* keys) const;
|
||||||
|
|
||||||
void SetLines(const std::string& sectionName, const std::vector<std::string> &lines);
|
void SetLines(const std::string& sectionName, const std::vector<std::string>& lines);
|
||||||
bool GetLines(const std::string& sectionName, std::vector<std::string>& lines, const bool remove_comments = true) const;
|
bool GetLines(const std::string& sectionName, std::vector<std::string>* lines, const bool remove_comments = true) const;
|
||||||
|
|
||||||
bool DeleteKey(const std::string& sectionName, const std::string& key);
|
bool DeleteKey(const std::string& sectionName, const std::string& key);
|
||||||
bool DeleteSection(const std::string& sectionName);
|
bool DeleteSection(const std::string& sectionName);
|
||||||
|
@ -123,8 +123,8 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, bool forceLoad
|
|||||||
|
|
||||||
std::vector<std::string> enabledLines;
|
std::vector<std::string> enabledLines;
|
||||||
std::set<std::string> enabledNames;
|
std::set<std::string> enabledNames;
|
||||||
localIni.GetLines("ActionReplay_Enabled", enabledLines);
|
localIni.GetLines("ActionReplay_Enabled", &enabledLines);
|
||||||
for (auto& line : enabledLines)
|
for (const std::string& line : enabledLines)
|
||||||
{
|
{
|
||||||
if (line.size() != 0 && line[0] == '$')
|
if (line.size() != 0 && line[0] == '$')
|
||||||
{
|
{
|
||||||
@ -140,12 +140,14 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, bool forceLoad
|
|||||||
std::vector<std::string> encryptedLines;
|
std::vector<std::string> encryptedLines;
|
||||||
ARCode currentCode;
|
ARCode currentCode;
|
||||||
|
|
||||||
ini->GetLines("ActionReplay", lines);
|
ini->GetLines("ActionReplay", &lines);
|
||||||
|
|
||||||
for (std::string line : lines)
|
for (const std::string& line : lines)
|
||||||
{
|
{
|
||||||
if (line.empty())
|
if (line.empty())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> pieces;
|
std::vector<std::string> pieces;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<Ge
|
|||||||
for (const IniFile* ini : inis)
|
for (const IniFile* ini : inis)
|
||||||
{
|
{
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
ini->GetLines("Gecko", lines, false);
|
ini->GetLines("Gecko", &lines, false);
|
||||||
|
|
||||||
GeckoCode gcode;
|
GeckoCode gcode;
|
||||||
|
|
||||||
@ -72,19 +72,25 @@ void LoadCodes(const IniFile& globalIni, const IniFile& localIni, std::vector<Ge
|
|||||||
|
|
||||||
// add the last code
|
// add the last code
|
||||||
if (gcode.name.size())
|
if (gcode.name.size())
|
||||||
|
{
|
||||||
gcodes.push_back(gcode);
|
gcodes.push_back(gcode);
|
||||||
|
}
|
||||||
|
|
||||||
ini->GetLines("Gecko_Enabled", lines, false);
|
ini->GetLines("Gecko_Enabled", &lines, false);
|
||||||
|
|
||||||
for (auto line : lines)
|
for (const std::string& line : lines)
|
||||||
{
|
{
|
||||||
if (line.size() == 0 || line[0] != '$')
|
if (line.size() == 0 || line[0] != '$')
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
std::string name = line.substr(1);
|
std::string name = line.substr(1);
|
||||||
for (auto& ogcode : gcodes)
|
for (GeckoCode& ogcode : gcodes)
|
||||||
{
|
{
|
||||||
if (ogcode.name == name)
|
if (ogcode.name == name)
|
||||||
|
{
|
||||||
ogcode.enabled = true;
|
ogcode.enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
|
|||||||
{
|
{
|
||||||
u8 mask;
|
u8 mask;
|
||||||
float x, y;
|
float x, y;
|
||||||
m_udpWrap->inst->getNunchuck(x, y, mask);
|
m_udpWrap->inst->getNunchuck(&x, &y, &mask);
|
||||||
// buttons
|
// buttons
|
||||||
if (mask & UDPWM_NC)
|
if (mask & UDPWM_NC)
|
||||||
ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_C;
|
ncdata->bt &= ~WiimoteEmu::Nunchuk::BUTTON_C;
|
||||||
@ -146,7 +146,7 @@ void Nunchuk::GetState(u8* const data, const bool focus)
|
|||||||
if (m_udpWrap->updNunAccel)
|
if (m_udpWrap->updNunAccel)
|
||||||
{
|
{
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
m_udpWrap->inst->getNunchuckAccel(x, y, z);
|
m_udpWrap->inst->getNunchuckAccel(&x, &y, &z);
|
||||||
accel.x = x;
|
accel.x = x;
|
||||||
accel.y = y;
|
accel.y = y;
|
||||||
accel.z = z;
|
accel.z = z;
|
||||||
|
@ -34,7 +34,7 @@ namespace UDPTLayer
|
|||||||
if (!(m->inst)) return;
|
if (!(m->inst)) return;
|
||||||
if (!(m->updAccel)) return;
|
if (!(m->updAccel)) return;
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
m->inst->getAccel(x, y, z);
|
m->inst->getAccel(&x, &y, &z);
|
||||||
data->x = x;
|
data->x = x;
|
||||||
data->y = y;
|
data->y = y;
|
||||||
data->z = z;
|
data->z = z;
|
||||||
@ -46,7 +46,7 @@ namespace UDPTLayer
|
|||||||
if (!(m->updIR)) return;
|
if (!(m->updIR)) return;
|
||||||
if ((*x >= -0.999) && (*x <= 0.999) && (*y >= -0.999) && (*y <= 0.999)) return; //the received values are used ONLY when the normal pointer is offscreen
|
if ((*x >= -0.999) && (*x <= 0.999) && (*y >= -0.999) && (*y <= 0.999)) return; //the received values are used ONLY when the normal pointer is offscreen
|
||||||
float _x, _y;
|
float _x, _y;
|
||||||
m->inst->getIR(_x, _y);
|
m->inst->getIR(&_x, &_y);
|
||||||
*x = _x * 2 - 1;
|
*x = _x * 2 - 1;
|
||||||
*y = -(_y * 2 - 1);
|
*y = -(_y * 2 - 1);
|
||||||
*z = 0;
|
*z = 0;
|
||||||
|
@ -53,7 +53,7 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
|
|||||||
std::string enabledSectionName = section + "_Enabled";
|
std::string enabledSectionName = section + "_Enabled";
|
||||||
std::vector<std::string> enabledLines;
|
std::vector<std::string> enabledLines;
|
||||||
std::set<std::string> enabledNames;
|
std::set<std::string> enabledNames;
|
||||||
localIni.GetLines(enabledSectionName, enabledLines);
|
localIni.GetLines(enabledSectionName, &enabledLines);
|
||||||
for (const std::string& line : enabledLines)
|
for (const std::string& line : enabledLines)
|
||||||
{
|
{
|
||||||
if (line.size() != 0 && line[0] == '$')
|
if (line.size() != 0 && line[0] == '$')
|
||||||
@ -69,7 +69,7 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
|
|||||||
{
|
{
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
Patch currentPatch;
|
Patch currentPatch;
|
||||||
ini->GetLines(section, lines);
|
ini->GetLines(section, &lines);
|
||||||
|
|
||||||
for (std::string& line : lines)
|
for (std::string& line : lines)
|
||||||
{
|
{
|
||||||
@ -80,7 +80,9 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
|
|||||||
{
|
{
|
||||||
// Take care of the previous code
|
// Take care of the previous code
|
||||||
if (currentPatch.name.size())
|
if (currentPatch.name.size())
|
||||||
|
{
|
||||||
patches.push_back(currentPatch);
|
patches.push_back(currentPatch);
|
||||||
|
}
|
||||||
currentPatch.entries.clear();
|
currentPatch.entries.clear();
|
||||||
|
|
||||||
// Set active and name
|
// Set active and name
|
||||||
@ -93,7 +95,9 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
|
|||||||
std::string::size_type loc = line.find_first_of('=', 0);
|
std::string::size_type loc = line.find_first_of('=', 0);
|
||||||
|
|
||||||
if (loc != std::string::npos)
|
if (loc != std::string::npos)
|
||||||
|
{
|
||||||
line[loc] = ':';
|
line[loc] = ':';
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> items;
|
std::vector<std::string> items;
|
||||||
SplitString(line, ':', items);
|
SplitString(line, ':', items);
|
||||||
@ -108,33 +112,41 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
|
|||||||
pE.type = PatchType(std::find(PatchTypeStrings, PatchTypeStrings + 3, items[1]) - PatchTypeStrings);
|
pE.type = PatchType(std::find(PatchTypeStrings, PatchTypeStrings + 3, items[1]) - PatchTypeStrings);
|
||||||
success &= (pE.type != (PatchType)3);
|
success &= (pE.type != (PatchType)3);
|
||||||
if (success)
|
if (success)
|
||||||
|
{
|
||||||
currentPatch.entries.push_back(pE);
|
currentPatch.entries.push_back(pE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPatch.name.size() && currentPatch.entries.size())
|
if (currentPatch.name.size() && currentPatch.entries.size())
|
||||||
|
{
|
||||||
patches.push_back(currentPatch);
|
patches.push_back(currentPatch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadDiscList(const char *section, std::vector<std::string> &_discList, IniFile &ini)
|
static void LoadDiscList(const std::string& section, IniFile& ini)
|
||||||
{
|
{
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
if (!ini.GetLines(section, lines))
|
if (!ini.GetLines(section, &lines))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const std::string& line : lines)
|
for (const std::string& line : lines)
|
||||||
{
|
{
|
||||||
if (!line.empty())
|
if (!line.empty())
|
||||||
_discList.push_back(line);
|
{
|
||||||
|
discList.push_back(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadSpeedhacks(const char *section, std::map<u32, int> &hacks, IniFile &ini)
|
static void LoadSpeedhacks(const std::string& section, IniFile& ini)
|
||||||
{
|
{
|
||||||
std::vector<std::string> keys;
|
std::vector<std::string> keys;
|
||||||
ini.GetKeys(section, keys);
|
ini.GetKeys(section, &keys);
|
||||||
for (const std::string& key : keys)
|
for (const std::string& key : keys)
|
||||||
{
|
{
|
||||||
std::string value;
|
std::string value;
|
||||||
@ -146,7 +158,8 @@ static void LoadSpeedhacks(const char *section, std::map<u32, int> &hacks, IniFi
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
success &= TryParse(key, &address);
|
success &= TryParse(key, &address);
|
||||||
success &= TryParse(value, &cycles);
|
success &= TryParse(value, &cycles);
|
||||||
if (success) {
|
if (success)
|
||||||
|
{
|
||||||
speedHacks[address] = (int)cycles;
|
speedHacks[address] = (int)cycles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,8 +189,8 @@ void LoadPatches()
|
|||||||
Gecko::LoadCodes(globalIni, localIni, gcodes);
|
Gecko::LoadCodes(globalIni, localIni, gcodes);
|
||||||
Gecko::SetActiveCodes(gcodes);
|
Gecko::SetActiveCodes(gcodes);
|
||||||
|
|
||||||
LoadSpeedhacks("Speedhacks", speedHacks, merged);
|
LoadSpeedhacks("Speedhacks", merged);
|
||||||
LoadDiscList("DiscList", discList, merged);
|
LoadDiscList("DiscList", merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyPatches(const std::vector<Patch> &patches)
|
void ApplyPatches(const std::vector<Patch> &patches)
|
||||||
|
@ -112,7 +112,7 @@ CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent
|
|||||||
m_BreakPointListView = new CBreakPointView(this, wxID_ANY);
|
m_BreakPointListView = new CBreakPointView(this, wxID_ANY);
|
||||||
|
|
||||||
m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top().
|
m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top().
|
||||||
LeftDockable(false).RightDockable(false).BottomDockable(false).Floatable(false));
|
LeftDockable(false).RightDockable(false).BottomDockable(false).Floatable(false));
|
||||||
m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane());
|
m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane());
|
||||||
m_mgr.Update();
|
m_mgr.Update();
|
||||||
}
|
}
|
||||||
@ -195,12 +195,19 @@ void CBreakPointWindow::LoadAll(wxCommandEvent& WXUNUSED(event))
|
|||||||
MemChecks::TMemChecksStr newmcs;
|
MemChecks::TMemChecksStr newmcs;
|
||||||
|
|
||||||
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ini.GetLines("BreakPoints", newbps, false))
|
if (ini.GetLines("BreakPoints", &newbps, false))
|
||||||
|
{
|
||||||
PowerPC::breakpoints.AddFromStrings(newbps);
|
PowerPC::breakpoints.AddFromStrings(newbps);
|
||||||
if (ini.GetLines("MemoryChecks", newmcs, false))
|
}
|
||||||
|
|
||||||
|
if (ini.GetLines("MemoryChecks", &newmcs, false))
|
||||||
|
{
|
||||||
PowerPC::memchecks.AddFromStrings(newmcs);
|
PowerPC::memchecks.AddFromStrings(newmcs);
|
||||||
|
}
|
||||||
|
|
||||||
NotifyUpdate();
|
NotifyUpdate();
|
||||||
}
|
}
|
||||||
|
@ -851,7 +851,9 @@ void CFrame::LoadIniPerspectives()
|
|||||||
|
|
||||||
// Don't save a blank perspective
|
// Don't save a blank perspective
|
||||||
if (Tmp.Name.empty())
|
if (Tmp.Name.empty())
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
|
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
|
||||||
ini.Get(_Section, "Perspective", &_Perspective,
|
ini.Get(_Section, "Perspective", &_Perspective,
|
||||||
|
@ -65,9 +65,9 @@ struct UDPWiimote::_d
|
|||||||
int UDPWiimote::noinst = 0;
|
int UDPWiimote::noinst = 0;
|
||||||
|
|
||||||
UDPWiimote::UDPWiimote(const std::string& _port, const std::string& name, int _index) :
|
UDPWiimote::UDPWiimote(const std::string& _port, const std::string& name, int _index) :
|
||||||
port(_port), displayName(name),
|
port(_port), displayName(name), d(new _d),
|
||||||
d(new _d) ,x(0), y(0), z(1.0f), naX(0), naY(0), naZ(-1.0f), nunX(0), nunY(0),
|
waX(0), waY(0), waZ(1), naX(0), naY(0), naZ(-1), nunX(0), nunY(0),
|
||||||
pointerX(1001.0f / 2), pointerY(0), nunMask(0), mask(0), index(_index), int_port(atoi(_port.c_str()))
|
pointerX(1001.0f / 2), pointerY(0), nunMask(0), wiimoteMask(0), index(_index), int_port(atoi(_port.c_str()))
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool sranded=false;
|
static bool sranded=false;
|
||||||
@ -275,9 +275,9 @@ int UDPWiimote::pharsePacket(u8 * bf, size_t size)
|
|||||||
ux=(double)((s32)ntohl(*p)); p++;
|
ux=(double)((s32)ntohl(*p)); p++;
|
||||||
uy=(double)((s32)ntohl(*p)); p++;
|
uy=(double)((s32)ntohl(*p)); p++;
|
||||||
uz=(double)((s32)ntohl(*p)); p++;
|
uz=(double)((s32)ntohl(*p)); p++;
|
||||||
x=ux/1048576; //packet accel data
|
waX=ux/1048576; //packet accel data
|
||||||
y=uy/1048576;
|
waY=uy/1048576;
|
||||||
z=uz/1048576;
|
waZ=uz/1048576;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bf[2] & BUTT_FLAG)
|
if (bf[2] & BUTT_FLAG)
|
||||||
@ -285,7 +285,7 @@ int UDPWiimote::pharsePacket(u8 * bf, size_t size)
|
|||||||
if ((size-(((u8*)p)-bf)) < 4)
|
if ((size-(((u8*)p)-bf)) < 4)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
mask=ntohl(*p); p++;
|
wiimoteMask = ntohl(*p); p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bf[2] & IR_FLAG)
|
if (bf[2] & IR_FLAG)
|
||||||
@ -388,43 +388,43 @@ void UDPWiimote::broadcastPresence()
|
|||||||
broadcastIPv6(bf,7+slen);
|
broadcastIPv6(bf,7+slen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPWiimote::getAccel(float &_x, float &_y, float &_z)
|
void UDPWiimote::getAccel(float* x, float* y, float* z)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(d->mutex);
|
std::lock_guard<std::mutex> lk(d->mutex);
|
||||||
_x=(float)x;
|
*x = (float)waX;
|
||||||
_y=(float)y;
|
*y = (float)waY;
|
||||||
_z=(float)z;
|
*z = (float)waZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 UDPWiimote::getButtons()
|
u32 UDPWiimote::getButtons()
|
||||||
{
|
{
|
||||||
u32 msk;
|
u32 msk;
|
||||||
std::lock_guard<std::mutex> lk(d->mutex);
|
std::lock_guard<std::mutex> lk(d->mutex);
|
||||||
msk=mask;
|
msk = wiimoteMask;
|
||||||
return msk;
|
return msk;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPWiimote::getIR(float& _x, float& _y)
|
void UDPWiimote::getIR(float* x, float* y)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(d->mutex);
|
std::lock_guard<std::mutex> lk(d->mutex);
|
||||||
_x=(float)pointerX;
|
*x = (float)pointerX;
|
||||||
_y=(float)pointerY;
|
*y = (float)pointerY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPWiimote::getNunchuck(float &_x, float &_y, u8 &_mask)
|
void UDPWiimote::getNunchuck(float* x, float* y, u8* mask)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(d->mutex);
|
std::lock_guard<std::mutex> lk(d->mutex);
|
||||||
_x=(float)nunX;
|
*x = (float)nunX;
|
||||||
_y=(float)nunY;
|
*y = (float)nunY;
|
||||||
_mask=nunMask;
|
*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);
|
std::lock_guard<std::mutex> lk(d->mutex);
|
||||||
_x = (float)naX;
|
*x = (float)naX;
|
||||||
_y = (float)naY;
|
*y = (float)naY;
|
||||||
_z = (float)naZ;
|
*z = (float)naZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& UDPWiimote::getPort()
|
const std::string& UDPWiimote::getPort()
|
||||||
|
@ -27,12 +27,15 @@ class UDPWiimote
|
|||||||
public:
|
public:
|
||||||
UDPWiimote(const std::string& port, const std::string& name, int index);
|
UDPWiimote(const std::string& port, const std::string& name, int index);
|
||||||
virtual ~UDPWiimote();
|
virtual ~UDPWiimote();
|
||||||
void getAccel(float& x, float& y, float& z);
|
void getAccel(float* x, float* y, float* z);
|
||||||
u32 getButtons();
|
u32 getButtons();
|
||||||
void getNunchuck(float& x, float& y, u8& mask);
|
void getNunchuck(float* x, float* y, u8* mask);
|
||||||
void getIR(float& x, float& y);
|
void getIR(float* x, float* y);
|
||||||
void getNunchuckAccel(float& x, float& y, float& z);
|
void getNunchuckAccel(float* x, float* y, float* z);
|
||||||
int getErrNo() { return err; }
|
int getErrNo()
|
||||||
|
{
|
||||||
|
return err;
|
||||||
|
}
|
||||||
const std::string& getPort();
|
const std::string& getPort();
|
||||||
void changeName(const std::string& name);
|
void changeName(const std::string& name);
|
||||||
|
|
||||||
@ -42,12 +45,12 @@ private:
|
|||||||
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 -_-
|
struct _d; //using pimpl because Winsock2.h doesn't have include guards -_-
|
||||||
_d* d;
|
_d* d;
|
||||||
double x,y,z;
|
double waX, waY, waZ;
|
||||||
double naX,naY,naZ;
|
double naX, naY, naZ;
|
||||||
double nunX,nunY;
|
double nunX, nunY;
|
||||||
double pointerX,pointerY;
|
double pointerX, pointerY;
|
||||||
u8 nunMask;
|
u8 nunMask;
|
||||||
u32 mask;
|
u32 wiimoteMask;
|
||||||
u16 bcastMagic;
|
u16 bcastMagic;
|
||||||
int err;
|
int err;
|
||||||
int index;
|
int index;
|
||||||
|
Reference in New Issue
Block a user