Rolling back GameCube HIDAPI support It causes the HIDAPI devices to always be opened on enumeration, which causes crashes in the Windows drivers when multiple applications are reading and writing at the same time. We can revisit this after 2.0.10 release.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712
diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj
index 082070c..a010a74 100644
--- a/VisualC/SDL/SDL.vcxproj
+++ b/VisualC/SDL/SDL.vcxproj
@@ -421,7 +421,6 @@
<ClCompile Include="..\..\src\haptic\windows\SDL_xinputhaptic.c" />
<ClCompile Include="..\..\src\hidapi\windows\hid.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapijoystick.c" />
- <ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps4.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_switch.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360.c" />
diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters
index b911d1b..75a9e4f 100644
--- a/VisualC/SDL/SDL.vcxproj.filters
+++ b/VisualC/SDL/SDL.vcxproj.filters
@@ -360,7 +360,6 @@
<ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c" />
<ClCompile Include="..\..\src\haptic\windows\SDL_xinputhaptic.c" />
<ClCompile Include="..\..\src\hidapi\windows\hid.c" />
- <ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_gamecube.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_ps4.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_switch.c" />
<ClCompile Include="..\..\src\joystick\hidapi\SDL_hidapi_xbox360.c" />
diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
index a87c80c..ef8539b 100644
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
@@ -468,9 +468,6 @@
F3BDD79B20F51CB8004ECBF3 /* SDL_hidapijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BDD79020F51CB8004ECBF3 /* SDL_hidapijoystick_c.h */; };
F3BDD79C20F51CB8004ECBF3 /* SDL_hidapijoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD79120F51CB8004ECBF3 /* SDL_hidapijoystick.c */; };
F3BDD79D20F51CB8004ECBF3 /* SDL_hidapijoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = F3BDD79120F51CB8004ECBF3 /* SDL_hidapijoystick.c */; };
- F3E3C55D223DEC6C007D243C /* SDL_hidapi_gamecube.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C55C223DEC6C007D243C /* SDL_hidapi_gamecube.c */; };
- F3E3C55E223DEC6C007D243C /* SDL_hidapi_gamecube.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C55C223DEC6C007D243C /* SDL_hidapi_gamecube.c */; };
- F3E3C55F224065AE007D243C /* SDL_hidapi_gamecube.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C55C223DEC6C007D243C /* SDL_hidapi_gamecube.c */; };
F3E3C658224069CE007D243C /* SDL_uikit_main.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C657224069CE007D243C /* SDL_uikit_main.c */; };
F3E3C65B2241389A007D243C /* SDL_blit.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683010DF2374E00F98A1A /* SDL_blit.h */; };
F3E3C65C2241389A007D243C /* SDL_uikitmetalview.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D7517191EE1D32200820EEA /* SDL_uikitmetalview.h */; };
@@ -657,7 +654,6 @@
F3E3C7122241389A007D243C /* SDL_uikitevents.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F0D0E26E5D900F90B21 /* SDL_uikitevents.m */; };
F3E3C7132241389A007D243C /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = AA13B3561FB8B46300D9FEE6 /* yuv_rgb.c */; };
F3E3C7142241389A007D243C /* SDL_uikitopengles.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F0F0E26E5D900F90B21 /* SDL_uikitopengles.m */; };
- F3E3C7152241389A007D243C /* SDL_hidapi_gamecube.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C55C223DEC6C007D243C /* SDL_hidapi_gamecube.c */; };
F3E3C7162241389A007D243C /* SDL_uikitvideo.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F110E26E5D900F90B21 /* SDL_uikitvideo.m */; };
F3E3C7172241389A007D243C /* SDL_uikitview.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F130E26E5D900F90B21 /* SDL_uikitview.m */; };
F3E3C7182241389A007D243C /* SDL_displayevents.c in Sources */ = {isa = PBXBuildFile; fileRef = A7C19D28212E552B00DF2152 /* SDL_displayevents.c */; };
@@ -1062,7 +1058,6 @@
F3BDD78E20F51CB8004ECBF3 /* SDL_hidapi_ps4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_ps4.c; sourceTree = "<group>"; };
F3BDD79020F51CB8004ECBF3 /* SDL_hidapijoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_hidapijoystick_c.h; sourceTree = "<group>"; };
F3BDD79120F51CB8004ECBF3 /* SDL_hidapijoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapijoystick.c; sourceTree = "<group>"; };
- F3E3C55C223DEC6C007D243C /* SDL_hidapi_gamecube.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_gamecube.c; sourceTree = "<group>"; };
F3E3C65222406928007D243C /* libSDLmain.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDLmain.a; sourceTree = BUILT_PRODUCTS_DIR; };
F3E3C657224069CE007D243C /* SDL_uikit_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_uikit_main.c; sourceTree = "<group>"; };
F3E3C7572241389A007D243C /* libSDL2.dylib */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL2.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1463,7 +1458,6 @@
F3BDD78A20F51C8D004ECBF3 /* hidapi */ = {
isa = PBXGroup;
children = (
- F3E3C55C223DEC6C007D243C /* SDL_hidapi_gamecube.c */,
F3BDD78E20F51CB8004ECBF3 /* SDL_hidapi_ps4.c */,
F3BDD78C20F51CB8004ECBF3 /* SDL_hidapi_switch.c */,
F3BDD78B20F51CB8004ECBF3 /* SDL_hidapi_xbox360.c */,
@@ -2518,7 +2512,6 @@
52ED1E24222889500061FCE0 /* SDL_uikitevents.m in Sources */,
52ED1E25222889500061FCE0 /* yuv_rgb.c in Sources */,
52ED1E26222889500061FCE0 /* SDL_uikitopengles.m in Sources */,
- F3E3C55F224065AE007D243C /* SDL_hidapi_gamecube.c in Sources */,
52ED1E27222889500061FCE0 /* SDL_uikitvideo.m in Sources */,
52ED1E28222889500061FCE0 /* SDL_uikitview.m in Sources */,
52ED1E29222889500061FCE0 /* SDL_displayevents.c in Sources */,
@@ -2647,7 +2640,6 @@
F3E3C7122241389A007D243C /* SDL_uikitevents.m in Sources */,
F3E3C7132241389A007D243C /* yuv_rgb.c in Sources */,
F3E3C7142241389A007D243C /* SDL_uikitopengles.m in Sources */,
- F3E3C7152241389A007D243C /* SDL_hidapi_gamecube.c in Sources */,
F3E3C7162241389A007D243C /* SDL_uikitvideo.m in Sources */,
F3E3C7172241389A007D243C /* SDL_uikitview.m in Sources */,
F3E3C7182241389A007D243C /* SDL_displayevents.c in Sources */,
@@ -2824,7 +2816,6 @@
FAB598BD1BB5C31600BE72C5 /* SDL_hints.c in Sources */,
FAB598BE1BB5C31600BE72C5 /* SDL_log.c in Sources */,
FAB598BF1BB5C31600BE72C5 /* SDL.c in Sources */,
- F3E3C55E223DEC6C007D243C /* SDL_hidapi_gamecube.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2895,7 +2886,6 @@
FD689F1D0E26E5D900F90B21 /* SDL_uikitevents.m in Sources */,
AA13B35A1FB8B46400D9FEE6 /* yuv_rgb.c in Sources */,
FD689F1F0E26E5D900F90B21 /* SDL_uikitopengles.m in Sources */,
- F3E3C55D223DEC6C007D243C /* SDL_hidapi_gamecube.c in Sources */,
FD689F210E26E5D900F90B21 /* SDL_uikitvideo.m in Sources */,
FD689F230E26E5D900F90B21 /* SDL_uikitview.m in Sources */,
A7C19D2A212E552C00DF2152 /* SDL_displayevents.c in Sources */,
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
index cdb8790..8052045 100755
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -919,9 +919,6 @@
F3950CD8212BC88D00F51292 /* SDL_sensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F3950CD7212BC88D00F51292 /* SDL_sensor.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3950CD9212BC88D00F51292 /* SDL_sensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F3950CD7212BC88D00F51292 /* SDL_sensor.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3950CDA212BC88D00F51292 /* SDL_sensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F3950CD7212BC88D00F51292 /* SDL_sensor.h */; settings = {ATTRIBUTES = (Public, ); }; };
- F3E3C559223DEBC7007D243C /* SDL_hidapi_gamecube.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C558223DEBC7007D243C /* SDL_hidapi_gamecube.c */; };
- F3E3C55A223DEBC7007D243C /* SDL_hidapi_gamecube.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C558223DEBC7007D243C /* SDL_hidapi_gamecube.c */; };
- F3E3C55B223DEBC7007D243C /* SDL_hidapi_gamecube.c in Sources */ = {isa = PBXBuildFile; fileRef = F3E3C558223DEBC7007D243C /* SDL_hidapi_gamecube.c */; };
FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
FA73671E19A54140004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
FA73671F19A54144004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
@@ -1252,7 +1249,6 @@
F30D9CCB212EB4810047DF2E /* SDL_displayevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_displayevents_c.h; sourceTree = "<group>"; };
F30D9CCC212EB4810047DF2E /* SDL_displayevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_displayevents.c; sourceTree = "<group>"; };
F3950CD7212BC88D00F51292 /* SDL_sensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sensor.h; sourceTree = "<group>"; };
- F3E3C558223DEBC7007D243C /* SDL_hidapi_gamecube.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_gamecube.c; sourceTree = "<group>"; };
F59C710300D5CB5801000001 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ReadMe.txt; sourceTree = "<group>"; };
F59C710600D5CB5801000001 /* SDL.info */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SDL.info; sourceTree = "<group>"; };
F5A2EF3900C6A39A01000001 /* BUGS.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = BUGS.txt; path = ../../BUGS.txt; sourceTree = SOURCE_ROOT; };
@@ -1932,7 +1928,6 @@
A704170C20F09AA600A82227 /* hidapi */ = {
isa = PBXGroup;
children = (
- F3E3C558223DEBC7007D243C /* SDL_hidapi_gamecube.c */,
A704171120F09AC900A82227 /* SDL_hidapi_ps4.c */,
A704170F20F09AC800A82227 /* SDL_hidapi_switch.c */,
A704171320F09AC900A82227 /* SDL_hidapi_xbox360.c */,
@@ -2707,7 +2702,6 @@
04BD005B12E6671800899322 /* SDL_syshaptic.c in Sources */,
04BD005F12E6671800899322 /* SDL_haptic.c in Sources */,
4D1664551EDD60AD003DE88E /* SDL_cocoavulkan.m in Sources */,
- F3E3C559223DEBC7007D243C /* SDL_hidapi_gamecube.c in Sources */,
04BD006612E6671800899322 /* SDL_sysjoystick.c in Sources */,
04BD007012E6671800899322 /* SDL_joystick.c in Sources */,
04BD008812E6671800899322 /* SDL_sysloadso.c in Sources */,
@@ -2846,7 +2840,6 @@
04BD026D12E6671800899322 /* SDL_quit.c in Sources */,
04BD026F12E6671800899322 /* SDL_touch.c in Sources */,
04BD027112E6671800899322 /* SDL_windowevents.c in Sources */,
- F3E3C55A223DEBC7007D243C /* SDL_hidapi_gamecube.c in Sources */,
04BD027412E6671800899322 /* SDL_rwopsbundlesupport.m in Sources */,
04BD027512E6671800899322 /* SDL_rwops.c in Sources */,
04BD027612E6671800899322 /* SDL_syshaptic.c in Sources */,
@@ -2985,7 +2978,6 @@
DB31401017554B71006C0E22 /* SDL_quit.c in Sources */,
DB31401117554B71006C0E22 /* SDL_touch.c in Sources */,
DB31401217554B71006C0E22 /* SDL_windowevents.c in Sources */,
- F3E3C55B223DEBC7007D243C /* SDL_hidapi_gamecube.c in Sources */,
DB31401317554B71006C0E22 /* SDL_rwopsbundlesupport.m in Sources */,
DB31401417554B71006C0E22 /* SDL_rwops.c in Sources */,
DB31401517554B71006C0E22 /* SDL_syshaptic.c in Sources */,
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index b5d9d8d..8fa0dd6 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -566,17 +566,6 @@ extern "C" {
#define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX"
/**
- * \brief A variable controlling whether the HIDAPI driver for Nintendo GameCube controllers should be used.
- *
- * This variable can be set to the following values:
- * "0" - HIDAPI driver is not used
- * "1" - HIDAPI driver is used
- *
- * The default is the value of SDL_HINT_JOYSTICK_HIDAPI
- */
-#define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE "SDL_JOYSTICK_HIDAPI_GAMECUBE"
-
-/**
* \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
*
* The variable can be set to the following values:
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index bd89a7c..12d5ea1 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -1037,11 +1037,6 @@ SDL_JoystickUpdate(void)
/* Make sure the list is unlocked while dispatching events to prevent application deadlocks */
SDL_UnlockJoysticks();
- /* Special function for HIDAPI devices, as a single device can provide multiple SDL_Joysticks */
-#ifdef SDL_JOYSTICK_HIDAPI
- SDL_HIDAPI_UpdateDevices();
-#endif /* SDL_JOYSTICK_HIDAPI */
-
for (joystick = SDL_joysticks; joystick; joystick = joystick->next) {
if (joystick->attached) {
/* This should always be true, but seeing a crash in the wild...? */
@@ -1200,12 +1195,6 @@ SDL_IsJoystickXboxOne(Uint16 vendor, Uint16 product)
}
SDL_bool
-SDL_IsJoystickGameCube(Uint16 vendor, Uint16 product)
-{
- return (GuessControllerType(vendor, product) == k_eControllerType_GameCube);
-}
-
-SDL_bool
SDL_IsJoystickXInput(SDL_JoystickGUID guid)
{
return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE;
diff --git a/src/joystick/SDL_joystick_c.h b/src/joystick/SDL_joystick_c.h
index f02d30b..165c370 100644
--- a/src/joystick/SDL_joystick_c.h
+++ b/src/joystick/SDL_joystick_c.h
@@ -66,9 +66,6 @@ extern SDL_bool SDL_IsJoystickXbox360(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick is an Xbox One controller */
extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id);
-/* Function to return whether a joystick is a GameCube controller */
-extern SDL_bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id);
-
/* Function to return whether a joystick guid comes from the XInput driver */
extern SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid);
diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h
index ef7f082..8f57523 100644
--- a/src/joystick/SDL_sysjoystick.h
+++ b/src/joystick/SDL_sysjoystick.h
@@ -152,9 +152,6 @@ extern SDL_JoystickDriver SDL_IOS_JoystickDriver;
extern SDL_JoystickDriver SDL_LINUX_JoystickDriver;
extern SDL_JoystickDriver SDL_WINDOWS_JoystickDriver;
-/* Special function to update HIDAPI devices */
-extern void SDL_HIDAPI_UpdateDevices(void);
-
#endif /* SDL_sysjoystick_h_ */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/joystick/controller_type.h b/src/joystick/controller_type.h
index 22dec71..51ac20b 100644
--- a/src/joystick/controller_type.h
+++ b/src/joystick/controller_type.h
@@ -57,7 +57,6 @@ typedef enum
k_eControllerType_SwitchJoyConPair = 41,
k_eControllerType_SwitchInputOnlyController = 42,
k_eControllerType_MobileTouch = 43,
- k_eControllerType_GameCube = 44,
k_eControllerType_LastController, // Don't add game controllers below this enumeration - this enumeration can change value
// Keyboards and Mice
@@ -388,8 +387,6 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x20d6, 0xa711 ), k_eControllerType_SwitchInputOnlyController }, // PowerA Wired Controller Plus
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0092 ), k_eControllerType_SwitchInputOnlyController }, // HORI Pokken Tournament DX Pro Pad
- { MAKE_CONTROLLER_ID( 0x057e, 0x0337 ), k_eControllerType_GameCube }, // Nintendo Wii U/Switch GameCube USB Adapter
-
// Valve products - don't add to public list
{ MAKE_CONTROLLER_ID( 0x0000, 0x11fb ), k_eControllerType_MobileTouch }, // Streaming mobile touch virtual controls
diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c
deleted file mode 100644
index d44c55d..0000000
--- a/src/joystick/hidapi/SDL_hidapi_gamecube.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../../SDL_internal.h"
-
-#ifdef SDL_JOYSTICK_HIDAPI
-
-#include "SDL_hints.h"
-#include "SDL_log.h"
-#include "SDL_events.h"
-#include "SDL_timer.h"
-#include "SDL_haptic.h"
-#include "SDL_joystick.h"
-#include "SDL_gamecontroller.h"
-#include "../SDL_sysjoystick.h"
-#include "SDL_hidapijoystick_c.h"
-
-
-#ifdef SDL_JOYSTICK_HIDAPI_GAMECUBE
-
-typedef struct {
- SDL_JoystickID joysticks[4];
- Uint8 wireless[4];
- Uint8 rumbleAllowed[4];
- Uint8 rumble[5];
- Uint32 rumbleExpiration[4];
- /* Without this variable, hid_write starts to lag a TON */
- Uint8 rumbleUpdate;
-} SDL_DriverGameCube_Context;
-
-static SDL_bool
-HIDAPI_DriverGameCube_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number)
-{
- return SDL_IsJoystickGameCube(vendor_id, product_id);
-}
-
-static const char *
-HIDAPI_DriverGameCube_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
-{
- /* Give a user friendly name for this controller */
- if (SDL_IsJoystickGameCube(vendor_id, product_id)) {
- return "Nintendo GameCube Controller";
- }
- return NULL;
-}
-
-static SDL_bool
-HIDAPI_DriverGameCube_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id, Uint16 product_id, int *num_joysticks)
-{
- SDL_DriverGameCube_Context *ctx;
- Uint8 packet[37];
- Uint8 *curSlot;
- Uint8 i;
- int size;
- Uint8 initMagic = 0x13;
- Uint8 rumbleMagic = 0x11;
-
- ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx));
- if (!ctx) {
- SDL_OutOfMemory();
- return SDL_FALSE;
- }
- ctx->joysticks[0] = -1;
- ctx->joysticks[1] = -1;
- ctx->joysticks[2] = -1;
- ctx->joysticks[3] = -1;
- ctx->rumble[0] = rumbleMagic;
-
- context->context = ctx;
-
- /* This is all that's needed to initialize the device. Really! */
- if (hid_write(context->device, &initMagic, sizeof(initMagic)) <= 0) {
- SDL_SetError("Couldn't initialize WUP-028");
- SDL_free(ctx);
- return SDL_FALSE;
- }
-
- /* Add all the applicable joysticks */
- while ((size = hid_read_timeout(context->device, packet, sizeof(packet), 0)) > 0) {
- if (size < 37 || packet[0] != 0x21) {
- continue; /* Nothing to do yet...? */
- }
-
- /* Go through all 4 slots */
- curSlot = packet + 1;
- for (i = 0; i < 4; i += 1, curSlot += 9) {
- ctx->wireless[i] = (curSlot[0] & 0x20) != 0;
-
- /* Only allow rumble if the adapter's second USB cable is connected */
- ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i];
-
- if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
- if (ctx->joysticks[i] == -1) {
- ctx->joysticks[i] = SDL_GetNextJoystickInstanceID();
-
- *num_joysticks += 1;
-
- SDL_PrivateJoystickAdded(ctx->joysticks[i]);
- }
- } else {
- if (ctx->joysticks[i] != -1) {
- SDL_PrivateJoystickRemoved(ctx->joysticks[i]);
-
- *num_joysticks -= 1;
-
- ctx->joysticks[i] = -1;
- }
- continue;
- }
- }
- }
-
- return SDL_TRUE;
-}
-
-static void
-HIDAPI_DriverGameCube_QuitDriver(SDL_HIDAPI_DriverData *context, SDL_bool send_event, int *num_joysticks)
-{
- SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
- Uint8 i;
-
- /* Stop all rumble activity */
- for (i = 1; i < 5; i += 1) {
- ctx->rumble[i] = 0;
- }
- hid_write(context->device, ctx->rumble, sizeof(ctx->rumble));
-
- /* Remove all joysticks! */
- for (i = 0; i < 4; i += 1) {
- if (ctx->joysticks[i] != -1) {
- *num_joysticks -= 1;
- if (send_event) {
- SDL_PrivateJoystickRemoved(ctx->joysticks[i]);
- }
- }
- }
-
- SDL_free(context->context);
-}
-
-static SDL_bool
-HIDAPI_DriverGameCube_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysticks)
-{
- SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
- SDL_Joystick *joystick;
- Uint8 packet[37];
- Uint8 *curSlot;
- Uint32 now;
- Uint8 i;
- int size;
-
- /* Read input packet */
- while ((size = hid_read_timeout(context->device, packet, sizeof(packet), 0)) > 0) {
- if (size < 37 || packet[0] != 0x21) {
- continue; /* Nothing to do right now...? */
- }
-
- /* Go through all 4 slots */
- curSlot = packet + 1;
- for (i = 0; i < 4; i += 1, curSlot += 9) {
- ctx->wireless[i] = (curSlot[0] & 0x20) != 0;
-
- /* Only allow rumble if the adapter's second USB cable is connected */
- ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i];
-
- if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */
- if (ctx->joysticks[i] == -1) {
- ctx->joysticks[i] = SDL_GetNextJoystickInstanceID();
-
- *num_joysticks += 1;
-
- SDL_PrivateJoystickAdded(ctx->joysticks[i]);
- }
- joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]);
-
- /* Hasn't been opened yet, skip */
- if (joystick == NULL) {
- continue;
- }
- } else {
- if (ctx->joysticks[i] != -1) {
- SDL_PrivateJoystickRemoved(ctx->joysticks[i]);
-
- *num_joysticks -= 1;
-
- ctx->joysticks[i] = -1;
- }
- continue;
- }
-
- #define READ_BUTTON(off, flag, button) \
- SDL_PrivateJoystickButton( \
- joystick, \
- button, \
- (curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED \
- );
- READ_BUTTON(1, 0x01, 0) /* A */
- READ_BUTTON(1, 0x02, 1) /* B */
- READ_BUTTON(1, 0x04, 2) /* X */
- READ_BUTTON(1, 0x08, 3) /* Y */
- READ_BUTTON(1, 0x10, 4) /* DPAD_LEFT */
- READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */
- READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */
- READ_BUTTON(1, 0x80, 7) /* DPAD_UP */
- READ_BUTTON(2, 0x01, 8) /* START */
- READ_BUTTON(2, 0x02, 9) /* RIGHTSHOULDER */
- /* These two buttons are for the bottoms of the analog triggers.
- * More than likely, you're going to want to read the axes instead!
- * -flibit
- */
- READ_BUTTON(2, 0x04, 10) /* TRIGGERRIGHT */
- READ_BUTTON(2, 0x08, 11) /* TRIGGERLEFT */
- #undef READ_BUTTON
-
- /* Axis math taken from SDL_xinputjoystick.c */
- #define READ_AXIS(off, axis) \
- SDL_PrivateJoystickAxis( \
- joystick, \
- axis, \
- (Sint16)(((int)curSlot[off] * 257) - 32768) \
- );
- READ_AXIS(3, 0) /* LEFTX */
- READ_AXIS(4, 1) /* LEFTY */
- READ_AXIS(5, 2) /* RIGHTX */
- READ_AXIS(6, 3) /* RIGHTY */
- READ_AXIS(7, 4) /* TRIGGERLEFT */
- READ_AXIS(8, 5) /* TRIGGERRIGHT */
- #undef READ_AXIS
- }
- }
-
- /* Write rumble packet */
- now = SDL_GetTicks();
- for (i = 0; i < 4; i += 1) {
- if (ctx->rumbleExpiration[i] > 0) {
- if (SDL_TICKS_PASSED(now, ctx->rumbleExpiration[i]) || !ctx->rumbleAllowed[i]) {
- ctx->rumble[i + 1] = 0;
- ctx->rumbleExpiration[i] = 0;
- ctx->rumbleUpdate = 1;
- }
- }
- }
- if (ctx->rumbleUpdate) {
- hid_write(context->device, ctx->rumble, sizeof(ctx->rumble));
- ctx->rumbleUpdate = 0;
- }
-
- /* If we got here, nothing bad happened! */
- return SDL_TRUE;
-}
-
-static int
-HIDAPI_DriverGameCube_NumJoysticks(SDL_HIDAPI_DriverData *context)
-{
- SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
- int i, joysticks = 0;
- for (i = 0; i < 4; i += 1) {
- if (ctx->joysticks[i] != -1) {
- joysticks += 1;
- }
- }
- return joysticks;
-}
-
-static int
-HIDAPI_DriverGameCube_PlayerIndexForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
- Uint8 i;
- for (i = 0; i < 4; i += 1) {
- if (ctx->joysticks[i] != -1) {
- if (index == 0) {
- return i;
- }
- index -= 1;
- }
- }
- return -1; /* Should never get here! */
-}
-
-static SDL_JoystickID
-HIDAPI_DriverGameCube_InstanceIDForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
- Uint8 i;
- for (i = 0; i < 4; i += 1) {
- if (ctx->joysticks[i] != -1) {
- if (index == 0) {
- return ctx->joysticks[i];
- }
- index -= 1;
- }
- }
- return -1; /* Should never get here! */
-}
-
-static SDL_bool
-HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick)
-{
- SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
- SDL_JoystickID instance = SDL_JoystickInstanceID(joystick);
- Uint8 i;
- for (i = 0; i < 4; i += 1) {
- if (instance == ctx->joysticks[i]) {
- joystick->nbuttons = 12;
- joystick->naxes = 6;
- joystick->epowerlevel = ctx->wireless[i] ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED;
- joystick->player_index = i;
- return SDL_TRUE;
- }
- }
- return SDL_FALSE; /* Should never get here! */
-}
-
-static int
-HIDAPI_DriverGameCube_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
-{
- SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)context->context;
- SDL_JoystickID instance = SDL_JoystickInstanceID(joystick);
- Uint8 i, val;
- for (i = 0; i < 4; i += 1) {
- if (instance == ctx->joysticks[i]) {
- if (ctx->wireless[i]) {
- return SDL_SetError("Ninteno GameCube WaveBird controllers do not support rumble");
- }
- if (!ctx->rumbleAllowed[i]) {
- return SDL_SetError("Second USB cable for WUP-028 not connected");
- }
- val = (low_frequency_rumble > 0 || high_frequency_rumble > 0);
- if (val != ctx->rumble[i + 1]) {
- ctx->rumble[i + 1] = val;
- ctx->rumbleUpdate = 1;
- }
- if (val && duration_ms < SDL_HAPTIC_INFINITY) {
- ctx->rumbleExpiration[i] = SDL_GetTicks() + duration_ms;
- } else {
- ctx->rumbleExpiration[i] = 0;
- }
- return 0;
- }
- }
- return -1; /* Should never get here! */
-}
-
-SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube =
-{
- SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE,
- SDL_TRUE,
- HIDAPI_DriverGameCube_IsSupportedDevice,
- HIDAPI_DriverGameCube_GetDeviceName,
- HIDAPI_DriverGameCube_InitDriver,
- HIDAPI_DriverGameCube_QuitDriver,
- HIDAPI_DriverGameCube_UpdateDriver,
- HIDAPI_DriverGameCube_NumJoysticks,
- HIDAPI_DriverGameCube_PlayerIndexForIndex,
- HIDAPI_DriverGameCube_InstanceIDForIndex,
- HIDAPI_DriverGameCube_OpenJoystick,
- HIDAPI_DriverGameCube_Rumble
-};
-
-#endif /* SDL_JOYSTICK_HIDAPI_GAMECUBE */
-
-#endif /* SDL_JOYSTICK_HIDAPI */
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 499f949..8a21ab7 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -108,7 +108,6 @@ typedef struct
} DS4EffectsState_t;
typedef struct {
- SDL_JoystickID joystickID;
SDL_bool is_dongle;
SDL_bool is_bluetooth;
SDL_bool audio_supported;
@@ -273,8 +272,10 @@ static SDL_bool HIDAPI_DriverPS4_CanRumble(Uint16 vendor_id, Uint16 product_id)
return SDL_TRUE;
}
+static int HIDAPI_DriverPS4_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
+
static SDL_bool
-HIDAPI_DriverPS4_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id, Uint16 product_id, int *num_joysticks)
+HIDAPI_DriverPS4_Init(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context)
{
SDL_DriverPS4_Context *ctx;
@@ -283,14 +284,14 @@ HIDAPI_DriverPS4_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id, Ui
SDL_OutOfMemory();
return SDL_FALSE;
}
- context->context = ctx;
+ *context = ctx;
/* Check for type of connection */
ctx->is_dongle = (vendor_id == SONY_USB_VID && product_id == SONY_DS4_DONGLE_PID);
if (ctx->is_dongle) {
ctx->is_bluetooth = SDL_FALSE;
} else if (vendor_id == SONY_USB_VID) {
- ctx->is_bluetooth = !CheckUSBConnected(context->device);
+ ctx->is_bluetooth = !CheckUSBConnected(dev);
} else {
/* Third party controllers appear to all be wired */
ctx->is_bluetooth = SDL_FALSE;
@@ -313,51 +314,8 @@ HIDAPI_DriverPS4_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id, Ui
}
}
- ctx->joystickID = SDL_GetNextJoystickInstanceID();
- *num_joysticks += 1;
- SDL_PrivateJoystickAdded(ctx->joystickID);
-
- return SDL_TRUE;
-}
-
-static void
-HIDAPI_DriverPS4_QuitDriver(SDL_HIDAPI_DriverData *context, SDL_bool send_event, int *num_joysticks)
-{
- SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)context->context;
-
- *num_joysticks -= 1;
- if (send_event) {
- SDL_PrivateJoystickRemoved(ctx->joystickID);
- }
- SDL_free(context->context);
-}
-
-static int
-HIDAPI_DriverPS4_NumJoysticks(SDL_HIDAPI_DriverData *context)
-{
- return 1;
-}
-
-static int
-HIDAPI_DriverPS4_PlayerIndexForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- return -1;
-}
-
-static SDL_JoystickID
-HIDAPI_DriverPS4_InstanceIDForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)context->context;
- return ctx->joystickID;
-}
-
-static int HIDAPI_DriverPS4_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
-
-static SDL_bool
-HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick)
-{
/* Initialize LED and effect state */
- HIDAPI_DriverPS4_Rumble(context, joystick, 0, 0, 0);
+ HIDAPI_DriverPS4_Rumble(joystick, dev, ctx, 0, 0, 0);
/* Initialize the joystick capabilities */
joystick->nbuttons = 16;
@@ -368,9 +326,9 @@ HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *joys
}
static int
-HIDAPI_DriverPS4_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
+HIDAPI_DriverPS4_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
- SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)context->context;
+ SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)context;
DS4EffectsState_t *effects;
Uint8 data[78];
int report_size, offset;
@@ -428,7 +386,7 @@ HIDAPI_DriverPS4_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick,
SDL_memcpy(&data[report_size - sizeof(unCRC)], &unCRC, sizeof(unCRC));
}
- if (hid_write(context->device, data, report_size) != report_size) {
+ if (hid_write(dev, data, report_size) != report_size) {
return SDL_SetError("Couldn't send rumble packet");
}
@@ -551,25 +509,20 @@ HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_
}
static SDL_bool
-HIDAPI_DriverPS4_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysticks)
+HIDAPI_DriverPS4_Update(SDL_Joystick *joystick, hid_device *dev, void *context)
{
- SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)context->context;
- SDL_Joystick *joystick = SDL_JoystickFromInstanceID(ctx->joystickID);
+ SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)context;
Uint8 data[USB_PACKET_LENGTH];
int size;
- if (joystick == NULL) {
- return SDL_TRUE; /* Nothing to do right now! */
- }
-
- while ((size = hid_read_timeout(context->device, data, sizeof(data), 0)) > 0) {
+ while ((size = hid_read_timeout(dev, data, sizeof(data), 0)) > 0) {
switch (data[0]) {
case k_EPS4ReportIdUsbState:
- HIDAPI_DriverPS4_HandleStatePacket(joystick, context->device, ctx, (PS4StatePacket_t *)&data[1]);
+ HIDAPI_DriverPS4_HandleStatePacket(joystick, dev, ctx, (PS4StatePacket_t *)&data[1]);
break;
case k_EPS4ReportIdBluetoothState:
/* Bluetooth state packets have two additional bytes at the beginning */
- HIDAPI_DriverPS4_HandleStatePacket(joystick, context->device, ctx, (PS4StatePacket_t *)&data[3]);
+ HIDAPI_DriverPS4_HandleStatePacket(joystick, dev, ctx, (PS4StatePacket_t *)&data[3]);
break;
default:
#ifdef DEBUG_JOYSTICK
@@ -582,27 +535,29 @@ HIDAPI_DriverPS4_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysticks
if (ctx->rumble_expiration) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, ctx->rumble_expiration)) {
- HIDAPI_DriverPS4_Rumble(context, joystick, 0, 0, 0);
+ HIDAPI_DriverPS4_Rumble(joystick, dev, context, 0, 0, 0);
}
}
return (size >= 0);
}
+static void
+HIDAPI_DriverPS4_Quit(SDL_Joystick *joystick, hid_device *dev, void *context)
+{
+ SDL_free(context);
+}
+
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4 =
{
SDL_HINT_JOYSTICK_HIDAPI_PS4,
SDL_TRUE,
HIDAPI_DriverPS4_IsSupportedDevice,
HIDAPI_DriverPS4_GetDeviceName,
- HIDAPI_DriverPS4_InitDriver,
- HIDAPI_DriverPS4_QuitDriver,
- HIDAPI_DriverPS4_UpdateDriver,
- HIDAPI_DriverPS4_NumJoysticks,
- HIDAPI_DriverPS4_PlayerIndexForIndex,
- HIDAPI_DriverPS4_InstanceIDForIndex,
- HIDAPI_DriverPS4_OpenJoystick,
- HIDAPI_DriverPS4_Rumble
+ HIDAPI_DriverPS4_Init,
+ HIDAPI_DriverPS4_Rumble,
+ HIDAPI_DriverPS4_Update,
+ HIDAPI_DriverPS4_Quit
};
#endif /* SDL_JOYSTICK_HIDAPI_PS4 */
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index d2f246b..27c988c 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -183,7 +183,6 @@ typedef struct
#pragma pack()
typedef struct {
- SDL_JoystickID joystickID;
hid_device *dev;
SDL_bool m_bIsUsingBluetooth;
Uint8 m_nCommandNumber;
@@ -571,7 +570,7 @@ static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, i
}
static SDL_bool
-HIDAPI_DriverSwitch_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id, Uint16 product_id, int *num_joysticks)
+HIDAPI_DriverSwitch_Init(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context)
{
SDL_DriverSwitch_Context *ctx;
Uint8 input_mode;
@@ -581,9 +580,9 @@ HIDAPI_DriverSwitch_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id,
SDL_OutOfMemory();
return SDL_FALSE;
}
- ctx->dev = context->device;
+ ctx->dev = dev;
- context->context = ctx;
+ *context = ctx;
/* Initialize rumble data */
SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[0]);
@@ -628,18 +627,6 @@ HIDAPI_DriverSwitch_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id,
}
}
- ctx->joystickID = SDL_GetNextJoystickInstanceID();
- *num_joysticks += 1;
- SDL_PrivateJoystickAdded(ctx->joystickID);
-
- return SDL_TRUE;
-}
-
-static SDL_bool
-HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick)
-{
- SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context->context;
-
/* Set the LED state */
SetHomeLED(ctx, 100);
SetSlotLED(ctx, (joystick->instance_id % 4));
@@ -653,9 +640,9 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *j
}
static int
-HIDAPI_DriverSwitch_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
+HIDAPI_DriverSwitch_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
- SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context->context;
+ SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context;
/* Experimentally determined rumble values. These will only matter on some controllers as tested ones
* seem to disregard these and just use any non-zero rumble values as a binary flag for constant rumble
@@ -860,16 +847,11 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C
}
static SDL_bool
-HIDAPI_DriverSwitch_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysticks)
+HIDAPI_DriverSwitch_Update(SDL_Joystick *joystick, hid_device *dev, void *context)
{
- SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context->context;
- SDL_Joystick *joystick = SDL_JoystickFromInstanceID(ctx->joystickID);
+ SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context;
int size;
- if (joystick == NULL) {
- return SDL_TRUE; /* Nothing to do right now! */
- }
-
while ((size = ReadInput(ctx)) > 0) {
switch (ctx->m_rgucReadBuffer[0]) {
case k_eSwitchInputReportIDs_SimpleControllerState:
@@ -886,7 +868,7 @@ HIDAPI_DriverSwitch_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysti
if (ctx->m_nRumbleExpiration) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, ctx->m_nRumbleExpiration)) {
- HIDAPI_DriverSwitch_Rumble(context, joystick, 0, 0, 0);
+ HIDAPI_DriverSwitch_Rumble(joystick, dev, context, 0, 0, 0);
}
}
@@ -894,37 +876,14 @@ HIDAPI_DriverSwitch_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysti
}
static void
-HIDAPI_DriverSwitch_QuitDriver(SDL_HIDAPI_DriverData *context, SDL_bool send_event, int *num_joysticks)
+HIDAPI_DriverSwitch_Quit(SDL_Joystick *joystick, hid_device *dev, void *context)
{
- SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context->context;
+ SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context;
/* Restore simple input mode for other applications */
SetInputMode(ctx, k_eSwitchInputReportIDs_SimpleControllerState);
- *num_joysticks -= 1;
- if (send_event) {
- SDL_PrivateJoystickRemoved(ctx->joystickID);
- }
- SDL_free(context->context);
-}
-
-static int
-HIDAPI_DriverSwitch_NumJoysticks(SDL_HIDAPI_DriverData *context)
-{
- return 1;
-}
-
-static int
-HIDAPI_DriverSwitch_PlayerIndexForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- return -1;
-}
-
-static SDL_JoystickID
-HIDAPI_DriverSwitch_InstanceIDForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- SDL_DriverSwitch_Context *ctx = (SDL_DriverSwitch_Context *)context->context;
- return ctx->joystickID;
+ SDL_free(context);
}
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch =
@@ -933,14 +892,10 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch =
SDL_TRUE,
HIDAPI_DriverSwitch_IsSupportedDevice,
HIDAPI_DriverSwitch_GetDeviceName,
- HIDAPI_DriverSwitch_InitDriver,
- HIDAPI_DriverSwitch_QuitDriver,
- HIDAPI_DriverSwitch_UpdateDriver,
- HIDAPI_DriverSwitch_NumJoysticks,
- HIDAPI_DriverSwitch_PlayerIndexForIndex,
- HIDAPI_DriverSwitch_InstanceIDForIndex,
- HIDAPI_DriverSwitch_OpenJoystick,
- HIDAPI_DriverSwitch_Rumble
+ HIDAPI_DriverSwitch_Init,
+ HIDAPI_DriverSwitch_Rumble,
+ HIDAPI_DriverSwitch_Update,
+ HIDAPI_DriverSwitch_Quit
};
#endif /* SDL_JOYSTICK_HIDAPI_SWITCH */
diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c
index eb67089..535e53f 100644
--- a/src/joystick/hidapi/SDL_hidapi_xbox360.c
+++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c
@@ -54,7 +54,6 @@
typedef struct {
- SDL_JoystickID joystickID;
Uint8 last_state[USB_PACKET_LENGTH];
Uint32 rumble_expiration;
#ifdef SDL_JOYSTICK_HIDAPI_WINDOWS_XINPUT
@@ -282,7 +281,7 @@ static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot)
}
static SDL_bool
-HIDAPI_DriverXbox360_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id, Uint16 product_id, int *num_joysticks)
+HIDAPI_DriverXbox360_Init(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context)
{
SDL_DriverXbox360_Context *ctx;
@@ -301,20 +300,10 @@ HIDAPI_DriverXbox360_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id
#ifdef SDL_JOYSTICK_HIDAPI_WINDOWS_GAMING_INPUT
HIDAPI_DriverXbox360_InitWindowsGamingInput(ctx);
#endif
- context->context = ctx;
+ *context = ctx;
- ctx->joystickID = SDL_GetNextJoystickInstanceID();
- *num_joysticks += 1;
- SDL_PrivateJoystickAdded(ctx->joystickID);
-
- return SDL_TRUE;
-}
-
-static SDL_bool
-HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick)
-{
/* Set the controller LED */
- SetSlotLED(context->device, (joystick->instance_id % 4));
+ SetSlotLED(dev, (joystick->instance_id % 4));
/* Initialize the joystick capabilities */
joystick->nbuttons = SDL_CONTROLLER_BUTTON_MAX;
@@ -325,28 +314,9 @@ HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *
}
static int
-HIDAPI_DriverXbox360_NumJoysticks(SDL_HIDAPI_DriverData *context)
+HIDAPI_DriverXbox360_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
- return 1;
-}
-
-static int
-HIDAPI_DriverXbox360_PlayerIndexForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- return -1;
-}
-
-static SDL_JoystickID
-HIDAPI_DriverXbox360_InstanceIDForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context->context;
- return ctx->joystickID;
-}
-
-static int
-HIDAPI_DriverXbox360_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
-{
- SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context->context;
+ SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context;
#ifdef __WIN32__
SDL_bool rumbled = SDL_FALSE;
@@ -399,7 +369,7 @@ HIDAPI_DriverXbox360_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joysti
rumble_packet[4] = (high_frequency_rumble >> 8);
#endif
- if (hid_write(context->device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
+ if (hid_write(dev, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
#endif /* __WIN32__ */
@@ -739,31 +709,26 @@ HIDAPI_DriverXboxOneS_HandleGuidePacket(SDL_Joystick *joystick, hid_device *dev,
#endif /* __MACOSX__ */
static SDL_bool
-HIDAPI_DriverXbox360_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysticks)
+HIDAPI_DriverXbox360_Update(SDL_Joystick *joystick, hid_device *dev, void *context)
{
- SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context->context;
- SDL_Joystick *joystick = SDL_JoystickFromInstanceID(ctx->joystickID);
+ SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context;
Uint8 data[USB_PACKET_LENGTH];
int size;
- if (joystick == NULL) {
- return SDL_TRUE; /* Nothing to do right now! */
- }
-
- while ((size = hid_read_timeout(context->device, data, sizeof(data), 0)) > 0) {
+ while ((size = hid_read_timeout(dev, data, sizeof(data), 0)) > 0) {
#ifdef __WIN32__
- HIDAPI_DriverXbox360_HandleStatePacket(joystick, context->device, ctx, data, size);
+ HIDAPI_DriverXbox360_HandleStatePacket(joystick, dev, ctx, data, size);
#else
switch (data[0]) {
case 0x00:
- HIDAPI_DriverXbox360_HandleStatePacket(joystick, context->device, ctx, data, size);
+ HIDAPI_DriverXbox360_HandleStatePacket(joystick, dev, ctx, data, size);
break;
#ifdef __MACOSX__
case 0x01:
- HIDAPI_DriverXboxOneS_HandleStatePacket(joystick, context->device, ctx, data, size);
+ HIDAPI_DriverXboxOneS_HandleStatePacket(joystick, dev, ctx, data, size);
break;
case 0x02:
- HIDAPI_DriverXboxOneS_HandleGuidePacket(joystick, context->device, ctx, data, size);
+ HIDAPI_DriverXboxOneS_HandleGuidePacket(joystick, dev, ctx, data, size);
break;
#endif
default:
@@ -781,7 +746,7 @@ HIDAPI_DriverXbox360_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joyst
if (ctx->rumble_expiration) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, ctx->rumble_expiration)) {
- HIDAPI_DriverXbox360_Rumble(context, joystick, 0, 0, 0);
+ HIDAPI_DriverXbox360_Rumble(joystick, dev, context, 0, 0, 0);
}
}
@@ -789,9 +754,11 @@ HIDAPI_DriverXbox360_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joyst
}
static void
-HIDAPI_DriverXbox360_QuitDriver(SDL_HIDAPI_DriverData *context, SDL_bool send_event, int *num_joysticks)
+HIDAPI_DriverXbox360_Quit(SDL_Joystick *joystick, hid_device *dev, void *context)
{
- SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context->context;
+#if defined(SDL_JOYSTICK_HIDAPI_WINDOWS_XINPUT) || defined(SDL_JOYSTICK_HIDAPI_WINDOWS_GAMING_INPUT)
+ SDL_DriverXbox360_Context *ctx = (SDL_DriverXbox360_Context *)context;
+#endif
#ifdef SDL_JOYSTICK_HIDAPI_WINDOWS_XINPUT
if (ctx->xinput_enabled) {
@@ -802,11 +769,7 @@ HIDAPI_DriverXbox360_QuitDriver(SDL_HIDAPI_DriverData *context, SDL_bool send_ev
#ifdef SDL_JOYSTICK_HIDAPI_WINDOWS_GAMING_INPUT
HIDAPI_DriverXbox360_InitWindowsGamingInput(ctx);
#endif
- *num_joysticks -= 1;
- if (send_event) {
- SDL_PrivateJoystickRemoved(ctx->joystickID);
- }
- SDL_free(context->context);
+ SDL_free(context);
}
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 =
@@ -815,14 +778,10 @@ SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360 =
SDL_TRUE,
HIDAPI_DriverXbox360_IsSupportedDevice,
HIDAPI_DriverXbox360_GetDeviceName,
- HIDAPI_DriverXbox360_InitDriver,
- HIDAPI_DriverXbox360_QuitDriver,
- HIDAPI_DriverXbox360_UpdateDriver,
- HIDAPI_DriverXbox360_NumJoysticks,
- HIDAPI_DriverXbox360_PlayerIndexForIndex,
- HIDAPI_DriverXbox360_InstanceIDForIndex,
- HIDAPI_DriverXbox360_OpenJoystick,
- HIDAPI_DriverXbox360_Rumble
+ HIDAPI_DriverXbox360_Init,
+ HIDAPI_DriverXbox360_Rumble,
+ HIDAPI_DriverXbox360_Update,
+ HIDAPI_DriverXbox360_Quit
};
#endif /* SDL_JOYSTICK_HIDAPI_XBOX360 */
diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c
index 734c76e..fde74bb 100644
--- a/src/joystick/hidapi/SDL_hidapi_xboxone.c
+++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c
@@ -124,7 +124,6 @@ static const SDL_DriverXboxOne_InitPacket xboxone_init_packets[] = {
};
typedef struct {
- SDL_JoystickID joystickID;
Uint8 sequence;
Uint8 last_state[USB_PACKET_LENGTH];
Uint32 rumble_expiration;
@@ -144,7 +143,7 @@ HIDAPI_DriverXboxOne_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
}
static SDL_bool
-HIDAPI_DriverXboxOne_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id, Uint16 product_id, int *num_joysticks)
+HIDAPI_DriverXboxOne_Init(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context)
{
SDL_DriverXboxOne_Context *ctx;
int i;
@@ -155,7 +154,7 @@ HIDAPI_DriverXboxOne_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id
SDL_OutOfMemory();
return SDL_FALSE;
}
- context->context = ctx;
+ *context = ctx;
/* Send the controller init data */
for (i = 0; i < SDL_arraysize(xboxone_init_packets); ++i) {
@@ -163,7 +162,7 @@ HIDAPI_DriverXboxOne_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id
if (!packet->vendor_id || (vendor_id == packet->vendor_id && product_id == packet->product_id)) {
SDL_memcpy(init_packet, packet->data, packet->size);
init_packet[2] = ctx->sequence++;
- if (hid_write(context->device, init_packet, packet->size) != packet->size) {
+ if (hid_write(dev, init_packet, packet->size) != packet->size) {
SDL_SetError("Couldn't write Xbox One initialization packet");
SDL_free(ctx);
return SDL_FALSE;
@@ -171,16 +170,6 @@ HIDAPI_DriverXboxOne_InitDriver(SDL_HIDAPI_DriverData *context, Uint16 vendor_id
}
}
- ctx->joystickID = SDL_GetNextJoystickInstanceID();
- *num_joysticks += 1;
- SDL_PrivateJoystickAdded(ctx->joystickID);
-
- return SDL_TRUE;
-}
-
-static SDL_bool
-HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick)
-{
/* Initialize the joystick capabilities */
joystick->nbuttons = SDL_CONTROLLER_BUTTON_MAX;
joystick->naxes = SDL_CONTROLLER_AXIS_MAX;
@@ -189,41 +178,10 @@ HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_DriverData *context, SDL_Joystick *
return SDL_TRUE;
}
-static void
-HIDAPI_DriverXboxOne_QuitDriver(SDL_HIDAPI_DriverData *context, SDL_bool send_event, int *num_joysticks)
-{
- SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context->context;
-
- *num_joysticks -= 1;
- if (send_event) {
- SDL_PrivateJoystickRemoved(ctx->joystickID);
- }
- SDL_free(context->context);
-}
-
static int
-HIDAPI_DriverXboxOne_NumJoysticks(SDL_HIDAPI_DriverData *context)
+HIDAPI_DriverXboxOne_Rumble(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
- return 1;
-}
-
-static int
-HIDAPI_DriverXboxOne_PlayerIndexForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- return -1;
-}
-
-static SDL_JoystickID
-HIDAPI_DriverXboxOne_InstanceIDForIndex(SDL_HIDAPI_DriverData *context, int index)
-{
- SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context->context;
- return ctx->joystickID;
-}
-
-static int
-HIDAPI_DriverXboxOne_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
-{
- SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context->context;
+ SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context;
Uint8 rumble_packet[] = { 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF };
/* The Rock Candy Xbox One Controller limits the range of
@@ -236,7 +194,7 @@ HIDAPI_DriverXboxOne_Rumble(SDL_HIDAPI_DriverData *context, SDL_Joystick *joysti
rumble_packet[8] = (low_frequency_rumble >> 9);
rumble_packet[9] = (high_frequency_rumble >> 9);
- if (hid_write(context->device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
+ if (hid_write(dev, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
@@ -309,24 +267,19 @@ HIDAPI_DriverXboxOne_HandleModePacket(SDL_Joystick *joystick, hid_device *dev, S
}
static SDL_bool
-HIDAPI_DriverXboxOne_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joysticks)
+HIDAPI_DriverXboxOne_Update(SDL_Joystick *joystick, hid_device *dev, void *context)
{
- SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context->context;
- SDL_Joystick *joystick = SDL_JoystickFromInstanceID(ctx->joystickID);
+ SDL_DriverXboxOne_Context *ctx = (SDL_DriverXboxOne_Context *)context;
Uint8 data[USB_PACKET_LENGTH];
int size;
- if (joystick == NULL) {
- return SDL_TRUE; /* Nothing to do right now! */
- }
-
- while ((size = hid_read_timeout(context->device, data, sizeof(data), 0)) > 0) {
+ while ((size = hid_read_timeout(dev, data, sizeof(data), 0)) > 0) {
switch (data[0]) {
case 0x20:
- HIDAPI_DriverXboxOne_HandleStatePacket(joystick, context->device, ctx, data, size);
+ HIDAPI_DriverXboxOne_HandleStatePacket(joystick, dev, ctx, data, size);
break;
case 0x07:
- HIDAPI_DriverXboxOne_HandleModePacket(joystick, context->device, ctx, data, size);
+ HIDAPI_DriverXboxOne_HandleModePacket(joystick, dev, ctx, data, size);
break;
default:
#ifdef DEBUG_JOYSTICK
@@ -339,27 +292,29 @@ HIDAPI_DriverXboxOne_UpdateDriver(SDL_HIDAPI_DriverData *context, int *num_joyst
if (ctx->rumble_expiration) {
Uint32 now = SDL_GetTicks();
if (SDL_TICKS_PASSED(now, ctx->rumble_expiration)) {
- HIDAPI_DriverXboxOne_Rumble(context, joystick, 0, 0, 0);
+ HIDAPI_DriverXboxOne_Rumble(joystick, dev, context, 0, 0, 0);
}
}
return (size >= 0);
}
+static void
+HIDAPI_DriverXboxOne_Quit(SDL_Joystick *joystick, hid_device *dev, void *context)
+{
+ SDL_free(context);
+}
+
SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne =
{
SDL_HINT_JOYSTICK_HIDAPI_XBOX,
SDL_TRUE,
HIDAPI_DriverXboxOne_IsSupportedDevice,
HIDAPI_DriverXboxOne_GetDeviceName,
- HIDAPI_DriverXboxOne_InitDriver,
- HIDAPI_DriverXboxOne_QuitDriver,
- HIDAPI_DriverXboxOne_UpdateDriver,
- HIDAPI_DriverXboxOne_NumJoysticks,
- HIDAPI_DriverXboxOne_PlayerIndexForIndex,
- HIDAPI_DriverXboxOne_InstanceIDForIndex,
- HIDAPI_DriverXboxOne_OpenJoystick,
- HIDAPI_DriverXboxOne_Rumble
+ HIDAPI_DriverXboxOne_Init,
+ HIDAPI_DriverXboxOne_Rumble,
+ HIDAPI_DriverXboxOne_Update,
+ HIDAPI_DriverXboxOne_Quit
};
#endif /* SDL_JOYSTICK_HIDAPI_XBOXONE */
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 319cf3a..e420354 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -50,10 +50,18 @@
#endif
#endif
-typedef struct _SDL_HIDAPI_Device
+struct joystick_hwdata
{
- SDL_HIDAPI_DriverData devdata;
+ SDL_HIDAPI_DeviceDriver *driver;
+ void *context;
+
SDL_mutex *mutex;
+ hid_device *dev;
+};
+
+typedef struct _SDL_HIDAPI_Device
+{
+ SDL_JoystickID instance_id;
char *name;
char *path;
Uint16 vendor_id;
@@ -87,9 +95,6 @@ static SDL_HIDAPI_DeviceDriver *SDL_HIDAPI_drivers[] = {
#ifdef SDL_JOYSTICK_HIDAPI_XBOXONE
&SDL_HIDAPI_DriverXboxOne,
#endif
-#ifdef SDL_JOYSTICK_HIDAPI_GAMECUBE
- &SDL_HIDAPI_DriverGameCube,
-#endif
};
static SDL_HIDAPI_Device *SDL_HIDAPI_devices;
static int SDL_HIDAPI_numjoysticks = 0;
@@ -388,36 +393,6 @@ HIDAPI_ShutdownDiscovery()
#endif
}
-static void
-HIDAPI_InitDriver(SDL_HIDAPI_Device *device)
-{
- device->devdata.device = hid_open_path(device->path, 0);
- if (!device->devdata.device) {
- SDL_SetError("Couldn't open HID device %s", device->path);
- device->driver = NULL;
- } else {
- device->driver->InitDriver(
- &device->devdata,
- device->vendor_id,
- device->product_id,
- &SDL_HIDAPI_numjoysticks
- );
- device->mutex = SDL_CreateMutex();
- }
-}
-
-static void
-HIDAPI_QuitDriver(SDL_HIDAPI_Device *device, SDL_bool send_event)
-{
- device->driver->QuitDriver(
- &device->devdata,
- send_event,
- &SDL_HIDAPI_numjoysticks
- );
- hid_close(device->devdata.device);
- SDL_DestroyMutex(device->mutex);
- device->driver = NULL;
-}
const char *
HIDAPI_XboxControllerName(Uint16 vendor_id, Uint16 product_id)
@@ -630,17 +605,15 @@ HIDAPI_GetDeviceDriver(SDL_HIDAPI_Device *device)
}
static SDL_HIDAPI_Device *
-HIDAPI_GetDeviceByIndex(int device_index)
+HIDAPI_GetJoystickByIndex(int device_index)
{
SDL_HIDAPI_Device *device = SDL_HIDAPI_devices;
- int joysticks;
while (device) {
if (device->driver) {
- joysticks = device->driver->NumJoysticks(&device->devdata);
- if (device_index < joysticks) {
+ if (device_index == 0) {
break;
}
- device_index -= joysticks;
+ --device_index;
}
device = device->next;
}
@@ -687,12 +660,20 @@ SDL_HIDAPIDriverHintChanged(void *userdata, const char *name, const char *oldVal
while (device) {
if (device->driver) {
if (!device->driver->enabled) {
- HIDAPI_QuitDriver(device, SDL_TRUE);
+ device->driver = NULL;
+
+ --SDL_HIDAPI_numjoysticks;
+
+ SDL_PrivateJoystickRemoved(device->instance_id);
}
} else {
device->driver = HIDAPI_GetDeviceDriver(device);
if (device->driver) {
- HIDAPI_InitDriver(device);
+ device->instance_id = SDL_GetNextJoystickInstanceID();
+
+ ++SDL_HIDAPI_numjoysticks;
+
+ SDL_PrivateJoystickAdded(device->instance_id);
}
}
device = device->next;
@@ -742,6 +723,7 @@ HIDAPI_AddDevice(struct hid_device_info *info)
if (!device) {
return;
}
+ device->instance_id = -1;
device->seen = SDL_TRUE;
device->vendor_id = info->vendor_id;
device->product_id = info->product_id;
@@ -836,8 +818,12 @@ HIDAPI_AddDevice(struct hid_device_info *info)
}
if (device->driver) {
- /* It's a joystick device! */
- HIDAPI_InitDriver(device);
+ /* It's a joystick! */
+ device->instance_id = SDL_GetNextJoystickInstanceID();
+
+ ++SDL_HIDAPI_numjoysticks;
+
+ SDL_PrivateJoystickAdded(device->instance_id);
}
}
@@ -854,8 +840,11 @@ HIDAPI_DelDevice(SDL_HIDAPI_Device *device, SDL_bool send_event)
SDL_HIDAPI_devices = curr->next;
}
- if (device->driver) {
- HIDAPI_QuitDriver(device, send_event);
+ if (device->driver && send_event) {
+ /* Need to decrement the joystick count before we post the event */
+ --SDL_HIDAPI_numjoysticks;
+
+ SDL_PrivateJoystickRemoved(device->instance_id);
}
SDL_free(device->name);
@@ -942,85 +931,101 @@ HIDAPI_JoystickDetect(void)
static const char *
HIDAPI_JoystickGetDeviceName(int device_index)
{
- return HIDAPI_GetDeviceByIndex(device_index)->name;
+ return HIDAPI_GetJoystickByIndex(device_index)->name;
}
static int
HIDAPI_JoystickGetDevicePlayerIndex(int device_index)
{
- SDL_HIDAPI_Device *device = SDL_HIDAPI_devices;
- int joysticks;
- while (device) {
- if (device->driver) {
- joysticks = device->driver->NumJoysticks(&device->devdata);
- if (device_index < joysticks) {
- break;
- }
- device_index -= joysticks;
- }
- device = device->next;
- }
- return device->driver->PlayerIndexForIndex(&device->devdata, device_index);
+ return -1;
}
static SDL_JoystickGUID
HIDAPI_JoystickGetDeviceGUID(int device_index)
{
- return HIDAPI_GetDeviceByIndex(device_index)->guid;
+ return HIDAPI_GetJoystickByIndex(device_index)->guid;
}
static SDL_JoystickID
HIDAPI_JoystickGetDeviceInstanceID(int device_index)
{
- SDL_HIDAPI_Device *device = SDL_HIDAPI_devices;
- int joysticks;
- while (device) {
- if (device->driver) {
- joysticks = device->driver->NumJoysticks(&device->devdata);
- if (device_index < joysticks) {
- break;
- }
- device_index -= joysticks;
- }
- device = device->next;
- }
- return device->driver->InstanceIDForIndex(&device->devdata, device_index);
+ return HIDAPI_GetJoystickByIndex(device_index)->instance_id;
}
static int
HIDAPI_JoystickOpen(SDL_Joystick * joystick, int device_index)
{
- SDL_HIDAPI_Device *device = HIDAPI_GetDeviceByIndex(device_index);
+ SDL_HIDAPI_Device *device = HIDAPI_GetJoystickByIndex(device_index);
+ struct joystick_hwdata *hwdata;
- if (!device->driver->OpenJoystick(&device->devdata, joystick)) {
+ hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata));
+ if (!hwdata) {
+ return SDL_OutOfMemory();
+ }
+
+ hwdata->driver = device->driver;
+ hwdata->dev = hid_open_path(device->path, 0);
+ if (!hwdata->dev) {
+ SDL_free(hwdata);
+ return SDL_SetError("Couldn't open HID device %s", device->path);
+ }
+ hwdata->mutex = SDL_CreateMutex();
+
+ if (!device->driver->Init(joystick, hwdata->dev, device->vendor_id, device->product_id, &hwdata->context)) {
+ hid_close(hwdata->dev);
+ SDL_free(hwdata);
return -1;
}
- joystick->hwdata = (struct joystick_hwdata *)device;
+ joystick->hwdata = hwdata;
return 0;
}
static int
HIDAPI_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
{
- SDL_HIDAPI_Device *device = (SDL_HIDAPI_Device *)joystick->hwdata;
+ struct joystick_hwdata *hwdata = joystick->hwdata;
+ SDL_HIDAPI_DeviceDriver *driver = hwdata->driver;
int result;
- SDL_LockMutex(device->mutex);
- result = device->driver->Rumble(&device->devdata, joystick, low_frequency_rumble, high_frequency_rumble, duration_ms);
- SDL_UnlockMutex(device->mutex);
+ SDL_LockMutex(hwdata->mutex);
+ result = driver->Rumble(joystick, hwdata->dev, hwdata->context, low_frequency_rumble, high_frequency_rumble, duration_ms);
+ SDL_UnlockMutex(hwdata->mutex);
return result;
}
static void
HIDAPI_JoystickUpdate(SDL_Joystick * joystick)
{
- /* No-op, all updates are done in SDL_HIDAPI_UpdateDevices */
+ struct joystick_hwdata *hwdata = joystick->hwdata;
+ SDL_HIDAPI_DeviceDriver *driver = hwdata->driver;
+ SDL_bool succeeded;
+
+ SDL_LockMutex(hwdata->mutex);
+ succeeded = driver->Update(joystick, hwdata->dev, hwdata->context);
+ SDL_UnlockMutex(hwdata->mutex);
+
+ if (!succeeded) {
+ SDL_HIDAPI_Device *device;
+ for (device = SDL_HIDAPI_devices; device; device = device->next) {
+ if (device->instance_id == joystick->instance_id) {
+ HIDAPI_DelDevice(device, SDL_TRUE);
+ break;
+ }
+ }
+ }
}
static void
HIDAPI_JoystickClose(SDL_Joystick * joystick)
{
+ struct joystick_hwdata *hwdata = joystick->hwdata;
+ SDL_HIDAPI_DeviceDriver *driver = hwdata->driver;
+ driver->Quit(joystick, hwdata->dev, hwdata->context);
+
+ hid_close(hwdata->dev);
+ SDL_DestroyMutex(hwdata->mutex);
+ SDL_free(hwdata);
joystick->hwdata = NULL;
}
@@ -1045,30 +1050,6 @@ HIDAPI_JoystickQuit(void)
hid_exit();
}
-void
-SDL_HIDAPI_UpdateDevices(void)
-{
- SDL_HIDAPI_Device *next, *device = SDL_HIDAPI_devices;
- SDL_bool succeeded;
-
- while (device) {
- if (device->driver) {
- SDL_LockMutex(device->mutex);
- succeeded = device->driver->UpdateDriver(&device->devdata, &SDL_HIDAPI_numjoysticks);
- SDL_UnlockMutex(device->mutex);
- if (!succeeded) {
- next = device->next;
- HIDAPI_DelDevice(device, SDL_TRUE);
- device = next;
- } else {
- device = device->next;
- }
- } else {
- device = device->next;
- }
- }
-}
-
SDL_JoystickDriver SDL_HIDAPI_JoystickDriver =
{
HIDAPI_JoystickInit,
diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h
index 5b2f736..a8e7073 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick_c.h
+++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h
@@ -30,7 +30,6 @@
#define SDL_JOYSTICK_HIDAPI_SWITCH
#define SDL_JOYSTICK_HIDAPI_XBOX360
#define SDL_JOYSTICK_HIDAPI_XBOXONE
-#define SDL_JOYSTICK_HIDAPI_GAMECUBE
#ifdef __WINDOWS__
/* On Windows, Xbox One controllers are handled by the Xbox 360 driver */
@@ -44,38 +43,16 @@
#undef SDL_JOYSTICK_HIDAPI_XBOXONE
#endif
-typedef struct _SDL_HIDAPI_DriverData
-{
- hid_device *device;
- void *context;
-} SDL_HIDAPI_DriverData;
-
typedef struct _SDL_HIDAPI_DeviceDriver
{
const char *hint;
SDL_bool enabled;
SDL_bool (*IsSupportedDevice)(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number);
const char *(*GetDeviceName)(Uint16 vendor_id, Uint16 product_id);
-
- SDL_bool (*InitDriver)(SDL_HIDAPI_DriverData *context,
- Uint16 vendor_id, Uint16 product_id, int *num_joysticks);
- void (*QuitDriver)(SDL_HIDAPI_DriverData *context,
- SDL_bool send_event,
- int *num_joysticks);
- SDL_bool (*UpdateDriver)(SDL_HIDAPI_DriverData *context,
- int *num_joysticks);
- int (*NumJoysticks)(SDL_HIDAPI_DriverData *context);
- int (*PlayerIndexForIndex)(SDL_HIDAPI_DriverData *context,
- int index);
- SDL_JoystickID (*InstanceIDForIndex)(SDL_HIDAPI_DriverData *context,
- int index);
- SDL_bool (*OpenJoystick)(SDL_HIDAPI_DriverData *context,
- SDL_Joystick *joystick);
- int (*Rumble)(SDL_HIDAPI_DriverData *context,
- SDL_Joystick *joystick,
- Uint16 low_frequency_rumble,
- Uint16 high_frequency_rumble,
- Uint32 duration_ms);
+ SDL_bool (*Init)(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context);
+ int (*Rumble)(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
+ SDL_bool (*Update)(SDL_Joystick *joystick, hid_device *dev, void *context);
+ void (*Quit)(SDL_Joystick *joystick, hid_device *dev, void *context);
} SDL_HIDAPI_DeviceDriver;
@@ -85,7 +62,6 @@ extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam;
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch;
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360;
extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne;
-extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube;
/* Return true if a HID device is present and supported as a joystick */
extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version);