mirror of
https://github.com/cathery/sys-con.git
synced 2024-10-06 06:19:43 +00:00
Closes #2
This commit is contained in:
parent
82e6eca5ab
commit
e85483e122
@ -29,7 +29,7 @@ If you want to make sure, the file should be located in `sdmc:/atmosphere/titles
|
|||||||
- [ ] **[Dualshock 3 Support](https://github.com/cathery/sys-con/issues/3)**
|
- [ ] **[Dualshock 3 Support](https://github.com/cathery/sys-con/issues/3)**
|
||||||
- [ ] **[Dualshock 4 Support](https://github.com/cathery/sys-con/issues/4)**
|
- [ ] **[Dualshock 4 Support](https://github.com/cathery/sys-con/issues/4)**
|
||||||
- [ ] **Config application**
|
- [ ] **Config application**
|
||||||
- [ ] **[\[5.0.0-7.0.0\] FW Version Support](https://github.com/cathery/sys-con/issues/2)**
|
- [x] **~~[\[5.0.0-7.0.0\] FW Version Support](https://github.com/cathery/sys-con/issues/2)~~**
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/H2H316ZQV)
|
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/H2H316ZQV)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "SwitchAbstractedPadHandler.h"
|
#include "SwitchAbstractedPadHandler.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
SwitchAbstractedPadHandler::SwitchAbstractedPadHandler(std::unique_ptr<IController> &&controller)
|
SwitchAbstractedPadHandler::SwitchAbstractedPadHandler(std::unique_ptr<IController> &&controller)
|
||||||
: SwitchVirtualGamepadHandler(std::move(controller))
|
: SwitchVirtualGamepadHandler(std::move(controller))
|
||||||
@ -33,17 +34,32 @@ void SwitchAbstractedPadHandler::Exit()
|
|||||||
//ExitRumbleThread();
|
//ExitRumbleThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Used to give out unique ids to abstracted pads
|
||||||
|
static std::array<bool, 8> uniqueIDs{false};
|
||||||
|
|
||||||
|
static s8 getUniqueId()
|
||||||
|
{
|
||||||
|
for (s8 i = 0; i != 8; ++i)
|
||||||
|
{
|
||||||
|
if (uniqueIDs[i] == false)
|
||||||
|
{
|
||||||
|
uniqueIDs[i] = true;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void freeUniqueId(s8 id)
|
||||||
|
{
|
||||||
|
uniqueIDs[id] = false;
|
||||||
|
}
|
||||||
|
|
||||||
Result SwitchAbstractedPadHandler::InitAbstractedPadState()
|
Result SwitchAbstractedPadHandler::InitAbstractedPadState()
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
/*
|
|
||||||
u64 pads[8] = {0};
|
|
||||||
HiddbgAbstractedPadState states[8] = {0};
|
|
||||||
s32 tmpout = 0;
|
|
||||||
rc = hiddbgGetAbstractedPadsState(pads, states, sizeof(pads) / sizeof(u64), &tmpout);
|
|
||||||
*/
|
|
||||||
m_state = {0};
|
m_state = {0};
|
||||||
m_abstractedPadID = 0;
|
m_abstractedPadID = getUniqueId();
|
||||||
m_state.type = BIT(0);
|
m_state.type = BIT(0);
|
||||||
m_state.npadInterfaceType = NpadInterfaceType_USB;
|
m_state.npadInterfaceType = NpadInterfaceType_USB;
|
||||||
m_state.flags = 0xff;
|
m_state.flags = 0xff;
|
||||||
@ -56,31 +72,11 @@ Result SwitchAbstractedPadHandler::InitAbstractedPadState()
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
/*
|
|
||||||
m_hdlHandle = 0;
|
|
||||||
m_deviceInfo = {0};
|
|
||||||
m_hdlState = {0};
|
|
||||||
|
|
||||||
// Set the controller type to Pro-Controller, and set the npadInterfaceType.
|
|
||||||
m_deviceInfo.deviceType = HidDeviceType_FullKey3;
|
|
||||||
m_deviceInfo.npadInterfaceType = NpadInterfaceType_USB;
|
|
||||||
// Set the controller colors. The grip colors are for Pro-Controller on [9.0.0+].
|
|
||||||
m_deviceInfo.singleColorBody = RGBA8_MAXALPHA(107, 107, 107);
|
|
||||||
m_deviceInfo.singleColorButtons = RGBA8_MAXALPHA(0, 0, 0);
|
|
||||||
m_deviceInfo.colorLeftGrip = RGBA8_MAXALPHA(23, 125, 62);
|
|
||||||
m_deviceInfo.colorRightGrip = RGBA8_MAXALPHA(23, 125, 62);
|
|
||||||
|
|
||||||
m_hdlState.batteryCharge = 4; // Set battery charge to full.
|
|
||||||
m_hdlState.joysticks[JOYSTICK_LEFT].dx = 0x1234;
|
|
||||||
m_hdlState.joysticks[JOYSTICK_LEFT].dy = -0x1234;
|
|
||||||
m_hdlState.joysticks[JOYSTICK_RIGHT].dx = 0x5678;
|
|
||||||
m_hdlState.joysticks[JOYSTICK_RIGHT].dy = -0x5678;
|
|
||||||
|
|
||||||
return hiddbgAttachHdlsVirtualDevice(&m_hdlHandle, &m_deviceInfo);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result SwitchAbstractedPadHandler::ExitAbstractedPadState()
|
Result SwitchAbstractedPadHandler::ExitAbstractedPadState()
|
||||||
{
|
{
|
||||||
|
freeUniqueId(m_abstractedPadID);
|
||||||
return hiddbgUnsetAutoPilotVirtualPadState(m_abstractedPadID);
|
return hiddbgUnsetAutoPilotVirtualPadState(m_abstractedPadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,10 +88,6 @@ void SwitchAbstractedPadHandler::FillAbstractedState(const NormalizedButtonData
|
|||||||
m_state.state.buttons |= (data.top_action ? KEY_X : 0);
|
m_state.state.buttons |= (data.top_action ? KEY_X : 0);
|
||||||
m_state.state.buttons |= (data.left_action ? KEY_Y : 0);
|
m_state.state.buttons |= (data.left_action ? KEY_Y : 0);
|
||||||
|
|
||||||
//Breaks when buttons has a value of more than 25 or more
|
|
||||||
//if buttons is 0x2000 or more, it also calls a interface change event, breaking any possibility of disconnecting a controller properly
|
|
||||||
//None of this happens on the main thread, this is a problem only when running from a separate thread
|
|
||||||
/*
|
|
||||||
m_state.state.buttons |= (data.left_stick_click ? KEY_LSTICK : 0);
|
m_state.state.buttons |= (data.left_stick_click ? KEY_LSTICK : 0);
|
||||||
m_state.state.buttons |= (data.right_stick_click ? KEY_RSTICK : 0);
|
m_state.state.buttons |= (data.right_stick_click ? KEY_RSTICK : 0);
|
||||||
|
|
||||||
@ -112,7 +104,7 @@ void SwitchAbstractedPadHandler::FillAbstractedState(const NormalizedButtonData
|
|||||||
m_state.state.buttons |= (data.dpad_up ? KEY_DUP : 0);
|
m_state.state.buttons |= (data.dpad_up ? KEY_DUP : 0);
|
||||||
m_state.state.buttons |= (data.dpad_right ? KEY_DRIGHT : 0);
|
m_state.state.buttons |= (data.dpad_right ? KEY_DRIGHT : 0);
|
||||||
m_state.state.buttons |= (data.dpad_down ? KEY_DDOWN : 0);
|
m_state.state.buttons |= (data.dpad_down ? KEY_DDOWN : 0);
|
||||||
*/
|
|
||||||
m_controllerHandler.ConvertAxisToSwitchAxis(data.left_stick_x, data.left_stick_y, 0, &m_state.state.joysticks[JOYSTICK_LEFT].dx, &m_state.state.joysticks[JOYSTICK_LEFT].dy);
|
m_controllerHandler.ConvertAxisToSwitchAxis(data.left_stick_x, data.left_stick_y, 0, &m_state.state.joysticks[JOYSTICK_LEFT].dx, &m_state.state.joysticks[JOYSTICK_LEFT].dy);
|
||||||
m_controllerHandler.ConvertAxisToSwitchAxis(data.right_stick_x, data.right_stick_y, 0, &m_state.state.joysticks[JOYSTICK_RIGHT].dx, &m_state.state.joysticks[JOYSTICK_RIGHT].dy);
|
m_controllerHandler.ConvertAxisToSwitchAxis(data.right_stick_x, data.right_stick_y, 0, &m_state.state.joysticks[JOYSTICK_RIGHT].dx, &m_state.state.joysticks[JOYSTICK_RIGHT].dy);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "SwitchUSBDevice.h"
|
#include "SwitchUSBDevice.h"
|
||||||
#include "libnxFix.h"
|
|
||||||
#include <cstring> //for memset
|
#include <cstring> //for memset
|
||||||
#include "malloc.h" //for memalign
|
#include "malloc.h" //for memalign
|
||||||
|
|
||||||
@ -39,13 +38,8 @@ void SwitchUSBDevice::Reset()
|
|||||||
//I'm expecting all interfaces to point to one device decsriptor
|
//I'm expecting all interfaces to point to one device decsriptor
|
||||||
// as such resetting on any of them should do the trick
|
// as such resetting on any of them should do the trick
|
||||||
//TODO: needs testing
|
//TODO: needs testing
|
||||||
for (auto &&interface : m_interfaces)
|
if (m_interfaces.size() != 0)
|
||||||
{
|
m_interfaces[0]->Reset();
|
||||||
interface->Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (m_interfaces.size() != 0)
|
|
||||||
//m_interfaces[0]->Reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwitchUSBDevice::SetInterfaces(UsbHsInterface *interfaces, int length)
|
void SwitchUSBDevice::SetInterfaces(UsbHsInterface *interfaces, int length)
|
||||||
|
Loading…
Reference in New Issue
Block a user