Skip to content

Commit

Permalink
Merge branch 'UDPWii' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kevlahnota authored Jun 7, 2017
2 parents e85d335 + c4f3122 commit 17aa35d
Show file tree
Hide file tree
Showing 19 changed files with 3,121 additions and 1,573 deletions.
1 change: 1 addition & 0 deletions Source/Core/Common/CommonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef u16 wm_core;
1 change: 1 addition & 0 deletions Source/Core/Core/Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@
<ClInclude Include="HW\WiimoteEmu\Attachment\Turntable.h" />
<ClInclude Include="HW\WiimoteEmu\Encryption.h" />
<ClInclude Include="HW\WiimoteEmu\MatrixMath.h" />
<ClInclude Include="HW\WiimoteEmu\UDPTLayer.h" />
<ClInclude Include="HW\WiimoteEmu\WiimoteEmu.h" />
<ClInclude Include="HW\WiimoteEmu\WiimoteHid.h" />
<ClInclude Include="HW\WiimoteReal\WiimoteReal.h" />
Expand Down
5 changes: 4 additions & 1 deletion Source/Core/Core/Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,11 @@
<ClInclude Include="ConfigLoaders\IsSettingSaveable.h">
<Filter>ConfigLoader</Filter>
</ClInclude>
<ClInclude Include="HW\WiimoteEmu\UDPTLayer.h">
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>
50 changes: 50 additions & 0 deletions Source/Core/Core/HW/WiimoteEmu/UDPTLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "InputCommon/UDPWiimote.h"

namespace UDPTLayer
{
static void GetButtons(UDPWrapper * m, wm_core * butt)
{
if (!(m->inst)) return;
if (!(m->updButt)) return;
u32 mask = m->inst->getButtons();
*butt |= (mask & UDPWM_BA) ? WiimoteEmu::Wiimote::BUTTON_A : 0;
*butt |= (mask & UDPWM_BB) ? WiimoteEmu::Wiimote::BUTTON_B : 0;
*butt |= (mask & UDPWM_B1) ? WiimoteEmu::Wiimote::BUTTON_ONE : 0;
*butt |= (mask & UDPWM_B2) ? WiimoteEmu::Wiimote::BUTTON_TWO : 0;
*butt |= (mask & UDPWM_BP) ? WiimoteEmu::Wiimote::BUTTON_PLUS : 0;
*butt |= (mask & UDPWM_BM) ? WiimoteEmu::Wiimote::BUTTON_MINUS : 0;
*butt |= (mask & UDPWM_BH) ? WiimoteEmu::Wiimote::BUTTON_HOME : 0;
*butt |= (mask & UDPWM_BU) ? WiimoteEmu::Wiimote::PAD_UP : 0;
*butt |= (mask & UDPWM_BD) ? WiimoteEmu::Wiimote::PAD_DOWN : 0;
*butt |= (mask & UDPWM_BL) ? WiimoteEmu::Wiimote::PAD_LEFT : 0;
*butt |= (mask & UDPWM_BR) ? WiimoteEmu::Wiimote::PAD_RIGHT : 0;
}

static void GetAcceleration(UDPWrapper * m, WiimoteEmu::AccelData * const data)
{
if (!(m->inst)) return;
if (!(m->updAccel)) return;
float x, y, z;
m->inst->getAccel(&x, &y, &z);
data->x = x;
data->y = y;
data->z = z;
}

static void GetIR(UDPWrapper * m, ControlState * x, ControlState * y, ControlState * z)
{
if (!(m->inst)) 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
float _x, _y;
m->inst->getIR(&_x, &_y);
// *x = _x * 2 - 1;
// *y = -(_y * 2 - 1);
*x = _x;
*y = _y;
*z = 0;
}
}
Loading

0 comments on commit 17aa35d

Please sign in to comment.