Skip to content

Commit eee8f23

Browse files
committed
Update dependencies for 12.0.0 FW support
1 parent 28f9ce9 commit eee8f23

File tree

8 files changed

+88
-85
lines changed

8 files changed

+88
-85
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Instead, clone the repository **recursively** using any git client you have. (Gi
4545

4646
Like all other switch projects, you need to have [devkitA64](https://switchbrew.org/wiki/Setting_up_Development_Environment) set up on your system.
4747

48-
This project uses libnx version **3.3.0**.
48+
For compatibility with the Atmosphere-libs dependency, this project currently uses a version of libnx at commit **[0d32a2c](https://github.com/switchbrew/libnx/commit/0d32a2c0d5343fe212a0957420d285c0ef44fb36)**. Clone the repository, checkout to that commit, and run `make install` to set it up.
4949

5050
If you have **Visual Studio Code**, you can open the project as a folder and run the build tasks from inside the program. It also has Intellisense configured for switch development, if you have DEVKITPRO correctly defined in your environment variables. Handy!
5151

source/AppletCompanion/source/main.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,25 @@
33

44
int main()
55
{
6-
consoleInit(NULL);
7-
8-
printf("Hello\n");
9-
10-
while(appletMainLoop())
11-
{
12-
hidScanInput();
13-
u64 kDown = 0;
14-
for (u8 controller = 0; controller < 10; controller++)
15-
kDown |= hidKeysDown(static_cast<HidControllerID>(controller));
16-
17-
if (kDown & KEY_PLUS || kDown & KEY_B)
18-
break;
19-
consoleUpdate(NULL);
20-
}
6+
consoleInit(NULL);
217

22-
consoleExit(NULL);
23-
return 0;
8+
padConfigureInput(8, HidNpadStyleSet_NpadStandard);
9+
PadState pad;
10+
padInitializeAny(&pad);
11+
hidSetNpadHandheldActivationMode(HidNpadHandheldActivationMode_Single);
12+
13+
printf("Hello\n");
14+
15+
while (appletMainLoop())
16+
{
17+
padUpdate(&pad);
18+
u64 kDown = padGetButtonsDown(&pad);
19+
20+
if (kDown & HidNpadButton_Plus || kDown & HidNpadButton_B)
21+
break;
22+
consoleUpdate(NULL);
23+
}
24+
25+
consoleExit(NULL);
26+
return 0;
2427
}

source/ControllerSwitch/SwitchAbstractedPadHandler.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ Result SwitchAbstractedPadHandler::InitAbstractedPadState()
7373
m_state = {0};
7474
m_abstractedPadID = getUniqueId();
7575
m_state.type = BIT(0);
76-
m_state.npadInterfaceType = NpadInterfaceType_USB;
76+
m_state.npadInterfaceType = HidNpadInterfaceType_USB;
7777
m_state.flags = 0xff;
78-
m_state.state.batteryCharge = 4;
78+
m_state.state.battery_level = 4;
7979
ControllerConfig *config = GetController()->GetConfig();
8080
m_state.singleColorBody = config->bodyColor.rgbaValue;
8181
m_state.singleColorButtons = config->buttonsColor.rgbaValue;
@@ -96,31 +96,31 @@ Result SwitchAbstractedPadHandler::ExitAbstractedPadState()
9696
void SwitchAbstractedPadHandler::FillAbstractedState(const NormalizedButtonData &data)
9797
{
9898
m_state.state.buttons = 0;
99-
m_state.state.buttons |= (data.buttons[0] ? KEY_X : 0);
100-
m_state.state.buttons |= (data.buttons[1] ? KEY_A : 0);
101-
m_state.state.buttons |= (data.buttons[2] ? KEY_B : 0);
102-
m_state.state.buttons |= (data.buttons[3] ? KEY_Y : 0);
99+
m_state.state.buttons |= (data.buttons[0] ? HidNpadButton_X : 0);
100+
m_state.state.buttons |= (data.buttons[1] ? HidNpadButton_A : 0);
101+
m_state.state.buttons |= (data.buttons[2] ? HidNpadButton_B : 0);
102+
m_state.state.buttons |= (data.buttons[3] ? HidNpadButton_Y : 0);
103103

104-
m_state.state.buttons |= (data.buttons[4] ? KEY_LSTICK : 0);
105-
m_state.state.buttons |= (data.buttons[5] ? KEY_RSTICK : 0);
104+
m_state.state.buttons |= (data.buttons[4] ? HidNpadButton_StickL : 0);
105+
m_state.state.buttons |= (data.buttons[5] ? HidNpadButton_StickR : 0);
106106

107-
m_state.state.buttons |= (data.buttons[6] ? KEY_L : 0);
108-
m_state.state.buttons |= (data.buttons[7] ? KEY_R : 0);
107+
m_state.state.buttons |= (data.buttons[6] ? HidNpadButton_L : 0);
108+
m_state.state.buttons |= (data.buttons[7] ? HidNpadButton_R : 0);
109109

110-
m_state.state.buttons |= (data.buttons[8] ? KEY_ZL : 0);
111-
m_state.state.buttons |= (data.buttons[9] ? KEY_ZR : 0);
110+
m_state.state.buttons |= (data.buttons[8] ? HidNpadButton_ZL : 0);
111+
m_state.state.buttons |= (data.buttons[9] ? HidNpadButton_ZR : 0);
112112

113-
m_state.state.buttons |= (data.buttons[10] ? KEY_MINUS : 0);
114-
m_state.state.buttons |= (data.buttons[11] ? KEY_PLUS : 0);
113+
m_state.state.buttons |= (data.buttons[10] ? HidNpadButton_Minus : 0);
114+
m_state.state.buttons |= (data.buttons[11] ? HidNpadButton_Plus : 0);
115115

116116
ControllerConfig *config = GetController()->GetConfig();
117117

118118
if (config && config->swapDPADandLSTICK)
119119
{
120-
m_state.state.buttons |= ((data.sticks[0].axis_y > 0.5f) ? KEY_DUP : 0);
121-
m_state.state.buttons |= ((data.sticks[0].axis_x > 0.5f) ? KEY_DRIGHT : 0);
122-
m_state.state.buttons |= ((data.sticks[0].axis_y < -0.5f) ? KEY_DDOWN : 0);
123-
m_state.state.buttons |= ((data.sticks[0].axis_x < -0.5f) ? KEY_DLEFT : 0);
120+
m_state.state.buttons |= ((data.sticks[0].axis_y > 0.5f) ? HidNpadButton_Up : 0);
121+
m_state.state.buttons |= ((data.sticks[0].axis_x > 0.5f) ? HidNpadButton_Right : 0);
122+
m_state.state.buttons |= ((data.sticks[0].axis_y < -0.5f) ? HidNpadButton_Down : 0);
123+
m_state.state.buttons |= ((data.sticks[0].axis_x < -0.5f) ? HidNpadButton_Left : 0);
124124

125125
float daxis_x{}, daxis_y{};
126126

@@ -129,22 +129,22 @@ void SwitchAbstractedPadHandler::FillAbstractedState(const NormalizedButtonData
129129
daxis_y += data.buttons[14] ? -1.0f : 0.0f; //DDOWN
130130
daxis_x += data.buttons[15] ? -1.0f : 0.0f; //DLEFT
131131

132-
ConvertAxisToSwitchAxis(daxis_x, daxis_y, 0, &m_state.state.joysticks[JOYSTICK_LEFT].dx, &m_state.state.joysticks[JOYSTICK_LEFT].dy);
132+
ConvertAxisToSwitchAxis(daxis_x, daxis_y, 0, &m_state.state.analog_stick_l.x, &m_state.state.analog_stick_l.y);
133133
}
134134
else
135135
{
136-
m_state.state.buttons |= (data.buttons[12] ? KEY_DUP : 0);
137-
m_state.state.buttons |= (data.buttons[13] ? KEY_DRIGHT : 0);
138-
m_state.state.buttons |= (data.buttons[14] ? KEY_DDOWN : 0);
139-
m_state.state.buttons |= (data.buttons[15] ? KEY_DLEFT : 0);
136+
m_state.state.buttons |= (data.buttons[12] ? HidNpadButton_Up : 0);
137+
m_state.state.buttons |= (data.buttons[13] ? HidNpadButton_Right : 0);
138+
m_state.state.buttons |= (data.buttons[14] ? HidNpadButton_Down : 0);
139+
m_state.state.buttons |= (data.buttons[15] ? HidNpadButton_Left : 0);
140140

141-
ConvertAxisToSwitchAxis(data.sticks[0].axis_x, data.sticks[0].axis_y, 0, &m_state.state.joysticks[JOYSTICK_LEFT].dx, &m_state.state.joysticks[JOYSTICK_LEFT].dy);
141+
ConvertAxisToSwitchAxis(data.sticks[0].axis_x, data.sticks[0].axis_y, 0, &m_state.state.analog_stick_l.x, &m_state.state.analog_stick_l.y);
142142
}
143143

144-
ConvertAxisToSwitchAxis(data.sticks[1].axis_x, data.sticks[1].axis_y, 0, &m_state.state.joysticks[JOYSTICK_RIGHT].dx, &m_state.state.joysticks[JOYSTICK_RIGHT].dy);
144+
ConvertAxisToSwitchAxis(data.sticks[1].axis_x, data.sticks[1].axis_y, 0, &m_state.state.analog_stick_r.x, &m_state.state.analog_stick_r.y);
145145

146-
m_state.state.buttons |= (data.buttons[16] ? KEY_CAPTURE : 0);
147-
m_state.state.buttons |= (data.buttons[17] ? KEY_HOME : 0);
146+
m_state.state.buttons |= (data.buttons[16] ? HiddbgNpadButton_Capture : 0);
147+
m_state.state.buttons |= (data.buttons[17] ? HiddbgNpadButton_Home : 0);
148148
}
149149

150150
Result SwitchAbstractedPadHandler::UpdateAbstractedState()
@@ -174,7 +174,7 @@ void SwitchAbstractedPadHandler::UpdateOutput()
174174
{
175175
Result rc;
176176
HidVibrationValue value;
177-
rc = hidGetActualVibrationValue(&m_vibrationDeviceHandle, &value);
177+
rc = hidGetActualVibrationValue(m_vibrationDeviceHandle, &value);
178178
if (R_SUCCEEDED(rc))
179179
GetController()->SetRumble(static_cast<uint8_t>(value.amp_high * 255.0f), static_cast<uint8_t>(value.amp_low * 255.0f));
180180
}

source/ControllerSwitch/SwitchHDLHandler.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ void SwitchHDLHandler::Exit()
4848

4949
Result SwitchHDLHandler::InitHdlState()
5050
{
51-
m_hdlHandle = 0;
51+
m_hdlHandle = {0};
5252
m_deviceInfo = {0};
5353
m_hdlState = {0};
5454

5555
// Set the controller type to Pro-Controller, and set the npadInterfaceType.
5656
m_deviceInfo.deviceType = HidDeviceType_FullKey15;
57-
m_deviceInfo.npadInterfaceType = NpadInterfaceType_USB;
57+
m_deviceInfo.npadInterfaceType = HidNpadInterfaceType_USB;
5858
// Set the controller colors. The grip colors are for Pro-Controller on [9.0.0+].
5959
ControllerConfig *config = m_controller->GetConfig();
6060
m_deviceInfo.singleColorBody = config->bodyColor.rgbaValue;
6161
m_deviceInfo.singleColorButtons = config->buttonsColor.rgbaValue;
6262
m_deviceInfo.colorLeftGrip = config->leftGripColor.rgbaValue;
6363
m_deviceInfo.colorRightGrip = config->rightGripColor.rgbaValue;
6464

65-
m_hdlState.batteryCharge = 4; // Set battery charge to full.
66-
m_hdlState.joysticks[JOYSTICK_LEFT].dx = 0x1234;
67-
m_hdlState.joysticks[JOYSTICK_LEFT].dy = -0x1234;
68-
m_hdlState.joysticks[JOYSTICK_RIGHT].dx = 0x5678;
69-
m_hdlState.joysticks[JOYSTICK_RIGHT].dy = -0x5678;
65+
m_hdlState.battery_level = 4; // Set battery charge to full.
66+
m_hdlState.analog_stick_l.x = 0x1234;
67+
m_hdlState.analog_stick_l.y = -0x1234;
68+
m_hdlState.analog_stick_r.x = 0x5678;
69+
m_hdlState.analog_stick_r.y = -0x5678;
7070

7171
if (m_controller->IsControllerActive())
7272
return hiddbgAttachHdlsVirtualDevice(&m_hdlHandle, &m_deviceInfo);
@@ -98,31 +98,31 @@ void SwitchHDLHandler::FillHdlState(const NormalizedButtonData &data)
9898
// we convert the input packet into switch-specific button states
9999
m_hdlState.buttons = 0;
100100

101-
m_hdlState.buttons |= (data.buttons[0] ? KEY_X : 0);
102-
m_hdlState.buttons |= (data.buttons[1] ? KEY_A : 0);
103-
m_hdlState.buttons |= (data.buttons[2] ? KEY_B : 0);
104-
m_hdlState.buttons |= (data.buttons[3] ? KEY_Y : 0);
101+
m_hdlState.buttons |= (data.buttons[0] ? HidNpadButton_X : 0);
102+
m_hdlState.buttons |= (data.buttons[1] ? HidNpadButton_A : 0);
103+
m_hdlState.buttons |= (data.buttons[2] ? HidNpadButton_B : 0);
104+
m_hdlState.buttons |= (data.buttons[3] ? HidNpadButton_Y : 0);
105105

106-
m_hdlState.buttons |= (data.buttons[4] ? KEY_LSTICK : 0);
107-
m_hdlState.buttons |= (data.buttons[5] ? KEY_RSTICK : 0);
106+
m_hdlState.buttons |= (data.buttons[4] ? HidNpadButton_StickL : 0);
107+
m_hdlState.buttons |= (data.buttons[5] ? HidNpadButton_StickR : 0);
108108

109-
m_hdlState.buttons |= (data.buttons[6] ? KEY_L : 0);
110-
m_hdlState.buttons |= (data.buttons[7] ? KEY_R : 0);
109+
m_hdlState.buttons |= (data.buttons[6] ? HidNpadButton_L : 0);
110+
m_hdlState.buttons |= (data.buttons[7] ? HidNpadButton_R : 0);
111111

112-
m_hdlState.buttons |= (data.buttons[8] ? KEY_ZL : 0);
113-
m_hdlState.buttons |= (data.buttons[9] ? KEY_ZR : 0);
112+
m_hdlState.buttons |= (data.buttons[8] ? HidNpadButton_ZL : 0);
113+
m_hdlState.buttons |= (data.buttons[9] ? HidNpadButton_ZR : 0);
114114

115-
m_hdlState.buttons |= (data.buttons[10] ? KEY_MINUS : 0);
116-
m_hdlState.buttons |= (data.buttons[11] ? KEY_PLUS : 0);
115+
m_hdlState.buttons |= (data.buttons[10] ? HidNpadButton_Minus : 0);
116+
m_hdlState.buttons |= (data.buttons[11] ? HidNpadButton_Plus : 0);
117117

118118
ControllerConfig *config = m_controller->GetConfig();
119119

120120
if (config && config->swapDPADandLSTICK)
121121
{
122-
m_hdlState.buttons |= ((data.sticks[0].axis_y > 0.5f) ? KEY_DUP : 0);
123-
m_hdlState.buttons |= ((data.sticks[0].axis_x > 0.5f) ? KEY_DRIGHT : 0);
124-
m_hdlState.buttons |= ((data.sticks[0].axis_y < -0.5f) ? KEY_DDOWN : 0);
125-
m_hdlState.buttons |= ((data.sticks[0].axis_x < -0.5f) ? KEY_DLEFT : 0);
122+
m_hdlState.buttons |= ((data.sticks[0].axis_y > 0.5f) ? HidNpadButton_Up : 0);
123+
m_hdlState.buttons |= ((data.sticks[0].axis_x > 0.5f) ? HidNpadButton_Right : 0);
124+
m_hdlState.buttons |= ((data.sticks[0].axis_y < -0.5f) ? HidNpadButton_Down : 0);
125+
m_hdlState.buttons |= ((data.sticks[0].axis_x < -0.5f) ? HidNpadButton_Left : 0);
126126

127127
float daxis_x{}, daxis_y{};
128128

@@ -139,22 +139,22 @@ void SwitchHDLHandler::FillHdlState(const NormalizedButtonData &data)
139139
daxis_x *= ratio;
140140
daxis_y *= ratio;
141141

142-
ConvertAxisToSwitchAxis(daxis_x, daxis_y, 0, &m_hdlState.joysticks[JOYSTICK_LEFT].dx, &m_hdlState.joysticks[JOYSTICK_LEFT].dy);
142+
ConvertAxisToSwitchAxis(daxis_x, daxis_y, 0, &m_hdlState.analog_stick_l.x, &m_hdlState.analog_stick_l.y);
143143
}
144144
else
145145
{
146-
m_hdlState.buttons |= (data.buttons[12] ? KEY_DUP : 0);
147-
m_hdlState.buttons |= (data.buttons[13] ? KEY_DRIGHT : 0);
148-
m_hdlState.buttons |= (data.buttons[14] ? KEY_DDOWN : 0);
149-
m_hdlState.buttons |= (data.buttons[15] ? KEY_DLEFT : 0);
146+
m_hdlState.buttons |= (data.buttons[12] ? HidNpadButton_Up : 0);
147+
m_hdlState.buttons |= (data.buttons[13] ? HidNpadButton_Right : 0);
148+
m_hdlState.buttons |= (data.buttons[14] ? HidNpadButton_Down : 0);
149+
m_hdlState.buttons |= (data.buttons[15] ? HidNpadButton_Left : 0);
150150

151-
ConvertAxisToSwitchAxis(data.sticks[0].axis_x, data.sticks[0].axis_y, 0, &m_hdlState.joysticks[JOYSTICK_LEFT].dx, &m_hdlState.joysticks[JOYSTICK_LEFT].dy);
151+
ConvertAxisToSwitchAxis(data.sticks[0].axis_x, data.sticks[0].axis_y, 0, &m_hdlState.analog_stick_l.x, &m_hdlState.analog_stick_l.y);
152152
}
153153

154-
ConvertAxisToSwitchAxis(data.sticks[1].axis_x, data.sticks[1].axis_y, 0, &m_hdlState.joysticks[JOYSTICK_RIGHT].dx, &m_hdlState.joysticks[JOYSTICK_RIGHT].dy);
154+
ConvertAxisToSwitchAxis(data.sticks[1].axis_x, data.sticks[1].axis_y, 0, &m_hdlState.analog_stick_r.x, &m_hdlState.analog_stick_r.y);
155155

156-
m_hdlState.buttons |= (data.buttons[16] ? KEY_CAPTURE : 0);
157-
m_hdlState.buttons |= (data.buttons[17] ? KEY_HOME : 0);
156+
m_hdlState.buttons |= (data.buttons[16] ? HiddbgNpadButton_Capture : 0);
157+
m_hdlState.buttons |= (data.buttons[17] ? HiddbgNpadButton_Home : 0);
158158
}
159159

160160
void SwitchHDLHandler::UpdateInput()
@@ -190,7 +190,7 @@ void SwitchHDLHandler::UpdateOutput()
190190
{
191191
Result rc;
192192
HidVibrationValue value;
193-
rc = hidGetActualVibrationValue(&m_vibrationDeviceHandle, &value);
193+
rc = hidGetActualVibrationValue(m_vibrationDeviceHandle, &value);
194194
if (R_SUCCEEDED(rc))
195195
m_controller->SetRumble(static_cast<uint8_t>(value.amp_high * 255.0f), static_cast<uint8_t>(value.amp_low * 255.0f));
196196
}

source/ControllerSwitch/SwitchHDLHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class SwitchHDLHandler : public SwitchVirtualGamepadHandler
99
{
1010
private:
11-
u64 m_hdlHandle;
11+
HiddbgHdlsHandle m_hdlHandle;
1212
HiddbgHdlsDeviceInfo m_deviceInfo;
1313
HiddbgHdlsState m_hdlState;
1414

source/ControllerSwitch/SwitchVirtualGamepadHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class SwitchVirtualGamepadHandler
88
{
99
protected:
10-
u32 m_vibrationDeviceHandle;
10+
HidVibrationDeviceHandle m_vibrationDeviceHandle;
1111
std::unique_ptr<IController> m_controller;
1212

1313
alignas(ams::os::ThreadStackAlignment) u8 input_thread_stack[0x1000];
@@ -52,5 +52,5 @@ class SwitchVirtualGamepadHandler
5252

5353
//Get the raw controller pointer
5454
inline IController *GetController() { return m_controller.get(); }
55-
inline u32 *GetVibrationHandle() { return &m_vibrationDeviceHandle; }
55+
inline HidVibrationDeviceHandle *GetVibrationHandle() { return &m_vibrationDeviceHandle; }
5656
};

source/Sysmodule/source/psc_module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace syscon::psc
1111
{
1212
PscPmModule pscModule;
1313
Waiter pscModuleWaiter;
14-
const uint16_t dependencies[] = {PscPmModuleId_Fs};
14+
const uint32_t dependencies[] = {PscPmModuleId_Fs};
1515

1616
//Thread to check for psc:pm state change (console waking up/going to sleep)
1717
void PscThreadFunc(void *arg);
@@ -53,7 +53,7 @@ namespace syscon::psc
5353
} // namespace
5454
Result Initialize()
5555
{
56-
R_TRY(pscmGetPmModule(&pscModule, PscPmModuleId(126), dependencies, sizeof(dependencies) / sizeof(uint16_t), true));
56+
R_TRY(pscmGetPmModule(&pscModule, PscPmModuleId(126), dependencies, sizeof(dependencies) / sizeof(uint32_t), true));
5757
pscModuleWaiter = waiterForEvent(&pscModule.event);
5858
is_psc_thread_running = true;
5959
R_ABORT_UNLESS(threadCreate(&g_psc_thread, &PscThreadFunc, nullptr, psc_thread_stack, sizeof(psc_thread_stack), 0x2C, -2));

source/libstratosphere

Submodule libstratosphere updated 1485 files

0 commit comments

Comments
 (0)