@@ -202,17 +202,60 @@ void GamepadSetState(InputOutState OutState)
202202 } else if (CurGamepad.ControllerType == NINTENDO_SWITCH_PRO) { // Need test
203203 unsigned char outputReport[64 ] = { 0 };
204204
205- outputReport[0 ] = 0x10 ;
205+ /* outputReport[0] = 0x10;
206206 outputReport[1] = (++CurGamepad.PacketCounter) & 0xF; if (CurGamepad.PacketCounter > 0xF) CurGamepad.PacketCounter = 0x0;
207207 outputReport[2] = std::clamp(OutState.SmallMotor - 0, 0, 229); // It seems that it is not recommended to use the Nintendo Switch motors at 100 % , there is a risk of damaging them, so we will limit ourselves to 90%
208208 outputReport[6] = std::clamp(OutState.LargeMotor - 0, 0, 229);
209209
210- // USB
210+ // BT
211+ if (!CurGamepad.USBConnection) {
212+ outputReport[0] = 0x80; // Заголовок для Bluetooth
213+ outputReport[1] = 0x92; // Команда вибрации для Bluetooth
214+ outputReport[3] = 0x31; // Подкоманда для вибрации
215+ outputReport[8] = 0x10; // Дополнительные данные для Bluetooth
216+ }*/
217+
218+ // Настройка амплитуды
219+ /* unsigned char h_amp = (OutState.SmallMotor / 649) * 2;
220+ unsigned char l_amp1 = (OutState.LargeMotor / 649);
221+ unsigned char l_amp2 = ((l_amp1 % 2) * 128);
222+ l_amp1 = (l_amp1 / 2) + 64;
223+
224+ outputReport[2] = 0x20; // Высокая частота
225+ outputReport[4] = 0x28; // Низкая частота
226+ outputReport[3] = h_amp;
227+ outputReport[5] = l_amp1;
228+ outputReport[4] += l_amp2;
229+
230+ // USB-пакет
211231 if (CurGamepad.USBConnection) {
212232 outputReport[0] = 0x80;
213233 outputReport[1] = 0x92;
214234 outputReport[3] = 0x31;
215235 outputReport[8] = 0x10;
236+ }*/
237+
238+ outputReport[0 ] = 0x10 ;
239+ outputReport[1 ] = (++CurGamepad.PacketCounter ) & 0xF ;
240+ if (CurGamepad.PacketCounter > 0xF ) CurGamepad.PacketCounter = 0x0 ;
241+
242+ unsigned char hf = 0x20 ; // Высокая частота
243+ unsigned char lf = 0x28 ; // Низкая частота
244+ unsigned char h_amp = std::clamp (OutState.SmallMotor * 2 / 229 , 0 , 255 );
245+ unsigned char l_amp1 = std::clamp (OutState.LargeMotor / 229 , 0 , 255 );
246+ unsigned char l_amp2 = ((l_amp1 % 2 ) * 128 );
247+ l_amp1 = (l_amp1 / 2 ) + 64 ;
248+
249+ outputReport[2 ] = hf;
250+ outputReport[3 ] = h_amp;
251+ outputReport[4 ] = lf + l_amp2;
252+ outputReport[5 ] = l_amp1;
253+
254+ if (!CurGamepad.USBConnection ) {
255+ outputReport[0 ] = 0x80 ;
256+ outputReport[1 ] = 0x92 ;
257+ outputReport[3 ] = 0x31 ;
258+ outputReport[8 ] = 0x10 ;
216259 }
217260
218261 hid_write (CurGamepad.HidHandle , outputReport, 64 );
@@ -256,12 +299,19 @@ void GamepadSearch() {
256299 CurGamepad.ControllerType = SONY_DUALSHOCK4;
257300 CurGamepad.USBConnection = true ;
258301
259- // BT detection
302+ // JoyShock Library apparently sent something, so it worked without a package (needed for BT detection to work, does not affect USB)
303+ unsigned char checkBT[2 ] = { 0x02 , 0x00 };
304+ hid_write (CurGamepad.HidHandle , checkBT, sizeof (checkBT));
305+
306+ // BT detection for compatible gamepads that output USB VID/PID on BT connection
260307 unsigned char buf[64 ];
261308 memset (buf, 0 , sizeof (buf));
262309 int bytesRead = hid_read_timeout (CurGamepad.HidHandle , buf, sizeof (buf), 100 );
263310 if (bytesRead > 0 && buf[0 ] == 0x11 )
264311 CurGamepad.USBConnection = false ;
312+
313+ // printf("Detected device ID: 0x%X\n", cur_dev->product_id);
314+ // if (CurGamepad.USBConnection) printf("USB"); else printf("Wireless");
265315
266316 } else if (cur_dev->product_id == SONY_DS4_BT) { // ?
267317 CurGamepad.ControllerType = SONY_DUALSHOCK4;
@@ -675,7 +725,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
675725
676726int main (int argc, char **argv)
677727{
678- SetConsoleTitle (" DSAdvance 1.0.2 " );
728+ SetConsoleTitle (" DSAdvance 1.0.3 " );
679729
680730 WNDCLASS AppWndClass = {};
681731 AppWndClass.lpfnWndProc = WindowProc;
@@ -687,7 +737,6 @@ int main(int argc, char **argv)
687737
688738 // Config parameters
689739 CIniReader IniFile (" Config.ini" );
690- CurGamepad.TestRumbleProController = IniFile.ReadBoolean (" Gamepad" , " ProContollerRumble" , false ); // Temporary test
691740 CurGamepad.Sticks .InvertLeftX = IniFile.ReadBoolean (" Gamepad" , " InvertLeftStickX" , false );
692741 CurGamepad.Sticks .InvertLeftY = IniFile.ReadBoolean (" Gamepad" , " InvertLeftStickY" , false );
693742 CurGamepad.Sticks .InvertRightX = IniFile.ReadBoolean (" Gamepad" , " InvertRightStickX" , false );
0 commit comments