summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon
diff options
context:
space:
mode:
authorTillmann Karras <tilkax@gmail.com>2014-03-15 03:29:53 +0100
committerTillmann Karras <tilkax@gmail.com>2014-03-17 02:55:57 +0100
commitfa3cc057530570ba4113e022b3f44c2483a87684 (patch)
tree346ce646a11c31b659b084cb9510ce5e03e357ba /Source/Core/InputCommon
parent7e39cf3b0d1bd41f830c8afe792bd0f2d9c8f2a6 (diff)
Turn some non-const refs into pointers
Diffstat (limited to 'Source/Core/InputCommon')
-rw-r--r--Source/Core/InputCommon/UDPWiimote.cpp46
-rw-r--r--Source/Core/InputCommon/UDPWiimote.h23
2 files changed, 36 insertions, 33 deletions
diff --git a/Source/Core/InputCommon/UDPWiimote.cpp b/Source/Core/InputCommon/UDPWiimote.cpp
index b4bccdb9f4..00023d66c3 100644
--- a/Source/Core/InputCommon/UDPWiimote.cpp
+++ b/Source/Core/InputCommon/UDPWiimote.cpp
@@ -65,9 +65,9 @@ struct UDPWiimote::_d
int UDPWiimote::noinst = 0;
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.c_str()))
+ port(_port), displayName(name), d(new _d),
+ waX(0), waY(0), waZ(1), naX(0), naY(0), naZ(-1), nunX(0), nunY(0),
+ pointerX(1001.0f / 2), pointerY(0), nunMask(0), wiimoteMask(0), index(_index), int_port(atoi(_port.c_str()))
{
static bool sranded=false;
@@ -275,9 +275,9 @@ int UDPWiimote::pharsePacket(u8 * bf, size_t size)
ux=(double)((s32)ntohl(*p)); p++;
uy=(double)((s32)ntohl(*p)); p++;
uz=(double)((s32)ntohl(*p)); p++;
- x=ux/1048576; //packet accel data
- y=uy/1048576;
- z=uz/1048576;
+ waX=ux/1048576; //packet accel data
+ waY=uy/1048576;
+ waZ=uz/1048576;
}
if (bf[2] & BUTT_FLAG)
@@ -285,7 +285,7 @@ int UDPWiimote::pharsePacket(u8 * bf, size_t size)
if ((size-(((u8*)p)-bf)) < 4)
return -1;
- mask=ntohl(*p); p++;
+ wiimoteMask = ntohl(*p); p++;
}
if (bf[2] & IR_FLAG)
@@ -388,43 +388,43 @@ void UDPWiimote::broadcastPresence()
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);
- _x=(float)x;
- _y=(float)y;
- _z=(float)z;
+ *x = (float)waX;
+ *y = (float)waY;
+ *z = (float)waZ;
}
u32 UDPWiimote::getButtons()
{
u32 msk;
std::lock_guard<std::mutex> lk(d->mutex);
- msk=mask;
+ msk = wiimoteMask;
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;
- _y=(float)pointerY;
+ *x = (float)pointerX;
+ *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);
- _x=(float)nunX;
- _y=(float)nunY;
- _mask=nunMask;
+ *x = (float)nunX;
+ *y = (float)nunY;
+ *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 std::string& UDPWiimote::getPort()
diff --git a/Source/Core/InputCommon/UDPWiimote.h b/Source/Core/InputCommon/UDPWiimote.h
index 806aa610e2..5dd2c500ca 100644
--- a/Source/Core/InputCommon/UDPWiimote.h
+++ b/Source/Core/InputCommon/UDPWiimote.h
@@ -27,12 +27,15 @@ class UDPWiimote
public:
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; }
+ 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);
@@ -42,12 +45,12 @@ private:
int pharsePacket(u8* data, size_t size);
struct _d; //using pimpl because Winsock2.h doesn't have include guards -_-
_d* d;
- double x,y,z;
- double naX,naY,naZ;
- double nunX,nunY;
- double pointerX,pointerY;
+ double waX, waY, waZ;
+ double naX, naY, naZ;
+ double nunX, nunY;
+ double pointerX, pointerY;
u8 nunMask;
- u32 mask;
+ u32 wiimoteMask;
u16 bcastMagic;
int err;
int index;