cleanup + some eolz

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5842 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004
2010-07-06 13:14:51 +00:00
parent 5133793c6c
commit e9e12ff100
19 changed files with 1117 additions and 1141 deletions

View File

@ -1,29 +1,29 @@
#include "UDPNunchuk.h"
#include "UDPWrapper.h"
#include "UDPWiimote.h"
#include "UDPNunchuk.h"
#include "UDPWrapper.h"
#include "UDPWiimote.h"
#define NUNCHUK_C 0x02
#define NUNCHUK_Z 0x01
#define NUNCHUK_Z 0x01
namespace WiimoteEmu
{
void UDPNunchuk::GetState( u8* const data, const bool focus )
{
Nunchuk::GetState(data,focus);
if (!(wrp->inst)) return;
wm_extension* const ncdata = (wm_extension*)data;
u8 mask;
float x,y;
wrp->inst->getNunchuck(x,y,mask);
if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C;
if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z;
if ((ncdata->jx==0x80)&&(ncdata->jy==0x80))
{
ncdata->jx=u8(0x80+x*127);
ncdata->jy=u8(0x80+y*127);
}
}
{
void UDPNunchuk::GetState( u8* const data, const bool focus )
{
Nunchuk::GetState(data, focus);
if (!(wrp->inst)) return;
wm_extension* const ncdata = (wm_extension*)data;
u8 mask;
float x, y;
wrp->inst->getNunchuck(x, y, mask);
if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C;
if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z;
if ((ncdata->jx==0x80)&&(ncdata->jy==0x80))
{
ncdata->jx=u8(0x80+x*127);
ncdata->jy=u8(0x80+y*127);
}
}
}

View File

@ -1,7 +1,7 @@
#ifndef UDPNUNCHUCK_H
#define UDPNUNCHUCK_H
#include "Nunchuk.h"
#ifndef UDPNUNCHUCK_H
#define UDPNUNCHUCK_H
#include "Nunchuk.h"
class UDPWrapper;
@ -11,11 +11,11 @@ namespace WiimoteEmu
class UDPNunchuk : public Nunchuk
{
public:
UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp ) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p
virtual void GetState( u8* const data, const bool focus );
private:
UDPWrapper * wrp;
};
}
#endif
UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p
virtual void GetState( u8* const data, const bool focus );
private:
UDPWrapper * wrp;
};
}
#endif

View File

@ -1,53 +1,53 @@
//UDP Wiimote Translation Layer
#ifndef UDPTLAYER_H
#define UDPTLAYER_H
#include "UDPWiimote.h"
namespace UDPTLayer
{
void GetButtons(UDPWrapper * m , wm_core * butt)
{
if (!(m->inst)) return;
if (!(m->updButt)) return;
u32 mask=m->inst->getButtons();
*butt|=(mask&UDPWM_BA)?WIIMOTE_A:0;
*butt|=(mask&UDPWM_BB)?WIIMOTE_B:0;
*butt|=(mask&UDPWM_B1)?WIIMOTE_ONE:0;
*butt|=(mask&UDPWM_B2)?WIIMOTE_TWO:0;
*butt|=(mask&UDPWM_BP)?WIIMOTE_PLUS:0;
*butt|=(mask&UDPWM_BM)?WIIMOTE_MINUS:0;
*butt|=(mask&UDPWM_BH)?WIIMOTE_HOME:0;
*butt|=(mask&UDPWM_BU)?WIIMOTE_PAD_UP:0;
*butt|=(mask&UDPWM_BD)?WIIMOTE_PAD_DOWN:0;
*butt|=(mask&UDPWM_BL)?WIIMOTE_PAD_LEFT:0;
*butt|=(mask&UDPWM_BR)?WIIMOTE_PAD_RIGHT:0;
}
void GetAcceleration(UDPWrapper * m , wm_accel * data, accel_cal * calib)
{
if (!(m->inst)) return;
if (!(m->updAccel)) return;
float x,y,z;
m->inst->getAccel(x,y,z);
data->x=u8(x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x);
data->y=u8(y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y);
data->z=u8(z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z);
}
void GetIR( UDPWrapper * m, float * x, float * y, float * z)
{
if (!(m->inst)) return;
if (!(m->updIR)) return;
if ((*x>-1)&&(*x<1)&&(*y>-1)&&(*y<1)) return; //the recieved values are used ONLY when the normal pointer is offscreen
float _x,_y;
m->inst->getIR(_x,_y);
*x=_x*2-1;
*y=-(_y*2-1);
*z=0;
}
}
#endif
//UDP Wiimote Translation Layer
#ifndef UDPTLAYER_H
#define UDPTLAYER_H
#include "UDPWiimote.h"
namespace UDPTLayer
{
void GetButtons(UDPWrapper * m , wm_core * butt)
{
if (!(m->inst)) return;
if (!(m->updButt)) return;
u32 mask=m->inst->getButtons();
*butt|=(mask&UDPWM_BA)?WIIMOTE_A:0;
*butt|=(mask&UDPWM_BB)?WIIMOTE_B:0;
*butt|=(mask&UDPWM_B1)?WIIMOTE_ONE:0;
*butt|=(mask&UDPWM_B2)?WIIMOTE_TWO:0;
*butt|=(mask&UDPWM_BP)?WIIMOTE_PLUS:0;
*butt|=(mask&UDPWM_BM)?WIIMOTE_MINUS:0;
*butt|=(mask&UDPWM_BH)?WIIMOTE_HOME:0;
*butt|=(mask&UDPWM_BU)?WIIMOTE_PAD_UP:0;
*butt|=(mask&UDPWM_BD)?WIIMOTE_PAD_DOWN:0;
*butt|=(mask&UDPWM_BL)?WIIMOTE_PAD_LEFT:0;
*butt|=(mask&UDPWM_BR)?WIIMOTE_PAD_RIGHT:0;
}
void GetAcceleration(UDPWrapper * m , wm_accel * data, accel_cal * calib)
{
if (!(m->inst)) return;
if (!(m->updAccel)) return;
float x,y,z;
m->inst->getAccel(x,y,z);
data->x=u8(x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x);
data->y=u8(y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y);
data->z=u8(z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z);
}
void GetIR( UDPWrapper * m, float * x, float * y, float * z)
{
if (!(m->inst)) return;
if (!(m->updIR)) return;
if ((*x>-1)&&(*x<1)&&(*y>-1)&&(*y<1)) return; //the recieved values are used ONLY when the normal pointer is offscreen
float _x,_y;
m->inst->getIR(_x,_y);
*x=_x*2-1;
*y=-(_y*2-1);
*z=0;
}
}
#endif