mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-11 16:49:28 +02:00
GCPad/New Wiimote Plugin: Individual keyboard and mouse devices are now listed on Windows(2 player with 2 keyboards possible). Improved the ability to map multiple inputs to the same control. Inputs from different devices can be mapped to the same button (example: Mouse Left and XInput A). More advanced mappings such as "Button 1 or 2 and NOT button 3" are possible. I hope the GUI after right clicking a button isn't too confusing(may change it to be a bit more user friendly). Hopefully, I didn't break OSX stuff by 'const'ing a few functions.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5757 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -12,8 +12,10 @@
|
||||
#ifdef _WIN32
|
||||
#define CIFACE_USE_XINPUT
|
||||
#define CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
#define CIFACE_USE_DIRECTINPUT_KBM
|
||||
#define CIFACE_USE_DIRECTINPUT_KEYBOARD
|
||||
#define CIFACE_USE_DIRECTINPUT_MOUSE
|
||||
#define CIFACE_USE_DIRECTINPUT
|
||||
#define DINPUT_SOURCE_NAME "DInput"
|
||||
#endif
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
#define CIFACE_USE_XLIB
|
||||
@ -43,7 +45,7 @@ public:
|
||||
//
|
||||
// Device
|
||||
//
|
||||
// Pretty obviously, a device class
|
||||
// a device class
|
||||
//
|
||||
class Device
|
||||
{
|
||||
@ -69,7 +71,8 @@ public:
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
virtual ~Input() {}
|
||||
// things like absolute axes/ absolute mouse position will override this
|
||||
virtual bool IsDetectable() { return true; }
|
||||
};
|
||||
|
||||
//
|
||||
@ -89,7 +92,7 @@ public:
|
||||
virtual int GetId() const = 0;
|
||||
virtual std::string GetSource() const = 0;
|
||||
|
||||
virtual ControlState GetInputState( const Input* const input ) = 0;
|
||||
virtual ControlState GetInputState( const Input* const input ) const = 0;
|
||||
virtual void SetOutputState( const Output* const output, const ControlState state ) = 0;
|
||||
|
||||
virtual bool UpdateInput() = 0;
|
||||
@ -97,12 +100,16 @@ public:
|
||||
|
||||
virtual void ClearInputState();
|
||||
|
||||
const std::vector< Input* >& Inputs();
|
||||
const std::vector< Output* >& Outputs();
|
||||
const std::vector<Input*>& Inputs() const { return m_inputs; }
|
||||
const std::vector<Output*>& Outputs() const { return m_outputs; }
|
||||
|
||||
protected:
|
||||
std::vector<Input*> inputs;
|
||||
std::vector<Output*> outputs;
|
||||
void AddInput(Input* const i);
|
||||
void AddOutput(Output* const o);
|
||||
|
||||
private:
|
||||
std::vector<Input*> m_inputs;
|
||||
std::vector<Output*> m_outputs;
|
||||
|
||||
};
|
||||
|
||||
@ -115,95 +122,57 @@ public:
|
||||
class DeviceQualifier
|
||||
{
|
||||
public:
|
||||
DeviceQualifier() : cid(-1){}
|
||||
DeviceQualifier( const std::string& _source, const int _id, const std::string& _name )
|
||||
DeviceQualifier() : cid(-1) {}
|
||||
DeviceQualifier(const std::string& _source, const int _id, const std::string& _name)
|
||||
: source(_source), cid(_id), name(_name) {}
|
||||
bool operator==(const Device* const dev) const;
|
||||
void FromDevice(const Device* const dev);
|
||||
void FromString(const std::string& str);
|
||||
std::string ToString() const;
|
||||
bool operator==(const DeviceQualifier& devq) const;
|
||||
|
||||
std::string source;
|
||||
int cid;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
//
|
||||
// ControlQualifier
|
||||
//
|
||||
// control qualifier includes input and output qualifiers
|
||||
// used to match controls on devices, only has name property
|
||||
// |input1|input2| form as well, || matches anything, might change this to * or something
|
||||
//
|
||||
class ControlQualifier
|
||||
{
|
||||
public:
|
||||
ControlQualifier() {};
|
||||
ControlQualifier( const std::string& _name ) : name(_name) {}
|
||||
virtual ~ControlQualifier() {}
|
||||
|
||||
virtual bool operator==(const Device::Control* const in) const;
|
||||
void FromControl(const Device::Control* const in);
|
||||
|
||||
std::string name;
|
||||
};
|
||||
|
||||
//
|
||||
// InputQualifier
|
||||
//
|
||||
// ControlQualifier for inputs
|
||||
//
|
||||
class InputQualifier : public ControlQualifier
|
||||
{
|
||||
public:
|
||||
InputQualifier() {};
|
||||
InputQualifier( const std::string& _name ) : ControlQualifier(_name) {}
|
||||
};
|
||||
|
||||
//
|
||||
// OutputQualifier
|
||||
//
|
||||
// ControlQualifier for outputs
|
||||
//
|
||||
class OutputQualifier : public ControlQualifier
|
||||
{
|
||||
public:
|
||||
OutputQualifier() {};
|
||||
OutputQualifier( const std::string& _name ) : ControlQualifier(_name) {}
|
||||
};
|
||||
|
||||
//
|
||||
// ControlReference
|
||||
//
|
||||
// these are what you create to actually use the inputs, InputReference or OutputReference
|
||||
// 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
|
||||
// ControlReference can update its own controls when you change its control qualifier
|
||||
// using ControlReference::UpdateControls but when you change its device qualifer
|
||||
// you must use ControllerInterface::UpdateReference
|
||||
// each one can link to multiple devices and controls
|
||||
// when you change a ControlReference's expression,
|
||||
// you must use ControllerInterface::UpdateReference on it to rebind controls
|
||||
//
|
||||
class ControlReference
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
|
||||
public:
|
||||
ControlReference( const bool _is_input ) : range(1), is_input(_is_input), device(NULL) {}
|
||||
virtual ~ControlReference() {}
|
||||
|
||||
virtual ControlState State( const ControlState state = 0 ) = 0;
|
||||
virtual bool Detect( const unsigned int ms, const unsigned int count = 1 ) = 0;
|
||||
virtual void UpdateControls() = 0;
|
||||
virtual ControlState State(const ControlState state = 0) = 0;
|
||||
virtual Device::Control* Detect(const unsigned int ms, Device* const device) = 0;
|
||||
size_t BoundCount() const { return m_controls.size(); }
|
||||
|
||||
ControlState range;
|
||||
|
||||
DeviceQualifier device_qualifier;
|
||||
ControlQualifier control_qualifier;
|
||||
|
||||
std::string expression;
|
||||
const bool is_input;
|
||||
Device* device;
|
||||
|
||||
std::vector<Device::Control*> controls;
|
||||
protected:
|
||||
ControlReference(const bool _is_input) : range(1), is_input(_is_input) {}
|
||||
|
||||
struct DeviceControl
|
||||
{
|
||||
DeviceControl() : device(NULL), control(NULL), mode(0) {}
|
||||
|
||||
Device* device;
|
||||
Device::Control* control;
|
||||
int mode;
|
||||
};
|
||||
|
||||
std::vector<DeviceControl> m_controls;
|
||||
};
|
||||
|
||||
//
|
||||
@ -214,12 +183,9 @@ public:
|
||||
class InputReference : public ControlReference
|
||||
{
|
||||
public:
|
||||
InputReference() : ControlReference(true), mode(0) {}
|
||||
ControlState State( const ControlState state );
|
||||
bool Detect( const unsigned int ms, const unsigned int count );
|
||||
void UpdateControls();
|
||||
|
||||
unsigned int mode;
|
||||
InputReference() : ControlReference(true) {}
|
||||
ControlState State(const ControlState state);
|
||||
Device::Control* Detect(const unsigned int ms, Device* const device);
|
||||
};
|
||||
|
||||
//
|
||||
@ -230,25 +196,24 @@ public:
|
||||
class OutputReference : public ControlReference
|
||||
{
|
||||
public:
|
||||
OutputReference() : ControlReference( false ) {}
|
||||
ControlState State( const ControlState state );
|
||||
bool Detect( const unsigned int ms, const unsigned int count );
|
||||
void UpdateControls();
|
||||
OutputReference() : ControlReference(false) {}
|
||||
ControlState State(const ControlState state);
|
||||
Device::Control* Detect(const unsigned int ms, Device* const device);
|
||||
};
|
||||
|
||||
ControllerInterface() : m_is_init(false) {}
|
||||
|
||||
void SetHwnd( void* const hwnd );
|
||||
void SetHwnd(void* const hwnd);
|
||||
void Init();
|
||||
// TODO: remove this hack param
|
||||
void DeInit(const bool hacks_no_sdl_quit = false);
|
||||
bool IsInit();
|
||||
bool IsInit() const { return m_is_init; }
|
||||
|
||||
void UpdateReference( ControlReference* control );
|
||||
void UpdateReference(ControlReference* control, const DeviceQualifier& default_device) const;
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
const std::vector<Device*>& Devices();
|
||||
const std::vector<Device*>& Devices() const { return m_devices; }
|
||||
|
||||
private:
|
||||
bool m_is_init;
|
||||
@ -256,4 +221,8 @@ private:
|
||||
void* m_hwnd;
|
||||
};
|
||||
|
||||
// used for std::find n stuff
|
||||
bool operator==(const ControllerInterface::Device* const dev, const ControllerInterface::DeviceQualifier& devq);
|
||||
bool operator==(const ControllerInterface::Device::Control* const c, const std::string& name);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user