diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2010-04-22 07:11:49 +0000 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2010-04-22 07:11:49 +0000 |
| commit | 7c22b83f668c9f5f8eebf4bab85359f10271b6c4 (patch) | |
| tree | 37b8971d2b16eebe4b0e9a9fae7e1d211073f49f /Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp | |
| parent | 140332c02ea905de29de1870c384174dda41303b (diff) | |
Improvements to new emulated wiimote plugin: IR cursor works with mouse or analog stick control. Wiimote mii data is saved/loaded to "User/Wii/mii.bin". Background input checkbox works properly. All reporting modes except the interleaved one should work. Fixed a rumble prob with multiple XInput devices.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5396 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp')
| -rw-r--r-- | Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp | 95 |
1 files changed, 93 insertions, 2 deletions
diff --git a/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp b/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp index b97aecca04..8d4fad8813 100644 --- a/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp +++ b/Source/Plugins/InputPluginCommon/Src/ControllerEmu.cpp @@ -211,7 +211,7 @@ ControllerEmu::AnalogStick::AnalogStick( const char* const _name ) : ControlGrou controls.push_back( new Input( modifier ) ); - settings.push_back( new Setting("Dead Zone", 0 ) ); + settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) ); settings.push_back( new Setting("Square Stick", 0 ) ); } @@ -253,6 +253,97 @@ ControllerEmu::Tilt::Tilt( const char* const _name ) : ControlGroup( _name, GROU controls.push_back( new Input( modifier ) ); - settings.push_back( new Setting("Dead Zone", 0 ) ); + settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) ); settings.push_back( new Setting("Circle Stick", 0 ) ); } + +ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize ) + : ControlGroup( _name, GROUP_TYPE_CURSOR ) + //, z(0) + , wiimote_initialize(_wiimote_initialize) +{ + for ( unsigned int i = 0; i < 4; ++i ) + controls.push_back( new Input( named_directions[i] ) ); + + settings.push_back( new Setting("Width", 0.5f ) ); + settings.push_back( new Setting("Height", 0.5f ) ); + settings.push_back( new Setting("Top", 0.5f ) ); + +} + +//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; + +#ifdef _WIN32 + // Get the cursor position for the entire screen + POINT point = { 1, 1 }; + 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 + win_width = Rect.right - Rect.left; + win_height = Rect.bottom - Rect.top; + +#elif defined(HAVE_X11) && HAVE_X11 + int root_x, root_y; + struct + { + int x, y; + } point = { 1, 1 }; + + // i think this if can be taken out, the plugin will handle that + if (IsFocus()) + { + Display* const wm_display = (Display*)wiimote_initialize->hWnd; + Window glwin = *(Window *)wiimote_initialize->pXWindow; + + XWindowAttributes win_attribs; + XGetWindowAttributes (wm_display, glwin, &win_attribs); + win_width = win_attribs.width; + win_height = win_attribs.height; + Window root_dummy, child_win; + unsigned int mask; + XQueryPointer(wm_display, glwin, &root_dummy, &child_win, &root_x, &root_y, &point.x, &point.y, &mask); + } +#endif + +#if ( defined(_WIN32) || (defined(HAVE_X11) && HAVE_X11)) + // Return the mouse position as a range from -1 to 1 + x = (float)point.x / (float)win_width * 2 - 1; + y = (float)point.y / (float)win_height * 2 - 1; +#else + x = 0; + y = 0; +#endif + +} |
