mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 14:39:01 +01:00
Merge pull request #23 from lioncash/sorta-large-input-cleanup
Larger cleanup to input-related source files (this time using unique_ptr).
This commit is contained in:
commit
3363b396af
@ -55,31 +55,31 @@ GCPad::GCPad(const unsigned int index) : m_index(index)
|
|||||||
int const mic_hax = index > 1;
|
int const mic_hax = index > 1;
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons(_trans("Buttons")));
|
groups.emplace_back(m_buttons = new Buttons(_trans("Buttons")));
|
||||||
for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons) - mic_hax; ++i)
|
for (unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons) - mic_hax; ++i)
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input(named_buttons[i]));
|
m_buttons->controls.emplace_back(new ControlGroup::Input(named_buttons[i]));
|
||||||
|
|
||||||
// sticks
|
// sticks
|
||||||
groups.push_back(m_main_stick = new AnalogStick(_trans("Main Stick")));
|
groups.emplace_back(m_main_stick = new AnalogStick(_trans("Main Stick")));
|
||||||
groups.push_back(m_c_stick = new AnalogStick(_trans("C-Stick")));
|
groups.emplace_back(m_c_stick = new AnalogStick(_trans("C-Stick")));
|
||||||
|
|
||||||
// triggers
|
// triggers
|
||||||
groups.push_back(m_triggers = new MixedTriggers(_trans("Triggers")));
|
groups.emplace_back(m_triggers = new MixedTriggers(_trans("Triggers")));
|
||||||
for (auto& named_trigger : named_triggers)
|
for (auto& named_trigger : named_triggers)
|
||||||
m_triggers->controls.push_back(new ControlGroup::Input(named_trigger));
|
m_triggers->controls.emplace_back(new ControlGroup::Input(named_trigger));
|
||||||
|
|
||||||
// rumble
|
// rumble
|
||||||
groups.push_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
groups.emplace_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||||
m_rumble->controls.push_back(new ControlGroup::Output(_trans("Motor")));
|
m_rumble->controls.emplace_back(new ControlGroup::Output(_trans("Motor")));
|
||||||
|
|
||||||
// dpad
|
// dpad
|
||||||
groups.push_back(m_dpad = new Buttons(_trans("D-Pad")));
|
groups.emplace_back(m_dpad = new Buttons(_trans("D-Pad")));
|
||||||
for (auto& named_direction : named_directions)
|
for (auto& named_direction : named_directions)
|
||||||
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
|
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||||
|
|
||||||
// options
|
// options
|
||||||
groups.push_back(m_options = new ControlGroup(_trans("Options")));
|
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
|
||||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCPad::GetName() const
|
std::string GCPad::GetName() const
|
||||||
|
@ -43,5 +43,5 @@ void Attachment::Reset()
|
|||||||
|
|
||||||
void ControllerEmu::Extension::GetState( u8* const data, const bool focus )
|
void ControllerEmu::Extension::GetState( u8* const data, const bool focus )
|
||||||
{
|
{
|
||||||
((WiimoteEmu::Attachment*)attachments[ active_extension ])->GetState( data, focus );
|
((WiimoteEmu::Attachment*)attachments[active_extension].get())->GetState( data, focus );
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,14 @@ namespace WiimoteEmu
|
|||||||
class Attachment : public ControllerEmu
|
class Attachment : public ControllerEmu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Attachment( const char* const _name, WiimoteEmu::ExtensionReg& _reg );
|
Attachment(const char* const _name, WiimoteEmu::ExtensionReg& _reg);
|
||||||
|
|
||||||
virtual void GetState( u8* const data, const bool focus = true ) {}
|
virtual void GetState(u8* const data, const bool focus = true) {}
|
||||||
void Reset();
|
void Reset();
|
||||||
std::string GetName() const override;
|
std::string GetName() const override;
|
||||||
|
|
||||||
const char* const name;
|
const char* const name;
|
||||||
WiimoteEmu::ExtensionReg& reg;
|
WiimoteEmu::ExtensionReg& reg;
|
||||||
|
|
||||||
u8 id[6];
|
u8 id[6];
|
||||||
u8 calibration[0x10];
|
u8 calibration[0x10];
|
||||||
@ -30,7 +30,7 @@ public:
|
|||||||
class None : public Attachment
|
class None : public Attachment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
None( WiimoteEmu::ExtensionReg& _reg );
|
None(WiimoteEmu::ExtensionReg& _reg);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,23 +56,23 @@ static const u16 classic_dpad_bitmasks[] =
|
|||||||
Classic::Classic(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Classic"), _reg)
|
Classic::Classic(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Classic"), _reg)
|
||||||
{
|
{
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||||
for (auto& classic_button_name : classic_button_names)
|
for (auto& classic_button_name : classic_button_names)
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input(classic_button_name));
|
m_buttons->controls.emplace_back(new ControlGroup::Input(classic_button_name));
|
||||||
|
|
||||||
// sticks
|
// sticks
|
||||||
groups.push_back(m_left_stick = new AnalogStick(_trans("Left Stick")));
|
groups.emplace_back(m_left_stick = new AnalogStick(_trans("Left Stick")));
|
||||||
groups.push_back(m_right_stick = new AnalogStick(_trans("Right Stick")));
|
groups.emplace_back(m_right_stick = new AnalogStick(_trans("Right Stick")));
|
||||||
|
|
||||||
// triggers
|
// triggers
|
||||||
groups.push_back(m_triggers = new MixedTriggers("Triggers"));
|
groups.emplace_back(m_triggers = new MixedTriggers("Triggers"));
|
||||||
for (auto& classic_trigger_name : classic_trigger_names)
|
for (auto& classic_trigger_name : classic_trigger_names)
|
||||||
m_triggers->controls.push_back(new ControlGroup::Input(classic_trigger_name));
|
m_triggers->controls.emplace_back(new ControlGroup::Input(classic_trigger_name));
|
||||||
|
|
||||||
// dpad
|
// dpad
|
||||||
groups.push_back(m_dpad = new Buttons("D-Pad"));
|
groups.emplace_back(m_dpad = new Buttons("D-Pad"));
|
||||||
for (auto& named_direction : named_directions)
|
for (auto& named_direction : named_directions)
|
||||||
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
|
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||||
|
|
||||||
// set up register
|
// set up register
|
||||||
// calibration
|
// calibration
|
||||||
|
@ -11,34 +11,34 @@ class Classic : public Attachment
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Classic(WiimoteEmu::ExtensionReg& _reg);
|
Classic(WiimoteEmu::ExtensionReg& _reg);
|
||||||
void GetState( u8* const data, const bool focus );
|
void GetState(u8* const data, const bool focus) override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PAD_RIGHT = 0x80,
|
PAD_RIGHT = 0x80,
|
||||||
PAD_DOWN = 0x40,
|
PAD_DOWN = 0x40,
|
||||||
TRIGGER_L = 0x20,
|
TRIGGER_L = 0x20,
|
||||||
BUTTON_MINUS = 0x10,
|
BUTTON_MINUS = 0x10,
|
||||||
BUTTON_HOME = 0x08,
|
BUTTON_HOME = 0x08,
|
||||||
BUTTON_PLUS = 0x04,
|
BUTTON_PLUS = 0x04,
|
||||||
TRIGGER_R = 0x02,
|
TRIGGER_R = 0x02,
|
||||||
NOTHING = 0x01,
|
NOTHING = 0x01,
|
||||||
BUTTON_ZL = 0x8000,
|
BUTTON_ZL = 0x8000,
|
||||||
BUTTON_B = 0x4000,
|
BUTTON_B = 0x4000,
|
||||||
BUTTON_Y = 0x2000,
|
BUTTON_Y = 0x2000,
|
||||||
BUTTON_A = 0x1000,
|
BUTTON_A = 0x1000,
|
||||||
BUTTON_X = 0x0800,
|
BUTTON_X = 0x0800,
|
||||||
BUTTON_ZR = 0x0400,
|
BUTTON_ZR = 0x0400,
|
||||||
PAD_LEFT = 0x0200,
|
PAD_LEFT = 0x0200,
|
||||||
PAD_UP = 0x0100,
|
PAD_UP = 0x0100,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Buttons* m_buttons;
|
Buttons* m_buttons;
|
||||||
MixedTriggers* m_triggers;
|
MixedTriggers* m_triggers;
|
||||||
Buttons* m_dpad;
|
Buttons* m_dpad;
|
||||||
AnalogStick* m_left_stick;
|
AnalogStick* m_left_stick;
|
||||||
AnalogStick* m_right_stick;
|
AnalogStick* m_right_stick;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@ static const u16 drum_button_bitmasks[] =
|
|||||||
Drums::Drums(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Drums"), _reg)
|
Drums::Drums(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Drums"), _reg)
|
||||||
{
|
{
|
||||||
// pads
|
// pads
|
||||||
groups.push_back(m_pads = new Buttons(_trans("Pads")));
|
groups.emplace_back(m_pads = new Buttons(_trans("Pads")));
|
||||||
for (auto& drum_pad_name : drum_pad_names)
|
for (auto& drum_pad_name : drum_pad_names)
|
||||||
m_pads->controls.push_back(new ControlGroup::Input(drum_pad_name));
|
m_pads->controls.emplace_back(new ControlGroup::Input(drum_pad_name));
|
||||||
|
|
||||||
// stick
|
// stick
|
||||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
groups.emplace_back(m_stick = new AnalogStick("Stick"));
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input("-"));
|
m_buttons->controls.emplace_back(new ControlGroup::Input("-"));
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input("+"));
|
m_buttons->controls.emplace_back(new ControlGroup::Input("+"));
|
||||||
|
|
||||||
// set up register
|
// set up register
|
||||||
// id
|
// id
|
||||||
|
@ -11,25 +11,25 @@ class Drums : public Attachment
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Drums(WiimoteEmu::ExtensionReg& _reg);
|
Drums(WiimoteEmu::ExtensionReg& _reg);
|
||||||
void GetState( u8* const data, const bool focus );
|
void GetState(u8* const data, const bool focus) override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BUTTON_PLUS = 0x04,
|
BUTTON_PLUS = 0x04,
|
||||||
BUTTON_MINUS = 0x10,
|
BUTTON_MINUS = 0x10,
|
||||||
|
|
||||||
PAD_BASS = 0x0400,
|
PAD_BASS = 0x0400,
|
||||||
PAD_BLUE = 0x0800,
|
PAD_BLUE = 0x0800,
|
||||||
PAD_GREEN = 0x1000,
|
PAD_GREEN = 0x1000,
|
||||||
PAD_YELLOW = 0x2000,
|
PAD_YELLOW = 0x2000,
|
||||||
PAD_RED = 0x4000,
|
PAD_RED = 0x4000,
|
||||||
PAD_ORANGE = 0x8000,
|
PAD_ORANGE = 0x8000,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Buttons* m_buttons;
|
Buttons* m_buttons;
|
||||||
Buttons* m_pads;
|
Buttons* m_pads;
|
||||||
AnalogStick* m_stick;
|
AnalogStick* m_stick;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,26 +39,26 @@ static const u16 guitar_strum_bitmasks[] =
|
|||||||
Guitar::Guitar(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Guitar"), _reg)
|
Guitar::Guitar(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Guitar"), _reg)
|
||||||
{
|
{
|
||||||
// frets
|
// frets
|
||||||
groups.push_back(m_frets = new Buttons(_trans("Frets")));
|
groups.emplace_back(m_frets = new Buttons(_trans("Frets")));
|
||||||
for (auto& guitar_fret_name : guitar_fret_names)
|
for (auto& guitar_fret_name : guitar_fret_names)
|
||||||
m_frets->controls.push_back(new ControlGroup::Input(guitar_fret_name));
|
m_frets->controls.emplace_back(new ControlGroup::Input(guitar_fret_name));
|
||||||
|
|
||||||
// strum
|
// strum
|
||||||
groups.push_back(m_strum = new Buttons(_trans("Strum")));
|
groups.emplace_back(m_strum = new Buttons(_trans("Strum")));
|
||||||
m_strum->controls.push_back(new ControlGroup::Input("Up"));
|
m_strum->controls.emplace_back(new ControlGroup::Input("Up"));
|
||||||
m_strum->controls.push_back(new ControlGroup::Input("Down"));
|
m_strum->controls.emplace_back(new ControlGroup::Input("Down"));
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input("-"));
|
m_buttons->controls.emplace_back(new ControlGroup::Input("-"));
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input("+"));
|
m_buttons->controls.emplace_back(new ControlGroup::Input("+"));
|
||||||
|
|
||||||
// stick
|
// stick
|
||||||
groups.push_back(m_stick = new AnalogStick(_trans("Stick")));
|
groups.emplace_back(m_stick = new AnalogStick(_trans("Stick")));
|
||||||
|
|
||||||
// whammy
|
// whammy
|
||||||
groups.push_back(m_whammy = new Triggers(_trans("Whammy")));
|
groups.emplace_back(m_whammy = new Triggers(_trans("Whammy")));
|
||||||
m_whammy->controls.push_back(new ControlGroup::Input(_trans("Bar")));
|
m_whammy->controls.emplace_back(new ControlGroup::Input(_trans("Bar")));
|
||||||
|
|
||||||
// set up register
|
// set up register
|
||||||
// id
|
// id
|
||||||
|
@ -11,28 +11,28 @@ class Guitar : public Attachment
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Guitar(WiimoteEmu::ExtensionReg& _reg);
|
Guitar(WiimoteEmu::ExtensionReg& _reg);
|
||||||
void GetState( u8* const data, const bool focus ) override;
|
void GetState(u8* const data, const bool focus) override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BUTTON_PLUS = 0x04,
|
BUTTON_PLUS = 0x04,
|
||||||
BUTTON_MINUS = 0x10,
|
BUTTON_MINUS = 0x10,
|
||||||
BAR_DOWN = 0x40,
|
BAR_DOWN = 0x40,
|
||||||
|
|
||||||
BAR_UP = 0x0100,
|
BAR_UP = 0x0100,
|
||||||
FRET_YELLOW = 0x0800,
|
FRET_YELLOW = 0x0800,
|
||||||
FRET_GREEN = 0x1000,
|
FRET_GREEN = 0x1000,
|
||||||
FRET_BLUE = 0x2000,
|
FRET_BLUE = 0x2000,
|
||||||
FRET_RED = 0x4000,
|
FRET_RED = 0x4000,
|
||||||
FRET_ORANGE = 0x8000,
|
FRET_ORANGE = 0x8000,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Buttons* m_buttons;
|
Buttons* m_buttons;
|
||||||
Buttons* m_frets;
|
Buttons* m_frets;
|
||||||
Buttons* m_strum;
|
Buttons* m_strum;
|
||||||
Triggers* m_whammy;
|
Triggers* m_whammy;
|
||||||
AnalogStick* m_stick;
|
AnalogStick* m_stick;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,24 +35,24 @@ Nunchuk::Nunchuk(UDPWrapper *wrp, WiimoteEmu::ExtensionReg& _reg)
|
|||||||
: Attachment(_trans("Nunchuk"), _reg) , m_udpWrap(wrp)
|
: Attachment(_trans("Nunchuk"), _reg) , m_udpWrap(wrp)
|
||||||
{
|
{
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input("C"));
|
m_buttons->controls.emplace_back(new ControlGroup::Input("C"));
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input("Z"));
|
m_buttons->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||||
|
|
||||||
// stick
|
// stick
|
||||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
groups.emplace_back(m_stick = new AnalogStick("Stick"));
|
||||||
|
|
||||||
// swing
|
// swing
|
||||||
groups.push_back(m_swing = new Force("Swing"));
|
groups.emplace_back(m_swing = new Force("Swing"));
|
||||||
|
|
||||||
// tilt
|
// tilt
|
||||||
groups.push_back(m_tilt = new Tilt("Tilt"));
|
groups.emplace_back(m_tilt = new Tilt("Tilt"));
|
||||||
|
|
||||||
// shake
|
// shake
|
||||||
groups.push_back(m_shake = new Buttons("Shake"));
|
groups.emplace_back(m_shake = new Buttons("Shake"));
|
||||||
m_shake->controls.push_back(new ControlGroup::Input("X"));
|
m_shake->controls.emplace_back(new ControlGroup::Input("X"));
|
||||||
m_shake->controls.push_back(new ControlGroup::Input("Y"));
|
m_shake->controls.emplace_back(new ControlGroup::Input("Y"));
|
||||||
m_shake->controls.push_back(new ControlGroup::Input("Z"));
|
m_shake->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||||
|
|
||||||
// set up register
|
// set up register
|
||||||
// calibration
|
// calibration
|
||||||
@ -159,24 +159,24 @@ void Nunchuk::GetState(u8* const data, const bool focus)
|
|||||||
void Nunchuk::LoadDefaults(const ControllerInterface& ciface)
|
void Nunchuk::LoadDefaults(const ControllerInterface& ciface)
|
||||||
{
|
{
|
||||||
// ugly macroooo
|
// ugly macroooo
|
||||||
#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
|
#define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
|
||||||
|
|
||||||
// Stick
|
// Stick
|
||||||
set_control(m_stick, 0, "W"); // up
|
set_control(m_stick, 0, "W"); // up
|
||||||
set_control(m_stick, 1, "S"); // down
|
set_control(m_stick, 1, "S"); // down
|
||||||
set_control(m_stick, 2, "A"); // left
|
set_control(m_stick, 2, "A"); // left
|
||||||
set_control(m_stick, 3, "D"); // right
|
set_control(m_stick, 3, "D"); // right
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
set_control(m_buttons, 0, "LCONTROL"); // C
|
set_control(m_buttons, 0, "LCONTROL"); // C
|
||||||
set_control(m_buttons, 1, "LSHIFT"); // Z
|
set_control(m_buttons, 1, "LSHIFT"); // Z
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
set_control(m_buttons, 0, "Left Control"); // C
|
set_control(m_buttons, 0, "Left Control"); // C
|
||||||
set_control(m_buttons, 1, "Left Shift"); // Z
|
set_control(m_buttons, 1, "Left Shift"); // Z
|
||||||
#else
|
#else
|
||||||
set_control(m_buttons, 0, "Control_L"); // C
|
set_control(m_buttons, 0, "Control_L"); // C
|
||||||
set_control(m_buttons, 1, "Shift_L"); // Z
|
set_control(m_buttons, 1, "Shift_L"); // Z
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class Nunchuk : public Attachment
|
|||||||
public:
|
public:
|
||||||
Nunchuk(UDPWrapper * wrp, WiimoteEmu::ExtensionReg& _reg);
|
Nunchuk(UDPWrapper * wrp, WiimoteEmu::ExtensionReg& _reg);
|
||||||
|
|
||||||
virtual void GetState( u8* const data, const bool focus ) override;
|
virtual void GetState(u8* const data, const bool focus) override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -28,15 +28,15 @@ public:
|
|||||||
void LoadDefaults(const ControllerInterface& ciface) override;
|
void LoadDefaults(const ControllerInterface& ciface) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tilt* m_tilt;
|
Tilt* m_tilt;
|
||||||
Force* m_swing;
|
Force* m_swing;
|
||||||
|
|
||||||
Buttons* m_shake;
|
Buttons* m_shake;
|
||||||
|
|
||||||
Buttons* m_buttons;
|
Buttons* m_buttons;
|
||||||
AnalogStick* m_stick;
|
AnalogStick* m_stick;
|
||||||
|
|
||||||
u8 m_shake_step[3];
|
u8 m_shake_step[3];
|
||||||
|
|
||||||
UDPWrapper* const m_udpWrap;
|
UDPWrapper* const m_udpWrap;
|
||||||
};
|
};
|
||||||
|
@ -33,23 +33,23 @@ static const char* const turntable_button_names[] =
|
|||||||
Turntable::Turntable(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Turntable"), _reg)
|
Turntable::Turntable(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Turntable"), _reg)
|
||||||
{
|
{
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||||
for (auto& turntable_button_name : turntable_button_names)
|
for (auto& turntable_button_name : turntable_button_names)
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input(turntable_button_name));
|
m_buttons->controls.emplace_back(new ControlGroup::Input(turntable_button_name));
|
||||||
|
|
||||||
// turntables
|
// turntables
|
||||||
groups.push_back(m_left_table = new Slider(_trans("Table Left")));
|
groups.emplace_back(m_left_table = new Slider(_trans("Table Left")));
|
||||||
groups.push_back(m_right_table = new Slider(_trans("Table Right")));
|
groups.emplace_back(m_right_table = new Slider(_trans("Table Right")));
|
||||||
|
|
||||||
// stick
|
// stick
|
||||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
groups.emplace_back(m_stick = new AnalogStick("Stick"));
|
||||||
|
|
||||||
// effect dial
|
// effect dial
|
||||||
groups.push_back(m_effect_dial = new Triggers(_trans("Effect")));
|
groups.emplace_back(m_effect_dial = new Triggers(_trans("Effect")));
|
||||||
m_effect_dial->controls.push_back(new ControlGroup::Input(_trans("Dial")));
|
m_effect_dial->controls.emplace_back(new ControlGroup::Input(_trans("Dial")));
|
||||||
|
|
||||||
// crossfade
|
// crossfade
|
||||||
groups.push_back(m_crossfade = new Slider(_trans("Crossfade")));
|
groups.emplace_back(m_crossfade = new Slider(_trans("Crossfade")));
|
||||||
|
|
||||||
// set up register
|
// set up register
|
||||||
// id
|
// id
|
||||||
|
@ -17,23 +17,25 @@ public:
|
|||||||
{
|
{
|
||||||
BUTTON_EUPHORIA = 0x1000,
|
BUTTON_EUPHORIA = 0x1000,
|
||||||
|
|
||||||
BUTTON_L_GREEN = 0x0800,
|
BUTTON_L_GREEN = 0x0800,
|
||||||
BUTTON_L_RED = 0x20,
|
BUTTON_L_RED = 0x20,
|
||||||
BUTTON_L_BLUE = 0x8000,
|
BUTTON_L_BLUE = 0x8000,
|
||||||
|
|
||||||
BUTTON_R_GREEN = 0x2000,
|
BUTTON_R_GREEN = 0x2000,
|
||||||
BUTTON_R_RED = 0x02,
|
BUTTON_R_RED = 0x02,
|
||||||
BUTTON_R_BLUE = 0x0400,
|
BUTTON_R_BLUE = 0x0400,
|
||||||
|
|
||||||
BUTTON_MINUS = 0x10,
|
BUTTON_MINUS = 0x10,
|
||||||
BUTTON_PLUS = 0x04,
|
BUTTON_PLUS = 0x04,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Buttons* m_buttons;
|
Buttons* m_buttons;
|
||||||
AnalogStick* m_stick;
|
AnalogStick* m_stick;
|
||||||
Triggers *m_effect_dial;
|
Triggers* m_effect_dial;
|
||||||
Slider *m_left_table, *m_right_table, *m_crossfade;
|
Slider* m_left_table;
|
||||||
|
Slider* m_right_table;
|
||||||
|
Slider* m_crossfade;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -852,7 +852,7 @@ void Wiimote::HandleExtensionSwap()
|
|||||||
m_extension->active_extension = m_extension->switch_extension;
|
m_extension->active_extension = m_extension->switch_extension;
|
||||||
|
|
||||||
// reset register
|
// reset register
|
||||||
((WiimoteEmu::Attachment*)m_extension->attachments[m_extension->active_extension])->Reset();
|
((WiimoteEmu::Attachment*)m_extension->attachments[m_extension->active_extension].get())->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,53 +268,53 @@ Wiimote::Wiimote( const unsigned int index )
|
|||||||
// ---- set up all the controls ----
|
// ---- set up all the controls ----
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
groups.emplace_back(m_buttons = new Buttons("Buttons"));
|
||||||
for (auto& named_button : named_buttons)
|
for (auto& named_button : named_buttons)
|
||||||
m_buttons->controls.push_back(new ControlGroup::Input( named_button));
|
m_buttons->controls.emplace_back(new ControlGroup::Input( named_button));
|
||||||
|
|
||||||
// udp
|
// udp
|
||||||
groups.push_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote")));
|
groups.emplace_back(m_udp = new UDPWrapper(m_index, _trans("UDP Wiimote")));
|
||||||
|
|
||||||
// ir
|
// ir
|
||||||
groups.push_back(m_ir = new Cursor(_trans("IR")));
|
groups.emplace_back(m_ir = new Cursor(_trans("IR")));
|
||||||
|
|
||||||
// swing
|
// swing
|
||||||
groups.push_back(m_swing = new Force(_trans("Swing")));
|
groups.emplace_back(m_swing = new Force(_trans("Swing")));
|
||||||
|
|
||||||
// tilt
|
// tilt
|
||||||
groups.push_back(m_tilt = new Tilt(_trans("Tilt")));
|
groups.emplace_back(m_tilt = new Tilt(_trans("Tilt")));
|
||||||
|
|
||||||
// shake
|
// shake
|
||||||
groups.push_back(m_shake = new Buttons(_trans("Shake")));
|
groups.emplace_back(m_shake = new Buttons(_trans("Shake")));
|
||||||
m_shake->controls.push_back(new ControlGroup::Input("X"));
|
m_shake->controls.emplace_back(new ControlGroup::Input("X"));
|
||||||
m_shake->controls.push_back(new ControlGroup::Input("Y"));
|
m_shake->controls.emplace_back(new ControlGroup::Input("Y"));
|
||||||
m_shake->controls.push_back(new ControlGroup::Input("Z"));
|
m_shake->controls.emplace_back(new ControlGroup::Input("Z"));
|
||||||
|
|
||||||
// extension
|
// extension
|
||||||
groups.push_back(m_extension = new Extension(_trans("Extension")));
|
groups.emplace_back(m_extension = new Extension(_trans("Extension")));
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::None(m_reg_ext));
|
m_extension->attachments.emplace_back(new WiimoteEmu::None(m_reg_ext));
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Nunchuk(m_udp, m_reg_ext));
|
m_extension->attachments.emplace_back(new WiimoteEmu::Nunchuk(m_udp, m_reg_ext));
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Classic(m_reg_ext));
|
m_extension->attachments.emplace_back(new WiimoteEmu::Classic(m_reg_ext));
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Guitar(m_reg_ext));
|
m_extension->attachments.emplace_back(new WiimoteEmu::Guitar(m_reg_ext));
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Drums(m_reg_ext));
|
m_extension->attachments.emplace_back(new WiimoteEmu::Drums(m_reg_ext));
|
||||||
m_extension->attachments.push_back(new WiimoteEmu::Turntable(m_reg_ext));
|
m_extension->attachments.emplace_back(new WiimoteEmu::Turntable(m_reg_ext));
|
||||||
|
|
||||||
m_extension->settings.push_back(new ControlGroup::Setting(_trans("Motion Plus"), 0, 0, 1));
|
m_extension->settings.emplace_back(new ControlGroup::Setting(_trans("Motion Plus"), 0, 0, 1));
|
||||||
|
|
||||||
// rumble
|
// rumble
|
||||||
groups.push_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
groups.emplace_back(m_rumble = new ControlGroup(_trans("Rumble")));
|
||||||
m_rumble->controls.push_back(new ControlGroup::Output(_trans("Motor")));
|
m_rumble->controls.emplace_back(new ControlGroup::Output(_trans("Motor")));
|
||||||
|
|
||||||
// dpad
|
// dpad
|
||||||
groups.push_back(m_dpad = new Buttons("D-Pad"));
|
groups.emplace_back(m_dpad = new Buttons("D-Pad"));
|
||||||
for (auto& named_direction : named_directions)
|
for (auto& named_direction : named_directions)
|
||||||
m_dpad->controls.push_back(new ControlGroup::Input(named_direction));
|
m_dpad->controls.emplace_back(new ControlGroup::Input(named_direction));
|
||||||
|
|
||||||
// options
|
// options
|
||||||
groups.push_back( m_options = new ControlGroup(_trans("Options")));
|
groups.emplace_back( m_options = new ControlGroup(_trans("Options")));
|
||||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Background Input"), false));
|
||||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Sideways Wiimote"), false));
|
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Sideways Wiimote"), false));
|
||||||
m_options->settings.push_back(new ControlGroup::Setting(_trans("Upright Wiimote"), false));
|
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Upright Wiimote"), false));
|
||||||
|
|
||||||
// TODO: This value should probably be re-read if SYSCONF gets changed
|
// TODO: This value should probably be re-read if SYSCONF gets changed
|
||||||
m_sensor_bar_on_top = SConfig::GetInstance().m_SYSCONF->GetData<u8>("BT.BAR") != 0;
|
m_sensor_bar_on_top = SConfig::GetInstance().m_SYSCONF->GetData<u8>("BT.BAR") != 0;
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
// Registry sizes
|
// Registry sizes
|
||||||
#define WIIMOTE_EEPROM_SIZE (16*1024)
|
#define WIIMOTE_EEPROM_SIZE (16*1024)
|
||||||
#define WIIMOTE_EEPROM_FREE_SIZE 0x1700
|
#define WIIMOTE_EEPROM_FREE_SIZE 0x1700
|
||||||
#define WIIMOTE_REG_SPEAKER_SIZE 10
|
#define WIIMOTE_REG_SPEAKER_SIZE 10
|
||||||
#define WIIMOTE_REG_EXT_SIZE 0x100
|
#define WIIMOTE_REG_EXT_SIZE 0x100
|
||||||
#define WIIMOTE_REG_IR_SIZE 0x34
|
#define WIIMOTE_REG_IR_SIZE 0x34
|
||||||
|
|
||||||
namespace WiimoteReal
|
namespace WiimoteReal
|
||||||
{
|
{
|
||||||
@ -49,26 +49,26 @@ struct ADPCMState
|
|||||||
|
|
||||||
struct ExtensionReg
|
struct ExtensionReg
|
||||||
{
|
{
|
||||||
u8 unknown1[0x08];
|
u8 unknown1[0x08];
|
||||||
|
|
||||||
// address 0x08
|
// address 0x08
|
||||||
u8 controller_data[0x06];
|
u8 controller_data[0x06];
|
||||||
u8 unknown2[0x12];
|
u8 unknown2[0x12];
|
||||||
|
|
||||||
// address 0x20
|
// address 0x20
|
||||||
u8 calibration[0x10];
|
u8 calibration[0x10];
|
||||||
u8 unknown3[0x10];
|
u8 unknown3[0x10];
|
||||||
|
|
||||||
// address 0x40
|
// address 0x40
|
||||||
u8 encryption_key[0x10];
|
u8 encryption_key[0x10];
|
||||||
u8 unknown4[0xA0];
|
u8 unknown4[0xA0];
|
||||||
|
|
||||||
// address 0xF0
|
// address 0xF0
|
||||||
u8 encryption;
|
u8 encryption;
|
||||||
u8 unknown5[0x9];
|
u8 unknown5[0x9];
|
||||||
|
|
||||||
// address 0xFA
|
// address 0xFA
|
||||||
u8 constant_id[6];
|
u8 constant_id[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const ReportFeatures reporting_mode_features[];
|
extern const ReportFeatures reporting_mode_features[];
|
||||||
@ -104,21 +104,21 @@ public:
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PAD_LEFT = 0x01,
|
PAD_LEFT = 0x01,
|
||||||
PAD_RIGHT = 0x02,
|
PAD_RIGHT = 0x02,
|
||||||
PAD_DOWN = 0x04,
|
PAD_DOWN = 0x04,
|
||||||
PAD_UP = 0x08,
|
PAD_UP = 0x08,
|
||||||
BUTTON_PLUS = 0x10,
|
BUTTON_PLUS = 0x10,
|
||||||
|
|
||||||
BUTTON_TWO = 0x0100,
|
BUTTON_TWO = 0x0100,
|
||||||
BUTTON_ONE = 0x0200,
|
BUTTON_ONE = 0x0200,
|
||||||
BUTTON_B = 0x0400,
|
BUTTON_B = 0x0400,
|
||||||
BUTTON_A = 0x0800,
|
BUTTON_A = 0x0800,
|
||||||
BUTTON_MINUS = 0x1000,
|
BUTTON_MINUS = 0x1000,
|
||||||
BUTTON_HOME = 0x8000,
|
BUTTON_HOME = 0x8000,
|
||||||
};
|
};
|
||||||
|
|
||||||
Wiimote( const unsigned int index );
|
Wiimote(const unsigned int index);
|
||||||
std::string GetName() const;
|
std::string GetName() const;
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
@ -147,9 +147,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
struct ReadRequest
|
struct ReadRequest
|
||||||
{
|
{
|
||||||
//u16 channel;
|
//u16 channel;
|
||||||
unsigned int address, size, position;
|
u32 address, size, position;
|
||||||
u8* data;
|
u8* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
@ -164,88 +164,85 @@ private:
|
|||||||
bool NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size);
|
bool NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size);
|
||||||
|
|
||||||
// control groups
|
// control groups
|
||||||
Buttons *m_buttons, *m_dpad, *m_shake;
|
Buttons *m_buttons, *m_dpad, *m_shake;
|
||||||
Cursor* m_ir;
|
Cursor* m_ir;
|
||||||
Tilt* m_tilt;
|
Tilt* m_tilt;
|
||||||
Force* m_swing;
|
Force* m_swing;
|
||||||
ControlGroup* m_rumble;
|
ControlGroup* m_rumble;
|
||||||
Extension* m_extension;
|
Extension* m_extension;
|
||||||
ControlGroup* m_options;
|
ControlGroup* m_options;
|
||||||
|
|
||||||
// WiiMote accel data
|
// WiiMote accel data
|
||||||
AccelData m_accel;
|
AccelData m_accel;
|
||||||
|
|
||||||
// wiimote index, 0-3
|
// wiimote index, 0-3
|
||||||
const u8 m_index;
|
const u8 m_index;
|
||||||
|
|
||||||
double ir_sin, ir_cos; //for the low pass filter
|
double ir_sin, ir_cos; //for the low pass filter
|
||||||
|
|
||||||
UDPWrapper* m_udp;
|
UDPWrapper* m_udp;
|
||||||
|
|
||||||
bool m_rumble_on;
|
bool m_rumble_on;
|
||||||
bool m_speaker_mute;
|
bool m_speaker_mute;
|
||||||
bool m_motion_plus_present;
|
bool m_motion_plus_present;
|
||||||
bool m_motion_plus_active;
|
bool m_motion_plus_active;
|
||||||
|
|
||||||
bool m_reporting_auto;
|
bool m_reporting_auto;
|
||||||
u8 m_reporting_mode;
|
u8 m_reporting_mode;
|
||||||
u16 m_reporting_channel;
|
u16 m_reporting_channel;
|
||||||
|
|
||||||
u8 m_shake_step[3];
|
u8 m_shake_step[3];
|
||||||
|
|
||||||
bool m_sensor_bar_on_top;
|
bool m_sensor_bar_on_top;
|
||||||
|
|
||||||
wm_status_report m_status;
|
wm_status_report m_status;
|
||||||
|
|
||||||
ADPCMState m_adpcm_state;
|
ADPCMState m_adpcm_state;
|
||||||
|
|
||||||
// read data request queue
|
// read data request queue
|
||||||
// maybe it isn't actually a queue
|
// maybe it isn't actually a queue
|
||||||
// maybe read requests cancel any current requests
|
// maybe read requests cancel any current requests
|
||||||
std::queue< ReadRequest > m_read_requests;
|
std::queue<ReadRequest> m_read_requests;
|
||||||
|
|
||||||
wiimote_key m_ext_key;
|
wiimote_key m_ext_key;
|
||||||
|
|
||||||
u8 m_eeprom[WIIMOTE_EEPROM_SIZE];
|
u8 m_eeprom[WIIMOTE_EEPROM_SIZE];
|
||||||
|
|
||||||
struct MotionPlusReg
|
struct MotionPlusReg
|
||||||
{
|
{
|
||||||
u8 unknown[0xF0];
|
u8 unknown[0xF0];
|
||||||
|
|
||||||
// address 0xF0
|
// address 0xF0
|
||||||
u8 activated;
|
u8 activated;
|
||||||
|
|
||||||
u8 unknown2[9];
|
u8 unknown2[9];
|
||||||
|
|
||||||
// address 0xFA
|
// address 0xFA
|
||||||
u8 ext_identifier[6];
|
u8 ext_identifier[6];
|
||||||
|
} m_reg_motion_plus;
|
||||||
} m_reg_motion_plus;
|
|
||||||
|
|
||||||
struct IrReg
|
struct IrReg
|
||||||
{
|
{
|
||||||
u8 data[0x33];
|
u8 data[0x33];
|
||||||
u8 mode;
|
u8 mode;
|
||||||
|
} m_reg_ir;
|
||||||
} m_reg_ir;
|
|
||||||
|
|
||||||
ExtensionReg m_reg_ext;
|
ExtensionReg m_reg_ext;
|
||||||
|
|
||||||
struct SpeakerReg
|
struct SpeakerReg
|
||||||
{
|
{
|
||||||
u8 unused_0;
|
u8 unused_0;
|
||||||
u8 unk_1;
|
u8 unk_1;
|
||||||
u8 format;
|
u8 format;
|
||||||
// seems to always play at 6khz no matter what this is set to?
|
// seems to always play at 6khz no matter what this is set to?
|
||||||
// or maybe it only applies to pcm input
|
// or maybe it only applies to pcm input
|
||||||
u16 sample_rate;
|
u16 sample_rate;
|
||||||
u8 volume;
|
u8 volume;
|
||||||
u8 unk_6;
|
u8 unk_6;
|
||||||
u8 unk_7;
|
u8 unk_7;
|
||||||
u8 play;
|
u8 play;
|
||||||
u8 unk_9;
|
u8 unk_9;
|
||||||
|
} m_reg_speaker;
|
||||||
} m_reg_speaker;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void Spy(Wiimote* wm_, const void* data_, size_t size_);
|
void Spy(Wiimote* wm_, const void* data_, size_t size_);
|
||||||
|
@ -31,8 +31,7 @@ void GamepadPage::ConfigExtension(wxCommandEvent& event)
|
|||||||
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
|
||||||
const std::size_t orig_size = control_groups.size();
|
const std::size_t orig_size = control_groups.size();
|
||||||
|
|
||||||
ControlGroupsSizer* const szr =
|
ControlGroupsSizer* const szr = new ControlGroupsSizer(ex->attachments[ex->switch_extension].get(), &dlg, this, &control_groups);
|
||||||
new ControlGroupsSizer(ex->attachments[ex->switch_extension], &dlg, this, &control_groups);
|
|
||||||
main_szr->Add(szr, 0, wxLEFT, 5);
|
main_szr->Add(szr, 0, wxLEFT, 5);
|
||||||
main_szr->Add(dlg.CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
main_szr->Add(dlg.CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
||||||
dlg.SetSizerAndFit(main_szr);
|
dlg.SetSizerAndFit(main_szr);
|
||||||
@ -49,13 +48,10 @@ PadSettingExtension::PadSettingExtension(wxWindow* const parent, ControllerEmu::
|
|||||||
: PadSetting(new wxChoice(parent, -1))
|
: PadSetting(new wxChoice(parent, -1))
|
||||||
, extension(ext)
|
, extension(ext)
|
||||||
{
|
{
|
||||||
|
for (auto& attachment : extension->attachments)
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
{
|
||||||
i = extension->attachments.begin(),
|
((wxChoice*)wxcontrol)->Append(wxGetTranslation(StrToWxStr(attachment->GetName())));
|
||||||
e = extension->attachments.end();
|
}
|
||||||
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
((wxChoice*)wxcontrol)->Append(wxGetTranslation(StrToWxStr((*i)->GetName())));
|
|
||||||
|
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
@ -152,29 +148,25 @@ void InputConfigDialog::UpdateProfileComboBox()
|
|||||||
const CFileSearch::XStringVector& sv = cfs.GetFileNames();
|
const CFileSearch::XStringVector& sv = cfs.GetFileNames();
|
||||||
|
|
||||||
wxArrayString strs;
|
wxArrayString strs;
|
||||||
CFileSearch::XStringVector::const_iterator si = sv.begin(),
|
for (auto si = sv.cbegin(); si != sv.cend(); ++si)
|
||||||
se = sv.end();
|
|
||||||
for (; si!=se; ++si)
|
|
||||||
{
|
{
|
||||||
std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ;
|
std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ;
|
||||||
strs.push_back(StrToWxStr(str));
|
strs.push_back(StrToWxStr(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
for (GamepadPage* page : m_padpages)
|
||||||
e = m_padpages.end();
|
|
||||||
for (; i != e; ++i)
|
|
||||||
{
|
{
|
||||||
(*i)->profile_cbox->Clear();
|
page->profile_cbox->Clear();
|
||||||
(*i)->profile_cbox->Append(strs);
|
page->profile_cbox->Append(strs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputConfigDialog::UpdateControlReferences()
|
void InputConfigDialog::UpdateControlReferences()
|
||||||
{
|
{
|
||||||
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
for (GamepadPage* page : m_padpages)
|
||||||
e = m_padpages.end();
|
{
|
||||||
for (; i != e; ++i)
|
page->controller->UpdateReferences(g_controller_interface);
|
||||||
(*i)->controller->UpdateReferences(g_controller_interface);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputConfigDialog::ClickSave(wxCommandEvent& event)
|
void InputConfigDialog::ClickSave(wxCommandEvent& event)
|
||||||
@ -192,21 +184,17 @@ void ControlDialog::UpdateListContents()
|
|||||||
{
|
{
|
||||||
if (control_reference->is_input)
|
if (control_reference->is_input)
|
||||||
{
|
{
|
||||||
// for inputs
|
for (Device::Input* input : dev->Inputs())
|
||||||
std::vector<Device::Input*>::const_iterator
|
{
|
||||||
i = dev->Inputs().begin(),
|
control_lbox->Append(StrToWxStr(input->GetName()));
|
||||||
e = dev->Inputs().end();
|
}
|
||||||
for (; i!=e; ++i)
|
|
||||||
control_lbox->Append(StrToWxStr((*i)->GetName()));
|
|
||||||
}
|
}
|
||||||
else
|
else // It's an output
|
||||||
{
|
{
|
||||||
// for outputs
|
for (Device::Output* output : dev->Outputs())
|
||||||
std::vector<Device::Output*>::const_iterator
|
{
|
||||||
i = dev->Outputs().begin(),
|
control_lbox->Append(StrToWxStr(output->GetName()));
|
||||||
e = dev->Outputs().end();
|
}
|
||||||
for (; i!=e; ++i)
|
|
||||||
control_lbox->Append(StrToWxStr((*i)->GetName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,24 +234,19 @@ void GamepadPage::UpdateGUI()
|
|||||||
{
|
{
|
||||||
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
|
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
|
||||||
|
|
||||||
std::vector< ControlGroupBox* >::const_iterator g = control_groups.begin(),
|
for (ControlGroupBox* cgBox : control_groups)
|
||||||
ge = control_groups.end();
|
|
||||||
for (; g!=ge; ++g)
|
|
||||||
{
|
{
|
||||||
// buttons
|
for (ControlButton* button : cgBox->control_buttons)
|
||||||
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin()
|
{
|
||||||
, e = (*g)->control_buttons.end();
|
wxString expr = StrToWxStr(button->control_reference->expression);
|
||||||
for (; i!=e; ++i) {
|
|
||||||
wxString expr = StrToWxStr((*i)->control_reference->expression);
|
|
||||||
expr.Replace("&", "&&");
|
expr.Replace("&", "&&");
|
||||||
(*i)->SetLabel(expr);
|
button->SetLabel(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cboxes
|
for (PadSetting* padSetting : cgBox->options)
|
||||||
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin()
|
{
|
||||||
, se = (*g)->options.end();
|
padSetting->UpdateGUI();
|
||||||
for (; si!=se; ++si)
|
}
|
||||||
(*si)->UpdateGUI();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,9 +325,10 @@ void ControlDialog::ClearControl(wxCommandEvent&)
|
|||||||
|
|
||||||
inline bool IsAlphabetic(wxString &str)
|
inline bool IsAlphabetic(wxString &str)
|
||||||
{
|
{
|
||||||
for (wxString::const_iterator it = str.begin(); it != str.end(); ++it)
|
for (wxUniChar c : str)
|
||||||
if (!isalpha(*it))
|
if (!isalpha(c))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +407,9 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
|||||||
expr = wxString::Format("%c(%s)", op, selection);
|
expr = wxString::Format("%c(%s)", op, selection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
expr = wxString::Format(" %c %s", op, device_expr);
|
expr = wxString::Format(" %c %s", op, device_expr);
|
||||||
|
}
|
||||||
|
|
||||||
textctrl->WriteText(expr);
|
textctrl->WriteText(expr);
|
||||||
control_reference->expression = textctrl->GetValue();
|
control_reference->expression = textctrl->GetValue();
|
||||||
@ -605,7 +591,7 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
|
|||||||
void GamepadPage::GetProfilePath(std::string& path)
|
void GamepadPage::GetProfilePath(std::string& path)
|
||||||
{
|
{
|
||||||
const wxString& name = profile_cbox->GetValue();
|
const wxString& name = profile_cbox->GetValue();
|
||||||
if (false == name.empty())
|
if (!name.empty())
|
||||||
{
|
{
|
||||||
// TODO: check for dumb characters maybe
|
// TODO: check for dumb characters maybe
|
||||||
|
|
||||||
@ -623,7 +609,7 @@ void GamepadPage::LoadProfile(wxCommandEvent&)
|
|||||||
std::string fname;
|
std::string fname;
|
||||||
GamepadPage::GetProfilePath(fname);
|
GamepadPage::GetProfilePath(fname);
|
||||||
|
|
||||||
if (false == File::Exists(fname))
|
if (!File::Exists(fname))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
@ -642,7 +628,7 @@ void GamepadPage::SaveProfile(wxCommandEvent&)
|
|||||||
GamepadPage::GetProfilePath(fname);
|
GamepadPage::GetProfilePath(fname);
|
||||||
File::CreateFullPath(fname);
|
File::CreateFullPath(fname);
|
||||||
|
|
||||||
if (false == fname.empty())
|
if (!fname.empty())
|
||||||
{
|
{
|
||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
controller->SaveConfig(inifile.GetOrCreateSection("Profile"));
|
controller->SaveConfig(inifile.GetOrCreateSection("Profile"));
|
||||||
@ -675,21 +661,18 @@ void GamepadPage::DeleteProfile(wxCommandEvent&)
|
|||||||
|
|
||||||
void InputConfigDialog::UpdateDeviceComboBox()
|
void InputConfigDialog::UpdateDeviceComboBox()
|
||||||
{
|
{
|
||||||
std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
|
|
||||||
e = m_padpages.end();
|
|
||||||
DeviceQualifier dq;
|
DeviceQualifier dq;
|
||||||
for (; i != e; ++i)
|
for (GamepadPage* page : m_padpages)
|
||||||
{
|
{
|
||||||
(*i)->device_cbox->Clear();
|
page->device_cbox->Clear();
|
||||||
std::vector<Device*>::const_iterator
|
|
||||||
di = g_controller_interface.Devices().begin(),
|
for (Device* d : g_controller_interface.Devices())
|
||||||
de = g_controller_interface.Devices().end();
|
|
||||||
for (; di!=de; ++di)
|
|
||||||
{
|
{
|
||||||
dq.FromDevice(*di);
|
dq.FromDevice(d);
|
||||||
(*i)->device_cbox->Append(StrToWxStr(dq.ToString()));
|
page->device_cbox->Append(StrToWxStr(dq.ToString()));
|
||||||
}
|
}
|
||||||
(*i)->device_cbox->SetValue(StrToWxStr((*i)->controller->default_device.ToString()));
|
|
||||||
|
page->device_cbox->SetValue(StrToWxStr(page->controller->default_device.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,11 +693,8 @@ void GamepadPage::RefreshDevices(wxCommandEvent&)
|
|||||||
|
|
||||||
ControlGroupBox::~ControlGroupBox()
|
ControlGroupBox::~ControlGroupBox()
|
||||||
{
|
{
|
||||||
std::vector<PadSetting*>::const_iterator
|
for (PadSetting* padSetting : options)
|
||||||
i = options.begin(),
|
delete padSetting;
|
||||||
e = options.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
delete *i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, GamepadPage* const eventsink)
|
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, GamepadPage* const eventsink)
|
||||||
@ -724,20 +704,16 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||||||
static_bitmap = NULL;
|
static_bitmap = NULL;
|
||||||
|
|
||||||
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||||
std::vector<ControllerEmu::ControlGroup::Control*>::iterator
|
for (auto& control : group->controls)
|
||||||
ci = group->controls.begin(),
|
|
||||||
ce = group->controls.end();
|
|
||||||
for (; ci != ce; ++ci)
|
|
||||||
{
|
{
|
||||||
|
wxStaticText* const label = new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(control->name)));
|
||||||
|
|
||||||
wxStaticText* const label = new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*ci)->name)));
|
ControlButton* const control_button = new ControlButton(parent, control->control_ref.get(), 80);
|
||||||
|
|
||||||
ControlButton* const control_button = new ControlButton(parent, (*ci)->control_ref, 80);
|
|
||||||
control_button->SetFont(m_SmallFont);
|
control_button->SetFont(m_SmallFont);
|
||||||
|
|
||||||
control_buttons.push_back(control_button);
|
control_buttons.push_back(control_button);
|
||||||
|
|
||||||
if ((*ci)->control_ref->is_input)
|
if (control->control_ref->is_input)
|
||||||
{
|
{
|
||||||
control_button->SetToolTip(_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
control_button->SetToolTip(_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
||||||
control_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::DetectControl, eventsink);
|
control_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::DetectControl, eventsink);
|
||||||
@ -774,17 +750,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||||||
dc.Clear();
|
dc.Clear();
|
||||||
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
||||||
|
|
||||||
std::vector< ControllerEmu::ControlGroup::Setting* >::const_iterator
|
|
||||||
i = group->settings.begin(),
|
|
||||||
e = group->settings.end();
|
|
||||||
|
|
||||||
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
|
||||||
for (; i!=e; ++i)
|
for (auto& groupSetting : group->settings)
|
||||||
{
|
{
|
||||||
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
|
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||||
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
||||||
options.push_back(setting);
|
options.push_back(setting);
|
||||||
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*i)->name))));
|
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(groupSetting->name))));
|
||||||
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
|
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,7 +774,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||||||
dc.Clear();
|
dc.Clear();
|
||||||
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
||||||
|
|
||||||
PadSettingSpin* const threshold_cbox = new PadSettingSpin(parent, group->settings[0]);
|
PadSettingSpin* const threshold_cbox = new PadSettingSpin(parent, group->settings[0].get());
|
||||||
threshold_cbox->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
threshold_cbox->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
||||||
|
|
||||||
threshold_cbox->wxcontrol->SetToolTip(_("Adjust the analog control pressure required to activate buttons."));
|
threshold_cbox->wxcontrol->SetToolTip(_("Adjust the analog control pressure required to activate buttons."));
|
||||||
@ -836,16 +808,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||||||
dc.Clear();
|
dc.Clear();
|
||||||
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
||||||
|
|
||||||
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
for (auto& groupSetting : group->settings)
|
||||||
i = group->settings.begin(),
|
|
||||||
e = group->settings.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
{
|
{
|
||||||
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
|
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
|
||||||
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
|
||||||
options.push_back(setting);
|
options.push_back(setting);
|
||||||
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
|
||||||
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*i)->name))), 0, wxCENTER|wxRIGHT, 3);
|
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(groupSetting->name))), 0, wxCENTER|wxRIGHT, 3);
|
||||||
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
|
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
|
||||||
Add(szr, 0, wxALL|wxCENTER, 3);
|
Add(szr, 0, wxALL|wxCENTER, 3);
|
||||||
}
|
}
|
||||||
@ -877,18 +846,13 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
//options
|
//options
|
||||||
|
for (auto& groupSetting : group->settings)
|
||||||
std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
|
|
||||||
i = group->settings.begin(),
|
|
||||||
e = group->settings.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
{
|
{
|
||||||
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, (*i)->value, (*i)->name);
|
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting->value, groupSetting->name);
|
||||||
setting_cbox->wxcontrol->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &GamepadPage::AdjustSetting, eventsink);
|
setting_cbox->wxcontrol->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &GamepadPage::AdjustSetting, eventsink);
|
||||||
options.push_back(setting_cbox);
|
options.push_back(setting_cbox);
|
||||||
|
|
||||||
Add(setting_cbox->wxcontrol, 0, wxALL|wxLEFT, 5);
|
Add(setting_cbox->wxcontrol, 0, wxALL|wxLEFT, 5);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -905,9 +869,9 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
|
|||||||
size_t col_size = 0;
|
size_t col_size = 0;
|
||||||
|
|
||||||
wxBoxSizer* stacked_groups = NULL;
|
wxBoxSizer* stacked_groups = NULL;
|
||||||
for (ControllerEmu::ControlGroup* group : controller->groups)
|
for (auto& group : controller->groups)
|
||||||
{
|
{
|
||||||
ControlGroupBox* control_group_box = new ControlGroupBox(group, parent, eventsink);
|
ControlGroupBox* control_group_box = new ControlGroupBox(group.get(), parent, eventsink);
|
||||||
wxStaticBoxSizer *control_group =
|
wxStaticBoxSizer *control_group =
|
||||||
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->name)));
|
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->name)));
|
||||||
control_group->Add(control_group_box);
|
control_group->Add(control_group_box);
|
||||||
|
@ -8,95 +8,33 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ControllerEmu::~ControllerEmu()
|
|
||||||
{
|
|
||||||
// control groups
|
|
||||||
std::vector<ControlGroup*>::const_iterator
|
|
||||||
i = groups.begin(),
|
|
||||||
e = groups.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
delete *i;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
for (; si!=se; ++si)
|
|
||||||
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)
|
void ControllerEmu::UpdateReferences(ControllerInterface& devi)
|
||||||
{
|
{
|
||||||
std::vector<ControlGroup*>::const_iterator
|
for (auto& ctrlGroup : groups)
|
||||||
i = groups.begin(),
|
|
||||||
e = groups.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
{
|
{
|
||||||
std::vector<ControlGroup::Control*>::const_iterator
|
for (auto& control : ctrlGroup->controls)
|
||||||
ci = (*i)->controls.begin(),
|
devi.UpdateReference(control->control_ref.get(), default_device);
|
||||||
ce = (*i)->controls.end();
|
|
||||||
for (; ci!=ce; ++ci)
|
|
||||||
devi.UpdateReference((*ci)->control_ref, default_device);
|
|
||||||
|
|
||||||
// extension
|
// extension
|
||||||
if (GROUP_TYPE_EXTENSION == (*i)->type)
|
if (ctrlGroup->type == GROUP_TYPE_EXTENSION)
|
||||||
{
|
{
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
for (auto& attachment : ((Extension*)ctrlGroup.get())->attachments)
|
||||||
ai = ((Extension*)*i)->attachments.begin(),
|
attachment->UpdateReferences(devi);
|
||||||
ae = ((Extension*)*i)->attachments.end();
|
|
||||||
for (; ai!=ae; ++ai)
|
|
||||||
(*ai)->UpdateReferences(devi);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerEmu::UpdateDefaultDevice()
|
void ControllerEmu::UpdateDefaultDevice()
|
||||||
{
|
{
|
||||||
std::vector<ControlGroup*>::const_iterator
|
for (auto& ctrlGroup : groups)
|
||||||
i = groups.begin(),
|
|
||||||
e = groups.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
{
|
{
|
||||||
//std::vector<ControlGroup::Control*>::const_iterator
|
|
||||||
//ci = (*i)->controls.begin(),
|
|
||||||
//ce = (*i)->controls.end();
|
|
||||||
//for (; ci!=ce; ++ci)
|
|
||||||
//(*ci)->control_ref->device_qualifier = default_device;
|
|
||||||
|
|
||||||
// extension
|
// extension
|
||||||
if (GROUP_TYPE_EXTENSION == (*i)->type)
|
if (ctrlGroup->type == GROUP_TYPE_EXTENSION)
|
||||||
{
|
{
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
for (auto& ai : ((Extension*)ctrlGroup.get())->attachments)
|
||||||
ai = ((Extension*)*i)->attachments.begin(),
|
|
||||||
ae = ((Extension*)*i)->attachments.end();
|
|
||||||
for (; ai!=ae; ++ai)
|
|
||||||
{
|
{
|
||||||
(*ai)->default_device = default_device;
|
ai->default_device = default_device;
|
||||||
(*ai)->UpdateDefaultDevice();
|
ai->UpdateDefaultDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,50 +45,42 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
|
|||||||
std::string group(base + name); group += "/";
|
std::string group(base + name); group += "/";
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
std::vector<ControlGroup::Setting*>::const_iterator
|
for (auto& s : settings)
|
||||||
si = settings.begin(),
|
|
||||||
se = settings.end();
|
|
||||||
for (; si!=se; ++si)
|
|
||||||
{
|
{
|
||||||
sec->Get((group+(*si)->name).c_str(), &(*si)->value, (*si)->default_value*100);
|
sec->Get((group + s->name).c_str(), &s->value, s->default_value * 100);
|
||||||
(*si)->value /= 100;
|
s->value /= 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// controls
|
for (auto& c : controls)
|
||||||
std::vector<ControlGroup::Control*>::const_iterator
|
|
||||||
ci = controls.begin(),
|
|
||||||
ce = controls.end();
|
|
||||||
for (; ci!=ce; ++ci)
|
|
||||||
{
|
{
|
||||||
// control expression
|
// control expression
|
||||||
sec->Get((group + (*ci)->name).c_str(), &(*ci)->control_ref->expression, "");
|
sec->Get((group + c->name).c_str(), &c->control_ref->expression, "");
|
||||||
|
|
||||||
// range
|
// range
|
||||||
sec->Get((group+(*ci)->name+"/Range").c_str(), &(*ci)->control_ref->range, 100.0f);
|
sec->Get((group + c->name + "/Range").c_str(), &c->control_ref->range, 100.0f);
|
||||||
(*ci)->control_ref->range /= 100;
|
c->control_ref->range /= 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// extensions
|
// extensions
|
||||||
if (GROUP_TYPE_EXTENSION == type)
|
if (type == GROUP_TYPE_EXTENSION)
|
||||||
{
|
{
|
||||||
Extension* const ex = ((Extension*)this);
|
Extension* const ext = ((Extension*)this);
|
||||||
|
|
||||||
ex->switch_extension = 0;
|
ext->switch_extension = 0;
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
std::string extname;
|
std::string extname;
|
||||||
sec->Get((base + name).c_str(), &extname, "");
|
sec->Get((base + name).c_str(), &extname, "");
|
||||||
|
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
for (auto& ai : ext->attachments)
|
||||||
ai = ((Extension*)this)->attachments.begin(),
|
|
||||||
ae = ((Extension*)this)->attachments.end();
|
|
||||||
for (; ai!=ae; ++ai,++n)
|
|
||||||
{
|
{
|
||||||
(*ai)->default_device.FromString(defdev);
|
ai->default_device.FromString(defdev);
|
||||||
(*ai)->LoadConfig(sec, base + (*ai)->GetName() + "/");
|
ai->LoadConfig(sec, base + ai->GetName() + "/");
|
||||||
|
|
||||||
if ((*ai)->GetName() == extname)
|
if (ai->GetName() == extname)
|
||||||
ex->switch_extension = n;
|
ext->switch_extension = n;
|
||||||
|
|
||||||
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,47 +93,35 @@ void ControllerEmu::LoadConfig(IniFile::Section *sec, const std::string& base)
|
|||||||
sec->Get((base + "Device").c_str(), &defdev, "");
|
sec->Get((base + "Device").c_str(), &defdev, "");
|
||||||
default_device.FromString(defdev);
|
default_device.FromString(defdev);
|
||||||
}
|
}
|
||||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
|
||||||
e = groups.end();
|
for (auto& cg : groups)
|
||||||
for (; i!=e; ++i)
|
cg->LoadConfig(sec, defdev, base);
|
||||||
(*i)->LoadConfig(sec, defdev, base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base)
|
void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::string& defdev, const std::string& base)
|
||||||
{
|
{
|
||||||
std::string group(base + name); group += "/";
|
std::string group(base + name); group += "/";
|
||||||
|
|
||||||
// settings
|
for (auto& s : settings)
|
||||||
std::vector<ControlGroup::Setting*>::const_iterator
|
sec->Set((group + s->name).c_str(), s->value*100.0f, s->default_value*100.0f);
|
||||||
si = settings.begin(),
|
|
||||||
se = settings.end();
|
|
||||||
for (; si!=se; ++si)
|
|
||||||
sec->Set((group+(*si)->name).c_str(), (*si)->value*100.0f, (*si)->default_value*100.0f);
|
|
||||||
|
|
||||||
// controls
|
for (auto& c : controls)
|
||||||
std::vector<ControlGroup::Control*>::const_iterator
|
|
||||||
ci = controls.begin(),
|
|
||||||
ce = controls.end();
|
|
||||||
for (; ci!=ce; ++ci)
|
|
||||||
{
|
{
|
||||||
// control expression
|
// control expression
|
||||||
sec->Set((group+(*ci)->name).c_str(), (*ci)->control_ref->expression, "");
|
sec->Set((group + c->name).c_str(), c->control_ref->expression, "");
|
||||||
|
|
||||||
// range
|
// range
|
||||||
sec->Set((group+(*ci)->name+"/Range").c_str(), (*ci)->control_ref->range*100.0f, 100.0f);
|
sec->Set((group + c->name + "/Range").c_str(), c->control_ref->range*100.0f, 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// extensions
|
// extensions
|
||||||
if (GROUP_TYPE_EXTENSION == type)
|
if (type == GROUP_TYPE_EXTENSION)
|
||||||
{
|
{
|
||||||
Extension* const ext = ((Extension*)this);
|
Extension* const ext = ((Extension*)this);
|
||||||
sec->Set((base + name).c_str(), ext->attachments[ext->switch_extension]->GetName(), "None");
|
sec->Set((base + name).c_str(), ext->attachments[ext->switch_extension]->GetName(), "None");
|
||||||
|
|
||||||
std::vector<ControllerEmu*>::const_iterator
|
for (auto& ai : ext->attachments)
|
||||||
ai = ((Extension*)this)->attachments.begin(),
|
ai->SaveConfig(sec, base + ai->GetName() + "/");
|
||||||
ae = ((Extension*)this)->attachments.end();
|
|
||||||
for (; ai!=ae; ++ai)
|
|
||||||
(*ai)->SaveConfig(sec, base + (*ai)->GetName() + "/");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,60 +131,58 @@ void ControllerEmu::SaveConfig(IniFile::Section *sec, const std::string& base)
|
|||||||
if (base.empty())
|
if (base.empty())
|
||||||
sec->Set((/*std::string(" ") +*/ base + "Device").c_str(), defdev, "");
|
sec->Set((/*std::string(" ") +*/ base + "Device").c_str(), defdev, "");
|
||||||
|
|
||||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
for (auto& ctrlGroup : groups)
|
||||||
e = groups.end();
|
ctrlGroup->SaveConfig(sec, defdev, base);
|
||||||
for (; i!=e; ++i)
|
|
||||||
(*i)->SaveConfig(sec, defdev, base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup(_name, GROUP_TYPE_STICK)
|
ControllerEmu::AnalogStick::AnalogStick(const char* const _name) : ControlGroup(_name, GROUP_TYPE_STICK)
|
||||||
{
|
{
|
||||||
for (auto& named_direction : named_directions)
|
for (auto& named_direction : named_directions)
|
||||||
controls.push_back(new Input(named_direction));
|
controls.emplace_back(new Input(named_direction));
|
||||||
|
|
||||||
controls.push_back(new Input(_trans("Modifier")));
|
controls.emplace_back(new Input(_trans("Modifier")));
|
||||||
|
|
||||||
settings.push_back(new Setting(_trans("Radius"), 0.7f, 0, 100));
|
settings.emplace_back(new Setting(_trans("Radius"), 0.7f, 0, 100));
|
||||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||||
settings.push_back(new Setting(_trans("Square Stick"), 0));
|
settings.emplace_back(new Setting(_trans("Square Stick"), 0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::Buttons::Buttons(const char* const _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS)
|
ControllerEmu::Buttons::Buttons(const char* const _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS)
|
||||||
{
|
{
|
||||||
settings.push_back(new Setting(_trans("Threshold"), 0.5f));
|
settings.emplace_back(new Setting(_trans("Threshold"), 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::MixedTriggers::MixedTriggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS)
|
ControllerEmu::MixedTriggers::MixedTriggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS)
|
||||||
{
|
{
|
||||||
settings.push_back(new Setting(_trans("Threshold"), 0.9f));
|
settings.emplace_back(new Setting(_trans("Threshold"), 0.9f));
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::Triggers::Triggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS)
|
ControllerEmu::Triggers::Triggers(const char* const _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS)
|
||||||
{
|
{
|
||||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
|
ControllerEmu::Slider::Slider(const char* const _name) : ControlGroup(_name, GROUP_TYPE_SLIDER)
|
||||||
{
|
{
|
||||||
controls.push_back(new Input("Left"));
|
controls.emplace_back(new Input("Left"));
|
||||||
controls.push_back(new Input("Right"));
|
controls.emplace_back(new Input("Right"));
|
||||||
|
|
||||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP_TYPE_FORCE)
|
ControllerEmu::Force::Force(const char* const _name) : ControlGroup(_name, GROUP_TYPE_FORCE)
|
||||||
{
|
{
|
||||||
memset(m_swing, 0, sizeof(m_swing));
|
memset(m_swing, 0, sizeof(m_swing));
|
||||||
|
|
||||||
controls.push_back(new Input(_trans("Up")));
|
controls.emplace_back(new Input(_trans("Up")));
|
||||||
controls.push_back(new Input(_trans("Down")));
|
controls.emplace_back(new Input(_trans("Down")));
|
||||||
controls.push_back(new Input(_trans("Left")));
|
controls.emplace_back(new Input(_trans("Left")));
|
||||||
controls.push_back(new Input(_trans("Right")));
|
controls.emplace_back(new Input(_trans("Right")));
|
||||||
controls.push_back(new Input(_trans("Forward")));
|
controls.emplace_back(new Input(_trans("Forward")));
|
||||||
controls.push_back(new Input(_trans("Backward")));
|
controls.emplace_back(new Input(_trans("Backward")));
|
||||||
|
|
||||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::Tilt::Tilt(const char* const _name)
|
ControllerEmu::Tilt::Tilt(const char* const _name)
|
||||||
@ -274,16 +190,16 @@ ControllerEmu::Tilt::Tilt(const char* const _name)
|
|||||||
{
|
{
|
||||||
memset(m_tilt, 0, sizeof(m_tilt));
|
memset(m_tilt, 0, sizeof(m_tilt));
|
||||||
|
|
||||||
controls.push_back(new Input("Forward"));
|
controls.emplace_back(new Input("Forward"));
|
||||||
controls.push_back(new Input("Backward"));
|
controls.emplace_back(new Input("Backward"));
|
||||||
controls.push_back(new Input("Left"));
|
controls.emplace_back(new Input("Left"));
|
||||||
controls.push_back(new Input("Right"));
|
controls.emplace_back(new Input("Right"));
|
||||||
|
|
||||||
controls.push_back(new Input(_trans("Modifier")));
|
controls.emplace_back(new Input(_trans("Modifier")));
|
||||||
|
|
||||||
settings.push_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
|
||||||
settings.push_back(new Setting(_trans("Circle Stick"), 0));
|
settings.emplace_back(new Setting(_trans("Circle Stick"), 0));
|
||||||
settings.push_back(new Setting(_trans("Angle"), 0.9f, 0, 180));
|
settings.emplace_back(new Setting(_trans("Angle"), 0.9f, 0, 180));
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::Cursor::Cursor(const char* const _name)
|
ControllerEmu::Cursor::Cursor(const char* const _name)
|
||||||
@ -291,14 +207,14 @@ ControllerEmu::Cursor::Cursor(const char* const _name)
|
|||||||
, m_z(0)
|
, m_z(0)
|
||||||
{
|
{
|
||||||
for (auto& named_direction : named_directions)
|
for (auto& named_direction : named_directions)
|
||||||
controls.push_back(new Input(named_direction));
|
controls.emplace_back(new Input(named_direction));
|
||||||
controls.push_back(new Input("Forward"));
|
controls.emplace_back(new Input("Forward"));
|
||||||
controls.push_back(new Input("Backward"));
|
controls.emplace_back(new Input("Backward"));
|
||||||
controls.push_back(new Input(_trans("Hide")));
|
controls.emplace_back(new Input(_trans("Hide")));
|
||||||
|
|
||||||
settings.push_back(new Setting(_trans("Center"), 0.5f));
|
settings.emplace_back(new Setting(_trans("Center"), 0.5f));
|
||||||
settings.push_back(new Setting(_trans("Width"), 0.5f));
|
settings.emplace_back(new Setting(_trans("Width"), 0.5f));
|
||||||
settings.push_back(new Setting(_trans("Height"), 0.5f));
|
settings.emplace_back(new Setting(_trans("Height"), 0.5f));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -42,7 +43,7 @@ enum
|
|||||||
SETTING_SQUARE,
|
SETTING_SQUARE,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * const named_directions[] =
|
const char* const named_directions[] =
|
||||||
{
|
{
|
||||||
"Up",
|
"Up",
|
||||||
"Down",
|
"Down",
|
||||||
@ -61,13 +62,13 @@ public:
|
|||||||
class Control
|
class Control
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
Control(ControllerInterface::ControlReference* const _ref, const char * const _name)
|
Control(ControllerInterface::ControlReference* const _ref, const char* const _name)
|
||||||
: control_ref(_ref), name(_name){}
|
: control_ref(_ref), name(_name) {}
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ~Control();
|
public:
|
||||||
ControllerInterface::ControlReference* const control_ref;
|
virtual ~Control() {}
|
||||||
const char * const name;
|
std::unique_ptr<ControllerInterface::ControlReference> const control_ref;
|
||||||
|
const char* const name;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,18 +76,16 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Input(const char * const _name)
|
Input(const char* const _name)
|
||||||
: Control(new ControllerInterface::InputReference, _name) {}
|
: Control(new ControllerInterface::InputReference, _name) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Output : public Control
|
class Output : public Control
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Output(const char * const _name)
|
Output(const char* const _name)
|
||||||
: Control(new ControllerInterface::OutputReference, _name) {}
|
: Control(new ControllerInterface::OutputReference, _name) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Setting
|
class Setting
|
||||||
@ -94,30 +93,30 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Setting(const char* const _name, const ControlState def_value
|
Setting(const char* const _name, const ControlState def_value
|
||||||
, const unsigned int _low = 0, const unsigned int _high = 100 )
|
, const unsigned int _low = 0, const unsigned int _high = 100)
|
||||||
: name(_name)
|
: name(_name)
|
||||||
, value(def_value)
|
, value(def_value)
|
||||||
, default_value(def_value)
|
, default_value(def_value)
|
||||||
, low(_low)
|
, low(_low)
|
||||||
, high(_high){}
|
, high(_high){}
|
||||||
|
|
||||||
const char* const name;
|
const char* const name;
|
||||||
ControlState value;
|
ControlState value;
|
||||||
const ControlState default_value;
|
const ControlState default_value;
|
||||||
const unsigned int low, high;
|
const unsigned int low, high;
|
||||||
};
|
};
|
||||||
|
|
||||||
ControlGroup(const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
|
ControlGroup(const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
|
||||||
virtual ~ControlGroup();
|
virtual ~ControlGroup() {}
|
||||||
|
|
||||||
virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
virtual void LoadConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||||
virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
virtual void SaveConfig(IniFile::Section *sec, const std::string& defdev = "", const std::string& base = "" );
|
||||||
|
|
||||||
const char* const name;
|
const char* const name;
|
||||||
const unsigned int type;
|
const unsigned int type;
|
||||||
|
|
||||||
std::vector< Control* > controls;
|
std::vector<std::unique_ptr<Control>> controls;
|
||||||
std::vector< Setting* > settings;
|
std::vector<std::unique_ptr<Setting>> settings;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -194,14 +193,12 @@ public:
|
|||||||
template <typename C>
|
template <typename C>
|
||||||
void GetState(C* const buttons, const C* bitmasks)
|
void GetState(C* const buttons, const C* bitmasks)
|
||||||
{
|
{
|
||||||
std::vector<Control*>::iterator
|
for (auto& control : controls)
|
||||||
i = controls.begin(),
|
|
||||||
e = controls.end();
|
|
||||||
|
|
||||||
for (; i!=e; ++i, ++bitmasks)
|
|
||||||
{
|
{
|
||||||
if ((*i)->control_ref->State() > settings[0]->value) // threshold
|
if (control->control_ref->State() > settings[0]->value) // threshold
|
||||||
*buttons |= *bitmasks;
|
*buttons |= *bitmasks;
|
||||||
|
|
||||||
|
bitmasks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,12 +284,13 @@ public:
|
|||||||
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
||||||
|
|
||||||
float &ax = m_swing[i >> 1];
|
float &ax = m_swing[i >> 1];
|
||||||
*axis++ = (C)((tmpf - ax) * range + base);
|
*axis++ = (C)((tmpf - ax) * range + base);
|
||||||
ax = tmpf;
|
ax = tmpf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_swing[3];
|
float m_swing[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
class Tilt : public ControlGroup
|
class Tilt : public ControlGroup
|
||||||
@ -370,8 +368,9 @@ public:
|
|||||||
*y = C(m_tilt[1] * angle * range + base);
|
*y = C(m_tilt[1] * angle * range + base);
|
||||||
*x = C(m_tilt[0] * angle * range + base);
|
*x = C(m_tilt[0] * angle * range + base);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_tilt[2];
|
float m_tilt[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cursor : public ControlGroup
|
class Cursor : public ControlGroup
|
||||||
@ -415,7 +414,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float m_z;
|
float m_z;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Extension : public ControlGroup
|
class Extension : public ControlGroup
|
||||||
@ -425,17 +424,18 @@ public:
|
|||||||
: ControlGroup(_name, GROUP_TYPE_EXTENSION)
|
: ControlGroup(_name, GROUP_TYPE_EXTENSION)
|
||||||
, switch_extension(0)
|
, switch_extension(0)
|
||||||
, active_extension(0) {}
|
, active_extension(0) {}
|
||||||
~Extension();
|
|
||||||
|
~Extension() {}
|
||||||
|
|
||||||
void GetState(u8* const data, const bool focus = true);
|
void GetState(u8* const data, const bool focus = true);
|
||||||
|
|
||||||
std::vector<ControllerEmu*> attachments;
|
std::vector<std::unique_ptr<ControllerEmu>> attachments;
|
||||||
|
|
||||||
int switch_extension;
|
int switch_extension;
|
||||||
int active_extension;
|
int active_extension;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~ControllerEmu();
|
virtual ~ControllerEmu() {}
|
||||||
|
|
||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
|
|
||||||
@ -447,9 +447,9 @@ public:
|
|||||||
|
|
||||||
void UpdateReferences(ControllerInterface& devi);
|
void UpdateReferences(ControllerInterface& devi);
|
||||||
|
|
||||||
std::vector< ControlGroup* > groups;
|
std::vector<std::unique_ptr<ControlGroup>> groups;
|
||||||
|
|
||||||
DeviceQualifier default_device;
|
DeviceQualifier default_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ const float INPUT_DETECT_THRESHOLD = 0.55f;
|
|||||||
ControllerInterface g_controller_interface;
|
ControllerInterface g_controller_interface;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init
|
// Init
|
||||||
//
|
//
|
||||||
// detect devices and inputs outputs / will make refresh function later
|
// Detect devices and inputs outputs / will make refresh function later
|
||||||
//
|
//
|
||||||
void ControllerInterface::Initialize()
|
void ControllerInterface::Initialize()
|
||||||
{
|
{
|
||||||
@ -79,31 +79,26 @@ if (GLWin.platform == EGL_PLATFORM_X11) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// DeInit
|
// DeInit
|
||||||
//
|
//
|
||||||
// remove all devices/ call library cleanup functions
|
// Remove all devices/ call library cleanup functions
|
||||||
//
|
//
|
||||||
void ControllerInterface::Shutdown()
|
void ControllerInterface::Shutdown()
|
||||||
{
|
{
|
||||||
if (false == m_is_init)
|
if (!m_is_init)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::vector<Device*>::const_iterator
|
for (Device* d : m_devices)
|
||||||
d = m_devices.begin(),
|
|
||||||
de = m_devices.end();
|
|
||||||
for ( ;d != de; ++d )
|
|
||||||
{
|
{
|
||||||
std::vector<Device::Output*>::const_iterator
|
// Set outputs to ZERO before destroying device
|
||||||
o = (*d)->Outputs().begin(),
|
for (Device::Output* o : d->Outputs())
|
||||||
oe = (*d)->Outputs().end();
|
o->SetState(0);
|
||||||
// set outputs to ZERO before destroying device
|
|
||||||
for ( ;o!=oe; ++o)
|
|
||||||
(*o)->SetState(0);
|
|
||||||
// update output
|
|
||||||
(*d)->UpdateOutput();
|
|
||||||
|
|
||||||
//delete device
|
// Update output
|
||||||
delete *d;
|
d->UpdateOutput();
|
||||||
|
|
||||||
|
// Delete device
|
||||||
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_devices.clear();
|
m_devices.clear();
|
||||||
@ -132,9 +127,9 @@ void ControllerInterface::Shutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// SetHwnd
|
// SetHwnd
|
||||||
//
|
//
|
||||||
// sets the hwnd used for some crap when initializing, use before calling Init
|
// Sets the hwnd used for some crap when initializing, use before calling Init
|
||||||
//
|
//
|
||||||
void ControllerInterface::SetHwnd( void* const hwnd )
|
void ControllerInterface::SetHwnd( void* const hwnd )
|
||||||
{
|
{
|
||||||
@ -142,9 +137,9 @@ void ControllerInterface::SetHwnd( void* const hwnd )
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// UpdateInput
|
// UpdateInput
|
||||||
//
|
//
|
||||||
// update input for all devices, return true if all devices returned successful
|
// Update input for all devices, return true if all devices returned successful
|
||||||
//
|
//
|
||||||
bool ControllerInterface::UpdateInput(const bool force)
|
bool ControllerInterface::UpdateInput(const bool force)
|
||||||
{
|
{
|
||||||
@ -153,16 +148,13 @@ bool ControllerInterface::UpdateInput(const bool force)
|
|||||||
if (force)
|
if (force)
|
||||||
lk.lock();
|
lk.lock();
|
||||||
else if (!lk.try_lock())
|
else if (!lk.try_lock())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_t ok_count = 0;
|
size_t ok_count = 0;
|
||||||
|
|
||||||
std::vector<Device*>::const_iterator
|
for (Device* d : m_devices)
|
||||||
d = m_devices.begin(),
|
|
||||||
e = m_devices.end();
|
|
||||||
for ( ;d != e; ++d )
|
|
||||||
{
|
{
|
||||||
if ((*d)->UpdateInput())
|
if (d->UpdateInput())
|
||||||
++ok_count;
|
++ok_count;
|
||||||
//else
|
//else
|
||||||
// disabled. it might be causing problems
|
// disabled. it might be causing problems
|
||||||
@ -173,9 +165,9 @@ bool ControllerInterface::UpdateInput(const bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// UpdateOutput
|
// UpdateOutput
|
||||||
//
|
//
|
||||||
// update output for all devices, return true if all devices returned successful
|
// Update output for all devices, return true if all devices returned successful
|
||||||
//
|
//
|
||||||
bool ControllerInterface::UpdateOutput(const bool force)
|
bool ControllerInterface::UpdateOutput(const bool force)
|
||||||
{
|
{
|
||||||
@ -188,9 +180,9 @@ bool ControllerInterface::UpdateOutput(const bool force)
|
|||||||
|
|
||||||
size_t ok_count = 0;
|
size_t ok_count = 0;
|
||||||
|
|
||||||
for (auto d = m_devices.cbegin(); d != m_devices.cend(); ++d)
|
for (Device* d : m_devices)
|
||||||
{
|
{
|
||||||
if ((*d)->UpdateOutput())
|
if (d->UpdateOutput())
|
||||||
++ok_count;
|
++ok_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,9 +190,9 @@ bool ControllerInterface::UpdateOutput(const bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// InputReference :: State
|
// InputReference :: State
|
||||||
//
|
//
|
||||||
// get the state of an input reference
|
// Gets the state of an input reference
|
||||||
// override function for ControlReference::State ...
|
// override function for ControlReference::State ...
|
||||||
//
|
//
|
||||||
ControlState ControllerInterface::InputReference::State( const ControlState ignore )
|
ControlState ControllerInterface::InputReference::State( const ControlState ignore )
|
||||||
@ -212,11 +204,11 @@ ControlState ControllerInterface::InputReference::State( const ControlState igno
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// OutputReference :: State
|
// OutputReference :: State
|
||||||
//
|
//
|
||||||
// set the state of all binded outputs
|
// Set the state of all binded outputs
|
||||||
// overrides ControlReference::State .. combined them so i could make the gui simple / inputs == same as outputs one list
|
// overrides ControlReference::State .. combined them so I could make the GUI simple / inputs == same as outputs one list
|
||||||
// i was lazy and it works so watever
|
// I was lazy and it works so watever
|
||||||
//
|
//
|
||||||
ControlState ControllerInterface::OutputReference::State(const ControlState state)
|
ControlState ControllerInterface::OutputReference::State(const ControlState state)
|
||||||
{
|
{
|
||||||
@ -226,9 +218,9 @@ ControlState ControllerInterface::OutputReference::State(const ControlState stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// UpdateReference
|
// UpdateReference
|
||||||
//
|
//
|
||||||
// updates a controlreference's binded devices/controls
|
// Updates a controlreference's binded devices/controls
|
||||||
// need to call this to re-parse a control reference's expression after changing it
|
// need to call this to re-parse a control reference's expression after changing it
|
||||||
//
|
//
|
||||||
void ControllerInterface::UpdateReference(ControllerInterface::ControlReference* ref
|
void ControllerInterface::UpdateReference(ControllerInterface::ControlReference* ref
|
||||||
@ -242,9 +234,9 @@ void ControllerInterface::UpdateReference(ControllerInterface::ControlReference*
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// InputReference :: Detect
|
// InputReference :: Detect
|
||||||
//
|
//
|
||||||
// wait for input on all binded devices
|
// Wait for input on all binded devices
|
||||||
// supports not detecting inputs that were held down at the time of Detect start,
|
// supports not detecting inputs that were held down at the time of Detect start,
|
||||||
// which is useful for those crazy flightsticks that have certain buttons that are always held down
|
// which is useful for those crazy flightsticks that have certain buttons that are always held down
|
||||||
// or some crazy axes or something
|
// or some crazy axes or something
|
||||||
@ -294,7 +286,7 @@ Device::Control* ControllerInterface::InputReference::Detect(const unsigned int
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// OutputReference :: Detect
|
// OutputReference :: Detect
|
||||||
//
|
//
|
||||||
// Totally different from the inputReference detect / I have them combined so it was simpler to make the GUI.
|
// Totally different from the inputReference detect / I have them combined so it was simpler to make the GUI.
|
||||||
// The GUI doesn't know the difference between an input and an output / it's odd but I was lazy and it was easy
|
// The GUI doesn't know the difference between an input and an output / it's odd but I was lazy and it was easy
|
||||||
|
@ -35,24 +35,24 @@
|
|||||||
using namespace ciface::Core;
|
using namespace ciface::Core;
|
||||||
|
|
||||||
//
|
//
|
||||||
// ControllerInterface
|
// ControllerInterface
|
||||||
//
|
//
|
||||||
// some crazy shit I made to control different device inputs and outputs
|
// Some crazy shit I made to control different device inputs and outputs
|
||||||
// from lots of different sources, hopefully more easily
|
// from lots of different sources, hopefully more easily.
|
||||||
//
|
//
|
||||||
class ControllerInterface : public DeviceContainer
|
class ControllerInterface : public DeviceContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//
|
//
|
||||||
// ControlReference
|
// ControlReference
|
||||||
//
|
//
|
||||||
// these are what you create to actually use the inputs, InputReference or OutputReference
|
// These are what you create to actually use the inputs, InputReference or OutputReference.
|
||||||
//
|
//
|
||||||
// after being bound to devices and controls with ControllerInterface::UpdateReference,
|
// After being bound to devices and controls with ControllerInterface::UpdateReference,
|
||||||
// each one can link to multiple devices and controls
|
// each one can link to multiple devices and controls
|
||||||
// when you change a ControlReference's expression,
|
// when you change a ControlReference's expression,
|
||||||
// you must use ControllerInterface::UpdateReference on it to rebind controls
|
// you must use ControllerInterface::UpdateReference on it to rebind controls
|
||||||
//
|
//
|
||||||
class ControlReference
|
class ControlReference
|
||||||
{
|
{
|
||||||
@ -62,15 +62,17 @@ public:
|
|||||||
virtual Device::Control* Detect(const unsigned int ms, Device* const device) = 0;
|
virtual Device::Control* Detect(const unsigned int ms, Device* const device) = 0;
|
||||||
|
|
||||||
ControlState range;
|
ControlState range;
|
||||||
std::string expression;
|
std::string expression;
|
||||||
const bool is_input;
|
const bool is_input;
|
||||||
ciface::ExpressionParser::ExpressionParseStatus parse_error;
|
ciface::ExpressionParser::ExpressionParseStatus parse_error;
|
||||||
|
|
||||||
virtual ~ControlReference() {
|
virtual ~ControlReference()
|
||||||
|
{
|
||||||
delete parsed_expression;
|
delete parsed_expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BoundCount() {
|
int BoundCount()
|
||||||
|
{
|
||||||
if (parsed_expression)
|
if (parsed_expression)
|
||||||
return parsed_expression->num_controls;
|
return parsed_expression->num_controls;
|
||||||
else
|
else
|
||||||
@ -83,9 +85,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// InputReference
|
// InputReference
|
||||||
//
|
//
|
||||||
// control reference for inputs
|
// Control reference for inputs
|
||||||
//
|
//
|
||||||
class InputReference : public ControlReference
|
class InputReference : public ControlReference
|
||||||
{
|
{
|
||||||
@ -96,9 +98,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// OutputReference
|
// OutputReference
|
||||||
//
|
//
|
||||||
// control reference for outputs
|
// Control reference for outputs
|
||||||
//
|
//
|
||||||
class OutputReference : public ControlReference
|
class OutputReference : public ControlReference
|
||||||
{
|
{
|
||||||
@ -122,8 +124,8 @@ public:
|
|||||||
std::recursive_mutex update_lock;
|
std::recursive_mutex update_lock;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_is_init;
|
bool m_is_init;
|
||||||
void* m_hwnd;
|
void* m_hwnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ControllerInterface g_controller_interface;
|
extern ControllerInterface g_controller_interface;
|
||||||
|
@ -49,81 +49,81 @@ void GetXInputGUIDS( std::vector<DWORD>& guids )
|
|||||||
|
|
||||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||||
|
|
||||||
IWbemLocator* pIWbemLocator = NULL;
|
IWbemLocator* pIWbemLocator = NULL;
|
||||||
IEnumWbemClassObject* pEnumDevices = NULL;
|
IEnumWbemClassObject* pEnumDevices = NULL;
|
||||||
IWbemClassObject* pDevices[20] = {0};
|
IWbemClassObject* pDevices[20] = {0};
|
||||||
IWbemServices* pIWbemServices = NULL;
|
IWbemServices* pIWbemServices = NULL;
|
||||||
BSTR bstrNamespace = NULL;
|
BSTR bstrNamespace = NULL;
|
||||||
BSTR bstrDeviceID = NULL;
|
BSTR bstrDeviceID = NULL;
|
||||||
BSTR bstrClassName = NULL;
|
BSTR bstrClassName = NULL;
|
||||||
DWORD uReturned = 0;
|
DWORD uReturned = 0;
|
||||||
VARIANT var;
|
VARIANT var;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
// CoInit if needed
|
// CoInit if needed
|
||||||
hr = CoInitialize(NULL);
|
hr = CoInitialize(NULL);
|
||||||
bool bCleanupCOM = SUCCEEDED(hr);
|
bool bCleanupCOM = SUCCEEDED(hr);
|
||||||
|
|
||||||
// Create WMI
|
// Create WMI
|
||||||
hr = CoCreateInstance( __uuidof(WbemLocator),
|
hr = CoCreateInstance(__uuidof(WbemLocator),
|
||||||
NULL,
|
NULL,
|
||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
__uuidof(IWbemLocator),
|
__uuidof(IWbemLocator),
|
||||||
(LPVOID*) &pIWbemLocator);
|
(LPVOID*) &pIWbemLocator);
|
||||||
if( FAILED(hr) || pIWbemLocator == NULL )
|
if (FAILED(hr) || pIWbemLocator == NULL)
|
||||||
goto LCleanup;
|
goto LCleanup;
|
||||||
|
|
||||||
bstrNamespace = SysAllocString( L"\\\\.\\root\\cimv2" );if( bstrNamespace == NULL ) goto LCleanup;
|
bstrNamespace = SysAllocString(L"\\\\.\\root\\cimv2");if(bstrNamespace == NULL) goto LCleanup;
|
||||||
bstrClassName = SysAllocString( L"Win32_PNPEntity" ); if( bstrClassName == NULL ) goto LCleanup;
|
bstrClassName = SysAllocString(L"Win32_PNPEntity"); if(bstrClassName == NULL) goto LCleanup;
|
||||||
bstrDeviceID = SysAllocString( L"DeviceID" ); if( bstrDeviceID == NULL ) goto LCleanup;
|
bstrDeviceID = SysAllocString(L"DeviceID"); if(bstrDeviceID == NULL) goto LCleanup;
|
||||||
|
|
||||||
// Connect to WMI
|
// Connect to WMI
|
||||||
hr = pIWbemLocator->ConnectServer( bstrNamespace, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices );
|
hr = pIWbemLocator->ConnectServer(bstrNamespace, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices);
|
||||||
if( FAILED(hr) || pIWbemServices == NULL )
|
if (FAILED(hr) || pIWbemServices == NULL)
|
||||||
goto LCleanup;
|
goto LCleanup;
|
||||||
|
|
||||||
// Switch security level to IMPERSONATE.
|
// Switch security level to IMPERSONATE.
|
||||||
CoSetProxyBlanket( pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
|
CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
|
||||||
RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
|
RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
|
||||||
|
|
||||||
hr = pIWbemServices->CreateInstanceEnum( bstrClassName, 0, NULL, &pEnumDevices );
|
hr = pIWbemServices->CreateInstanceEnum(bstrClassName, 0, NULL, &pEnumDevices);
|
||||||
if( FAILED(hr) || pEnumDevices == NULL )
|
if (FAILED(hr) || pEnumDevices == NULL)
|
||||||
goto LCleanup;
|
goto LCleanup;
|
||||||
|
|
||||||
// Loop over all devices
|
// Loop over all devices
|
||||||
while( true )
|
while (true)
|
||||||
{
|
{
|
||||||
// Get 20 at a time
|
// Get 20 at a time
|
||||||
hr = pEnumDevices->Next( 10000, 20, pDevices, &uReturned );
|
hr = pEnumDevices->Next(10000, 20, pDevices, &uReturned);
|
||||||
if( FAILED(hr) || uReturned == 0 )
|
if (FAILED(hr) || uReturned == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for( UINT iDevice=0; iDevice<uReturned; ++iDevice )
|
for (UINT iDevice = 0; iDevice < uReturned; ++iDevice)
|
||||||
{
|
{
|
||||||
// For each device, get its device ID
|
// For each device, get its device ID
|
||||||
hr = pDevices[iDevice]->Get( bstrDeviceID, 0L, &var, NULL, NULL );
|
hr = pDevices[iDevice]->Get(bstrDeviceID, 0L, &var, NULL, NULL);
|
||||||
if( SUCCEEDED( hr ) && var.vt == VT_BSTR && var.bstrVal != NULL )
|
if (SUCCEEDED(hr) && var.vt == VT_BSTR && var.bstrVal != NULL)
|
||||||
{
|
{
|
||||||
// Check if the device ID contains "IG_". If it does, then it's an XInput device
|
// Check if the device ID contains "IG_". If it does, then it's an XInput device
|
||||||
// This information can not be found from DirectInput
|
// This information can not be found from DirectInput
|
||||||
if( wcsstr( var.bstrVal, L"IG_" ) )
|
if (wcsstr(var.bstrVal, L"IG_"))
|
||||||
{
|
{
|
||||||
// If it does, then get the VID/PID from var.bstrVal
|
// If it does, then get the VID/PID from var.bstrVal
|
||||||
DWORD dwPid = 0, dwVid = 0;
|
DWORD dwPid = 0, dwVid = 0;
|
||||||
WCHAR* strVid = wcsstr( var.bstrVal, L"VID_" );
|
WCHAR* strVid = wcsstr(var.bstrVal, L"VID_");
|
||||||
if( strVid && swscanf( strVid, L"VID_%4X", &dwVid ) != 1 )
|
if (strVid && swscanf(strVid, L"VID_%4X", &dwVid) != 1)
|
||||||
dwVid = 0;
|
dwVid = 0;
|
||||||
WCHAR* strPid = wcsstr( var.bstrVal, L"PID_" );
|
WCHAR* strPid = wcsstr(var.bstrVal, L"PID_");
|
||||||
if( strPid && swscanf( strPid, L"PID_%4X", &dwPid ) != 1 )
|
if (strPid && swscanf(strPid, L"PID_%4X", &dwPid) != 1)
|
||||||
dwPid = 0;
|
dwPid = 0;
|
||||||
|
|
||||||
// Compare the VID/PID to the DInput device
|
// Compare the VID/PID to the DInput device
|
||||||
DWORD dwVidPid = MAKELONG( dwVid, dwPid );
|
DWORD dwVidPid = MAKELONG(dwVid, dwPid);
|
||||||
guids.push_back( dwVidPid );
|
guids.push_back(dwVidPid);
|
||||||
//bIsXinputDevice = true;
|
//bIsXinputDevice = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SAFE_RELEASE( pDevices[iDevice] );
|
SAFE_RELEASE(pDevices[iDevice]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,13 +134,13 @@ LCleanup:
|
|||||||
SysFreeString(bstrDeviceID);
|
SysFreeString(bstrDeviceID);
|
||||||
if(bstrClassName)
|
if(bstrClassName)
|
||||||
SysFreeString(bstrClassName);
|
SysFreeString(bstrClassName);
|
||||||
for( UINT iDevice=0; iDevice<20; iDevice++ )
|
for (UINT iDevice = 0; iDevice < 20; iDevice++)
|
||||||
SAFE_RELEASE( pDevices[iDevice] );
|
SAFE_RELEASE(pDevices[iDevice]);
|
||||||
SAFE_RELEASE( pEnumDevices );
|
SAFE_RELEASE(pEnumDevices);
|
||||||
SAFE_RELEASE( pIWbemLocator );
|
SAFE_RELEASE(pIWbemLocator);
|
||||||
SAFE_RELEASE( pIWbemServices );
|
SAFE_RELEASE(pIWbemServices);
|
||||||
|
|
||||||
if( bCleanupCOM )
|
if (bCleanupCOM)
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,17 +156,14 @@ void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices
|
|||||||
std::vector<DWORD> xinput_guids;
|
std::vector<DWORD> xinput_guids;
|
||||||
GetXInputGUIDS( xinput_guids );
|
GetXInputGUIDS( xinput_guids );
|
||||||
|
|
||||||
std::list<DIDEVICEINSTANCE>::iterator
|
for (DIDEVICEINSTANCE& joystick : joysticks)
|
||||||
i = joysticks.begin(),
|
|
||||||
e = joysticks.end();
|
|
||||||
for ( ; i!=e; ++i )
|
|
||||||
{
|
{
|
||||||
// skip XInput Devices
|
// skip XInput Devices
|
||||||
if ( std::find( xinput_guids.begin(), xinput_guids.end(), i->guidProduct.Data1 ) != xinput_guids.end() )
|
if (std::find(xinput_guids.begin(), xinput_guids.end(), joystick.guidProduct.Data1) != xinput_guids.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
LPDIRECTINPUTDEVICE8 js_device;
|
LPDIRECTINPUTDEVICE8 js_device;
|
||||||
if (SUCCEEDED(idi8->CreateDevice(i->guidInstance, &js_device, NULL)))
|
if (SUCCEEDED(idi8->CreateDevice(joystick.guidInstance, &js_device, NULL)))
|
||||||
{
|
{
|
||||||
if (SUCCEEDED(js_device->SetDataFormat(&c_dfDIJoystick)))
|
if (SUCCEEDED(js_device->SetDataFormat(&c_dfDIJoystick)))
|
||||||
{
|
{
|
||||||
@ -182,7 +179,7 @@ void InitJoystick(IDirectInput8* const idi8, std::vector<Core::Device*>& devices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Joystick* js = new Joystick(/*&*i, */js_device, name_counts[i->tszInstanceName]++);
|
Joystick* js = new Joystick(/*&*i, */js_device, name_counts[joystick.tszInstanceName]++);
|
||||||
// only add if it has some inputs/outputs
|
// only add if it has some inputs/outputs
|
||||||
if (js->Inputs().size() || js->Outputs().size())
|
if (js->Inputs().size() || js->Outputs().size())
|
||||||
devices.push_back(js);
|
devices.push_back(js);
|
||||||
@ -359,14 +356,11 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
|
|||||||
Joystick::~Joystick()
|
Joystick::~Joystick()
|
||||||
{
|
{
|
||||||
// release the ff effect iface's
|
// release the ff effect iface's
|
||||||
std::list<EffectState>::iterator
|
for (EffectState& state : m_state_out)
|
||||||
i = m_state_out.begin(),
|
|
||||||
e = m_state_out.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
{
|
{
|
||||||
i->iface->Stop();
|
state.iface->Stop();
|
||||||
i->iface->Unload();
|
state.iface->Unload();
|
||||||
i->iface->Release();
|
state.iface->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->Unacquire();
|
m_device->Unacquire();
|
||||||
@ -377,7 +371,7 @@ void Joystick::ClearInputState()
|
|||||||
{
|
{
|
||||||
ZeroMemory(&m_state_in, sizeof(m_state_in));
|
ZeroMemory(&m_state_in, sizeof(m_state_in));
|
||||||
// set hats to center
|
// set hats to center
|
||||||
memset( m_state_in.rgdwPOV, 0xFF, sizeof(m_state_in.rgdwPOV) );
|
memset(m_state_in.rgdwPOV, 0xFF, sizeof(m_state_in.rgdwPOV));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Joystick::GetName() const
|
std::string Joystick::GetName() const
|
||||||
@ -449,26 +443,23 @@ bool Joystick::UpdateOutput()
|
|||||||
eff.dwSize = sizeof(DIEFFECT);
|
eff.dwSize = sizeof(DIEFFECT);
|
||||||
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
|
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
|
||||||
|
|
||||||
std::list<EffectState>::iterator
|
for (EffectState& state : m_state_out)
|
||||||
i = m_state_out.begin(),
|
|
||||||
e = m_state_out.end();
|
|
||||||
for (; i!=e; ++i)
|
|
||||||
{
|
{
|
||||||
if (i->params)
|
if (state.params)
|
||||||
{
|
{
|
||||||
if (i->size)
|
if (state.size)
|
||||||
{
|
{
|
||||||
eff.cbTypeSpecificParams = i->size;
|
eff.cbTypeSpecificParams = state.size;
|
||||||
eff.lpvTypeSpecificParams = i->params;
|
eff.lpvTypeSpecificParams = state.params;
|
||||||
// set params and start effect
|
// set params and start effect
|
||||||
ok_count += SUCCEEDED(i->iface->SetParameters(&eff, DIEP_TYPESPECIFICPARAMS | DIEP_START));
|
ok_count += SUCCEEDED(state.iface->SetParameters(&eff, DIEP_TYPESPECIFICPARAMS | DIEP_START));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ok_count += SUCCEEDED(i->iface->Stop());
|
ok_count += SUCCEEDED(state.iface->Stop());
|
||||||
}
|
}
|
||||||
|
|
||||||
i->params = NULL;
|
state.params = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -540,6 +531,7 @@ ControlState Joystick::Hat::GetState() const
|
|||||||
// hat centered code from MSDN
|
// hat centered code from MSDN
|
||||||
if (0xFFFF == LOWORD(m_hat))
|
if (0xFFFF == LOWORD(m_hat))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (abs((int)(m_hat / 4500 - m_direction * 2 + 8) % 8 - 4) > 2);
|
return (abs((int)(m_hat / 4500 - m_direction * 2 + 8) % 8 - 4) > 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ private:
|
|||||||
{
|
{
|
||||||
EffectState(LPDIRECTINPUTEFFECT eff) : iface(eff), params(NULL), size(0) {}
|
EffectState(LPDIRECTINPUTEFFECT eff) : iface(eff), params(NULL), size(0) {}
|
||||||
|
|
||||||
LPDIRECTINPUTEFFECT iface;
|
LPDIRECTINPUTEFFECT iface;
|
||||||
void* params; // null when force hasn't changed
|
void* params; // null when force hasn't changed
|
||||||
u8 size; // zero when force should stop
|
u8 size; // zero when force should stop
|
||||||
};
|
};
|
||||||
|
|
||||||
class Button : public Input
|
class Button : public Input
|
||||||
@ -76,9 +76,9 @@ private:
|
|||||||
P params;
|
P params;
|
||||||
const u8 m_index;
|
const u8 m_index;
|
||||||
};
|
};
|
||||||
typedef Force<DICONSTANTFORCE> ForceConstant;
|
typedef Force<DICONSTANTFORCE> ForceConstant;
|
||||||
typedef Force<DIRAMPFORCE> ForceRamp;
|
typedef Force<DIRAMPFORCE> ForceRamp;
|
||||||
typedef Force<DIPERIODIC> ForcePeriodic;
|
typedef Force<DIPERIODIC> ForcePeriodic;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool UpdateInput();
|
bool UpdateInput();
|
||||||
@ -94,13 +94,13 @@ public:
|
|||||||
std::string GetSource() const;
|
std::string GetSource() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const LPDIRECTINPUTDEVICE8 m_device;
|
const LPDIRECTINPUTDEVICE8 m_device;
|
||||||
const unsigned int m_index;
|
const unsigned int m_index;
|
||||||
|
|
||||||
DIJOYSTATE m_state_in;
|
DIJOYSTATE m_state_in;
|
||||||
std::list<EffectState> m_state_out;
|
std::list<EffectState> m_state_out;
|
||||||
|
|
||||||
bool m_buffered;
|
bool m_buffered;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
// (lower would be more sensitive) user can lower sensitivity by setting range
|
// (lower would be more sensitive) user can lower sensitivity by setting range
|
||||||
// seems decent here ( at 8 ), I don't think anyone would need more sensitive than this
|
// seems decent here ( at 8 ), I don't think anyone would need more sensitive than this
|
||||||
// and user can lower it much farther than they would want to with the range
|
// and user can lower it much farther than they would want to with the range
|
||||||
#define MOUSE_AXIS_SENSITIVITY 8
|
#define MOUSE_AXIS_SENSITIVITY 8
|
||||||
|
|
||||||
// if input hasn't been received for this many ms, mouse input will be skipped
|
// if input hasn't been received for this many ms, mouse input will be skipped
|
||||||
// otherwise it is just some crazy value
|
// otherwise it is just some crazy value
|
||||||
#define DROP_INPUT_TIME 250
|
#define DROP_INPUT_TIME 250
|
||||||
|
|
||||||
namespace ciface
|
namespace ciface
|
||||||
{
|
{
|
||||||
@ -18,8 +18,8 @@ namespace DInput
|
|||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
const BYTE code;
|
const BYTE code;
|
||||||
const char* const name;
|
const char* const name;
|
||||||
} named_keys[] =
|
} named_keys[] =
|
||||||
{
|
{
|
||||||
#include "NamedKeys.h"
|
#include "NamedKeys.h"
|
||||||
@ -27,8 +27,8 @@ static const struct
|
|||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
const BYTE code;
|
const BYTE code;
|
||||||
const char* const name;
|
const char* const name;
|
||||||
} named_lights[] =
|
} named_lights[] =
|
||||||
{
|
{
|
||||||
{ VK_NUMLOCK, "NUM LOCK" },
|
{ VK_NUMLOCK, "NUM LOCK" },
|
||||||
|
@ -21,8 +21,8 @@ class KeyboardMouse : public Core::Device
|
|||||||
private:
|
private:
|
||||||
struct State
|
struct State
|
||||||
{
|
{
|
||||||
BYTE keyboard[256];
|
BYTE keyboard[256];
|
||||||
DIMOUSESTATE2 mouse;
|
DIMOUSESTATE2 mouse;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
float x, y;
|
float x, y;
|
||||||
@ -98,13 +98,13 @@ public:
|
|||||||
std::string GetSource() const;
|
std::string GetSource() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const LPDIRECTINPUTDEVICE8 m_kb_device;
|
const LPDIRECTINPUTDEVICE8 m_kb_device;
|
||||||
const LPDIRECTINPUTDEVICE8 m_mo_device;
|
const LPDIRECTINPUTDEVICE8 m_mo_device;
|
||||||
|
|
||||||
DWORD m_last_update;
|
DWORD m_last_update;
|
||||||
State m_state_in;
|
State m_state_in;
|
||||||
unsigned char m_state_out[3]; // NUM CAPS SCROLL
|
unsigned char m_state_out[3]; // NUM CAPS SCROLL
|
||||||
bool m_current_state_out[3]; // NUM CAPS SCROLL
|
bool m_current_state_out[3]; // NUM CAPS SCROLL
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,29 +10,19 @@ namespace Core
|
|||||||
{
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// Device :: ~Device
|
// Device :: ~Device
|
||||||
//
|
//
|
||||||
// Destructor, delete all inputs/outputs on device destruction
|
// Destructor, delete all inputs/outputs on device destruction
|
||||||
//
|
//
|
||||||
Device::~Device()
|
Device::~Device()
|
||||||
{
|
{
|
||||||
{
|
|
||||||
// delete inputs
|
// delete inputs
|
||||||
std::vector<Device::Input*>::iterator
|
for (Device::Input* input : m_inputs)
|
||||||
i = m_inputs.begin(),
|
delete input;
|
||||||
e = m_inputs.end();
|
|
||||||
for ( ;i!=e; ++i)
|
|
||||||
delete *i;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
// delete outputs
|
// delete outputs
|
||||||
std::vector<Device::Output*>::iterator
|
for (Device::Output* output: m_outputs)
|
||||||
o = m_outputs.begin(),
|
delete output;
|
||||||
e = m_outputs.end();
|
|
||||||
for ( ;o!=e; ++o)
|
|
||||||
delete *o;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::AddInput(Device::Input* const i)
|
void Device::AddInput(Device::Input* const i)
|
||||||
@ -47,30 +37,28 @@ void Device::AddOutput(Device::Output* const o)
|
|||||||
|
|
||||||
Device::Input* Device::FindInput(const std::string &name) const
|
Device::Input* Device::FindInput(const std::string &name) const
|
||||||
{
|
{
|
||||||
std::vector<Input*>::const_iterator
|
for (Input* input : m_inputs)
|
||||||
it = m_inputs.begin(),
|
{
|
||||||
itend = m_inputs.end();
|
if (input->GetName() == name)
|
||||||
for (; it != itend; ++it)
|
return input;
|
||||||
if ((*it)->GetName() == name)
|
}
|
||||||
return *it;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::Output* Device::FindOutput(const std::string &name) const
|
Device::Output* Device::FindOutput(const std::string &name) const
|
||||||
{
|
{
|
||||||
std::vector<Output*>::const_iterator
|
for (Output* output : m_outputs)
|
||||||
it = m_outputs.begin(),
|
{
|
||||||
itend = m_outputs.end();
|
if (output->GetName() == name)
|
||||||
for (; it != itend; ++it)
|
return output;
|
||||||
if ((*it)->GetName() == name)
|
}
|
||||||
return *it;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Device :: ClearInputState
|
// Device :: ClearInputState
|
||||||
//
|
//
|
||||||
// Device classes should override this function
|
// Device classes should override this function
|
||||||
// ControllerInterface will call this when the device returns failure during UpdateInput
|
// ControllerInterface will call this when the device returns failure during UpdateInput
|
||||||
@ -84,26 +72,28 @@ void Device::ClearInputState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// DeviceQualifier :: ToString
|
// DeviceQualifier :: ToString
|
||||||
//
|
//
|
||||||
// get string from a device qualifier / serialize
|
// Get string from a device qualifier / serialize
|
||||||
//
|
//
|
||||||
std::string DeviceQualifier::ToString() const
|
std::string DeviceQualifier::ToString() const
|
||||||
{
|
{
|
||||||
if (source.empty() && (cid < 0) && name.empty())
|
if (source.empty() && (cid < 0) && name.empty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << source << '/';
|
ss << source << '/';
|
||||||
if ( cid > -1 )
|
if (cid > -1)
|
||||||
ss << cid;
|
ss << cid;
|
||||||
ss << '/' << name;
|
ss << '/' << name;
|
||||||
|
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// DeviceQualifier :: FromString
|
// DeviceQualifier :: FromString
|
||||||
//
|
//
|
||||||
// set a device qualifier from a string / unserialize
|
// Set a device qualifier from a string / unserialize
|
||||||
//
|
//
|
||||||
void DeviceQualifier::FromString(const std::string& str)
|
void DeviceQualifier::FromString(const std::string& str)
|
||||||
{
|
{
|
||||||
@ -119,9 +109,9 @@ void DeviceQualifier::FromString(const std::string& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// DeviceQualifier :: FromDevice
|
// DeviceQualifier :: FromDevice
|
||||||
//
|
//
|
||||||
// set a device qualifier from a device
|
// Set a device qualifier from a device
|
||||||
//
|
//
|
||||||
void DeviceQualifier::FromDevice(const Device* const dev)
|
void DeviceQualifier::FromDevice(const Device* const dev)
|
||||||
{
|
{
|
||||||
@ -136,6 +126,7 @@ bool DeviceQualifier::operator==(const Device* const dev) const
|
|||||||
if (dev->GetName() == name)
|
if (dev->GetName() == name)
|
||||||
if (dev->GetSource() == source)
|
if (dev->GetSource() == source)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,12 +142,11 @@ bool DeviceQualifier::operator==(const DeviceQualifier& devq) const
|
|||||||
|
|
||||||
Device* DeviceContainer::FindDevice(const DeviceQualifier& devq) const
|
Device* DeviceContainer::FindDevice(const DeviceQualifier& devq) const
|
||||||
{
|
{
|
||||||
std::vector<Device*>::const_iterator
|
for (Device* d : m_devices)
|
||||||
di = m_devices.begin(),
|
{
|
||||||
de = m_devices.end();
|
if (devq == d)
|
||||||
for (; di!=de; ++di)
|
return d;
|
||||||
if (devq == *di)
|
}
|
||||||
return *di;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -170,12 +160,9 @@ Device::Input* DeviceContainer::FindInput(const std::string& name, const Device*
|
|||||||
return inp;
|
return inp;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Device*>::const_iterator
|
for (Device* d : m_devices)
|
||||||
di = m_devices.begin(),
|
|
||||||
de = m_devices.end();
|
|
||||||
for (; di != de; ++di)
|
|
||||||
{
|
{
|
||||||
Device::Input* const i = (*di)->FindInput(name);
|
Device::Input* const i = d->FindInput(name);
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
return i;
|
return i;
|
||||||
|
@ -19,9 +19,9 @@ namespace Core
|
|||||||
class DeviceQualifier;
|
class DeviceQualifier;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Device
|
// Device
|
||||||
//
|
//
|
||||||
// a device class
|
// A device class
|
||||||
//
|
//
|
||||||
class Device
|
class Device
|
||||||
{
|
{
|
||||||
@ -30,11 +30,11 @@ public:
|
|||||||
class Output;
|
class Output;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Control
|
// Control
|
||||||
//
|
//
|
||||||
// control includes inputs and outputs
|
// Control includes inputs and outputs
|
||||||
//
|
//
|
||||||
class Control // input or output
|
class Control // input or output
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
@ -45,9 +45,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Input
|
// Input
|
||||||
//
|
//
|
||||||
// an input on a device
|
// An input on a device
|
||||||
//
|
//
|
||||||
class Input : public Control
|
class Input : public Control
|
||||||
{
|
{
|
||||||
@ -61,9 +61,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Output
|
// Output
|
||||||
//
|
//
|
||||||
// an output on a device
|
// An output on a device
|
||||||
//
|
//
|
||||||
class Output : public Control
|
class Output : public Control
|
||||||
{
|
{
|
||||||
@ -126,15 +126,15 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Input*> m_inputs;
|
std::vector<Input*> m_inputs;
|
||||||
std::vector<Output*> m_outputs;
|
std::vector<Output*> m_outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// DeviceQualifier
|
// DeviceQualifier
|
||||||
//
|
//
|
||||||
// device qualifier used to match devices
|
// Device qualifier used to match devices.
|
||||||
// currently has ( source, id, name ) properties which match a device
|
// Currently has ( source, id, name ) properties which match a device
|
||||||
//
|
//
|
||||||
class DeviceQualifier
|
class DeviceQualifier
|
||||||
{
|
{
|
||||||
@ -148,9 +148,9 @@ public:
|
|||||||
bool operator==(const DeviceQualifier& devq) const;
|
bool operator==(const DeviceQualifier& devq) const;
|
||||||
bool operator==(const Device* const dev) const;
|
bool operator==(const Device* const dev) const;
|
||||||
|
|
||||||
std::string source;
|
std::string source;
|
||||||
int cid;
|
int cid;
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeviceContainer
|
class DeviceContainer
|
||||||
|
@ -27,16 +27,16 @@
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned short button; // Or-ed PAD_BUTTON_* and PAD_TRIGGER_* bits
|
unsigned short button; // Or-ed PAD_BUTTON_* and PAD_TRIGGER_* bits
|
||||||
unsigned char stickX; // 0 <= stickX <= 255
|
unsigned char stickX; // 0 <= stickX <= 255
|
||||||
unsigned char stickY; // 0 <= stickY <= 255
|
unsigned char stickY; // 0 <= stickY <= 255
|
||||||
unsigned char substickX; // 0 <= substickX <= 255
|
unsigned char substickX; // 0 <= substickX <= 255
|
||||||
unsigned char substickY; // 0 <= substickY <= 255
|
unsigned char substickY; // 0 <= substickY <= 255
|
||||||
unsigned char triggerLeft; // 0 <= triggerLeft <= 255
|
unsigned char triggerLeft; // 0 <= triggerLeft <= 255
|
||||||
unsigned char triggerRight; // 0 <= triggerRight <= 255
|
unsigned char triggerRight; // 0 <= triggerRight <= 255
|
||||||
unsigned char analogA; // 0 <= analogA <= 255
|
unsigned char analogA; // 0 <= analogA <= 255
|
||||||
unsigned char analogB; // 0 <= analogB <= 255
|
unsigned char analogB; // 0 <= analogB <= 255
|
||||||
signed char err; // one of PAD_ERR_* number
|
signed char err; // one of PAD_ERR_* number
|
||||||
} SPADStatus;
|
} SPADStatus;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,10 +10,8 @@
|
|||||||
InputPlugin::~InputPlugin()
|
InputPlugin::~InputPlugin()
|
||||||
{
|
{
|
||||||
// delete pads
|
// delete pads
|
||||||
std::vector<ControllerEmu*>::const_iterator i = controllers.begin(),
|
for (ControllerEmu* pad : controllers)
|
||||||
e = controllers.end();
|
delete pad;
|
||||||
for ( ; i != e; ++i )
|
|
||||||
delete *i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputPlugin::LoadConfig(bool isGC)
|
bool InputPlugin::LoadConfig(bool isGC)
|
||||||
@ -58,25 +56,26 @@ bool InputPlugin::LoadConfig(bool isGC)
|
|||||||
|
|
||||||
if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini"))
|
if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini"))
|
||||||
{
|
{
|
||||||
std::vector< ControllerEmu* >::const_iterator
|
int n = 0;
|
||||||
i = controllers.begin(),
|
for (ControllerEmu* pad : controllers)
|
||||||
e = controllers.end();
|
|
||||||
for (int n = 0; i!=e; ++i, ++n)
|
|
||||||
{
|
{
|
||||||
// load settings from ini
|
// Load settings from ini
|
||||||
if (useProfile[n])
|
if (useProfile[n])
|
||||||
{
|
{
|
||||||
IniFile profile_ini;
|
IniFile profile_ini;
|
||||||
profile_ini.Load(File::GetUserPath(D_CONFIG_IDX) + path + profile[n] + ".ini");
|
profile_ini.Load(File::GetUserPath(D_CONFIG_IDX) + path + profile[n] + ".ini");
|
||||||
(*i)->LoadConfig(profile_ini.GetOrCreateSection("Profile"));
|
pad->LoadConfig(profile_ini.GetOrCreateSection("Profile"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
pad->LoadConfig(inifile.GetOrCreateSection(pad->GetName().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// update refs
|
// Update refs
|
||||||
(*i)->UpdateReferences(g_controller_interface);
|
pad->UpdateReferences(g_controller_interface);
|
||||||
|
|
||||||
|
// Next profile
|
||||||
|
n++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -95,10 +94,8 @@ void InputPlugin::SaveConfig()
|
|||||||
IniFile inifile;
|
IniFile inifile;
|
||||||
inifile.Load(ini_filename);
|
inifile.Load(ini_filename);
|
||||||
|
|
||||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
for (ControllerEmu* pad : controllers)
|
||||||
e = controllers.end();
|
pad->SaveConfig(inifile.GetOrCreateSection(pad->GetName().c_str()));
|
||||||
for ( ; i!=e; ++i )
|
|
||||||
(*i)->SaveConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
|
||||||
|
|
||||||
inifile.Save(ini_filename);
|
inifile.Save(ini_filename);
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,13 @@ public:
|
|||||||
bool LoadConfig(bool isGC);
|
bool LoadConfig(bool isGC);
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
|
|
||||||
std::vector< ControllerEmu* > controllers;
|
std::vector<ControllerEmu*> controllers;
|
||||||
|
|
||||||
std::recursive_mutex controls_lock; // for changing any control references
|
std::recursive_mutex controls_lock; // for changing any control references
|
||||||
|
|
||||||
const char * const ini_name;
|
const char* const ini_name;
|
||||||
const char * const gui_name;
|
const char* const gui_name;
|
||||||
const char * const profile_name;
|
const char* const profile_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user