summaryrefslogtreecommitdiff
path: root/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2010-04-24 00:44:10 +0000
committerJordan Woyak <jordan.woyak@gmail.com>2010-04-24 00:44:10 +0000
commit23689387e1f00bf045daa44df5c733950cdfb5d2 (patch)
treeeee9dbd66cdc19e8309791e1bff89a9560d99395 /Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp
parent1d8db5ce3f44cf637a88a6521680e2a336ff8f7c (diff)
More improvements to new wiimote plugin: Added emulated Drums/Guitar extensions. Wiimote rumble now handled for every output report. Fixed some mem leaks. Hopefully fixed a floating point exception in Linux, thanks to glennrics.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5403 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp')
-rw-r--r--Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp58
1 files changed, 26 insertions, 32 deletions
diff --git a/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp b/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp
index 70aa0998cb..b15607e5cc 100644
--- a/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp
+++ b/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp
@@ -4,11 +4,9 @@
#include <X11/Xlib.h>
#endif
-const char modifier[] = "Modifier";
-
-
ControllerEmu::~ControllerEmu()
{
+ // control groups
std::vector<ControlGroup*>::const_iterator
i = groups.begin(),
e = groups.end();
@@ -18,12 +16,14 @@ ControllerEmu::~ControllerEmu()
ControllerEmu::ControlGroup::~ControlGroup()
{
+ // controls
std::vector<Control*>::const_iterator
ci = controls.begin(),
ce = controls.end();
for ( ; ci!=ce; ++ci )
delete *ci;
+ // settings
std::vector<Setting*>::const_iterator
si = settings.begin(),
se = settings.end();
@@ -31,6 +31,20 @@ ControllerEmu::ControlGroup::~ControlGroup()
delete *si;
}
+ControllerEmu::Extension::~Extension()
+{
+ // attachments
+ std::vector<ControllerEmu*>::const_iterator
+ ai = attachments.begin(),
+ ae = attachments.end();
+ for ( ; ai!=ae; ++ai )
+ delete *ai;
+}
+ControllerEmu::ControlGroup::Control::~Control()
+{
+ delete control_ref;
+}
+
void ControllerEmu::UpdateReferences( ControllerInterface& devi )
{
std::vector<ControlGroup*>::const_iterator
@@ -170,7 +184,7 @@ void ControllerEmu::ControlGroup::SaveConfig( IniFile::Section& sec, const std::
for ( ; ci!=ce; ++ci )
{
// control and dev qualifier
- sec[group + (*ci)->name] = (*ci)->control_ref->control_qualifier.name;
+ sec.Set( group+(*ci)->name, (*ci)->control_ref->control_qualifier.name );
sec.Set( group+(*ci)->name+"/Device", (*ci)->control_ref->device_qualifier.ToString(), defdev );
// range
@@ -200,7 +214,7 @@ void ControllerEmu::SaveConfig( IniFile::Section& sec, const std::string& base )
{
const std::string defdev = default_device.ToString();
if ( base.empty() )
- sec[ std::string(" ") + base + "Device" ] = defdev;
+ sec.Set( std::string(" ") + base + "Device", defdev );
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
e = groups.end();
@@ -213,7 +227,7 @@ ControllerEmu::AnalogStick::AnalogStick( const char* const _name ) : ControlGrou
for ( unsigned int i = 0; i < 4; ++i )
controls.push_back( new Input( named_directions[i] ) );
- controls.push_back( new Input( modifier ) );
+ controls.push_back( new Input( "Modifier" ) );
settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
settings.push_back( new Setting("Square Stick", 0 ) );
@@ -230,6 +244,11 @@ ControllerEmu::MixedTriggers::MixedTriggers( const char* const _name ) : Control
settings.push_back( new Setting("Threshold", 0.9f ) );
}
+ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TRIGGERS )
+{
+ settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
+}
+
ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
{
controls.push_back( new Input( "X-" ) );
@@ -255,7 +274,7 @@ ControllerEmu::Tilt::Tilt( const char* const _name ) : ControlGroup( _name, GROU
controls.push_back( new Input( "Left" ) );
controls.push_back( new Input( "Right" ) );
- controls.push_back( new Input( modifier ) );
+ controls.push_back( new Input( "Modifier" ) );
settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
settings.push_back( new Setting("Circle Stick", 0 ) );
@@ -275,31 +294,6 @@ ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize
}
-//void GetMousePos(float& x, float& y, const SWiimoteInitialize* const wiimote_initialize)
-//{
-//#ifdef _WIN32
-// // Get the cursor position for the entire screen
-// POINT point;
-// GetCursorPos(&point);
-// // Get the cursor position relative to the upper left corner of the rendering window
-// ScreenToClient(wiimote_initialize->hWnd, &point);
-//
-// // Get the size of the rendering window. (In my case Rect.top and Rect.left was zero.)
-// RECT Rect;
-// GetClientRect(wiimote_initialize->hWnd, &Rect);
-// // Width and height is the size of the rendering window
-// float WinWidth = (float)(Rect.right - Rect.left);
-// float WinHeight = (float)(Rect.bottom - Rect.top);
-// float XOffset = 0, YOffset = 0;
-// float PictureWidth = WinWidth, PictureHeight = WinHeight;
-//#endif
-//
-// x = ((float)point.x - XOffset) / PictureWidth;
-// y = ((float)point.y - YOffset) / PictureHeight;
-// x *=2; x-=1;
-// y *=2; y-=1;
-//}
-
void GetMousePos(float& x, float& y, const SWiimoteInitialize* const wiimote_initialize)
{
unsigned int win_width = 2, win_height = 2;