mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 13:49:53 -06:00
Move UDPConfigDiag into Dolphin, to allow building of UDP Wiimote again.
Please test this, I don't have any phones or whatever capable of communicating with it. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6405 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -27,11 +27,7 @@ static const u8 nunchuk_button_bitmasks[] =
|
|||||||
Nunchuk::BUTTON_Z,
|
Nunchuk::BUTTON_Z,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
Nunchuk::Nunchuk(UDPWrapper *wrp) : Attachment("Nunchuk") , m_udpWrap(wrp)
|
Nunchuk::Nunchuk(UDPWrapper *wrp) : Attachment("Nunchuk") , m_udpWrap(wrp)
|
||||||
#else
|
|
||||||
Nunchuk::Nunchuk() : Attachment("Nunchuk")
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||||
@ -89,7 +85,6 @@ void Nunchuk::GetState(u8* const data, const bool focus)
|
|||||||
// flip the button bits :/
|
// flip the button bits :/
|
||||||
ncdata->bt ^= 0x03;
|
ncdata->bt ^= 0x03;
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
if (m_udpWrap->inst)
|
if (m_udpWrap->inst)
|
||||||
{
|
{
|
||||||
if (m_udpWrap->updNun)
|
if (m_udpWrap->updNun)
|
||||||
@ -111,21 +106,19 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
wm_accel* dt = (wm_accel*)&ncdata->ax;
|
wm_accel* dt = (wm_accel*)&ncdata->ax;
|
||||||
accel_cal* calib = (accel_cal*)®[0x20];
|
accel_cal* calib = (accel_cal*)®[0x20];
|
||||||
dt->x=u8(trim(accel.x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x));
|
dt->x = u8(trim(accel.x * (calib->one_g.x - calib->zero_g.x) + calib->zero_g.x));
|
||||||
dt->y=u8(trim(accel.y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y));
|
dt->y = u8(trim(accel.y * (calib->one_g.y - calib->zero_g.y) + calib->zero_g.y));
|
||||||
dt->z=u8(trim(accel.z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z));
|
dt->z = u8(trim(accel.z * (calib->one_g.z - calib->zero_g.z) + calib->zero_g.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,7 @@ namespace WiimoteEmu
|
|||||||
class Nunchuk : public Attachment
|
class Nunchuk : public Attachment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
Nunchuk(UDPWrapper * wrp);
|
Nunchuk(UDPWrapper * wrp);
|
||||||
#else
|
|
||||||
Nunchuk();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual void GetState( u8* const data, const bool focus );
|
virtual void GetState( u8* const data, const bool focus );
|
||||||
|
|
||||||
@ -37,9 +32,7 @@ private:
|
|||||||
|
|
||||||
unsigned int m_shake_step[3];
|
unsigned int m_shake_step[3];
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
UDPWrapper* const m_udpWrap;
|
UDPWrapper* const m_udpWrap;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,53 @@
|
|||||||
//UDP Wiimote Translation Layer
|
//UDP Wiimote Translation Layer
|
||||||
|
|
||||||
#if (defined(USE_UDP_WIIMOTE) && !defined(UDPTLAYER_H))
|
#ifndef UDPTLAYER_H
|
||||||
#define UDPTLAYER_H
|
#define UDPTLAYER_H
|
||||||
|
|
||||||
#include "UDPWiimote.h"
|
#include "UDPWiimote.h"
|
||||||
#include "WiimoteEmu.h"
|
#include "WiimoteEmu.h"
|
||||||
|
|
||||||
using WiimoteEmu::Wiimote;
|
|
||||||
|
|
||||||
namespace UDPTLayer
|
namespace UDPTLayer
|
||||||
{
|
{
|
||||||
void GetButtons(UDPWrapper * m , wm_core * butt)
|
void GetButtons(UDPWrapper * m , wm_core * butt)
|
||||||
{
|
{
|
||||||
if (!(m->inst)) return;
|
if (!(m->inst)) return;
|
||||||
if (!(m->updButt)) return;
|
if (!(m->updButt)) return;
|
||||||
u32 mask=m->inst->getButtons();
|
u32 mask = m->inst->getButtons();
|
||||||
*butt|=(mask&UDPWM_BA)?Wiimote::BUTTON_A:0;
|
*butt |= (mask & UDPWM_BA) ? WiimoteEmu::Wiimote::BUTTON_A : 0;
|
||||||
*butt|=(mask&UDPWM_BB)?Wiimote::BUTTON_B:0;
|
*butt |= (mask & UDPWM_BB) ? WiimoteEmu::Wiimote::BUTTON_B : 0;
|
||||||
*butt|=(mask&UDPWM_B1)?Wiimote::BUTTON_ONE:0;
|
*butt |= (mask & UDPWM_B1) ? WiimoteEmu::Wiimote::BUTTON_ONE : 0;
|
||||||
*butt|=(mask&UDPWM_B2)?Wiimote::BUTTON_TWO:0;
|
*butt |= (mask & UDPWM_B2) ? WiimoteEmu::Wiimote::BUTTON_TWO : 0;
|
||||||
*butt|=(mask&UDPWM_BP)?Wiimote::BUTTON_PLUS:0;
|
*butt |= (mask & UDPWM_BP) ? WiimoteEmu::Wiimote::BUTTON_PLUS : 0;
|
||||||
*butt|=(mask&UDPWM_BM)?Wiimote::BUTTON_MINUS:0;
|
*butt |= (mask & UDPWM_BM) ? WiimoteEmu::Wiimote::BUTTON_MINUS : 0;
|
||||||
*butt|=(mask&UDPWM_BH)?Wiimote::BUTTON_HOME:0;
|
*butt |= (mask & UDPWM_BH) ? WiimoteEmu::Wiimote::BUTTON_HOME : 0;
|
||||||
*butt|=(mask&UDPWM_BU)?Wiimote::PAD_UP:0;
|
*butt |= (mask & UDPWM_BU) ? WiimoteEmu::Wiimote::PAD_UP : 0;
|
||||||
*butt|=(mask&UDPWM_BD)?Wiimote::PAD_DOWN:0;
|
*butt |= (mask & UDPWM_BD) ? WiimoteEmu::Wiimote::PAD_DOWN : 0;
|
||||||
*butt|=(mask&UDPWM_BL)?Wiimote::PAD_LEFT:0;
|
*butt |= (mask & UDPWM_BL) ? WiimoteEmu::Wiimote::PAD_LEFT : 0;
|
||||||
*butt|=(mask&UDPWM_BR)?Wiimote::PAD_RIGHT:0;
|
*butt |= (mask & UDPWM_BR) ? WiimoteEmu::Wiimote::PAD_RIGHT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAcceleration(UDPWrapper * m , WiimoteEmu::AccelData * const data)
|
void GetAcceleration(UDPWrapper * m , WiimoteEmu::AccelData * const data)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetIR( UDPWrapper * m, float * x, float * y, float * z)
|
void GetIR( UDPWrapper * m, float * x, float * y, float * z)
|
||||||
{
|
{
|
||||||
if (!(m->inst)) return;
|
if (!(m->inst)) return;
|
||||||
if (!(m->updIR)) return;
|
if (!(m->updIR)) return;
|
||||||
if ((*x>=-0.999)&&(*x<=0.999)&&(*y>=-0.999)&&(*y<=0.999)) return; //the recieved 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 recieved 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -251,10 +251,8 @@ Wiimote::Wiimote( const unsigned int index )
|
|||||||
// tilt
|
// tilt
|
||||||
groups.push_back(m_tilt = new Tilt("Tilt"));
|
groups.push_back(m_tilt = new Tilt("Tilt"));
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
// udp
|
// udp
|
||||||
groups.push_back(m_udp = new UDPWrapper(m_index, "UDP Wiimote"));
|
groups.push_back(m_udp = new UDPWrapper(m_index, "UDP Wiimote"));
|
||||||
#endif
|
|
||||||
|
|
||||||
// shake
|
// shake
|
||||||
groups.push_back(m_shake = new Buttons("Shake"));
|
groups.push_back(m_shake = new Buttons("Shake"));
|
||||||
@ -265,11 +263,7 @@ Wiimote::Wiimote( const unsigned int index )
|
|||||||
// extension
|
// extension
|
||||||
groups.push_back(m_extension = new Extension("Extension"));
|
groups.push_back(m_extension = new Extension("Extension"));
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::None());
|
m_extension->attachments.push_back(new WiimoteEmu::None());
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk(m_udp));
|
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk(m_udp));
|
||||||
#else
|
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk());
|
|
||||||
#endif
|
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Classic());
|
m_extension->attachments.push_back(new WiimoteEmu::Classic());
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Guitar());
|
m_extension->attachments.push_back(new WiimoteEmu::Guitar());
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Drums());
|
m_extension->attachments.push_back(new WiimoteEmu::Drums());
|
||||||
@ -345,9 +339,7 @@ bool Wiimote::Step()
|
|||||||
{
|
{
|
||||||
m_buttons->GetState(&m_status.buttons, button_bitmasks);
|
m_buttons->GetState(&m_status.buttons, button_bitmasks);
|
||||||
m_dpad->GetState(&m_status.buttons, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks);
|
m_dpad->GetState(&m_status.buttons, is_sideways ? dpad_sideways_bitmasks : dpad_bitmasks);
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
UDPTLayer::GetButtons(m_udp, &m_status.buttons);
|
UDPTLayer::GetButtons(m_udp, &m_status.buttons);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if there is a read data request
|
// check if there is a read data request
|
||||||
@ -407,9 +399,7 @@ void Wiimote::GetAccelData(u8* const data, u8* const buttons)
|
|||||||
{
|
{
|
||||||
EmulateSwing(&m_accel, m_swing, is_sideways, is_upright);
|
EmulateSwing(&m_accel, m_swing, is_sideways, is_upright);
|
||||||
EmulateShake(&m_accel, m_shake, m_shake_step);
|
EmulateShake(&m_accel, m_shake, m_shake_step);
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
UDPTLayer::GetAcceleration(m_udp, &m_accel);
|
UDPTLayer::GetAcceleration(m_udp, &m_accel);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
wm_accel* dt = (wm_accel*)data;
|
wm_accel* dt = (wm_accel*)data;
|
||||||
accel_cal* calib = (accel_cal*)&m_eeprom[0x16];
|
accel_cal* calib = (accel_cal*)&m_eeprom[0x16];
|
||||||
@ -476,9 +466,7 @@ void Wiimote::GetIRData(u8* const data, bool use_accel)
|
|||||||
LowPassFilter(ir_cos,ncos,1.0f/60);
|
LowPassFilter(ir_cos,ncos,1.0f/60);
|
||||||
|
|
||||||
m_ir->GetState(&xx, &yy, &zz, true);
|
m_ir->GetState(&xx, &yy, &zz, true);
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
UDPTLayer::GetIR(m_udp, &xx, &yy, &zz);
|
UDPTLayer::GetIR(m_udp, &xx, &yy, &zz);
|
||||||
#endif
|
|
||||||
|
|
||||||
Vertex v[4];
|
Vertex v[4];
|
||||||
|
|
||||||
|
@ -146,9 +146,7 @@ private:
|
|||||||
|
|
||||||
double ir_sin,ir_cos; //for the low pass filter
|
double ir_sin,ir_cos; //for the low pass filter
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
UDPWrapper* m_udp;
|
UDPWrapper* m_udp;
|
||||||
#endif
|
|
||||||
|
|
||||||
bool m_rumble_on;
|
bool m_rumble_on;
|
||||||
bool m_speaker_mute;
|
bool m_speaker_mute;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9,00"
|
||||||
Name="Dolphin"
|
Name="Dolphin"
|
||||||
ProjectGUID="{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
|
ProjectGUID="{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
|
||||||
RootNamespace="DolphinWX"
|
RootNamespace="DolphinWX"
|
||||||
@ -924,6 +924,14 @@
|
|||||||
RelativePath=".\Src\PatchAddEdit.h"
|
RelativePath=".\Src\PatchAddEdit.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\UDPConfigDiag.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\UDPConfigDiag.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\WiimoteConfigDiag.cpp"
|
RelativePath=".\Src\WiimoteConfigDiag.cpp"
|
||||||
>
|
>
|
||||||
|
@ -16,19 +16,21 @@
|
|||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "InputConfigDiag.h"
|
#include "InputConfigDiag.h"
|
||||||
|
#include "UDPConfigDiag.h"
|
||||||
|
|
||||||
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
|
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
|
||||||
#define WXSTR_FROM_STR(s) (wxString::From8BitData((s).c_str()))
|
#define WXSTR_FROM_STR(s) (wxString::From8BitData((s).c_str()))
|
||||||
// ToAscii was causing probs with some extended ascii characters, To8BitData seems to work
|
// ToAscii was causing probs with some extended ascii characters, To8BitData seems to work
|
||||||
#define STR_FROM_WXSTR(w) (std::string((w).To8BitData()))
|
#define STR_FROM_WXSTR(w) (std::string((w).To8BitData()))
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
void GamepadPage::ConfigUDPWii(wxCommandEvent &event)
|
void GamepadPage::ConfigUDPWii(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
UDPWrapper* const wrp = ((UDPConfigButton*)event.GetEventObject())->wrapper;
|
UDPWrapper* const wrp = ((UDPConfigButton*)event.GetEventObject())->wrapper;
|
||||||
wrp->Configure(this);
|
wxDialog * diag = new UDPConfigDiag(this, wrp);
|
||||||
|
diag->Center();
|
||||||
|
diag->ShowModal();
|
||||||
|
diag->Destroy();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void GamepadPage::ConfigExtension( wxCommandEvent& event )
|
void GamepadPage::ConfigExtension( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
@ -836,7 +838,6 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
|
|||||||
Add(configure_btn, 0, wxALL|wxEXPAND, 3 );
|
Add(configure_btn, 0, wxALL|wxEXPAND, 3 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
case GROUP_TYPE_UDPWII:
|
case GROUP_TYPE_UDPWII:
|
||||||
{
|
{
|
||||||
wxButton* const btn = new UDPConfigButton( parent, (UDPWrapper*)group );
|
wxButton* const btn = new UDPConfigButton( parent, (UDPWrapper*)group );
|
||||||
@ -844,7 +845,6 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
|
|||||||
Add(btn, 0, wxALL|wxEXPAND, 3);
|
Add(btn, 0, wxALL|wxEXPAND, 3);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//options
|
//options
|
||||||
|
@ -146,8 +146,6 @@ public:
|
|||||||
ControllerInterface::ControlReference* const control_reference;
|
ControllerInterface::ControlReference* const control_reference;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
|
|
||||||
class UDPConfigButton : public wxButton
|
class UDPConfigButton : public wxButton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -158,8 +156,6 @@ public:
|
|||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class ControlGroupBox : public wxStaticBoxSizer
|
class ControlGroupBox : public wxStaticBoxSizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -177,8 +173,6 @@ class ControlGroupsSizer : public wxBoxSizer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ControlGroupsSizer( ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* const groups = NULL );
|
ControlGroupsSizer( ControllerEmu* const controller, wxWindow* const parent, wxWindow* const eventsink, std::vector<ControlGroupBox*>* const groups = NULL );
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputConfigDialog;
|
class InputConfigDialog;
|
||||||
|
86
Source/Core/DolphinWX/Src/UDPConfigDiag.cpp
Normal file
86
Source/Core/DolphinWX/Src/UDPConfigDiag.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#include "UDPConfigDiag.h"
|
||||||
|
#include "UDPWrapper.h"
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
#include "ControllerEmu.h"
|
||||||
|
#include "IniFile.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
|
||||||
|
|
||||||
|
UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
|
||||||
|
wxDialog(parent, -1, wxT("UDP Wiimote"), wxDefaultPosition, wxDefaultSize),
|
||||||
|
wrp(_wrp)
|
||||||
|
{
|
||||||
|
wxBoxSizer *const outer_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
wxBoxSizer *const sizer1 = new wxBoxSizer(wxVERTICAL);
|
||||||
|
wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Update"));
|
||||||
|
|
||||||
|
outer_sizer->Add(sizer1, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 5);
|
||||||
|
outer_sizer->Add(sizer2, 1, wxLEFT | wxRIGHT | wxEXPAND, 10);
|
||||||
|
|
||||||
|
enable = new wxCheckBox(this,wxID_ANY,wxT("Enable"));
|
||||||
|
butt = new wxCheckBox(this,wxID_ANY,wxT("Buttons"));
|
||||||
|
accel = new wxCheckBox(this,wxID_ANY,wxT("Acceleration"));
|
||||||
|
point = new wxCheckBox(this,wxID_ANY,wxT("IR Pointer"));
|
||||||
|
nun = new wxCheckBox(this,wxID_ANY,wxT("Nunchuk"));
|
||||||
|
nunaccel = new wxCheckBox(this,wxID_ANY,wxT("Nunchuk Acceleration"));
|
||||||
|
|
||||||
|
wxButton *const ok_butt = new wxButton(this,wxID_ANY,wxT("OK"));
|
||||||
|
|
||||||
|
wxBoxSizer *const port_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
port_sizer->Add(new wxStaticText(this, wxID_ANY, wxT("UDP Port:")), 0, wxALIGN_CENTER);
|
||||||
|
port_tbox = new wxTextCtrl(this, wxID_ANY, wxString::FromUTF8(wrp->port.c_str()));
|
||||||
|
port_sizer->Add(port_tbox, 1, wxLEFT | wxEXPAND , 5);
|
||||||
|
|
||||||
|
_connect_macro_(enable, UDPConfigDiag::ChangeState ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||||
|
_connect_macro_(butt, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||||
|
_connect_macro_(accel, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||||
|
_connect_macro_(point, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||||
|
_connect_macro_(nun, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||||
|
_connect_macro_(nunaccel, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
||||||
|
_connect_macro_(ok_butt, UDPConfigDiag::OKPressed, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
||||||
|
_connect_macro_(port_tbox, UDPConfigDiag::ChangeState, wxEVT_COMMAND_TEXT_UPDATED, this);
|
||||||
|
|
||||||
|
enable->SetValue(wrp->udpEn);
|
||||||
|
butt->SetValue(wrp->updButt);
|
||||||
|
accel->SetValue(wrp->updAccel);
|
||||||
|
point->SetValue(wrp->updIR);
|
||||||
|
nun->SetValue(wrp->updNun);
|
||||||
|
nunaccel->SetValue(wrp->updNunAccel);
|
||||||
|
|
||||||
|
sizer1->Add(enable, 1, wxALL | wxEXPAND, 5);
|
||||||
|
sizer1->Add(port_sizer, 1, wxBOTTOM | wxLEFT| wxRIGHT | wxEXPAND, 5);
|
||||||
|
|
||||||
|
sizer2->Add(butt, 1, wxALL | wxEXPAND, 5);
|
||||||
|
sizer2->Add(accel, 1, wxALL | wxEXPAND, 5);
|
||||||
|
sizer2->Add(point, 1, wxALL | wxEXPAND, 5);
|
||||||
|
sizer2->Add(nun, 1, wxALL | wxEXPAND, 5);
|
||||||
|
sizer2->Add(nunaccel, 1, wxALL | wxEXPAND, 5);
|
||||||
|
|
||||||
|
outer_sizer->Add(ok_butt, 0, wxALL | wxALIGN_RIGHT, 5);
|
||||||
|
|
||||||
|
SetSizerAndFit(outer_sizer);
|
||||||
|
Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDPConfigDiag::ChangeUpdateFlags(wxCommandEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wrp->updAccel=accel->GetValue();
|
||||||
|
wrp->updButt=butt->GetValue();
|
||||||
|
wrp->updIR=point->GetValue();
|
||||||
|
wrp->updNun=nun->GetValue();
|
||||||
|
wrp->updNunAccel=nunaccel->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDPConfigDiag::ChangeState(wxCommandEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wrp->udpEn=enable->GetValue();
|
||||||
|
wrp->port=port_tbox->GetValue().mb_str(wxConvUTF8);
|
||||||
|
wrp->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDPConfigDiag::OKPressed(wxCommandEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
35
Source/Core/DolphinWX/Src/UDPConfigDiag.h
Normal file
35
Source/Core/DolphinWX/Src/UDPConfigDiag.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef UDPCONFIGDIAG_H
|
||||||
|
#define UDPCONFIGDIAG_H
|
||||||
|
|
||||||
|
#include "UDPWrapper.h"
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/listbox.h>
|
||||||
|
#include <wx/textctrl.h>
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/stattext.h>
|
||||||
|
#include <wx/combobox.h>
|
||||||
|
#include <wx/checkbox.h>
|
||||||
|
#include <wx/notebook.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/spinctrl.h>
|
||||||
|
|
||||||
|
class UDPConfigDiag : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp);
|
||||||
|
private:
|
||||||
|
UDPWrapper * wrp;
|
||||||
|
void ChangeUpdateFlags(wxCommandEvent & event);
|
||||||
|
void ChangeState(wxCommandEvent & event);
|
||||||
|
void OKPressed(wxCommandEvent & event);
|
||||||
|
wxCheckBox * enable;
|
||||||
|
wxCheckBox * butt;
|
||||||
|
wxCheckBox * accel;
|
||||||
|
wxCheckBox * point;
|
||||||
|
wxCheckBox * nun;
|
||||||
|
wxCheckBox * nunaccel;
|
||||||
|
wxTextCtrl * port_tbox;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
#include "UDPWiimote.h"
|
#include "UDPWiimote.h"
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
@ -78,7 +76,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
|
|||||||
static bool sranded=false;
|
static bool sranded=false;
|
||||||
if (!sranded)
|
if (!sranded)
|
||||||
{
|
{
|
||||||
srand(time(0));
|
srand((unsigned int)time(0));
|
||||||
sranded=true;
|
sranded=true;
|
||||||
}
|
}
|
||||||
bcastMagic=rand() & 0xFFFF;
|
bcastMagic=rand() & 0xFFFF;
|
||||||
@ -125,7 +123,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
|
|||||||
if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == BAD_SOCK) {
|
if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == BAD_SOCK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (bind(sock, p->ai_addr, p->ai_addrlen) == -1) {
|
if (bind(sock, p->ai_addr, (int)p->ai_addrlen) == -1) {
|
||||||
close(sock);
|
close(sock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -181,7 +179,7 @@ void UDPWiimote::mainThread()
|
|||||||
broadcastPresence();
|
broadcastPresence();
|
||||||
} else {
|
} else {
|
||||||
tleft-=telapsed;
|
tleft-=telapsed;
|
||||||
timeout.tv_sec=tleft/1000;
|
timeout.tv_sec=(long)(tleft/1000);
|
||||||
timeout.tv_usec=(tleft%1000)*1000;
|
timeout.tv_usec=(tleft%1000)*1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +326,7 @@ void UDPWiimote::broadcastIPv4(const void * data, size_t size)
|
|||||||
memset(their_addr.sin_zero, '\0', sizeof their_addr.sin_zero);
|
memset(their_addr.sin_zero, '\0', sizeof their_addr.sin_zero);
|
||||||
|
|
||||||
int num;
|
int num;
|
||||||
if ((num=sendto(d->bipv4_fd,(const dataz)data,size,0,(struct sockaddr *) &their_addr, sizeof their_addr)) == -1)
|
if ((num=sendto(d->bipv4_fd,(const dataz)data,(int)size,0,(struct sockaddr *) &their_addr, sizeof their_addr)) == -1)
|
||||||
{
|
{
|
||||||
WARN_LOG(WIIMOTE,"sendto() failed");
|
WARN_LOG(WIIMOTE,"sendto() failed");
|
||||||
return;
|
return;
|
||||||
@ -421,5 +419,3 @@ void UDPWiimote::changeName(const char * name)
|
|||||||
displayName=name;
|
displayName=name;
|
||||||
d->nameMutex.Leave();
|
d->nameMutex.Leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
|
#ifndef UDPWIIMOTE_H
|
||||||
//#define USE_UDP_WIIMOTE
|
|
||||||
|
|
||||||
#if (!defined(UDPWIIMOTE_H) && defined(USE_UDP_WIIMOTE))
|
|
||||||
#define UDPWIIMOTE_H
|
#define UDPWIIMOTE_H
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
|
|
||||||
#include "UDPWrapper.h"
|
#include "UDPWrapper.h"
|
||||||
|
|
||||||
#ifdef USE_UDP_WIIMOTE
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -93,113 +90,3 @@ UDPWrapper::~UDPWrapper()
|
|||||||
if (inst)
|
if (inst)
|
||||||
delete inst;
|
delete inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_WX) && HAVE_WX
|
|
||||||
|
|
||||||
#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s)
|
|
||||||
|
|
||||||
class UDPConfigDiag : public wxDialog
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp);
|
|
||||||
UDPWrapper * wrp;
|
|
||||||
void ChangeUpdateFlags(wxCommandEvent & event);
|
|
||||||
void ChangeState(wxCommandEvent & event);
|
|
||||||
void OKPressed(wxCommandEvent & event);
|
|
||||||
wxCheckBox * enable;
|
|
||||||
wxCheckBox * butt;
|
|
||||||
wxCheckBox * accel;
|
|
||||||
wxCheckBox * point;
|
|
||||||
wxCheckBox * nun;
|
|
||||||
wxCheckBox * nunaccel;
|
|
||||||
wxTextCtrl * port_tbox;
|
|
||||||
};
|
|
||||||
|
|
||||||
UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
|
|
||||||
wxDialog(parent, -1, wxT("UDP Wiimote"), wxDefaultPosition, wxDefaultSize),
|
|
||||||
wrp(_wrp)
|
|
||||||
{
|
|
||||||
wxBoxSizer *const outer_sizer = new wxBoxSizer(wxVERTICAL);
|
|
||||||
wxBoxSizer *const sizer1 = new wxBoxSizer(wxVERTICAL);
|
|
||||||
wxStaticBoxSizer *const sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Update"));
|
|
||||||
|
|
||||||
outer_sizer->Add(sizer1, 0, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, 5);
|
|
||||||
outer_sizer->Add(sizer2, 1, wxLEFT | wxRIGHT | wxEXPAND, 10);
|
|
||||||
|
|
||||||
enable = new wxCheckBox(this,wxID_ANY,wxT("Enable"));
|
|
||||||
butt = new wxCheckBox(this,wxID_ANY,wxT("Buttons"));
|
|
||||||
accel = new wxCheckBox(this,wxID_ANY,wxT("Acceleration"));
|
|
||||||
point = new wxCheckBox(this,wxID_ANY,wxT("IR Pointer"));
|
|
||||||
nun = new wxCheckBox(this,wxID_ANY,wxT("Nunchuk"));
|
|
||||||
nunaccel = new wxCheckBox(this,wxID_ANY,wxT("Nunchuk Acceleration"));
|
|
||||||
|
|
||||||
wxButton *const ok_butt = new wxButton(this,wxID_ANY,wxT("OK"));
|
|
||||||
|
|
||||||
wxBoxSizer *const port_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
||||||
port_sizer->Add(new wxStaticText(this, wxID_ANY, wxT("UDP Port:")), 0, wxALIGN_CENTER);
|
|
||||||
port_tbox = new wxTextCtrl(this, wxID_ANY, wxString::FromUTF8(wrp->port.c_str()));
|
|
||||||
port_sizer->Add(port_tbox, 1, wxLEFT | wxEXPAND , 5);
|
|
||||||
|
|
||||||
_connect_macro_(enable, UDPConfigDiag::ChangeState ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
|
||||||
_connect_macro_(butt, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
|
||||||
_connect_macro_(accel, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
|
||||||
_connect_macro_(point, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
|
||||||
_connect_macro_(nun, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
|
||||||
_connect_macro_(nunaccel, UDPConfigDiag::ChangeUpdateFlags ,wxEVT_COMMAND_CHECKBOX_CLICKED, this);
|
|
||||||
_connect_macro_(ok_butt, UDPConfigDiag::OKPressed, wxEVT_COMMAND_BUTTON_CLICKED, this);
|
|
||||||
_connect_macro_(port_tbox, UDPConfigDiag::ChangeState, wxEVT_COMMAND_TEXT_UPDATED, this);
|
|
||||||
|
|
||||||
enable->SetValue(wrp->udpEn);
|
|
||||||
butt->SetValue(wrp->updButt);
|
|
||||||
accel->SetValue(wrp->updAccel);
|
|
||||||
point->SetValue(wrp->updIR);
|
|
||||||
nun->SetValue(wrp->updNun);
|
|
||||||
nunaccel->SetValue(wrp->updNunAccel);
|
|
||||||
|
|
||||||
sizer1->Add(enable, 1, wxALL | wxEXPAND, 5);
|
|
||||||
sizer1->Add(port_sizer, 1, wxBOTTOM | wxLEFT| wxRIGHT | wxEXPAND, 5);
|
|
||||||
|
|
||||||
sizer2->Add(butt, 1, wxALL | wxEXPAND, 5);
|
|
||||||
sizer2->Add(accel, 1, wxALL | wxEXPAND, 5);
|
|
||||||
sizer2->Add(point, 1, wxALL | wxEXPAND, 5);
|
|
||||||
sizer2->Add(nun, 1, wxALL | wxEXPAND, 5);
|
|
||||||
sizer2->Add(nunaccel, 1, wxALL | wxEXPAND, 5);
|
|
||||||
|
|
||||||
outer_sizer->Add(ok_butt, 0, wxALL | wxALIGN_RIGHT, 5);
|
|
||||||
|
|
||||||
SetSizerAndFit(outer_sizer);
|
|
||||||
Layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UDPConfigDiag::ChangeUpdateFlags(wxCommandEvent & event)
|
|
||||||
{
|
|
||||||
wrp->updAccel=accel->GetValue();
|
|
||||||
wrp->updButt=butt->GetValue();
|
|
||||||
wrp->updIR=point->GetValue();
|
|
||||||
wrp->updNun=nun->GetValue();
|
|
||||||
wrp->updNunAccel=nunaccel->GetValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UDPConfigDiag::ChangeState(wxCommandEvent & event)
|
|
||||||
{
|
|
||||||
wrp->udpEn=enable->GetValue();
|
|
||||||
wrp->port=port_tbox->GetValue().mb_str(wxConvUTF8);
|
|
||||||
wrp->Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UDPConfigDiag::OKPressed(wxCommandEvent & event)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void UDPWrapper::Configure(wxWindow * parent)
|
|
||||||
{
|
|
||||||
wxDialog * diag = new UDPConfigDiag(parent,this);
|
|
||||||
diag->Center();
|
|
||||||
diag->ShowModal();
|
|
||||||
diag->Destroy();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,42 +1,25 @@
|
|||||||
|
#ifndef UDPWRAPPER_H
|
||||||
|
#define UDPWRAPPER_H
|
||||||
|
|
||||||
#include "UDPWiimote.h"
|
#include "UDPWiimote.h"
|
||||||
|
|
||||||
#if (defined(USE_UDP_WIIMOTE) && !defined(UDPWRAPPER_H))
|
|
||||||
#define UDPWRAPPER_H
|
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ControllerEmu.h"
|
#include "ControllerEmu.h"
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(HAVE_WX) && HAVE_WX
|
|
||||||
#include <wx/wx.h>
|
|
||||||
#include <wx/listbox.h>
|
|
||||||
#include <wx/textctrl.h>
|
|
||||||
#include <wx/button.h>
|
|
||||||
#include <wx/stattext.h>
|
|
||||||
#include <wx/combobox.h>
|
|
||||||
#include <wx/checkbox.h>
|
|
||||||
#include <wx/notebook.h>
|
|
||||||
#include <wx/panel.h>
|
|
||||||
#include <wx/spinctrl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class UDPWrapper : public ControllerEmu::ControlGroup
|
class UDPWrapper : public ControllerEmu::ControlGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UDPWiimote * inst;
|
UDPWiimote * inst;
|
||||||
int index;
|
int index;
|
||||||
bool updIR,updAccel,updButt,updNun,updNunAccel,udpEn; //upd from update and udp from... well... UDP
|
bool updIR, updAccel, updButt, updNun, updNunAccel, udpEn; //upd from update and udp from... well... UDP
|
||||||
std::string port;
|
std::string port;
|
||||||
|
|
||||||
UDPWrapper(int index, const char* const _name);
|
UDPWrapper(int index, const char* const _name);
|
||||||
virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
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 = "" );
|
virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "");
|
||||||
void Refresh();
|
void Refresh();
|
||||||
#if defined(HAVE_WX) && HAVE_WX
|
|
||||||
void Configure(wxWindow * parent);
|
|
||||||
#endif
|
|
||||||
virtual ~UDPWrapper();
|
virtual ~UDPWrapper();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user