Add jstick member functions missing on Windows implementation.
This commit is contained in:
@@ -49,8 +49,7 @@ namespace jstick {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum class XBoxButton : uint8_t
|
enum class XBoxButton : uint8_t {
|
||||||
{
|
|
||||||
ButtonA = 0,
|
ButtonA = 0,
|
||||||
ButtonB = 1,
|
ButtonB = 1,
|
||||||
ButtonX = 2,
|
ButtonX = 2,
|
||||||
@@ -62,7 +61,6 @@ namespace jstick {
|
|||||||
TheBigOne = 8,
|
TheBigOne = 8,
|
||||||
ThumbL = 9,
|
ThumbL = 9,
|
||||||
ThumbR = 10,
|
ThumbR = 10,
|
||||||
|
|
||||||
DPadDown = 11,
|
DPadDown = 11,
|
||||||
DPadRight = 12,
|
DPadRight = 12,
|
||||||
DPadUp = 13,
|
DPadUp = 13,
|
||||||
@@ -72,27 +70,26 @@ namespace jstick {
|
|||||||
/// This event is fired when a new joystick device is detected.
|
/// This event is fired when a new joystick device is detected.
|
||||||
// TODO: Call JoystickConnected for each device found on library runtime start.
|
// TODO: Call JoystickConnected for each device found on library runtime start.
|
||||||
inline Event<int> JoystickConnected;
|
inline Event<int> JoystickConnected;
|
||||||
|
|
||||||
/// This event is fired when a joystick device is unplugged or otherwise dropped.
|
/// This event is fired when a joystick device is unplugged or otherwise dropped.
|
||||||
inline Event<int> JoystickDisconnected;
|
inline Event<int> JoystickDisconnected;
|
||||||
|
|
||||||
/// This event is fired when a joystick button is pressed.
|
/// This event is fired when a joystick button is pressed.
|
||||||
inline Event<XBoxButton> ButtonPressed;
|
inline Event<XBoxButton> ButtonPressed;
|
||||||
|
|
||||||
/// This event is fired when a xbox button is pressed.
|
/// This event is fired when a xbox button is pressed.
|
||||||
inline Event<XBoxButton> ButtonReleased;
|
inline Event<XBoxButton> ButtonReleased;
|
||||||
|
///
|
||||||
inline Event<Vector2> LeftThumbstickMoved;
|
inline Event<Vector2> LeftThumbstickMoved;
|
||||||
|
///
|
||||||
inline Event<Vector2> RightThumbstickMoved;
|
inline Event<Vector2> RightThumbstickMoved;
|
||||||
|
///
|
||||||
inline Event<Vector2> DPadMoved;
|
inline Event<Vector2> DPadMoved;
|
||||||
|
///
|
||||||
inline Event<short> LeftTriggerMoved;
|
inline Event<short> LeftTriggerMoved;
|
||||||
|
///
|
||||||
inline Event<short> RightTriggerMoved;
|
inline Event<short> RightTriggerMoved;
|
||||||
//Event<int, JoystickAxis> AxisMoved;
|
|
||||||
|
|
||||||
|
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
bool Cleanup();
|
bool Cleanup();
|
||||||
|
|
||||||
|
|
||||||
/// @return true if the input system treats the DPad as a Vector2 axis, or false if treated as four buttons.
|
/// @return true if the input system treats the DPad as a Vector2 axis, or false if treated as four buttons.
|
||||||
bool GetDPadIsAxisOrButtons();
|
bool GetDPadIsAxisOrButtons();
|
||||||
|
|
||||||
|
@@ -22,6 +22,25 @@ bool jstick::Cleanup() { return true; }
|
|||||||
|
|
||||||
void jstick::JoystickServiceUpdate() { }
|
void jstick::JoystickServiceUpdate() { }
|
||||||
|
|
||||||
|
// XInput cannot tell us what type of device it is, so assume it's a legitimate Microsoft XB360 controller.
|
||||||
|
std::string jstick::GetDeviceName(int hwid) { return "Microsoft X-Box 360 pad"; }
|
||||||
|
|
||||||
|
jstick::ControllerType jstick::GetDeviceTypeFromName(const std::string &name) {
|
||||||
|
// On Windows, we assume the standard controller, we have no way of knowing specifics currently.
|
||||||
|
// ~josh.
|
||||||
|
return ControllerType::XBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
int jstick::NumJoysticksDetected() {
|
||||||
|
// TODO: Check it properly!!
|
||||||
|
if (JoystickDetected())
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector2 jstick::GetDPadAxis(float deadzone, int hwid)
|
Vector2 jstick::GetDPadAxis(float deadzone, int hwid)
|
||||||
{
|
{
|
||||||
// "Synthesize" a DPad vector based upon whether the buttons are pressed.
|
// "Synthesize" a DPad vector based upon whether the buttons are pressed.
|
||||||
@@ -150,6 +169,17 @@ Vector2 jstick::GetRightThumbstickAxis(float deadzone, int hwid)
|
|||||||
return Vector2(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY);
|
return Vector2(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int jstick::Connect(int hwid)
|
||||||
|
{
|
||||||
|
return hwid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool jstick::Disconnect(int hwid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool jstick::Connected(int hwid) { return true; }
|
||||||
|
|
||||||
Vector2 jstick::GetRightThumbstickAxisNormalized(float deadzone, int hwid)
|
Vector2 jstick::GetRightThumbstickAxisNormalized(float deadzone, int hwid)
|
||||||
{
|
{
|
||||||
Vector2 axisL = jstick::GetLeftThumbstickAxis(deadzone, hwid);
|
Vector2 axisL = jstick::GetLeftThumbstickAxis(deadzone, hwid);
|
||||||
|
Reference in New Issue
Block a user