mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-29 15:26:35 +00:00
Clean up all the GetName methods for XInput2 controls.
This commit is contained in:
parent
9fbc5ff27c
commit
fe2fe8b6cc
2 changed files with 29 additions and 38 deletions
|
@ -340,48 +340,39 @@ ControlState KeyboardMouse::Key::GetState() const
|
||||||
return (m_keyboard[m_keycode / 8] & (1 << (m_keycode % 8))) != 0;
|
return (m_keyboard[m_keycode / 8] & (1 << (m_keycode % 8))) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons)
|
||||||
|
: m_buttons(buttons), m_index(index)
|
||||||
|
{
|
||||||
|
// this will be a problem if we remove the hardcoded five-button limit
|
||||||
|
name = std::string("Click ") + (char)('1' + m_index);
|
||||||
|
}
|
||||||
|
|
||||||
ControlState KeyboardMouse::Button::GetState() const
|
ControlState KeyboardMouse::Button::GetState() const
|
||||||
{
|
{
|
||||||
return ((m_buttons & (1 << m_index)) != 0);
|
return ((m_buttons & (1 << m_index)) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float& cursor)
|
||||||
|
: m_cursor(cursor), m_index(index), m_positive(positive)
|
||||||
|
{
|
||||||
|
name = std::string("Cursor ") + (char)('X' + m_index) + (m_positive ? '+' : '-');
|
||||||
|
}
|
||||||
|
|
||||||
ControlState KeyboardMouse::Cursor::GetState() const
|
ControlState KeyboardMouse::Cursor::GetState() const
|
||||||
{
|
{
|
||||||
return std::max(0.0f, m_cursor / (m_positive ? 1.0f : -1.0f));
|
return std::max(0.0f, m_cursor / (m_positive ? 1.0f : -1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyboardMouse::Axis::Axis(u8 index, bool positive, const float& axis)
|
||||||
|
: m_axis(axis), m_index(index), m_positive(positive)
|
||||||
|
{
|
||||||
|
name = std::string("Axis ") + (char)('X' + m_index) + (m_positive ? '+' : '-');
|
||||||
|
}
|
||||||
|
|
||||||
ControlState KeyboardMouse::Axis::GetState() const
|
ControlState KeyboardMouse::Axis::GetState() const
|
||||||
{
|
{
|
||||||
return std::max(0.0f, m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY));
|
return std::max(0.0f, m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string KeyboardMouse::Key::GetName() const
|
|
||||||
{
|
|
||||||
return m_keyname;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string KeyboardMouse::Cursor::GetName() const
|
|
||||||
{
|
|
||||||
static char tmpstr[] = "Cursor ..";
|
|
||||||
tmpstr[7] = (char)('X' + m_index);
|
|
||||||
tmpstr[8] = (m_positive ? '+' : '-');
|
|
||||||
return tmpstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string KeyboardMouse::Axis::GetName() const
|
|
||||||
{
|
|
||||||
static char tmpstr[] = "Axis ..";
|
|
||||||
tmpstr[5] = (char)('X' + m_index);
|
|
||||||
tmpstr[6] = (m_positive ? '+' : '-');
|
|
||||||
return tmpstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string KeyboardMouse::Button::GetName() const
|
|
||||||
{
|
|
||||||
static char tmpstr[] = "Click .";
|
|
||||||
tmpstr[6] = m_index + '1';
|
|
||||||
return tmpstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ private:
|
||||||
{
|
{
|
||||||
friend class KeyboardMouse;
|
friend class KeyboardMouse;
|
||||||
public:
|
public:
|
||||||
std::string GetName() const;
|
std::string GetName() const { return m_keyname; }
|
||||||
Key(Display* display, KeyCode keycode, const char* keyboard);
|
Key(Display* display, KeyCode keycode, const char* keyboard);
|
||||||
ControlState GetState() const;
|
ControlState GetState() const;
|
||||||
|
|
||||||
|
@ -54,44 +54,44 @@ private:
|
||||||
class Button : public Input
|
class Button : public Input
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string GetName() const;
|
std::string GetName() const { return name; }
|
||||||
Button(unsigned int index, unsigned int& buttons)
|
Button(unsigned int index, unsigned int& buttons);
|
||||||
: m_buttons(buttons), m_index(index) {}
|
|
||||||
ControlState GetState() const;
|
ControlState GetState() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const unsigned int& m_buttons;
|
const unsigned int& m_buttons;
|
||||||
const unsigned int m_index;
|
const unsigned int m_index;
|
||||||
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cursor : public Input
|
class Cursor : public Input
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string GetName() const;
|
std::string GetName() const { return name; }
|
||||||
bool IsDetectable() { return false; }
|
bool IsDetectable() { return false; }
|
||||||
Cursor(u8 index, bool positive, const float& cursor)
|
Cursor(u8 index, bool positive, const float& cursor);
|
||||||
: m_cursor(cursor), m_index(index), m_positive(positive) {}
|
|
||||||
ControlState GetState() const;
|
ControlState GetState() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const float& m_cursor;
|
const float& m_cursor;
|
||||||
const u8 m_index;
|
const u8 m_index;
|
||||||
const bool m_positive;
|
const bool m_positive;
|
||||||
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Axis : public Input
|
class Axis : public Input
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string GetName() const;
|
std::string GetName() const { return name; }
|
||||||
bool IsDetectable() { return false; }
|
bool IsDetectable() { return false; }
|
||||||
Axis(u8 index, bool positive, const float& axis)
|
Axis(u8 index, bool positive, const float& axis);
|
||||||
: m_axis(axis), m_index(index), m_positive(positive) {}
|
|
||||||
ControlState GetState() const;
|
ControlState GetState() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const float& m_axis;
|
const float& m_axis;
|
||||||
const u8 m_index;
|
const u8 m_index;
|
||||||
const bool m_positive;
|
const bool m_positive;
|
||||||
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue