New Wiimote Plugin: Added "Upright Wiimote" option. Fixed a nunchuk problem in ZTP and Wii Sports with some Hacks. Some work on emulated Swing and Speaker (disabled). Fixes/Cleanups. ControllerInterface: Fixed an issue when a DInput device reports the same axis more than once. Fixed some old comments.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5422 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2010-04-29 18:51:04 +00:00
parent 81f06220ce
commit 22c2276cef
17 changed files with 579 additions and 290 deletions

View File

@ -16,7 +16,6 @@
#define CIFACE_USE_DIRECTINPUT
#endif
#if defined(HAVE_X11) && HAVE_X11
// Xlib is not tested at all currently, it is like 80% complete at least though
#define CIFACE_USE_XLIB
#endif
#ifndef CIFACE_USE_DIRECTINPUT_JOYSTICK
@ -74,7 +73,7 @@ public:
//
// Output
//
// guess wut it is, yup and output
// an output on a device
//
class Output : public Control
{
@ -175,7 +174,7 @@ public:
// ControlReference
//
// these are what you create to actually use the inputs, InputReference or OutputReference
// they have a vector < struct { device , vector < controls > } >
// they have a DeviceQualifier and ControlQualifier used to match 1 or more inputs
//
// after being binded to devices and controls with ControllerInterface::UpdateReference,
// each one can binded to a devices, and 0+ controls the device

View File

@ -4,6 +4,11 @@
#include "DirectInputJoystick.h"
inline bool operator<(const GUID & lhs, const GUID & rhs)
{
return memcmp(&lhs, &rhs, sizeof(GUID)) < 0 ? true : false;
}
namespace ciface
{
namespace DirectInput
@ -231,8 +236,18 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
}
// get up to 6 axes and 2 sliders
std::vector<DIDEVICEOBJECTINSTANCE> axes;
m_device->EnumObjects( DIEnumDeviceObjectsCallback, (LPVOID)&axes, DIDFT_ABSAXIS );
unsigned int cur_slider = 0;
m_device->EnumObjects( DIEnumDeviceObjectsCallback, (LPVOID)&axes, DIDFT_AXIS );
// map of axis offsets in joystate dataformat based on axis guidType
std::map<GUID,int> types;
types[GUID_XAxis] = 0;
types[GUID_YAxis] = 1;
types[GUID_ZAxis] = 2;
types[GUID_RxAxis] = 3;
types[GUID_RyAxis] = 4;
types[GUID_RzAxis] = 5;
// going in reverse leaves the list more organized in the end for me :/
std::vector<DIDEVICEOBJECTINSTANCE>::const_reverse_iterator i = axes.rbegin(),
@ -254,24 +269,25 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
if ( DI_OK == m_device->GetProperty( DIPROP_RANGE, &range.diph ) )
{
int offset = -1;
const GUID type = i->guidType;
// figure out which axis this is
if ( type == GUID_XAxis )
offset = 0;
else if ( type == GUID_YAxis )
offset = 1;
else if ( type == GUID_ZAxis )
offset = 2;
else if ( type == GUID_RxAxis )
offset = 3;
else if ( type == GUID_RyAxis )
offset = 4;
else if ( type == GUID_RzAxis )
offset = 5;
else if ( type == GUID_Slider )
if ( cur_slider < 2 )
if (GUID_Slider ==i->guidType)
{
// max of 2 sliders / limit of used data format
if (cur_slider < 2)
offset = 6 + cur_slider++;
}
else
{
// don't add duplicate axes, some buggy drivers report the same axis twice
const std::map<GUID,int>::iterator f = types.find(i->guidType);
if (types.end() != f)
{
offset = f->second;
// remove from the map so it isn't added again
types.erase(f);
}
}
if ( offset >= 0 )
{