@@ -48,25 +48,25 @@ void SwitchHDLHandler::Exit()
4848
4949Result 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
160160void 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 }
0 commit comments