2009-07-28 21:32:10 +00:00
// Copyright (C) 2003 Dolphin Project.
2009-07-05 04:29:00 +00:00
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
# include "wiimote_real.h" // Local
# include "wiimote_hid.h"
# include "main.h"
# include "ConfigBasicDlg.h"
# include "ConfigPadDlg.h"
# include "Config.h"
# include "EmuMain.h" // for SetDefaultExtensionRegistry
# include "EmuSubroutines.h" // for WmRequestStatus
BEGIN_EVENT_TABLE ( WiimoteBasicConfigDialog , wxDialog )
EVT_CLOSE ( WiimoteBasicConfigDialog : : OnClose )
2010-02-25 06:12:35 +00:00
EVT_BUTTON ( wxID_OK , WiimoteBasicConfigDialog : : ButtonClick )
EVT_BUTTON ( wxID_CANCEL , WiimoteBasicConfigDialog : : ButtonClick )
2009-07-05 04:29:00 +00:00
EVT_BUTTON ( ID_BUTTONMAPPING , WiimoteBasicConfigDialog : : ButtonClick )
EVT_BUTTON ( ID_BUTTONRECORDING , WiimoteBasicConfigDialog : : ButtonClick )
2009-12-27 19:31:02 +00:00
EVT_NOTEBOOK_PAGE_CHANGED ( ID_NOTEBOOK , WiimoteBasicConfigDialog : : NotebookPageChanged )
2010-01-11 13:56:11 +00:00
EVT_BUTTON ( IDB_PAIRUP_REAL , WiimoteBasicConfigDialog : : ButtonClick )
EVT_BUTTON ( IDB_REFRESH_REAL , WiimoteBasicConfigDialog : : ButtonClick )
2009-12-27 19:31:02 +00:00
EVT_CHOICE ( IDC_INPUT_SOURCE , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
2009-12-11 13:57:25 +00:00
EVT_CHECKBOX ( IDC_SIDEWAYSWIIMOTE , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
EVT_CHECKBOX ( IDC_UPRIGHTWIIMOTE , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
2010-03-27 04:21:19 +00:00
EVT_CHECKBOX ( IDC_MOTIONPLUSCONNECTED , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
EVT_CHECKBOX ( IDC_WIIAUTORECONNECT , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
2010-04-15 16:47:55 +00:00
EVT_CHECKBOX ( IDC_WIIAUTOUNPAIR , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
2010-04-26 17:51:32 +00:00
EVT_CHECKBOX ( IDC_WIIAUTOPAIR , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
2010-03-31 11:47:46 +00:00
EVT_CHOICE ( IDC_EXTCONNECTED , WiimoteBasicConfigDialog : : GeneralSettingsChanged )
2010-03-28 09:51:57 +00:00
2010-04-13 01:34:11 +00:00
//UDPWii
EVT_CHECKBOX ( IDC_UDPWIIENABLE , WiimoteBasicConfigDialog : : UDPWiiSettingsChanged )
EVT_CHECKBOX ( IDC_UDPWIIACCEL , WiimoteBasicConfigDialog : : UDPWiiSettingsChanged )
EVT_CHECKBOX ( IDC_UDPWIIBUTT , WiimoteBasicConfigDialog : : UDPWiiSettingsChanged )
EVT_CHECKBOX ( IDC_UDPWIIIR , WiimoteBasicConfigDialog : : UDPWiiSettingsChanged )
EVT_CHECKBOX ( IDC_UDPWIINUN , WiimoteBasicConfigDialog : : UDPWiiSettingsChanged )
EVT_TEXT ( IDT_UDPWIIPORT , WiimoteBasicConfigDialog : : UDPWiiSettingsChanged )
2009-07-05 20:11:33 +00:00
// IR cursor
EVT_COMMAND_SCROLL ( IDS_WIDTH , WiimoteBasicConfigDialog : : IRCursorChanged )
EVT_COMMAND_SCROLL ( IDS_HEIGHT , WiimoteBasicConfigDialog : : IRCursorChanged )
EVT_COMMAND_SCROLL ( IDS_LEFT , WiimoteBasicConfigDialog : : IRCursorChanged )
EVT_COMMAND_SCROLL ( IDS_TOP , WiimoteBasicConfigDialog : : IRCursorChanged )
2010-03-26 12:36:28 +00:00
EVT_COMMAND_SCROLL ( IDS_LEVEL , WiimoteBasicConfigDialog : : IRCursorChanged )
2010-05-14 21:47:35 +00:00
EVT_COMMAND_SCROLL ( IDS_TIMEOUT , WiimoteBasicConfigDialog : : IRCursorChanged ) //scrollevent
2009-07-05 20:11:33 +00:00
2009-07-05 04:29:00 +00:00
EVT_TIMER ( IDTM_UPDATE_ONCE , WiimoteBasicConfigDialog : : UpdateOnce )
END_EVENT_TABLE ( )
WiimoteBasicConfigDialog : : WiimoteBasicConfigDialog ( wxWindow * parent , wxWindowID id , const wxString & title ,
const wxPoint & position , const wxSize & size , long style )
: wxDialog ( parent , id , title , position , size , style )
{
# if wxUSE_TIMER
m_TimeoutOnce = new wxTimer ( this , IDTM_UPDATE_ONCE ) ;
m_ShutDownTimer = new wxTimer ( this , IDTM_SHUTDOWN ) ;
# endif
ControlsCreated = false ;
2009-12-27 19:31:02 +00:00
m_Page = 0 ;
2010-07-22 03:29:35 +00:00
# if defined HAVE_WIIUSE && HAVE_WIIUSE
2010-01-01 03:19:46 +00:00
// Initialize the Real WiiMotes here, so we get a count of how many were found and set everything properly
2010-02-21 18:53:11 +00:00
WiiMoteReal : : Initialize ( ) ;
2010-07-22 03:29:35 +00:00
# endif
2009-12-27 19:31:02 +00:00
2009-07-05 04:29:00 +00:00
CreateGUIControls ( ) ;
UpdateGUI ( ) ;
}
void WiimoteBasicConfigDialog : : OnClose ( wxCloseEvent & event )
{
2009-11-29 17:58:52 +00:00
EndModal ( wxID_CLOSE ) ;
2009-07-05 04:29:00 +00:00
}
void WiimoteBasicConfigDialog : : ButtonClick ( wxCommandEvent & event )
{
switch ( event . GetId ( ) )
{
2010-02-25 06:12:35 +00:00
case wxID_OK :
2010-07-22 03:29:35 +00:00
# if defined HAVE_WIIUSE && HAVE_WIIUSE
2010-01-01 16:50:11 +00:00
WiiMoteReal : : Allocate ( ) ;
2010-07-22 03:29:35 +00:00
# endif
2009-12-14 02:23:14 +00:00
g_Config . Save ( ) ;
Close ( ) ;
2009-07-05 04:29:00 +00:00
break ;
2010-02-25 06:12:35 +00:00
case wxID_CANCEL :
2009-12-14 02:23:14 +00:00
g_Config . Load ( ) ;
Close ( ) ;
2009-07-05 04:29:00 +00:00
break ;
case ID_BUTTONMAPPING :
2009-12-27 19:31:02 +00:00
g_Config . CurrentPage = m_Page ;
2009-12-04 12:22:36 +00:00
m_PadConfigFrame = new WiimotePadConfigDialog ( this ) ;
m_PadConfigFrame - > ShowModal ( ) ;
m_PadConfigFrame - > Destroy ( ) ;
m_PadConfigFrame = NULL ;
2009-12-27 19:31:02 +00:00
m_Page = g_Config . CurrentPage ;
m_Notebook - > ChangeSelection ( g_Config . CurrentPage ) ;
UpdateGUI ( ) ;
2009-07-05 04:29:00 +00:00
break ;
2010-01-11 13:56:11 +00:00
# ifdef _WIN32
case IDB_PAIRUP_REAL :
if ( g_EmulatorState ! = PLUGIN_EMUSTATE_PLAY )
{
2010-04-26 17:51:32 +00:00
WiiMoteReal : : g_StartAutopairThread . Set ( ) ;
2010-01-05 17:38:37 +00:00
}
break ;
# endif
2010-01-11 13:56:11 +00:00
case IDB_REFRESH_REAL :
// If the config dialog was open when the user click on Play/Pause, the GUI was not updated, so this could crash everything!
if ( g_EmulatorState ! = PLUGIN_EMUSTATE_PLAY )
{
DoRefreshReal ( ) ;
}
UpdateGUI ( ) ;
2010-01-01 16:50:11 +00:00
break ;
2009-07-05 04:29:00 +00:00
}
}
void WiimoteBasicConfigDialog : : CreateGUIControls ( )
{
2009-12-27 19:31:02 +00:00
wxArrayString arrayStringFor_source ;
arrayStringFor_source . Add ( wxT ( " Inactive " ) ) ;
arrayStringFor_source . Add ( wxT ( " Emulated Wiimote " ) ) ;
2010-03-27 04:21:19 +00:00
arrayStringFor_source . Add ( wxT ( " Real Wiimote " ) ) ;
2009-12-27 19:31:02 +00:00
wxArrayString arrayStringFor_extension ;
arrayStringFor_extension . Add ( wxT ( " None " ) ) ;
arrayStringFor_extension . Add ( wxT ( " Nunchuck " ) ) ;
arrayStringFor_extension . Add ( wxT ( " Classic Controller " ) ) ;
arrayStringFor_extension . Add ( wxT ( " Guitar Hero 3 Guitar " ) ) ;
2009-07-05 04:29:00 +00:00
m_Notebook = new wxNotebook ( this , ID_NOTEBOOK , wxDefaultPosition , wxDefaultSize ) ;
for ( int i = 0 ; i < MAX_WIIMOTES ; i + + )
{
m_Controller [ i ] = new wxPanel ( m_Notebook , ID_CONTROLLERPAGE1 + i , wxDefaultPosition , wxDefaultSize ) ;
m_Notebook - > AddPage ( m_Controller [ i ] , wxString : : Format ( wxT ( " Wiimote %d " ) , i + 1 ) ) ;
// Basic Settings
2009-12-27 19:31:02 +00:00
m_InputSource [ i ] = new wxChoice ( m_Controller [ i ] , IDC_INPUT_SOURCE , wxDefaultPosition , wxDefaultSize , arrayStringFor_source , 0 , wxDefaultValidator ) ;
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
m_InputSource [ i ] - > SetToolTip ( wxT ( " This can only be changed when the emulator is paused or stopped. " ) ) ;
2009-07-05 04:29:00 +00:00
// Emulated Wiimote
2009-12-11 13:57:25 +00:00
m_SidewaysWiimote [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_SIDEWAYSWIIMOTE , wxT ( " Sideways Wiimote " ) ) ;
2009-12-09 14:52:30 +00:00
m_SidewaysWiimote [ i ] - > SetToolTip ( wxT ( " Treat the sideways position as neutral " ) ) ;
2009-12-11 13:57:25 +00:00
m_UprightWiimote [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_UPRIGHTWIIMOTE , wxT ( " Upright Wiimote " ) ) ;
2009-12-06 18:26:20 +00:00
m_UprightWiimote [ i ] - > SetToolTip ( wxT ( " Treat the upright position as neutral " ) ) ;
2009-07-05 04:29:00 +00:00
2009-12-27 19:31:02 +00:00
m_WiiMotionPlusConnected [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_MOTIONPLUSCONNECTED , wxT ( " Wii Motion Plus Connected " ) ) ;
m_Extension [ i ] = new wxChoice ( m_Controller [ i ] , IDC_EXTCONNECTED , wxDefaultPosition , wxDefaultSize , arrayStringFor_extension , 0 , wxDefaultValidator ) ;
2010-04-13 01:34:11 +00:00
// UDPWii
m_UDPWiiEnable [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_UDPWIIENABLE , wxT ( " Enable UDPWii " ) ) ;
m_UDPWiiEnable [ i ] - > SetToolTip ( wxT ( " Enable listening for wiimote data on the network. Requires emulation restart " ) ) ;
m_UDPWiiAccel [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_UDPWIIACCEL , wxT ( " Update acceleration from UDPWii " ) ) ;
m_UDPWiiAccel [ i ] - > SetToolTip ( wxT ( " Retrieve acceleration data from a device on the network " ) ) ;
m_UDPWiiButt [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_UDPWIIBUTT , wxT ( " Update buttons from UDPWii " ) ) ;
m_UDPWiiButt [ i ] - > SetToolTip ( wxT ( " Retrieve button data from a device on the network. This doesn't affect keyboard mappings " ) ) ;
m_UDPWiiIR [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_UDPWIIIR , wxT ( " Update IR pointer from UDPWii " ) ) ;
m_UDPWiiIR [ i ] - > SetToolTip ( wxT ( " Retrieve IR pointer from a device on the network. Disables using mouse as pointer " ) ) ;
m_UDPWiiNun [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_UDPWIINUN , wxT ( " Update nunchuck from UDPWii " ) ) ;
m_UDPWiiNun [ i ] - > SetToolTip ( wxT ( " Retrieve nunchuck data from a device on the network. " ) ) ;
m_UDPWiiPort [ i ] = new wxTextCtrl ( m_Controller [ i ] , IDT_UDPWIIPORT ) ;
m_UDPWiiPort [ i ] - > SetMaxLength ( 9 ) ;
m_TextUDPWiiPort [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " UDP Port: " ) ) ;
m_TextUDPWiiPort [ i ] - > SetToolTip ( wxT ( " The UDP port on witch UDPWii listens for this remote. " ) ) ;
2009-12-27 19:31:02 +00:00
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-05-14 21:47:35 +00:00
m_PairUpRealWiimote [ i ] = new wxButton ( m_Controller [ i ] , IDB_PAIRUP_REAL , wxT ( " Pair Up " ) ) ;
2010-01-11 13:56:11 +00:00
m_PairUpRealWiimote [ i ] - > SetToolTip ( wxT ( " Press the Buttons 1 and 2 on your Wiimote. \n This might take a few seconds. \n It only works if you are using Microsoft Bluetooth stack. " ) ) ; // Only working with MS BT Stack.
2010-06-16 00:15:58 +00:00
# endif
2010-05-14 21:47:35 +00:00
2010-01-11 13:56:11 +00:00
m_TextFoundRealWiimote [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Connected to 0 Real Wiimotes " ) ) ;
2010-05-14 21:47:35 +00:00
m_ConnectRealWiimote [ i ] = new wxButton ( m_Controller [ i ] , IDB_REFRESH_REAL , wxT ( " Refresh " ) ) ;
2010-01-11 13:56:11 +00:00
m_ConnectRealWiimote [ i ] - > SetToolTip ( wxT ( " This can only be done when the emulator is paused or stopped. " ) ) ;
2010-03-28 09:51:57 +00:00
2010-05-15 17:04:03 +00:00
m_TextWiimoteTimeout [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Timeout: 000 ms " ) ) ;
2010-05-14 21:47:35 +00:00
m_WiimoteTimeout [ i ] = new wxSlider ( m_Controller [ i ] , IDS_TIMEOUT , 0 , 10 , 200 , wxDefaultPosition , wxSize ( 75 , - 1 ) ) ;
2010-07-24 17:00:31 +00:00
m_WiimoteTimeout [ i ] - > SetToolTip ( wxT ( " General Real Wiimote Read Timeout, Default: 30 (ms). Higher values eliminate frequent disconnects and packet loss. " ) ) ;
2010-05-14 21:47:35 +00:00
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-05-14 21:47:35 +00:00
//Real Wiimote / automatic settings
2010-04-15 16:47:55 +00:00
m_WiiAutoReconnect [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_WIIAUTORECONNECT , wxT ( " Reconnect Wiimote on disconnect " ) ) ;
2010-03-27 04:21:19 +00:00
m_WiiAutoReconnect [ i ] - > SetToolTip ( wxT ( " This makes dolphin automatically reconnect a wiimote when it has being disconnected. \n This will cause problems when 2 controllers are connected for a 1 player game. " ) ) ;
2010-04-15 16:47:55 +00:00
m_WiiAutoUnpair [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_WIIAUTOUNPAIR , wxT ( " Unpair Wiimote on close " ) ) ;
m_WiiAutoUnpair [ i ] - > SetToolTip ( wxT ( " This makes dolphin automatically unpair a wiimote when dolphin is about to be closed. " ) ) ;
2010-04-26 17:51:32 +00:00
m_WiiExtendedPairUp [ i ] = new wxCheckBox ( m_Controller [ i ] , IDC_WIIAUTOPAIR , wxT ( " Extended PairUp/Connect " ) ) ;
m_WiiExtendedPairUp [ i ] - > SetToolTip ( wxT ( " This makes dolphin automatically pair up and connect Wiimotes on pressing 1+2 on your Wiimote. " ) ) ;
2010-04-15 16:47:55 +00:00
# endif
2010-06-16 00:15:58 +00:00
2009-07-05 04:29:00 +00:00
//IR Pointer
m_TextScreenWidth [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Width: 000 " ) ) ;
m_TextScreenHeight [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Height: 000 " ) ) ;
m_TextScreenLeft [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Left: 000 " ) ) ;
m_TextScreenTop [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Top: 000 " ) ) ;
2010-03-26 12:36:28 +00:00
m_TextScreenIrLevel [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Sensivity: 000 " ) ) ;
2009-07-05 04:29:00 +00:00
m_SliderWidth [ i ] = new wxSlider ( m_Controller [ i ] , IDS_WIDTH , 0 , 100 , 923 , wxDefaultPosition , wxSize ( 75 , - 1 ) ) ;
m_SliderHeight [ i ] = new wxSlider ( m_Controller [ i ] , IDS_HEIGHT , 0 , 0 , 727 , wxDefaultPosition , wxSize ( 75 , - 1 ) ) ;
m_SliderLeft [ i ] = new wxSlider ( m_Controller [ i ] , IDS_LEFT , 0 , 100 , 500 , wxDefaultPosition , wxSize ( 75 , - 1 ) ) ;
m_SliderTop [ i ] = new wxSlider ( m_Controller [ i ] , IDS_TOP , 0 , 0 , 500 , wxDefaultPosition , wxSize ( 75 , - 1 ) ) ;
2010-03-26 12:36:28 +00:00
m_SliderIrLevel [ i ] = new wxSlider ( m_Controller [ i ] , IDS_LEVEL , 0 , 1 , 5 , wxDefaultPosition , wxSize ( 75 , - 1 ) ) ;
2009-07-05 04:29:00 +00:00
// These are changed from the graphics plugin settings, so they are just here to show the loaded status
m_TextAR [ i ] = new wxStaticText ( m_Controller [ i ] , wxID_ANY , wxT ( " Aspect Ratio " ) ) ;
m_CheckAR43 [ i ] = new wxCheckBox ( m_Controller [ i ] , wxID_ANY , wxT ( " 4:3 " ) , wxDefaultPosition , wxSize ( - 1 , - 1 ) , 0 , wxDefaultValidator ) ;
m_CheckAR43 [ i ] - > Enable ( false ) ;
2009-12-27 19:31:02 +00:00
m_CheckAR169 [ i ] = new wxCheckBox ( m_Controller [ i ] , wxID_ANY , wxT ( " 16:9 " ) , wxDefaultPosition , wxSize ( - 1 , - 1 ) , 0 , wxDefaultValidator ) ;
2009-07-05 04:29:00 +00:00
m_CheckAR169 [ i ] - > Enable ( false ) ;
2009-12-27 19:31:02 +00:00
m_Crop [ i ] = new wxCheckBox ( m_Controller [ i ] , wxID_ANY , wxT ( " Crop " ) , wxDefaultPosition , wxSize ( - 1 , - 1 ) , 0 , wxDefaultValidator ) ;
2009-07-05 04:29:00 +00:00
m_Crop [ i ] - > Enable ( false ) ;
2009-11-28 05:59:46 +00:00
// Sizers
2009-12-27 19:31:02 +00:00
m_SizeBasic [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ] , wxT ( " Input Source " ) ) ;
m_SizeBasic [ i ] - > Add ( m_InputSource [ i ] , 0 , wxEXPAND | wxALL , 5 ) ;
2009-11-28 05:59:46 +00:00
2009-12-06 18:26:20 +00:00
m_SizeEmu [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ] , wxT ( " Emulated Position " ) ) ;
2009-12-09 14:52:30 +00:00
m_SizeEmu [ i ] - > Add ( m_SidewaysWiimote [ i ] , 0 , wxEXPAND | wxALL , 5 ) ;
2009-11-28 05:59:46 +00:00
m_SizeEmu [ i ] - > Add ( m_UprightWiimote [ i ] , 0 , wxEXPAND | ( wxLEFT | wxDOWN | wxRIGHT ) , 5 ) ;
2009-12-06 18:26:20 +00:00
m_SizeExtensions [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ] , wxT ( " Emulated Extension " ) ) ;
m_SizeExtensions [ i ] - > Add ( m_WiiMotionPlusConnected [ i ] , 0 , wxEXPAND | wxALL , 5 ) ;
2009-12-27 19:31:02 +00:00
m_SizeExtensions [ i ] - > Add ( m_Extension [ i ] , 0 , wxEXPAND | wxALL , 5 ) ;
2009-12-06 18:26:20 +00:00
2010-04-13 01:34:11 +00:00
m_SizeUDPWii [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ] , wxT ( " Emulated UDPWii " ) ) ;
m_SizeUDPWii [ i ] - > Add ( m_UDPWiiEnable [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
m_SizeUDPWiiPort [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
m_SizeUDPWiiPort [ i ] - > Add ( m_TextUDPWiiPort [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
m_SizeUDPWiiPort [ i ] - > Add ( m_UDPWiiPort [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
m_SizeUDPWii [ i ] - > Add ( m_SizeUDPWiiPort [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
m_SizeUDPWii [ i ] - > Add ( m_UDPWiiAccel [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
m_SizeUDPWii [ i ] - > Add ( m_UDPWiiButt [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
m_SizeUDPWii [ i ] - > Add ( m_UDPWiiIR [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
m_SizeUDPWii [ i ] - > Add ( m_UDPWiiNun [ i ] , 0 , wxEXPAND | wxALL , 1 ) ;
2010-03-27 04:21:19 +00:00
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-04-15 16:47:55 +00:00
m_SizeRealAuto [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ] , wxT ( " Automatic " ) ) ;
m_SizeRealAuto [ i ] - > Add ( m_WiiAutoReconnect [ i ] , 0 , wxEXPAND | ( wxDOWN | wxTOP ) , 5 ) ;
m_SizeRealAuto [ i ] - > Add ( m_WiiAutoUnpair [ i ] , 0 , wxEXPAND | ( wxDOWN | wxTOP ) , 5 ) ;
2010-04-26 17:51:32 +00:00
m_SizeRealAuto [ i ] - > Add ( m_WiiExtendedPairUp [ i ] , 0 , wxEXPAND | ( wxDOWN | wxTOP ) , 5 ) ;
2010-06-16 00:15:58 +00:00
# endif
2010-04-15 16:47:55 +00:00
2010-05-14 21:47:35 +00:00
m_SizeRealTimeout [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
m_SizeRealTimeout [ i ] - > Add ( m_TextWiimoteTimeout [ i ] , 0 , wxEXPAND | ( wxTOP ) , 3 ) ;
m_SizeRealTimeout [ i ] - > Add ( m_WiimoteTimeout [ i ] , 0 , wxEXPAND | ( wxRIGHT ) , 0 ) ;
m_SizeRealRefreshPair [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-05-14 21:47:35 +00:00
m_SizeRealRefreshPair [ i ] - > Add ( m_PairUpRealWiimote [ i ] , 0 , wxEXPAND | wxALL , 5 ) ;
2010-06-16 00:15:58 +00:00
# endif
2010-05-14 21:47:35 +00:00
m_SizeRealRefreshPair [ i ] - > Add ( m_ConnectRealWiimote [ i ] , 0 , wxEXPAND | wxALL , 5 ) ;
2009-12-06 18:26:20 +00:00
m_SizeReal [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ] , wxT ( " Real Wiimote " ) ) ;
2010-05-14 21:47:35 +00:00
m_SizeReal [ i ] - > Add ( m_TextFoundRealWiimote [ i ] , 0 , wxALIGN_CENTER | wxALL , 5 ) ;
m_SizeReal [ i ] - > Add ( m_SizeRealRefreshPair [ i ] , 0 , wxALIGN_CENTER | ( wxLEFT | wxDOWN | wxRIGHT ) , 5 ) ;
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-04-15 16:47:55 +00:00
m_SizeReal [ i ] - > Add ( m_SizeRealAuto [ i ] , 0 , wxEXPAND | wxALL , 5 ) ;
2010-06-16 00:15:58 +00:00
# endif
2010-05-14 21:47:35 +00:00
m_SizeReal [ i ] - > Add ( m_SizeRealTimeout [ i ] , 0 , wxEXPAND | ( wxLEFT | wxDOWN | wxRIGHT ) , 5 ) ;
2009-12-06 18:26:20 +00:00
m_SizerIRPointerWidth [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
m_SizerIRPointerWidth [ i ] - > Add ( m_TextScreenLeft [ i ] , 0 , wxEXPAND | ( wxTOP ) , 3 ) ;
m_SizerIRPointerWidth [ i ] - > Add ( m_SliderLeft [ i ] , 0 , wxEXPAND | ( wxRIGHT ) , 0 ) ;
m_SizerIRPointerWidth [ i ] - > Add ( m_TextScreenWidth [ i ] , 0 , wxEXPAND | ( wxTOP ) , 3 ) ;
m_SizerIRPointerWidth [ i ] - > Add ( m_SliderWidth [ i ] , 0 , wxEXPAND | ( wxLEFT ) , 0 ) ;
2009-12-27 19:31:02 +00:00
2009-12-06 18:26:20 +00:00
m_SizerIRPointerHeight [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
m_SizerIRPointerHeight [ i ] - > Add ( m_TextScreenTop [ i ] , 0 , wxEXPAND | ( wxTOP ) , 3 ) ;
m_SizerIRPointerHeight [ i ] - > Add ( m_SliderTop [ i ] , 0 , wxEXPAND | ( wxRIGHT ) , 0 ) ;
m_SizerIRPointerHeight [ i ] - > Add ( m_TextScreenHeight [ i ] , 0 , wxEXPAND | ( wxTOP ) , 3 ) ;
m_SizerIRPointerHeight [ i ] - > Add ( m_SliderHeight [ i ] , 0 , wxEXPAND | ( wxLEFT ) , 0 ) ;
2009-07-05 04:29:00 +00:00
m_SizerIRPointerScreen [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
m_SizerIRPointerScreen [ i ] - > Add ( m_TextAR [ i ] , 0 , wxEXPAND | ( wxTOP ) , 0 ) ;
m_SizerIRPointerScreen [ i ] - > Add ( m_CheckAR43 [ i ] , 0 , wxEXPAND | ( wxLEFT ) , 5 ) ;
m_SizerIRPointerScreen [ i ] - > Add ( m_CheckAR169 [ i ] , 0 , wxEXPAND | ( wxLEFT ) , 5 ) ;
m_SizerIRPointerScreen [ i ] - > Add ( m_Crop [ i ] , 0 , wxEXPAND | ( wxLEFT ) , 5 ) ;
2010-03-26 12:36:28 +00:00
m_SizerIRPointerSensitivity [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
m_SizerIRPointerSensitivity [ i ] - > Add ( m_TextScreenIrLevel [ i ] , 0 , wxEXPAND | ( wxTOP ) , 3 ) ;
m_SizerIRPointerSensitivity [ i ] - > Add ( m_SliderIrLevel [ i ] , 0 , wxEXPAND | ( wxRIGHT ) , 0 ) ;
2009-12-06 18:26:20 +00:00
m_SizerIRPointer [ i ] = new wxStaticBoxSizer ( wxVERTICAL , m_Controller [ i ] , wxT ( " IR Pointer " ) ) ;
2009-07-05 04:29:00 +00:00
m_SizerIRPointer [ i ] - > Add ( m_SizerIRPointerWidth [ i ] , 0 , wxEXPAND | ( wxLEFT | wxDOWN | wxRIGHT ) , 5 ) ;
m_SizerIRPointer [ i ] - > Add ( m_SizerIRPointerHeight [ i ] , 0 , wxEXPAND | ( wxLEFT | wxDOWN | wxRIGHT ) , 5 ) ;
2010-03-26 12:36:28 +00:00
m_SizerIRPointer [ i ] - > Add ( m_SizerIRPointerSensitivity [ i ] , 0 , wxEXPAND | ( wxLEFT | wxDOWN | wxRIGHT ) , 5 ) ;
2009-12-06 18:26:20 +00:00
m_SizerIRPointer [ i ] - > Add ( m_SizerIRPointerScreen [ i ] , 0 , wxALIGN_CENTER | ( wxUP | wxDOWN ) , 10 ) ;
m_SizeBasicGeneralLeft [ i ] = new wxBoxSizer ( wxVERTICAL ) ;
m_SizeBasicGeneralLeft [ i ] - > Add ( m_SizeBasic [ i ] , 0 , wxEXPAND | ( wxUP ) , 5 ) ;
m_SizeBasicGeneralLeft [ i ] - > Add ( m_SizeEmu [ i ] , 0 , wxEXPAND | ( wxUP ) , 5 ) ;
m_SizeBasicGeneralLeft [ i ] - > Add ( m_SizeExtensions [ i ] , 0 , wxEXPAND | ( wxUP ) , 5 ) ;
2010-04-13 01:34:11 +00:00
m_SizeBasicGeneralLeft [ i ] - > Add ( m_SizeUDPWii [ i ] , 0 , wxEXPAND | ( wxUP ) , 5 ) ;
2009-07-05 04:29:00 +00:00
m_SizeBasicGeneralRight [ i ] = new wxBoxSizer ( wxVERTICAL ) ;
2009-12-06 18:26:20 +00:00
m_SizeBasicGeneralRight [ i ] - > Add ( m_SizeReal [ i ] , 0 , wxEXPAND | ( wxUP ) , 5 ) ;
2009-07-05 04:29:00 +00:00
m_SizeBasicGeneralRight [ i ] - > Add ( m_SizerIRPointer [ i ] , 0 , wxEXPAND | ( wxUP ) , 5 ) ;
m_SizeBasicGeneral [ i ] = new wxBoxSizer ( wxHORIZONTAL ) ;
2009-12-27 19:31:02 +00:00
m_SizeBasicGeneral [ i ] - > Add ( m_SizeBasicGeneralLeft [ i ] , 0 , wxEXPAND | ( wxLEFT | wxRIGHT | wxDOWN ) , 5 ) ;
m_SizeBasicGeneral [ i ] - > Add ( m_SizeBasicGeneralRight [ i ] , 0 , wxEXPAND | ( wxLEFT | wxRIGHT | wxDOWN ) , 5 ) ;
2009-07-05 04:29:00 +00:00
// Set the main sizer
2009-12-27 19:31:02 +00:00
m_Controller [ i ] - > SetSizer ( m_SizeBasicGeneral [ i ] ) ;
2009-07-05 04:29:00 +00:00
}
m_ButtonMapping = new wxButton ( this , ID_BUTTONMAPPING , wxT ( " Button Mapping " ) ) ;
2010-01-05 17:38:37 +00:00
2010-02-25 06:12:35 +00:00
m_OK = new wxButton ( this , wxID_OK , wxT ( " OK " ) ) ;
2009-12-14 02:23:14 +00:00
m_OK - > SetToolTip ( wxT ( " Save changes and close " ) ) ;
2010-02-25 06:12:35 +00:00
m_Cancel = new wxButton ( this , wxID_CANCEL , wxT ( " Cancel " ) ) ;
2009-12-14 02:23:14 +00:00
m_Cancel - > SetToolTip ( wxT ( " Discard changes and close " ) ) ;
2009-07-05 04:29:00 +00:00
wxBoxSizer * sButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
sButtons - > Add ( m_ButtonMapping , 0 , ( wxALL ) , 0 ) ;
sButtons - > AddStretchSpacer ( ) ;
2009-12-14 02:23:14 +00:00
sButtons - > Add ( m_OK , 0 , ( wxALL ) , 0 ) ;
sButtons - > Add ( m_Cancel , 0 , ( wxLEFT ) , 5 ) ;
2009-07-05 04:29:00 +00:00
m_MainSizer = new wxBoxSizer ( wxVERTICAL ) ;
m_MainSizer - > Add ( m_Notebook , 1 , wxEXPAND | wxALL , 5 ) ;
m_MainSizer - > Add ( sButtons , 0 , wxEXPAND | ( wxLEFT | wxRIGHT | wxDOWN ) , 5 ) ;
2009-12-14 02:23:14 +00:00
SetSizer ( m_MainSizer ) ;
Layout ( ) ;
2009-07-05 04:29:00 +00:00
Fit ( ) ;
// Center the window if there is room for it
# ifdef _WIN32
2009-12-11 13:57:25 +00:00
if ( GetSystemMetrics ( SM_CYFULLSCREEN ) > 600 )
2009-07-05 04:29:00 +00:00
Center ( ) ;
# endif
2009-12-14 02:23:14 +00:00
2009-07-05 04:29:00 +00:00
ControlsCreated = true ;
}
2009-12-27 19:31:02 +00:00
// Execute a delayed function
void WiimoteBasicConfigDialog : : UpdateOnce ( wxTimerEvent & event )
{
switch ( event . GetId ( ) )
{
case IDTM_UPDATE_ONCE :
// Reenable the checkbox
SetCursor ( wxCursor ( wxCURSOR_ARROW ) ) ;
UpdateGUI ( ) ;
break ;
}
}
2010-02-21 18:53:11 +00:00
# if HAVE_WIIUSE
2010-01-01 16:50:11 +00:00
void WiimoteBasicConfigDialog : : DoRefreshReal ( )
{
2010-02-21 18:53:11 +00:00
WiiMoteReal : : Shutdown ( ) ;
WiiMoteReal : : Initialize ( ) ;
2010-01-01 16:50:11 +00:00
}
2010-04-26 17:51:32 +00:00
void WiimoteBasicConfigDialog : : UpdateBasicConfigDialog ( bool state ) {
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-04-26 17:51:32 +00:00
if ( m_BasicConfigFrame ! = NULL ) {
if ( state ) {
m_PairUpRealWiimote [ m_Page ] - > Enable ( true ) ;
m_BasicConfigFrame - > UpdateGUI ( ) ;
}
else
m_PairUpRealWiimote [ m_Page ] - > Enable ( false ) ;
}
2010-06-16 00:15:58 +00:00
# endif
2010-04-26 17:51:32 +00:00
}
2009-07-05 04:29:00 +00:00
void WiimoteBasicConfigDialog : : DoUseReal ( )
{
2010-01-01 16:50:11 +00:00
if ( ! g_RealWiiMotePresent )
2009-12-14 02:23:14 +00:00
return ;
2009-07-05 04:29:00 +00:00
// Clear any eventual events in the Wiimote queue
WiiMoteReal : : ClearEvents ( ) ;
// Are we using an extension now? The report that it's removed, then reconnected.
bool UsingExtension = false ;
2010-05-07 22:39:06 +00:00
if ( ( WiiMoteEmu : : WiiMapping [ m_Page ] . iExtensionConnected ! = WiiMoteEmu : : EXT_NONE ) | | ( WiiMoteEmu : : WiiMapping [ m_Page ] . bMotionPlusConnected ) )
2009-07-05 04:29:00 +00:00
UsingExtension = true ;
2009-09-15 02:12:55 +00:00
DEBUG_LOG ( WIIMOTE , " DoUseReal() Connect extension: %i " , ! UsingExtension ) ;
2009-07-05 04:29:00 +00:00
DoExtensionConnectedDisconnected ( UsingExtension ? 0 : 1 ) ;
UsingExtension = ! UsingExtension ;
2009-09-15 02:12:55 +00:00
DEBUG_LOG ( WIIMOTE , " DoUseReal() Connect extension: %i " , ! UsingExtension ) ;
2009-07-05 04:29:00 +00:00
DoExtensionConnectedDisconnected ( UsingExtension ? 1 : 0 ) ;
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
if ( g_EmulatorState = = PLUGIN_EMUSTATE_PLAY )
2009-07-05 04:29:00 +00:00
{
// Disable the checkbox for a moment
SetCursor ( wxCursor ( wxCURSOR_WAIT ) ) ;
// We may not need this if there is already a message queue that allows the nessesary timeout
//sleep(100);
/* Start the timer to allow the approximate time it takes for the Wiimote to come online
it would simpler to use sleep ( 1000 ) but that doesn ' t work because we need the functions in main . cpp
to work */
m_TimeoutOnce - > Start ( 1000 , true ) ;
}
}
2010-02-21 18:53:11 +00:00
# endif
2009-07-05 04:29:00 +00:00
2009-07-06 00:27:32 +00:00
// Generate connect/disconnect status event
2009-07-05 04:29:00 +00:00
void WiimoteBasicConfigDialog : : DoExtensionConnectedDisconnected ( int Extension )
{
// There is no need for this if no game is running
2010-01-01 03:19:46 +00:00
if ( ! g_EmulatorRunning | | WiiMoteEmu : : WiiMapping [ m_Page ] . Source ! = 1 )
2009-12-27 19:31:02 +00:00
return ;
2009-07-05 04:29:00 +00:00
2009-12-27 19:31:02 +00:00
u8 DataFrame [ 8 ] = { 0 } ; // make a blank report for it
2009-07-05 04:29:00 +00:00
wm_request_status * rs = ( wm_request_status * ) DataFrame ;
// Check if a game is running, in that case change the status
2010-01-01 00:38:24 +00:00
if ( WiiMoteEmu : : g_ReportingChannel [ m_Page ] > 0 )
2009-12-27 19:31:02 +00:00
{
WiiMoteEmu : : g_ID = m_Page ;
WiiMoteEmu : : WmRequestStatus ( WiiMoteEmu : : g_ReportingChannel [ m_Page ] , rs , Extension ) ;
}
2009-07-05 04:29:00 +00:00
}
2009-12-27 19:31:02 +00:00
// Notebook page changed
void WiimoteBasicConfigDialog : : NotebookPageChanged ( wxNotebookEvent & event )
{
// Update the global variable
m_Page = event . GetSelection ( ) ;
// Update GUI
if ( ControlsCreated )
UpdateGUI ( ) ;
}
2009-07-05 04:29:00 +00:00
void WiimoteBasicConfigDialog : : GeneralSettingsChanged ( wxCommandEvent & event )
{
switch ( event . GetId ( ) )
{
2010-01-01 00:38:24 +00:00
case IDC_INPUT_SOURCE :
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
// If the config dialog was open when the user click on Play/Pause, the GUI was not updated, so this could crash everything!
if ( g_EmulatorState = = PLUGIN_EMUSTATE_PLAY )
{
PanicAlert ( " This can only be changed when the emulator is paused or stopped! " ) ;
WiiMoteEmu : : WiiMapping [ m_Page ] . Source = 0 ;
}
else
2010-01-01 00:38:24 +00:00
{
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
if ( m_InputSource [ m_Page ] - > GetSelection ( ) = = 2 )
2010-01-01 00:38:24 +00:00
{
2010-01-01 16:50:11 +00:00
WiiMoteEmu : : WiiMapping [ m_Page ] . Source = 2 ;
DoUseReal ( ) ;
2010-01-01 00:38:24 +00:00
}
else
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
WiiMoteEmu : : WiiMapping [ m_Page ] . Source = m_InputSource [ m_Page ] - > GetSelection ( ) ;
2010-01-01 00:38:24 +00:00
}
break ;
case IDC_SIDEWAYSWIIMOTE :
WiiMoteEmu : : WiiMapping [ m_Page ] . bSideways = m_SidewaysWiimote [ m_Page ] - > IsChecked ( ) ;
break ;
case IDC_UPRIGHTWIIMOTE :
WiiMoteEmu : : WiiMapping [ m_Page ] . bUpright = m_UprightWiimote [ m_Page ] - > IsChecked ( ) ;
break ;
case IDC_MOTIONPLUSCONNECTED :
WiiMoteEmu : : WiiMapping [ m_Page ] . bMotionPlusConnected = m_WiiMotionPlusConnected [ m_Page ] - > IsChecked ( ) ;
2010-05-07 22:39:06 +00:00
DoExtensionConnectedDisconnected ( WiiMoteEmu : : EXT_NONE ) ;
if ( g_EmulatorRunning )
SLEEP ( 25 ) ;
WiiMoteEmu : : UpdateExtRegisterBlocks ( m_Page ) ;
DoExtensionConnectedDisconnected ( ) ;
2010-01-01 00:38:24 +00:00
break ;
2010-03-27 04:21:19 +00:00
case IDC_WIIAUTORECONNECT :
WiiMoteEmu : : WiiMapping [ m_Page ] . bWiiAutoReconnect = m_WiiAutoReconnect [ m_Page ] - > IsChecked ( ) ;
break ;
2010-04-15 16:47:55 +00:00
case IDC_WIIAUTOUNPAIR :
g_Config . bUnpairRealWiimote = m_WiiAutoUnpair [ m_Page ] - > IsChecked ( ) ;
break ;
2010-04-26 17:51:32 +00:00
# ifdef _WIN32
case IDC_WIIAUTOPAIR :
if ( m_WiiExtendedPairUp [ m_Page ] - > IsChecked ( ) )
WiiMoteReal : : g_StartAutopairThread . Set ( ) ;
g_Config . bPairRealWiimote = m_WiiExtendedPairUp [ m_Page ] - > IsChecked ( ) ;
break ;
# endif
2010-01-01 00:38:24 +00:00
case IDC_EXTCONNECTED :
// Disconnect the extension so that the game recognize the change
DoExtensionConnectedDisconnected ( WiiMoteEmu : : EXT_NONE ) ;
// It doesn't seem to be needed but shouldn't it at least take 25 ms to
// reconnect an extension after we disconnected another?
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
if ( g_EmulatorRunning )
2010-01-01 00:38:24 +00:00
SLEEP ( 25 ) ;
// Update status
WiiMoteEmu : : WiiMapping [ m_Page ] . iExtensionConnected = m_Extension [ m_Page ] - > GetSelection ( ) ;
// Copy the calibration data
WiiMoteEmu : : UpdateExtRegisterBlocks ( m_Page ) ;
// Generate connect/disconnect status event
DoExtensionConnectedDisconnected ( ) ;
break ;
2009-07-05 04:29:00 +00:00
}
UpdateGUI ( ) ;
}
void WiimoteBasicConfigDialog : : IRCursorChanged ( wxScrollEvent & event )
{
switch ( event . GetId ( ) )
{
case IDS_WIDTH :
2009-12-27 19:31:02 +00:00
g_Config . iIRWidth = m_SliderWidth [ m_Page ] - > GetValue ( ) ;
2009-07-05 04:29:00 +00:00
break ;
case IDS_HEIGHT :
2009-12-27 19:31:02 +00:00
g_Config . iIRHeight = m_SliderHeight [ m_Page ] - > GetValue ( ) ;
2009-07-05 04:29:00 +00:00
break ;
case IDS_LEFT :
2009-12-27 19:31:02 +00:00
g_Config . iIRLeft = m_SliderLeft [ m_Page ] - > GetValue ( ) ;
2009-07-05 04:29:00 +00:00
break ;
case IDS_TOP :
2009-12-27 19:31:02 +00:00
g_Config . iIRTop = m_SliderTop [ m_Page ] - > GetValue ( ) ;
2009-07-05 04:29:00 +00:00
break ;
2010-03-26 12:36:28 +00:00
case IDS_LEVEL :
g_Config . iIRLevel = m_SliderIrLevel [ m_Page ] - > GetValue ( ) ;
if ( g_RealWiiMotePresent ) {
for ( int i = 0 ; i < WiiMoteReal : : g_NumberOfWiiMotes ; i + + )
wiiuse_set_ir_sensitivity ( WiiMoteReal : : g_WiiMotesFromWiiUse [ i ] , g_Config . iIRLevel ) ;
}
break ;
2010-05-14 21:47:35 +00:00
case IDS_TIMEOUT :
g_Config . bWiiReadTimeout = m_WiimoteTimeout [ m_Page ] - > GetValue ( ) ;
if ( g_RealWiiMotePresent ) {
External/wiiuse clean up, part 2.
- More removal of unnecessary code
- Windows: Modification of Wiiuse_Find under windows,
instead of always deleting and recreating the whole wiimote_t struct, we do maintain the old one,
adding/removing new wiimotes to/from it
- some wiimote bugfixes, see below for details
Windows related stuff:
Fixed most of the disconnection issues (single and mulitple real wiimotes, both wiimote plugins) (I haven't had a disconnect msg in hours anymore(ms stack)).
Rumble bug should be fixed now(both plugins,pls verify).
Fixed some pair up issues( sometimes you had to press the pair up button up to 3 times, till it paired up your wiimote).
More dongles might be now supported via ms stack, pls try and report back!
Fixed a problem where multiple wiimotes would swap slots on pair-up/addition of a real wiimote (2-4 real wiimotes) (both plugins, but not integrated into new plugin).
Improved ingame auto-pairup for real wiimotes(thx to the new wiiuse_find routine).
Fixed a bug on setting wiimote timeouts, which means changing the timeout was just a dummy earlier.
Most of the stuff concerns stuff in the old wiimote plugin, dont worry, in the end it's important for both plugins. It will get ported to the new plugin sooner or later.:')
Some minor stuff.
This might break osx/linux build and maybe the new plugin realwiimote-wise only. Thx to glennrics to pointing me to some breakings on linux, I didn't fix them all.
PS I hope i haven't forgotten anything, enjoy.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5940 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-07-22 04:31:36 +00:00
wiiuse_set_timeout ( WiiMoteReal : : g_WiiMotesFromWiiUse , WiiMoteReal : : g_NumberOfWiiMotes , g_Config . bWiiReadTimeout ) ;
2010-05-14 21:47:35 +00:00
}
break ;
2009-07-05 04:29:00 +00:00
}
UpdateGUI ( ) ;
}
2010-04-13 01:34:11 +00:00
void WiimoteBasicConfigDialog : : UDPWiiSettingsChanged ( wxCommandEvent & event )
{
switch ( event . GetId ( ) )
{
case IDC_UDPWIIENABLE :
WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enable = m_UDPWiiEnable [ m_Page ] - > GetValue ( ) ;
break ;
case IDC_UDPWIIACCEL :
WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableAccel = m_UDPWiiAccel [ m_Page ] - > GetValue ( ) ;
break ;
case IDC_UDPWIIIR :
WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableIR = m_UDPWiiIR [ m_Page ] - > GetValue ( ) ;
break ;
case IDC_UDPWIIBUTT :
WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableButtons = m_UDPWiiButt [ m_Page ] - > GetValue ( ) ;
break ;
case IDC_UDPWIINUN :
WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableNunchuck = m_UDPWiiNun [ m_Page ] - > GetValue ( ) ;
break ;
case IDT_UDPWIIPORT :
strncpy ( WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . port , ( const char * ) ( m_UDPWiiPort [ m_Page ] - > GetValue ( ) . mb_str ( wxConvUTF8 ) ) , 10 ) ;
break ;
}
UpdateGUI ( ) ;
}
2009-12-27 19:31:02 +00:00
void WiimoteBasicConfigDialog : : UpdateGUI ( )
2009-07-05 04:29:00 +00:00
{
/* I have disabled this option during a running game because it's enough to be able to switch
between using and not using then . To also use the connect option during a running game would
mean that the wiimote must be sent the current reporting mode and the channel ID after it
has been initialized . Functions for that are basically already in place so these two options
could possibly be simplified to one option . */
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-01-11 13:56:11 +00:00
m_PairUpRealWiimote [ m_Page ] - > Enable ( g_EmulatorState ! = PLUGIN_EMUSTATE_PLAY ) ;
2010-06-16 00:15:58 +00:00
# endif
2010-01-11 13:56:11 +00:00
m_TextFoundRealWiimote [ m_Page ] - > SetLabel ( wxString : : Format ( wxT ( " Connected to %i Real Wiimotes " ) , WiiMoteReal : : g_NumberOfWiiMotes ) ) ;
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
m_ConnectRealWiimote [ m_Page ] - > Enable ( g_EmulatorState ! = PLUGIN_EMUSTATE_PLAY ) ;
2009-12-16 19:12:07 +00:00
2010-01-01 03:19:46 +00:00
m_InputSource [ m_Page ] - > SetSelection ( WiiMoteEmu : : WiiMapping [ m_Page ] . Source ) ;
2010-01-11 13:56:11 +00:00
m_InputSource [ m_Page ] - > Enable ( g_EmulatorState ! = PLUGIN_EMUSTATE_PLAY ) ;
2010-05-14 21:47:35 +00:00
2010-01-01 03:19:46 +00:00
if ( WiiMoteEmu : : WiiMapping [ m_Page ] . Source = = 2 )
2010-01-01 00:38:24 +00:00
{
2010-05-14 21:47:35 +00:00
m_Extension [ m_Page ] - > Enable ( false ) ;
2010-05-15 17:04:03 +00:00
m_WiiMotionPlusConnected [ m_Page ] - > Enable ( false ) ;
2010-01-01 00:38:24 +00:00
m_SidewaysWiimote [ m_Page ] - > Enable ( false ) ;
m_UprightWiimote [ m_Page ] - > Enable ( false ) ;
2010-05-14 21:47:35 +00:00
m_WiimoteTimeout [ m_Page ] - > Enable ( true ) ;
2010-03-28 09:51:57 +00:00
m_SliderIrLevel [ m_Page ] - > Enable ( true ) ;
2010-01-01 00:38:24 +00:00
}
else
{
2010-05-14 21:47:35 +00:00
m_Extension [ m_Page ] - > Enable ( true ) ;
2010-05-15 17:04:03 +00:00
m_WiiMotionPlusConnected [ m_Page ] - > Enable ( true ) ;
2010-01-01 00:38:24 +00:00
m_SidewaysWiimote [ m_Page ] - > Enable ( true ) ;
m_UprightWiimote [ m_Page ] - > Enable ( true ) ;
2010-05-14 21:47:35 +00:00
m_WiimoteTimeout [ m_Page ] - > Enable ( false ) ;
2010-03-28 09:51:57 +00:00
m_SliderIrLevel [ m_Page ] - > Enable ( false ) ;
2010-01-01 00:38:24 +00:00
}
2010-05-14 21:47:35 +00:00
//General settings
m_Extension [ m_Page ] - > SetSelection ( WiiMoteEmu : : WiiMapping [ m_Page ] . iExtensionConnected ) ;
2009-12-27 19:31:02 +00:00
m_SidewaysWiimote [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . bSideways ) ;
m_UprightWiimote [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . bUpright ) ;
m_WiiMotionPlusConnected [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . bMotionPlusConnected ) ;
2010-05-14 21:47:35 +00:00
//Real Wiimote related settings
2010-06-16 00:15:58 +00:00
# ifdef _WIN32
2010-05-14 21:47:35 +00:00
//Automatic settings
2010-03-27 04:21:19 +00:00
m_WiiAutoReconnect [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . bWiiAutoReconnect ) ;
2010-04-15 16:47:55 +00:00
m_WiiAutoUnpair [ m_Page ] - > SetValue ( g_Config . bUnpairRealWiimote ) ;
2010-04-26 17:51:32 +00:00
m_WiiExtendedPairUp [ m_Page ] - > SetValue ( g_Config . bPairRealWiimote ) ;
2010-06-16 00:15:58 +00:00
# endif
2010-05-15 17:04:03 +00:00
m_TextWiimoteTimeout [ m_Page ] - > SetLabel ( wxString : : Format ( wxT ( " Timeout: %i ms " ) , g_Config . bWiiReadTimeout ) ) ;
2010-05-14 21:47:35 +00:00
m_WiimoteTimeout [ m_Page ] - > SetValue ( g_Config . bWiiReadTimeout ) ;
2009-12-16 19:12:07 +00:00
// Update the Wiimote IR pointer calibration
2009-12-27 19:31:02 +00:00
m_TextScreenWidth [ m_Page ] - > SetLabel ( wxString : : Format ( wxT ( " Width: %i " ) , g_Config . iIRWidth ) ) ;
m_TextScreenHeight [ m_Page ] - > SetLabel ( wxString : : Format ( wxT ( " Height: %i " ) , g_Config . iIRHeight ) ) ;
m_TextScreenLeft [ m_Page ] - > SetLabel ( wxString : : Format ( wxT ( " Left: %i " ) , g_Config . iIRLeft ) ) ;
m_TextScreenTop [ m_Page ] - > SetLabel ( wxString : : Format ( wxT ( " Top: %i " ) , g_Config . iIRTop ) ) ;
2010-03-26 12:36:28 +00:00
m_TextScreenIrLevel [ m_Page ] - > SetLabel ( wxString : : Format ( wxT ( " Sensitivity: %i " ) , g_Config . iIRLevel ) ) ;
2010-05-14 21:47:35 +00:00
2009-12-27 19:31:02 +00:00
// Update the slider position if a configuration has been loaded
m_SliderWidth [ m_Page ] - > SetValue ( g_Config . iIRWidth ) ;
m_SliderHeight [ m_Page ] - > SetValue ( g_Config . iIRHeight ) ;
m_SliderLeft [ m_Page ] - > SetValue ( g_Config . iIRLeft ) ;
m_SliderTop [ m_Page ] - > SetValue ( g_Config . iIRTop ) ;
2010-03-26 12:36:28 +00:00
m_SliderIrLevel [ m_Page ] - > SetValue ( g_Config . iIRLevel ) ;
2009-12-27 19:31:02 +00:00
2010-05-14 21:47:35 +00:00
m_CheckAR43 [ m_Page ] - > SetValue ( g_Config . bKeepAR43 ) ;
m_CheckAR169 [ m_Page ] - > SetValue ( g_Config . bKeepAR169 ) ;
m_Crop [ m_Page ] - > SetValue ( g_Config . bCrop ) ;
2010-04-13 01:34:11 +00:00
//Update UDPWii
m_UDPWiiEnable [ m_Page ] - > Enable ( g_EmulatorState ! = PLUGIN_EMUSTATE_PLAY ) ;
m_UDPWiiPort [ m_Page ] - > Enable ( g_EmulatorState ! = PLUGIN_EMUSTATE_PLAY ) ;
m_UDPWiiEnable [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enable ) ;
m_UDPWiiAccel [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableAccel ) ;
m_UDPWiiButt [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableButtons ) ;
m_UDPWiiIR [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableIR ) ;
m_UDPWiiNun [ m_Page ] - > SetValue ( WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . enableNunchuck ) ;
m_UDPWiiPort [ m_Page ] - > ChangeValue ( wxString : : FromAscii ( WiiMoteEmu : : WiiMapping [ m_Page ] . UDPWM . port ) ) ;
2009-07-05 04:29:00 +00:00
}