mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -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:
@ -1,8 +1,6 @@
|
||||
|
||||
#include "UDPWiimote.h"
|
||||
|
||||
#ifdef USE_UDP_WIIMOTE
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <winsock2.h>
|
||||
@ -78,7 +76,7 @@ UDPWiimote::UDPWiimote(const char *_port, const char * name, int _index) :
|
||||
static bool sranded=false;
|
||||
if (!sranded)
|
||||
{
|
||||
srand(time(0));
|
||||
srand((unsigned int)time(0));
|
||||
sranded=true;
|
||||
}
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
if (bind(sock, p->ai_addr, p->ai_addrlen) == -1) {
|
||||
if (bind(sock, p->ai_addr, (int)p->ai_addrlen) == -1) {
|
||||
close(sock);
|
||||
continue;
|
||||
}
|
||||
@ -181,7 +179,7 @@ void UDPWiimote::mainThread()
|
||||
broadcastPresence();
|
||||
} else {
|
||||
tleft-=telapsed;
|
||||
timeout.tv_sec=tleft/1000;
|
||||
timeout.tv_sec=(long)(tleft/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);
|
||||
|
||||
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");
|
||||
return;
|
||||
@ -421,5 +419,3 @@ void UDPWiimote::changeName(const char * name)
|
||||
displayName=name;
|
||||
d->nameMutex.Leave();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,4 @@
|
||||
|
||||
//#define USE_UDP_WIIMOTE
|
||||
|
||||
#if (!defined(UDPWIIMOTE_H) && defined(USE_UDP_WIIMOTE))
|
||||
#ifndef UDPWIIMOTE_H
|
||||
#define UDPWIIMOTE_H
|
||||
|
||||
#include "Common.h"
|
||||
|
@ -1,8 +1,5 @@
|
||||
|
||||
#include "UDPWrapper.h"
|
||||
|
||||
#ifdef USE_UDP_WIIMOTE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -93,113 +90,3 @@ UDPWrapper::~UDPWrapper()
|
||||
if (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"
|
||||
|
||||
#if (defined(USE_UDP_WIIMOTE) && !defined(UDPWRAPPER_H))
|
||||
#define UDPWRAPPER_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "ControllerEmu.h"
|
||||
#include "IniFile.h"
|
||||
#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
|
||||
{
|
||||
public:
|
||||
UDPWiimote * inst;
|
||||
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;
|
||||
|
||||
UDPWrapper(int index, const char* const _name);
|
||||
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 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 = "");
|
||||
void Refresh();
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
void Configure(wxWindow * parent);
|
||||
#endif
|
||||
virtual ~UDPWrapper();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user