WinRT: merged with SDL 2.0.0 codebase (aka. SDL hg rev d4ce48ff30d1)
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 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205
diff --git a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj
new file mode 100644
index 0000000..5c59515
--- /dev/null
+++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj
@@ -0,0 +1,403 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{33048af1-031a-4ce6-b61e-fad2db832e9e}</ProjectGuid>
+ <RootNamespace>SDL</RootNamespace>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
+ <ProjectName>SDL-WinPhone</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110_wp80</PlatformToolset>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110_wp80</PlatformToolset>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110_wp80</PlatformToolset>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110_wp80</PlatformToolset>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PreprocessorDefinitions>_USRDLL;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ <MinimalRebuild>false</MinimalRebuild>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PreprocessorDefinitions>_USRDLL;UNICODE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <ClCompile>
+ <PreprocessorDefinitions>_USRDLL;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ <MinimalRebuild>false</MinimalRebuild>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <ClCompile>
+ <PreprocessorDefinitions>_USRDLL;UNICODE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Reference Include="Windows">
+ <IsWinMDFile>true</IsWinMDFile>
+ </Reference>
+ <Reference Include="platform.winmd">
+ <IsWinMDFile>true</IsWinMDFile>
+ <Private>false</Private>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\begin_code.h" />
+ <ClInclude Include="..\..\include\close_code.h" />
+ <ClInclude Include="..\..\include\SDL.h" />
+ <ClInclude Include="..\..\include\SDL_assert.h" />
+ <ClInclude Include="..\..\include\SDL_atomic.h" />
+ <ClInclude Include="..\..\include\SDL_audio.h" />
+ <ClInclude Include="..\..\include\SDL_blendmode.h" />
+ <ClInclude Include="..\..\include\SDL_clipboard.h" />
+ <ClInclude Include="..\..\include\SDL_config.h" />
+ <ClInclude Include="..\..\include\SDL_config_minimal.h" />
+ <ClInclude Include="..\..\include\SDL_config_windowsrt.h" />
+ <ClInclude Include="..\..\include\SDL_copying.h" />
+ <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
+ <ClInclude Include="..\..\include\SDL_endian.h" />
+ <ClInclude Include="..\..\include\SDL_error.h" />
+ <ClInclude Include="..\..\include\SDL_events.h" />
+ <ClInclude Include="..\..\include\SDL_haptic.h" />
+ <ClInclude Include="..\..\include\SDL_hints.h" />
+ <ClInclude Include="..\..\include\SDL_input.h" />
+ <ClInclude Include="..\..\include\SDL_joystick.h" />
+ <ClInclude Include="..\..\include\SDL_keyboard.h" />
+ <ClInclude Include="..\..\include\SDL_keycode.h" />
+ <ClInclude Include="..\..\include\SDL_loadso.h" />
+ <ClInclude Include="..\..\include\SDL_log.h" />
+ <ClInclude Include="..\..\include\SDL_main.h" />
+ <ClInclude Include="..\..\include\SDL_mouse.h" />
+ <ClInclude Include="..\..\include\SDL_mutex.h" />
+ <ClInclude Include="..\..\include\SDL_name.h" />
+ <ClInclude Include="..\..\include\SDL_pixels.h" />
+ <ClInclude Include="..\..\include\SDL_platform.h" />
+ <ClInclude Include="..\..\include\SDL_power.h" />
+ <ClInclude Include="..\..\include\SDL_quit.h" />
+ <ClInclude Include="..\..\include\SDL_rect.h" />
+ <ClInclude Include="..\..\include\SDL_render.h" />
+ <ClInclude Include="..\..\include\SDL_revision.h" />
+ <ClInclude Include="..\..\include\SDL_rwops.h" />
+ <ClInclude Include="..\..\include\SDL_scancode.h" />
+ <ClInclude Include="..\..\include\SDL_shape.h" />
+ <ClInclude Include="..\..\include\SDL_stdinc.h" />
+ <ClInclude Include="..\..\include\SDL_surface.h" />
+ <ClInclude Include="..\..\include\SDL_system.h" />
+ <ClInclude Include="..\..\include\SDL_syswm.h" />
+ <ClInclude Include="..\..\include\SDL_thread.h" />
+ <ClInclude Include="..\..\include\SDL_timer.h" />
+ <ClInclude Include="..\..\include\SDL_touch.h" />
+ <ClInclude Include="..\..\include\SDL_types.h" />
+ <ClInclude Include="..\..\include\SDL_version.h" />
+ <ClInclude Include="..\..\include\SDL_video.h" />
+ <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
+ <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
+ <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
+ <ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
+ <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
+ <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
+ <ClInclude Include="..\..\src\audio\SDL_wave.h" />
+ <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
+ <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
+ <ClInclude Include="..\..\src\events\blank_cursor.h" />
+ <ClInclude Include="..\..\src\events\default_cursor.h" />
+ <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_dropevents_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_events_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_keyboard_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_sysevents.h" />
+ <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
+ <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
+ <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
+ <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
+ <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
+ <ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h" />
+ <ClInclude Include="..\..\src\render\mmx.h" />
+ <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
+ <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_draw.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_drawline.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_rotate.h" />
+ <ClInclude Include="..\..\src\SDL_assert_c.h" />
+ <ClInclude Include="..\..\src\SDL_error_c.h" />
+ <ClInclude Include="..\..\src\SDL_fatal.h" />
+ <ClInclude Include="..\..\src\SDL_hints_c.h" />
+ <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
+ <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h" />
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h" />
+ <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h" />
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
+ <ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_rect_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
+ <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
+ <ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
+ <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
+ <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audio.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audiocvt.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
+ <ClCompile Include="..\..\src\audio\SDL_mixer.c" />
+ <ClCompile Include="..\..\src\audio\SDL_wave.c" />
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c">
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
+ <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
+ <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
+ <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
+ <ClCompile Include="..\..\src\events\SDL_events.c" />
+ <ClCompile Include="..\..\src\events\SDL_gesture.c" />
+ <ClCompile Include="..\..\src\events\SDL_keyboard.c" />
+ <ClCompile Include="..\..\src\events\SDL_mouse.c" />
+ <ClCompile Include="..\..\src\events\SDL_quit.c" />
+ <ClCompile Include="..\..\src\events\SDL_touch.c" />
+ <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
+ <ClCompile Include="..\..\src\file\SDL_rwops.c" />
+ <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c" />
+ <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
+ <ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
+ <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
+ <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
+ <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
+ <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_render.c" />
+ <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
+ <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_drawline.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_render_sw.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_rotate.c" />
+ <ClCompile Include="..\..\src\SDL.c" />
+ <ClCompile Include="..\..\src\SDL_assert.c" />
+ <ClCompile Include="..\..\src\SDL_error.c" />
+ <ClCompile Include="..\..\src\SDL_fatal.c" />
+ <ClCompile Include="..\..\src\SDL_hints.c" />
+ <ClCompile Include="..\..\src\SDL_log.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
+ <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c" />
+ <ClCompile Include="..\..\src\thread\SDL_thread.c" />
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp" />
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp" />
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp" />
+ <ClCompile Include="..\..\src\timer\SDL_timer.c" />
+ <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
+ <ClCompile Include="..\..\src\video\SDL_bmp.c" />
+ <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
+ <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
+ <ClCompile Include="..\..\src\video\SDL_pixels.c" />
+ <ClCompile Include="..\..\src\video\SDL_rect.c" />
+ <ClCompile Include="..\..\src\video\SDL_RLEaccel.c" />
+ <ClCompile Include="..\..\src\video\SDL_shape.c" />
+ <ClCompile Include="..\..\src\video\SDL_stretch.c" />
+ <ClCompile Include="..\..\src\video\SDL_surface.c" />
+ <ClCompile Include="..\..\src\video\SDL_video.c" />
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
+ </FxCompile>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters
new file mode 100644
index 0000000..4eb56ac
--- /dev/null
+++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters
@@ -0,0 +1,608 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{02b21b9a-45a7-41ee-a8a6-e45d14aa28da}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{abc3a7e6-f955-4cb5-8340-fae0f653e9c1}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="GPU Shaders">
+ <UniqueIdentifier>{fd67993e-5155-488b-9313-d1eb06a1b67e}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\begin_code.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\close_code.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_assert.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_atomic.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_audio.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_blendmode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_clipboard.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_config_minimal.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_config_windowsrt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_copying.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_cpuinfo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_endian.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_error.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_events.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_haptic.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_hints.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_input.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_joystick.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_keyboard.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_keycode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_loadso.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_log.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_main.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_mouse.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_mutex.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_name.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_pixels.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_platform.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_power.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_quit.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_rect.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_render.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_revision.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_rwops.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_scancode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_shape.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_stdinc.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_surface.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_system.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_syswm.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_thread.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_timer.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_touch.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_types.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_video.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_audiomem.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_audio_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_sysaudio.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_wave.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\core\windows\SDL_windows.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\blank_cursor.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\default_cursor.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_dropevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_events_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_keyboard_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_mouse_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_sysevents.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_touch_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_windowevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\mmx.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\SDL_sysrender.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_blendline.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_draw.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_drawline.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_rotate.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_assert_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_error_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_fatal.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_hints_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\SDL_systhread.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\SDL_thread_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\timer\SDL_timer_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit_auto.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit_copy.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit_slow.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_pixels_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_rect_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_shape_internals.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_sysvideo.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\atomic\SDL_atomic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\atomic\SDL_spinlock.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audio.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audiocvt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audiodev.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_mixer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_wave.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windows\SDL_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_clipboardevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_dropevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_events.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_gesture.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_keyboard.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_mouse.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_quit.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_touch.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_windowevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\file\SDL_rwops.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\haptic\SDL_haptic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\joystick\SDL_joystick.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_render.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_yuv_sw.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_blendline.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_drawline.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_render_sw.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_rotate.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_assert.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_error.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_fatal.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_hints.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_log.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_getenv.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_iconv.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_qsort.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_string.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\SDL_thread.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\timer\SDL_timer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_0.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_1.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_A.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_auto.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_copy.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_N.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_slow.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_bmp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_clipboard.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_fillrect.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_pixels.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_rect.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_RLEaccel.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_shape.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_stretch.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_surface.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_video.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
+ <Filter>GPU Shaders</Filter>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
+ <Filter>GPU Shaders</Filter>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
+ <Filter>GPU Shaders</Filter>
+ </FxCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj
new file mode 100644
index 0000000..40a8ffd
--- /dev/null
+++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj
@@ -0,0 +1,505 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
+ <ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
+ <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
+ <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audio.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audiocvt.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
+ <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
+ <ClCompile Include="..\..\src\audio\SDL_mixer.c" />
+ <ClCompile Include="..\..\src\audio\SDL_wave.c" />
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c">
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
+ <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
+ <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
+ <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
+ <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
+ <ClCompile Include="..\..\src\events\SDL_events.c" />
+ <ClCompile Include="..\..\src\events\SDL_gesture.c" />
+ <ClCompile Include="..\..\src\events\SDL_keyboard.c" />
+ <ClCompile Include="..\..\src\events\SDL_mouse.c" />
+ <ClCompile Include="..\..\src\events\SDL_quit.c" />
+ <ClCompile Include="..\..\src\events\SDL_touch.c" />
+ <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
+ <ClCompile Include="..\..\src\file\SDL_rwops.c" />
+ <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c" />
+ <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
+ <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
+ <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
+ <ClCompile Include="..\..\src\joystick\windowsrt\SDL_xinputjoystick.c" />
+ <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
+ <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_render.c" />
+ <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
+ <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_drawline.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_render_sw.c" />
+ <ClCompile Include="..\..\src\render\software\SDL_rotate.c" />
+ <ClCompile Include="..\..\src\SDL.c" />
+ <ClCompile Include="..\..\src\SDL_assert.c" />
+ <ClCompile Include="..\..\src\SDL_error.c" />
+ <ClCompile Include="..\..\src\SDL_fatal.c" />
+ <ClCompile Include="..\..\src\SDL_hints.c" />
+ <ClCompile Include="..\..\src\SDL_log.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
+ <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
+ <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c" />
+ <ClCompile Include="..\..\src\thread\SDL_thread.c" />
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp" />
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp" />
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp" />
+ <ClCompile Include="..\..\src\timer\SDL_timer.c" />
+ <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
+ <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
+ <ClCompile Include="..\..\src\video\SDL_bmp.c" />
+ <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
+ <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
+ <ClCompile Include="..\..\src\video\SDL_pixels.c" />
+ <ClCompile Include="..\..\src\video\SDL_rect.c" />
+ <ClCompile Include="..\..\src\video\SDL_RLEaccel.c" />
+ <ClCompile Include="..\..\src\video\SDL_shape.c" />
+ <ClCompile Include="..\..\src\video\SDL_stretch.c" />
+ <ClCompile Include="..\..\src\video\SDL_surface.c" />
+ <ClCompile Include="..\..\src\video\SDL_video.c" />
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\begin_code.h" />
+ <ClInclude Include="..\..\include\close_code.h" />
+ <ClInclude Include="..\..\include\SDL.h" />
+ <ClInclude Include="..\..\include\SDL_assert.h" />
+ <ClInclude Include="..\..\include\SDL_atomic.h" />
+ <ClInclude Include="..\..\include\SDL_audio.h" />
+ <ClInclude Include="..\..\include\SDL_blendmode.h" />
+ <ClInclude Include="..\..\include\SDL_clipboard.h" />
+ <ClInclude Include="..\..\include\SDL_config.h" />
+ <ClInclude Include="..\..\include\SDL_config_minimal.h" />
+ <ClInclude Include="..\..\include\SDL_config_windowsrt.h" />
+ <ClInclude Include="..\..\include\SDL_copying.h" />
+ <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
+ <ClInclude Include="..\..\include\SDL_endian.h" />
+ <ClInclude Include="..\..\include\SDL_error.h" />
+ <ClInclude Include="..\..\include\SDL_events.h" />
+ <ClInclude Include="..\..\include\SDL_haptic.h" />
+ <ClInclude Include="..\..\include\SDL_hints.h" />
+ <ClInclude Include="..\..\include\SDL_input.h" />
+ <ClInclude Include="..\..\include\SDL_joystick.h" />
+ <ClInclude Include="..\..\include\SDL_keyboard.h" />
+ <ClInclude Include="..\..\include\SDL_keycode.h" />
+ <ClInclude Include="..\..\include\SDL_loadso.h" />
+ <ClInclude Include="..\..\include\SDL_log.h" />
+ <ClInclude Include="..\..\include\SDL_main.h" />
+ <ClInclude Include="..\..\include\SDL_mouse.h" />
+ <ClInclude Include="..\..\include\SDL_mutex.h" />
+ <ClInclude Include="..\..\include\SDL_name.h" />
+ <ClInclude Include="..\..\include\SDL_pixels.h" />
+ <ClInclude Include="..\..\include\SDL_platform.h" />
+ <ClInclude Include="..\..\include\SDL_power.h" />
+ <ClInclude Include="..\..\include\SDL_quit.h" />
+ <ClInclude Include="..\..\include\SDL_rect.h" />
+ <ClInclude Include="..\..\include\SDL_render.h" />
+ <ClInclude Include="..\..\include\SDL_revision.h" />
+ <ClInclude Include="..\..\include\SDL_rwops.h" />
+ <ClInclude Include="..\..\include\SDL_scancode.h" />
+ <ClInclude Include="..\..\include\SDL_shape.h" />
+ <ClInclude Include="..\..\include\SDL_stdinc.h" />
+ <ClInclude Include="..\..\include\SDL_surface.h" />
+ <ClInclude Include="..\..\include\SDL_system.h" />
+ <ClInclude Include="..\..\include\SDL_syswm.h" />
+ <ClInclude Include="..\..\include\SDL_thread.h" />
+ <ClInclude Include="..\..\include\SDL_timer.h" />
+ <ClInclude Include="..\..\include\SDL_touch.h" />
+ <ClInclude Include="..\..\include\SDL_types.h" />
+ <ClInclude Include="..\..\include\SDL_version.h" />
+ <ClInclude Include="..\..\include\SDL_video.h" />
+ <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
+ <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
+ <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
+ <ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
+ <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
+ <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
+ <ClInclude Include="..\..\src\audio\SDL_wave.h" />
+ <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
+ <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
+ <ClInclude Include="..\..\src\events\blank_cursor.h" />
+ <ClInclude Include="..\..\src\events\default_cursor.h" />
+ <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_dropevents_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_events_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_keyboard_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_sysevents.h" />
+ <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
+ <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
+ <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
+ <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
+ <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
+ <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
+ <ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h" />
+ <ClInclude Include="..\..\src\render\mmx.h" />
+ <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
+ <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_draw.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_drawline.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h" />
+ <ClInclude Include="..\..\src\render\software\SDL_rotate.h" />
+ <ClInclude Include="..\..\src\SDL_assert_c.h" />
+ <ClInclude Include="..\..\src\SDL_error_c.h" />
+ <ClInclude Include="..\..\src\SDL_fatal.h" />
+ <ClInclude Include="..\..\src\SDL_hints_c.h" />
+ <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
+ <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h" />
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h" />
+ <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h" />
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
+ <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
+ <ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_rect_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
+ <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
+ <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0_level_9_1</ShaderModel>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
+ <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0_level_9_1</ShaderModel>
+ <ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0_level_9_1</ShaderModel>
+ </FxCompile>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <ProjectName>SDL-WinRT</ProjectName>
+ <RootNamespace>SDL_VS2012_WinRT</RootNamespace>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
+ <AppContainerApplication>true</AppContainerApplication>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <GenerateManifest>false</GenerateManifest>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ <TargetName>SDL</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <GenerateManifest>false</GenerateManifest>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ <TargetName>SDL</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <GenerateManifest>false</GenerateManifest>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ <TargetName>SDL</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <GenerateManifest>false</GenerateManifest>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ <TargetName>SDL</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <GenerateManifest>false</GenerateManifest>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ <TargetName>SDL</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <GenerateManifest>false</GenerateManifest>
+ <IgnoreImportLibrary>false</IgnoreImportLibrary>
+ <TargetName>SDL</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <CompileAsWinRT>false</CompileAsWinRT>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
+ <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
+ <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters
new file mode 100644
index 0000000..74dd2dc
--- /dev/null
+++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters
@@ -0,0 +1,608 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
+ <Filter>GPU Shaders</Filter>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
+ <Filter>GPU Shaders</Filter>
+ </FxCompile>
+ <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
+ <Filter>GPU Shaders</Filter>
+ </FxCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\SDL.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_assert.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\atomic\SDL_atomic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audio.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audiocvt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audiodev.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_blendline.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_0.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_1.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_A.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_auto.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_copy.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_N.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_blit_slow.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_bmp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_clipboard.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_clipboardevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_drawline.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_dropevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_error.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_events.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_fatal.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_fillrect.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_gesture.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_getenv.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\haptic\SDL_haptic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_hints.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_iconv.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\joystick\SDL_joystick.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_keyboard.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\SDL_log.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_mixer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_mouse.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_pixels.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_qsort.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_quit.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_rect.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_render.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_render_sw.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_RLEaccel.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\software\SDL_rotate.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\file\SDL_rwops.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_shape.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\atomic\SDL_spinlock.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_stretch.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\stdlib\SDL_string.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_surface.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\thread\SDL_thread.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\timer\SDL_timer.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_touch.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\SDL_video.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\SDL_wave.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\events\SDL_windowevents.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windows\SDL_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\SDL_yuv_sw.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\joystick\windowsrt\SDL_xinputjoystick.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\begin_code.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\close_code.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_assert.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_error_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_events_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_hints_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_mouse_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_types.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_assert_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_audio_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_dropevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_keyboard_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_pixels_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\SDL_thread_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\timer\SDL_timer_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_touch_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_windowevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_audio.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_atomic.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_blendmode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_clipboard.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_audiomem.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_blendline.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit_auto.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit_copy.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_blit_slow.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\mmx.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_config_minimal.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_config_windowsrt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_copying.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_cpuinfo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_draw.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_drawline.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_endian.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_error.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_events.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\SDL_fatal.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_main.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_haptic.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_hints.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_input.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_joystick.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_keyboard.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_keycode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_loadso.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_log.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_name.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_mouse.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_mutex.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_quit.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_pixels.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_platform.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_power.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_rect_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_rect.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\software\SDL_rotate.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_shape.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_render.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_revision.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_rwops.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_scancode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_surface.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_stdinc.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_video.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_syswm.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_thread.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_timer.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_touch.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_shape_internals.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_sysaudio.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\SDL_sysevents.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\SDL_sysrender.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\thread\SDL_systhread.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\SDL_sysvideo.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\SDL_wave.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\core\windows\SDL_windows.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\blank_cursor.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\events\default_cursor.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\SDL_system.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{20773b57-7034-4c24-af5a-334844585f1b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{ddf04d85-6a87-4c5a-bc52-869b38f45a61}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="GPU Shaders">
+ <UniqueIdentifier>{83ed1283-8234-4c77-99a8-ffcfd8ce7381}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/VisualC-WinRT/SDL_VS2012-WinRT.sln b/VisualC-WinRT/SDL_VS2012-WinRT.sln
new file mode 100644
index 0000000..046e6b7
--- /dev/null
+++ b/VisualC-WinRT/SDL_VS2012-WinRT.sln
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Express 2012 for Windows 8
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL_VS2012-WinRT", "SDL\SDL_VS2012-WinRT.vcxproj", "{AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|ARM = Release|ARM
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|ARM.ActiveCfg = Debug|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|ARM.Build.0 = Debug|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|Win32.Build.0 = Debug|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|x64.ActiveCfg = Debug|x64
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|x64.Build.0 = Debug|x64
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|ARM.ActiveCfg = Release|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|ARM.Build.0 = Release|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|Win32.ActiveCfg = Release|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|Win32.Build.0 = Release|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|x64.ActiveCfg = Release|x64
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/VisualC-WinRT/tests/loopwave/Assets/Logo.png b/VisualC-WinRT/tests/loopwave/Assets/Logo.png
new file mode 100644
index 0000000..e26771c
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/Logo.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png b/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png
new file mode 100644
index 0000000..1eb0d9d
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png b/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png
new file mode 100644
index 0000000..c951e03
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png b/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png
new file mode 100644
index 0000000..dcb6727
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Package.appxmanifest b/VisualC-WinRT/tests/loopwave/Package.appxmanifest
new file mode 100644
index 0000000..3b62bf1
--- /dev/null
+++ b/VisualC-WinRT/tests/loopwave/Package.appxmanifest
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
+
+ <Identity Name="1702c480-cf09-431e-a5e4-b21b283ec818"
+ Publisher="CN=David"
+ Version="1.0.0.0" />
+
+ <Properties>
+ <DisplayName>loopwave_VS2012_WinRT</DisplayName>
+ <PublisherDisplayName>David</PublisherDisplayName>
+ <Logo>Assets\StoreLogo.png</Logo>
+ </Properties>
+
+ <Prerequisites>
+ <OSMinVersion>6.2.1</OSMinVersion>
+ <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
+ </Prerequisites>
+
+ <Resources>
+ <Resource Language="x-generate"/>
+ </Resources>
+
+ <Applications>
+ <Application Id="App"
+ Executable="$targetnametoken$.exe"
+ EntryPoint="loopwave_VS2012_WinRT.App">
+ <VisualElements
+ DisplayName="loopwave_VS2012_WinRT"
+ Logo="Assets\Logo.png"
+ SmallLogo="Assets\SmallLogo.png"
+ Description="loopwave_VS2012_WinRT"
+ ForegroundText="light"
+ BackgroundColor="#464646">
+ <DefaultTile ShowName="allLogos" />
+ <SplashScreen Image="Assets\SplashScreen.png" />
+ </VisualElements>
+ </Application>
+ </Applications>
+ <Capabilities>
+ <Capability Name="internetClient" />
+ </Capabilities>
+</Package>
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj b/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj
new file mode 100644
index 0000000..14e57e5
--- /dev/null
+++ b/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{03fcc293-9406-49c2-acf6-6e7d460c3239}</ProjectGuid>
+ <RootNamespace>loopwave_VS2012</RootNamespace>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
+ <AppContainerApplication>true</AppContainerApplication>
+ <ProjectName>loopwave</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <PackageCertificateKeyFile>loopwave_VS2012_TemporaryKey.pfx</PackageCertificateKeyFile>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <Link>
+ <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <ClCompile>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
+ <AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);$(ProjectDir)..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4453</DisableSpecificWarnings>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
+ <ClCompile>
+ <PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
+ <ClCompile>
+ <PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Image Include="Assets\Logo.png" />
+ <Image Include="Assets\SmallLogo.png" />
+ <Image Include="Assets\StoreLogo.png" />
+ <Image Include="Assets\SplashScreen.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <AppxManifest Include="Package.appxmanifest">
+ <SubType>Designer</SubType>
+ </AppxManifest>
+ <None Include="loopwave_VS2012_TemporaryKey.pfx" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\src\main\windowsrt\SDL_winrt_main.cpp" />
+ <ClCompile Include="..\..\..\test\loopwave.c">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsWinRT>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Media Include="..\..\..\test\sample.wav" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\SDL\SDL_VS2012-WinRT.vcxproj">
+ <Project>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx b/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx
new file mode 100644
index 0000000..3c07b77
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/Logo.png b/VisualC-WinRT/tests/testthread/Assets/Logo.png
new file mode 100644
index 0000000..e26771c
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/Logo.png differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png b/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png
new file mode 100644
index 0000000..1eb0d9d
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png b/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png
new file mode 100644
index 0000000..c951e03
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png b/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png
new file mode 100644
index 0000000..dcb6727
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png differ
diff --git a/VisualC-WinRT/tests/testthread/Package.appxmanifest b/VisualC-WinRT/tests/testthread/Package.appxmanifest
new file mode 100644
index 0000000..f02b3a1
--- /dev/null
+++ b/VisualC-WinRT/tests/testthread/Package.appxmanifest
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
+
+ <Identity Name="ca3178f1-b2b2-43bf-97dd-28ee1b7d32c5"
+ Publisher="CN=David"
+ Version="1.0.0.0" />
+
+ <Properties>
+ <DisplayName>testthread_VS2012_WinRT</DisplayName>
+ <PublisherDisplayName>David</PublisherDisplayName>
+ <Logo>Assets\StoreLogo.png</Logo>
+ </Properties>
+
+ <Prerequisites>
+ <OSMinVersion>6.2.1</OSMinVersion>
+ <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
+ </Prerequisites>
+
+ <Resources>
+ <Resource Language="x-generate"/>
+ </Resources>
+
+ <Applications>
+ <Application Id="App"
+ Executable="$targetnametoken$.exe"
+ EntryPoint="testthread_VS2012_WinRT.App">
+ <VisualElements
+ DisplayName="testthread_VS2012_WinRT"
+ Logo="Assets\Logo.png"
+ SmallLogo="Assets\SmallLogo.png"
+ Description="testthread_VS2012_WinRT"
+ ForegroundText="light"
+ BackgroundColor="#464646">
+ <DefaultTile ShowName="allLogos" />
+ <SplashScreen Image="Assets\SplashScreen.png" />
+ </VisualElements>
+ </Application>
+ </Applications>
+ <Capabilities>
+ <Capability Name="internetClient" />
+ </Capabilities>
+</Package>
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj b/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj
new file mode 100644
index 0000000..1940fe3
--- /dev/null
+++ b/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{a8705bee-d01d-46a4-b2ab-feedfb5fdd11}</ProjectGuid>
+ <RootNamespace>testthread_VS2012</RootNamespace>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
+ <AppContainerApplication>true</AppContainerApplication>
+ <ProjectName>testthread</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <PackageCertificateKeyFile>testthread_VS2012_TemporaryKey.pfx</PackageCertificateKeyFile>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <Link>
+ <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <ClCompile>
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
+ <AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);$(ProjectDir)..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4453</DisableSpecificWarnings>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
+ <ClCompile>
+ <PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsWinRT>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
+ <ClCompile>
+ <PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsWinRT>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Image Include="Assets\Logo.png" />
+ <Image Include="Assets\SmallLogo.png" />
+ <Image Include="Assets\StoreLogo.png" />
+ <Image Include="Assets\SplashScreen.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <AppxManifest Include="Package.appxmanifest">
+ <SubType>Designer</SubType>
+ </AppxManifest>
+ <None Include="testthread_VS2012_TemporaryKey.pfx" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\src\main\windowsrt\SDL_winrt_main.cpp">
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
+ <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
+ </ClCompile>
+ <ClCompile Include="..\..\..\test\testthread.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\SDL\SDL_VS2012-WinRT.vcxproj">
+ <Project>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx b/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx
new file mode 100644
index 0000000..97fd1e1
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx differ
diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
index f3122ec..4d349d2 100755
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
@@ -547,6 +547,7 @@
);
name = CustomTemplate;
sourceTree = "<group>";
+ usesTabs = 0;
};
56EA86F813E9EBF9002E47EB /* coreaudio */ = {
isa = PBXGroup;
diff --git a/include/SDL_config.h b/include/SDL_config.h
index 7440940..9022af8 100644
--- a/include/SDL_config.h
+++ b/include/SDL_config.h
@@ -31,6 +31,8 @@
/* Add any platform that doesn't build using the configure system. */
#if defined(__WIN32__)
#include "SDL_config_windows.h"
+#elif defined(__WINRT__)
+#include "SDL_config_windowsrt.h"
#elif defined(__MACOSX__)
#include "SDL_config_macosx.h"
#elif defined(__IPHONEOS__)
diff --git a/include/SDL_config_windowsrt.h b/include/SDL_config_windowsrt.h
new file mode 100644
index 0000000..b6ecc00
--- /dev/null
+++ b/include/SDL_config_windowsrt.h
@@ -0,0 +1,180 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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.
+*/
+
+#ifndef _SDL_config_windows_h
+#define _SDL_config_windows_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
+#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
+#define HAVE_STDINT_H 1
+#elif defined(_MSC_VER)
+typedef signed __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef signed __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef signed __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#ifndef _UINTPTR_T_DEFINED
+#ifdef _WIN64
+typedef unsigned __int64 uintptr_t;
+#else
+typedef unsigned int uintptr_t;
+#endif
+#define _UINTPTR_T_DEFINED
+#endif
+/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
+#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
+#define DWORD_PTR DWORD
+#endif
+#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
+#define LONG_PTR LONG
+#endif
+#else /* !__GNUC__ && !_MSC_VER */
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef unsigned int size_t;
+#endif
+typedef unsigned int uintptr_t;
+#endif /* __GNUC__ || _MSC_VER */
+#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
+
+#ifdef _WIN64
+# define SIZEOF_VOIDP 8
+#else
+# define SIZEOF_VOIDP 4
+#endif
+
+/* Useful headers */
+#define HAVE_LIBC 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#define HAVE_SIGNAL_H 1
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE__STRREV 1
+#define HAVE__STRUPR 1
+//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead
+//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead
+//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+//#define HAVE_STRTOLL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE__STRICMP 1
+#define HAVE__STRNICMP 1
+#define HAVE_VSNPRINTF 1
+//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead
+#define HAVE_M_PI 1
+#define HAVE_ATAN 1
+#define HAVE_ATAN2 1
+#define HAVE_CEIL 1
+//#define HAVE_COPYSIGN 1 // TODO, WinRT: consider using _copysign instead
+#define HAVE_COS 1
+#define HAVE_COSF 1
+#define HAVE_FABS 1
+#define HAVE_FLOOR 1
+#define HAVE_LOG 1
+#define HAVE_POW 1
+//#define HAVE_SCALBN 1
+#define HAVE_SIN 1
+#define HAVE_SINF 1
+#define HAVE_SQRT 1
+#define HAVE__FSEEKI64 1
+
+/* Enable various audio drivers */
+#define SDL_AUDIO_DRIVER_XAUDIO2 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various input drivers */
+// TODO, WinRT: Get haptic support working
+#define SDL_HAPTIC_DISABLED 1
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+#define SDL_JOYSTICK_DISABLED 1
+#else
+#define SDL_JOYSTICK_XINPUT 1
+#endif
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_WINDOWS 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_STDCPP 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_WINDOWS 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_WINRT 1
+#define SDL_VIDEO_DRIVER_DUMMY 1
+
+// TODO, WinRT: Get a Direct3D 11 based renderer working in SDL.
+/* Enable appropriate renderer(s) */
+#define SDL_VIDEO_RENDER_D3D11 1
+
+/* Enable system power support */
+// TODO, WinRT: investigate system power support. The Win32-based APIs don't work on WinRT.
+#define SDL_POWER_DISABLED 1
+
+/* Enable assembly routines (Win64 doesn't have inline asm) */
+#ifndef _WIN64
+#define SDL_ASSEMBLY_ROUTINES 1
+#endif
+
+#endif /* _SDL_config_windows_h */
diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h
index dde3074..a722ee4 100644
--- a/include/SDL_cpuinfo.h
+++ b/include/SDL_cpuinfo.h
@@ -32,7 +32,7 @@
/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
-#if defined(_MSC_VER) && (_MSC_VER >= 1500)
+#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
#include <intrin.h>
#ifndef _WIN64
#define __MMX__
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index 7fa9c10..bc39c2a 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -71,6 +71,13 @@
# include <ctype.h>
#endif
#ifdef HAVE_MATH_H
+# if defined(__WINRT__)
+/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
+ Windows RT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
+ for more information.
+*/
+# define _USE_MATH_DEFINES
+# endif
# include <math.h>
#endif
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
diff --git a/include/SDL_system.h b/include/SDL_system.h
index 26e9eaa..cb74906 100644
--- a/include/SDL_system.h
+++ b/include/SDL_system.h
@@ -94,6 +94,71 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath();
#endif /* __ANDROID__ */
+/* Platform specific functions for Windows RT */
+#if defined(__WINRT__) && __WINRT__
+
+/**
+ * \brief Windows RT / Windows Phone path types
+ */
+typedef enum
+{
+ /** \brief The installed app's root directory.
+ Files here are likely to be read-only. */
+ SDL_WINRT_PATH_INSTALLED_LOCATION,
+
+ /** \brief The app's local data store. Files may be written here */
+ SDL_WINRT_PATH_LOCAL_FOLDER,
+
+ /** \brief The app's roaming data store. Unsupported on Windows Phone.
+ Files written here may be copied to other machines via a network
+ connection.
+ */
+ SDL_WINRT_PATH_ROAMING_FOLDER,
+
+ /** \brief The app's temporary data store. Unsupported on Windows Phone.
+ Files written here may be deleted at any time. */
+ SDL_WINRT_PATH_TEMP_FOLDER
+} SDL_WinRT_Path;
+
+
+/**
+ * \brief Retrieves a Windows RT defined path on the local file system
+ *
+ * \note Documentation on most app-specific path types on Windows RT
+ * can be found on MSDN, at the URL:
+ * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
+ *
+ * \param pathType The type of path to retrieve.
+ * \ret A UCS-2 string (16-bit, wide-char) containing the path, or NULL
+ * if the path is not available for any reason. Not all paths are
+ * available on all versions of Windows. This is especially true on
+ * Windows Phone. Check the documentation for the given
+ * SDL_WinRT_Path for more information on which path types are
+ * supported where.
+ */
+extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
+
+/**
+ * \brief Retrieves a Windows RT defined path on the local file system
+ *
+ * \note Documentation on most app-specific path types on Windows RT
+ * can be found on MSDN, at the URL:
+ * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
+ *
+ * \param pathType The type of path to retrieve.
+ * \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
+ * if the path is not available for any reason. Not all paths are
+ * available on all versions of Windows. This is especially true on
+ * Windows Phone. Check the documentation for the given
+ * SDL_WinRT_Path for more information on which path types are
+ * supported where.
+ */
+extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
+
+
+#endif /* __WINRT__ */
+
+
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h
index 5e4454f..3b503ae 100644
--- a/include/SDL_syswm.h
+++ b/include/SDL_syswm.h
@@ -56,6 +56,10 @@ struct SDL_SysWMinfo;
#include <windows.h>
#endif
+#if defined(SDL_VIDEO_DRIVER_WINRT)
+#include <Unknwn.h>
+#endif
+
/* This is the structure for custom window manager events */
#if defined(SDL_VIDEO_DRIVER_X11)
#if defined(__APPLE__) && defined(__MACH__)
@@ -90,6 +94,7 @@ typedef struct _NSWindow NSWindow;
#include <UIKit/UIKit.h>
#else
typedef struct _UIWindow UIWindow;
+typedef struct _UIViewController UIViewController;
#endif
#endif
@@ -100,6 +105,7 @@ typedef enum
{
SDL_SYSWM_UNKNOWN,
SDL_SYSWM_WINDOWS,
+ SDL_SYSWM_WINDOWSRT,
SDL_SYSWM_X11,
SDL_SYSWM_DIRECTFB,
SDL_SYSWM_COCOA,
@@ -168,6 +174,12 @@ struct SDL_SysWMinfo
HWND window; /**< The window handle */
} win;
#endif
+#if defined(SDL_VIDEO_DRIVER_WINRT)
+ struct
+ {
+ IUnknown * window; /**< The Windows RT CoreWindow */
+ } winrt;
+#endif
#if defined(SDL_VIDEO_DRIVER_X11)
struct
{
@@ -193,6 +205,7 @@ struct SDL_SysWMinfo
struct
{
UIWindow *window; /* The UIKit window */
+ UIViewController *viewcontroller; /* The UIKit view controller */
} uikit;
#endif
/* Can't have an empty union */
diff --git a/include/begin_code.h b/include/begin_code.h
index dd1f061..8997a72 100644
--- a/include/begin_code.h
+++ b/include/begin_code.h
@@ -41,7 +41,7 @@
# else
# define DECLSPEC __declspec(export)
# endif
-# elif defined(__WIN32__)
+# elif defined(__WIN32__) || defined(__WINRT__)
# ifdef __BORLANDC__
# ifdef BUILD_SDL
# define DECLSPEC
@@ -62,7 +62,7 @@
/* By default SDL uses the C calling convention */
#ifndef SDLCALL
-#if defined(__WIN32__) && !defined(__GNUC__)
+#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
#define SDLCALL __cdecl
#else
#define SDLCALL
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index a4cf643..73ebfe5 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -37,8 +37,10 @@
#else /* fprintf, _exit(), etc. */
#include <stdio.h>
#include <stdlib.h>
+#if ! defined(__WINRT__)
#include <unistd.h>
#endif
+#endif
static SDL_assert_state
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
diff --git a/src/SDL_log.c b/src/SDL_log.c
index 2245946..a19a2c4 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#endif
-#if defined(__WIN32__)
+#if defined(__WIN32__) || defined(__WINRT__)
#include "core/windows/SDL_windows.h"
#elif defined(__ANDROID__)
#include <android/log.h>
@@ -315,7 +315,7 @@ static void
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
const char *message)
{
-#if defined(__WIN32__)
+#if defined(__WIN32__) || defined(__WINRT__)
/* Way too many allocations here, urgh */
/* Note: One can't call SDL_SetError here, since that function itself logs. */
{
diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index f3aeea0..f90528c 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -25,7 +25,7 @@
#include "SDL_timer.h"
/* Don't do the check for Visual Studio 2005, it's safe here */
-#ifdef __WIN32__
+#if defined(__WIN32__) || defined(__WINRT__)
#include "../core/windows/SDL_windows.h"
#endif
diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c
index a2c45ba..19f7cdc 100644
--- a/src/audio/xaudio2/SDL_xaudio2.c
+++ b/src/audio/xaudio2/SDL_xaudio2.c
@@ -1,437 +1,583 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2013 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_config.h"
-
-#if SDL_AUDIO_DRIVER_XAUDIO2
-
-#include "../../core/windows/SDL_windows.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_assert.h"
-
-#ifdef __GNUC__
-/* The configure script already did any necessary checking */
-# define SDL_XAUDIO2_HAS_SDK 1
-#else
-#include <dxsdkver.h> /* XAudio2 exists as of the March 2008 DirectX SDK */
-#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
-# pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.")
-#else
-# define SDL_XAUDIO2_HAS_SDK 1
-#endif
-#endif /* __GNUC__ */
-
-#ifdef SDL_XAUDIO2_HAS_SDK
-
-#define INITGUID 1
-#include <xaudio2.h>
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- IXAudio2 *ixa2;
- IXAudio2SourceVoice *source;
- IXAudio2MasteringVoice *mastering;
- HANDLE semaphore;
- Uint8 *mixbuf;
- int mixlen;
- Uint8 *nextbuf;
-};
-
-
-static __inline__ char *
-utf16_to_utf8(const WCHAR *S)
-{
- /* !!! FIXME: this should be UTF-16, not UCS-2! */
- return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S),
- (SDL_wcslen(S)+1)*sizeof(WCHAR));
-}
-
-static void
-XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
-{
- IXAudio2 *ixa2 = NULL;
- UINT32 devcount = 0;
- UINT32 i = 0;
-
- if (iscapture) {
- SDL_SetError("XAudio2: capture devices unsupported.");
- return;
- } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
- SDL_SetError("XAudio2: XAudio2Create() failed at detection.");
- return;
- } else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
- SDL_SetError("XAudio2: IXAudio2::GetDeviceCount() failed.");
- IXAudio2_Release(ixa2);
- return;
- }
-
- for (i = 0; i < devcount; i++) {
- XAUDIO2_DEVICE_DETAILS details;
- if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
- char *str = utf16_to_utf8(details.DisplayName);
- if (str != NULL) {
- addfn(str);
- SDL_free(str); /* addfn() made a copy of the string. */
- }
- }
- }
-
- IXAudio2_Release(ixa2);
-}
-
-static void STDMETHODCALLTYPE
-VoiceCBOnBufferEnd(THIS_ void *data)
-{
- /* Just signal the SDL audio thread and get out of XAudio2's way. */
- SDL_AudioDevice *this = (SDL_AudioDevice *) data;
- ReleaseSemaphore(this->hidden->semaphore, 1, NULL);
-}
-
-static void STDMETHODCALLTYPE
-VoiceCBOnVoiceError(THIS_ void *data, HRESULT Error)
-{
- /* !!! FIXME: attempt to recover, or mark device disconnected. */
- SDL_assert(0 && "write me!");
-}
-
-/* no-op callbacks... */
-static void STDMETHODCALLTYPE VoiceCBOnStreamEnd(THIS) {}
-static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassStart(THIS_ UINT32 b) {}
-static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassEnd(THIS) {}
-static void STDMETHODCALLTYPE VoiceCBOnBufferStart(THIS_ void *data) {}
-static void STDMETHODCALLTYPE VoiceCBOnLoopEnd(THIS_ void *data) {}
-
-
-static Uint8 *
-XAUDIO2_GetDeviceBuf(_THIS)
-{
- return this->hidden->nextbuf;
-}
-
-static void
-XAUDIO2_PlayDevice(_THIS)
-{
- XAUDIO2_BUFFER buffer;
- Uint8 *mixbuf = this->hidden->mixbuf;
- Uint8 *nextbuf = this->hidden->nextbuf;
- const int mixlen = this->hidden->mixlen;
- IXAudio2SourceVoice *source = this->hidden->source;
- HRESULT result = S_OK;
-
- if (!this->enabled) { /* shutting down? */
- return;
- }
-
- /* Submit the next filled buffer */
- SDL_zero(buffer);
- buffer.AudioBytes = mixlen;
- buffer.pAudioData = nextbuf;
- buffer.pContext = this;
-
- if (nextbuf == mixbuf) {
- nextbuf += mixlen;
- } else {
- nextbuf = mixbuf;
- }
- this->hidden->nextbuf = nextbuf;
-
- result = IXAudio2SourceVoice_SubmitSourceBuffer(source, &buffer, NULL);
- if (result == XAUDIO2_E_DEVICE_INVALIDATED) {
- /* !!! FIXME: possibly disconnected or temporary lost. Recover? */
- }
-
- if (result != S_OK) { /* uhoh, panic! */
- IXAudio2SourceVoice_FlushSourceBuffers(source);
- this->enabled = 0;
- }
-}
-
-static void
-XAUDIO2_WaitDevice(_THIS)
-{
- if (this->enabled) {
- WaitForSingleObject(this->hidden->semaphore, INFINITE);
- }
-}
-
-static void
-XAUDIO2_WaitDone(_THIS)
-{
- IXAudio2SourceVoice *source = this->hidden->source;
- XAUDIO2_VOICE_STATE state;
- SDL_assert(!this->enabled); /* flag that stops playing. */
- IXAudio2SourceVoice_Discontinuity(source);
- IXAudio2SourceVoice_GetState(source, &state);
- while (state.BuffersQueued > 0) {
- WaitForSingleObject(this->hidden->semaphore, INFINITE);
- IXAudio2SourceVoice_GetState(source, &state);
- }
-}
-
-
-static void
-XAUDIO2_CloseDevice(_THIS)
-{
- if (this->hidden != NULL) {
- IXAudio2 *ixa2 = this->hidden->ixa2;
- IXAudio2SourceVoice *source = this->hidden->source;
- IXAudio2MasteringVoice *mastering = this->hidden->mastering;
-
- if (source != NULL) {
- IXAudio2SourceVoice_Stop(source, 0, XAUDIO2_COMMIT_NOW);
- IXAudio2SourceVoice_FlushSourceBuffers(source);
- IXAudio2SourceVoice_DestroyVoice(source);
- }
- if (ixa2 != NULL) {
- IXAudio2_StopEngine(ixa2);
- }
- if (mastering != NULL) {
- IXAudio2MasteringVoice_DestroyVoice(mastering);
- }
- if (ixa2 != NULL) {
- IXAudio2_Release(ixa2);
- }
- if (this->hidden->mixbuf != NULL) {
- SDL_free(this->hidden->mixbuf);
- }
- if (this->hidden->semaphore != NULL) {
- CloseHandle(this->hidden->semaphore);
- }
-
- SDL_free(this->hidden);
- this->hidden = NULL;
- }
-}
-
-static int
-XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
-{
- HRESULT result = S_OK;
- WAVEFORMATEX waveformat;
- int valid_format = 0;
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
- IXAudio2 *ixa2 = NULL;
- IXAudio2SourceVoice *source = NULL;
- UINT32 devId = 0; /* 0 == system default device. */
-
- static IXAudio2VoiceCallbackVtbl callbacks_vtable = {
- VoiceCBOnVoiceProcessPassStart,
- VoiceCBOnVoiceProcessPassEnd,
- VoiceCBOnStreamEnd,
- VoiceCBOnBufferStart,
- VoiceCBOnBufferEnd,
- VoiceCBOnLoopEnd,
- VoiceCBOnVoiceError
- };
-
- static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
-
- if (iscapture) {
- return SDL_SetError("XAudio2: capture devices unsupported.");
- } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
- return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
- }
-
- if (devname != NULL) {
- UINT32 devcount = 0;
- UINT32 i = 0;
-
- if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
- IXAudio2_Release(ixa2);
- return SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed.");
- }
- for (i = 0; i < devcount; i++) {
- XAUDIO2_DEVICE_DETAILS details;
- if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
- char *str = utf16_to_utf8(details.DisplayName);
- if (str != NULL) {
- const int match = (SDL_strcmp(str, devname) == 0);
- SDL_free(str);
- if (match) {
- devId = i;
- break;
- }
- }
- }
- }
-
- if (i == devcount) {
- IXAudio2_Release(ixa2);
- return SDL_SetError("XAudio2: Requested device not found.");
- }
- }
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- IXAudio2_Release(ixa2);
- return SDL_OutOfMemory();
- }
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
-
- this->hidden->ixa2 = ixa2;
- this->hidden->semaphore = CreateSemaphore(NULL, 1, 2, NULL);
- if (this->hidden->semaphore == NULL) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: CreateSemaphore() failed!");
- }
-
- while ((!valid_format) && (test_format)) {
- switch (test_format) {
- case AUDIO_U8:
- case AUDIO_S16:
- case AUDIO_S32:
- case AUDIO_F32:
- this->spec.format = test_format;
- valid_format = 1;
- break;
- }
- test_format = SDL_NextAudioFormat();
- }
-
- if (!valid_format) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: Unsupported audio format");
- }
-
- /* Update the fragment size as size in bytes */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* We feed a Source, it feeds the Mastering, which feeds the device. */
- this->hidden->mixlen = this->spec.size;
- this->hidden->mixbuf = (Uint8 *) SDL_malloc(2 * this->hidden->mixlen);
- if (this->hidden->mixbuf == NULL) {
- XAUDIO2_CloseDevice(this);
- return SDL_OutOfMemory();
- }
- this->hidden->nextbuf = this->hidden->mixbuf;
- SDL_memset(this->hidden->mixbuf, 0, 2 * this->hidden->mixlen);
-
- /* We use XAUDIO2_DEFAULT_CHANNELS instead of this->spec.channels. On
- Xbox360, this means 5.1 output, but on Windows, it means "figure out
- what the system has." It might be preferable to let XAudio2 blast
- stereo output to appropriate surround sound configurations
- instead of clamping to 2 channels, even though we'll configure the
- Source Voice for whatever number of channels you supply. */
- result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
- XAUDIO2_DEFAULT_CHANNELS,
- this->spec.freq, 0, devId, NULL);
- if (result != S_OK) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: Couldn't create mastering voice");
- }
-
- SDL_zero(waveformat);
- if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
- waveformat.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- waveformat.wFormatTag = WAVE_FORMAT_PCM;
- }
- waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
- waveformat.nChannels = this->spec.channels;
- waveformat.nSamplesPerSec = this->spec.freq;
- waveformat.nBlockAlign =
- waveformat.nChannels * (waveformat.wBitsPerSample / 8);
- waveformat.nAvgBytesPerSec =
- waveformat.nSamplesPerSec * waveformat.nBlockAlign;
-
- result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
- XAUDIO2_VOICE_NOSRC |
- XAUDIO2_VOICE_NOPITCH,
- 1.0f, &callbacks, NULL, NULL);
- if (result != S_OK) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: Couldn't create source voice");
- }
- this->hidden->source = source;
-
- /* Start everything playing! */
- result = IXAudio2_StartEngine(ixa2);
- if (result != S_OK) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: Couldn't start engine");
- }
-
- result = IXAudio2SourceVoice_Start(source, 0, XAUDIO2_COMMIT_NOW);
- if (result != S_OK) {
- XAUDIO2_CloseDevice(this);
- return SDL_SetError("XAudio2: Couldn't start source voice");
- }
-
- return 0; /* good to go. */
-}
-
-static void
-XAUDIO2_Deinitialize(void)
-{
- WIN_CoUninitialize();
-}
-
-#endif /* SDL_XAUDIO2_HAS_SDK */
-
-
-static int
-XAUDIO2_Init(SDL_AudioDriverImpl * impl)
-{
-#ifndef SDL_XAUDIO2_HAS_SDK
- SDL_SetError("XAudio2: SDL was built without XAudio2 support (old DirectX SDK).");
- return 0; /* no XAudio2 support, ever. Update your SDK! */
-#else
- /* XAudio2Create() is a macro that uses COM; we don't load the .dll */
- IXAudio2 *ixa2 = NULL;
- if (FAILED(WIN_CoInitialize())) {
- SDL_SetError("XAudio2: CoInitialize() failed");
- return 0;
- }
-
- if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
- WIN_CoUninitialize();
- SDL_SetError("XAudio2: XAudio2Create() failed at initialization");
- return 0; /* not available. */
- }
- IXAudio2_Release(ixa2);
-
- /* Set the function pointers */
- impl->DetectDevices = XAUDIO2_DetectDevices;
- impl->OpenDevice = XAUDIO2_OpenDevice;
- impl->PlayDevice = XAUDIO2_PlayDevice;
- impl->WaitDevice = XAUDIO2_WaitDevice;
- impl->WaitDone = XAUDIO2_WaitDone;
- impl->GetDeviceBuf = XAUDIO2_GetDeviceBuf;
- impl->CloseDevice = XAUDIO2_CloseDevice;
- impl->Deinitialize = XAUDIO2_Deinitialize;
-
- return 1; /* this audio target is available. */
-#endif
-}
-
-AudioBootStrap XAUDIO2_bootstrap = {
- "xaudio2", "XAudio2", XAUDIO2_Init, 0
-};
-
-#endif /* SDL_AUDIO_DRIVER_XAUDIO2 */
-
-/* vi: set ts=4 sw=4 expandtab: */
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 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.
+*/
+
+/* WinRT NOTICE:
+
+ A number of changes were warranted to SDL's XAudio2 backend in order to
+ get it compiling for Windows RT.
+
+ When compiling for WinRT, XAudio2.h requires that it be compiled in a C++
+ file, and not a straight C file. Trying to compile it as C leads to lots
+ of errors, at least with MSVC 2012 and Windows SDK 8.0, as of Nov 22, 2012.
+ To address this specific issue, a few changes were made to SDL_xaudio2.c:
+
+ 1. SDL_xaudio2.c is compiled as a C++ file in WinRT builds. Exported
+ symbols, namely XAUDIO2_bootstrap, uses 'extern "C"' to make sure the
+ rest of SDL can access it. Non-WinRT builds continue to compile
+ SDL_xaudio2.c as a C file.
+ 2. A macro redefines variables named 'this' to '_this', to prevent compiler
+ errors (C2355 in Visual C++) related to 'this' being a reserverd keyword.
+ This hack may need to be altered in the future, particularly if C++'s
+ 'this' keyword needs to be used (within SDL_xaudio2.c). At the time
+ WinRT support was initially added to SDL's XAudio2 backend, this
+ capability was not needed.
+ 3. The C-style macros to invoke XAudio2's COM-based methods were
+ rewritten to be C++-friendly. These are provided in the file,
+ SDL_xaudio2_winrthelpers.h.
+ 4. IXAudio2::CreateSourceVoice, when used in C++, requires its callbacks to
+ be specified via a C++ class. SDL's XAudio2 backend was written with
+ C-style callbacks. A class to bridge these two interfaces,
+ SDL_XAudio2VoiceCallback, was written to make XAudio2 happy. Its methods
+ just call SDL's existing, C-style callbacks.
+ 5. Multiple checks for the __cplusplus macro were made, in appropriate
+ places.
+
+
+ A few additional changes to SDL's XAudio2 backend were warranted by API
+ changes to Windows. Many, but not all of these are documented by Microsoft
+ at:
+ http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx
+
+ 1. Windows' thread synchronization function, CreateSemaphore, was removed
+ from Windows RT. SDL's semaphore API was substituted instead.
+ 2. The method calls, IXAudio2::GetDeviceCount and IXAudio2::GetDeviceDetails
+ were removed from the XAudio2 API. Microsoft is telling developers to
+ use APIs in Windows::Foundation instead.
+ For SDL, the missing methods were reimplemented using the APIs Microsoft
+ said to use.
+ 3. CoInitialize and CoUninitialize are not available in Windows RT.
+ These calls were removed, as COM will have been initialized earlier,
+ at least by the call to the WinRT app's main function
+ (aka 'int main(Platform::Array<Platform::String^>^)). (DLudwig:
+ This was my understanding of how WinRT: the 'main' function uses
+ a tag of [MTAThread], which should initialize COM. My understanding
+ of COM is somewhat limited, and I may be incorrect here.)
+ 4. IXAudio2::CreateMasteringVoice changed its integer-based 'DeviceIndex'
+ argument to a string-based one, 'szDeviceId'. In Windows RT, the
+ string-based argument will be used.
+*/
+
+#include "SDL_config.h"
+
+#if SDL_AUDIO_DRIVER_XAUDIO2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "../../core/windows/SDL_windows.h"
+#include "SDL_audio.h"
+#include "../SDL_audio_c.h"
+#include "../SDL_sysaudio.h"
+#include "SDL_assert.h"
+#ifdef __cplusplus
+}
+#endif
+
+#if defined(__WINRT__)
+# define SDL_XAUDIO2_HAS_SDK 1
+#endif
+#if defined(__WIN32__)
+#ifdef __GNUC__
+/* The configure script already did any necessary checking */
+# define SDL_XAUDIO2_HAS_SDK 1
+#elif defined(__WINRT__)
+/* WinRT always has access to the .the XAudio 2 SD
+# define SDL_XAUDIO2_HAS_SDK
+#else
+#include <dxsdkver.h> /* XAudio2 exists as of the March 2008 DirectX SDK */
+#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
+# pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.")
+#else
+# define SDL_XAUDIO2_HAS_SDK 1
+#endif
+#endif
+
+#ifdef SDL_XAUDIO2_HAS_SDK
+
+#define INITGUID 1
+#include <xaudio2.h>
+
+/* Hidden "this" pointer for the audio functions */
+#define _THIS SDL_AudioDevice *this
+
+#ifdef __cplusplus
+#define this _this
+#include "SDL_xaudio2_winrthelpers.h"
+#endif
+
+struct SDL_PrivateAudioData
+{
+ IXAudio2 *ixa2;
+ IXAudio2SourceVoice *source;
+ IXAudio2MasteringVoice *mastering;
+ SDL_sem * semaphore;
+ Uint8 *mixbuf;
+ int mixlen;
+ Uint8 *nextbuf;
+};
+
+
+static void
+XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
+{
+ IXAudio2 *ixa2 = NULL;
+ UINT32 devcount = 0;
+ UINT32 i = 0;
+
+ if (iscapture) {
+ SDL_SetError("XAudio2: capture devices unsupported.");
+ return;
+ } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
+ SDL_SetError("XAudio2: XAudio2Create() failed at detection.");
+ return;
+ } else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
+ SDL_SetError("XAudio2: IXAudio2::GetDeviceCount() failed.");
+ IXAudio2_Release(ixa2);
+ return;
+ }
+
+ for (i = 0; i < devcount; i++) {
+ XAUDIO2_DEVICE_DETAILS details;
+ if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
+ char *str = WIN_StringToUTF8(details.DisplayName);
+ if (str != NULL) {
+ addfn(str);
+ SDL_free(str); /* addfn() made a copy of the string. */
+ }
+ }
+ }
+
+ IXAudio2_Release(ixa2);
+}
+
+static void STDMETHODCALLTYPE
+VoiceCBOnBufferEnd(THIS_ void *data)
+{
+ /* Just signal the SDL audio thread and get out of XAudio2's way. */
+ SDL_AudioDevice *this = (SDL_AudioDevice *) data;
+ SDL_SemPost(this->hidden->semaphore);
+}
+
+static void STDMETHODCALLTYPE
+VoiceCBOnVoiceError(THIS_ void *data, HRESULT Error)
+{
+ /* !!! FIXME: attempt to recover, or mark device disconnected. */
+ SDL_assert(0 && "write me!");
+}
+
+/* no-op callbacks... */
+static void STDMETHODCALLTYPE VoiceCBOnStreamEnd(THIS) {}
+static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassStart(THIS_ UINT32 b) {}
+static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassEnd(THIS) {}
+static void STDMETHODCALLTYPE VoiceCBOnBufferStart(THIS_ void *data) {}
+static void STDMETHODCALLTYPE VoiceCBOnLoopEnd(THIS_ void *data) {}
+
+#if defined(__cplusplus)
+class SDL_XAudio2VoiceCallback : public IXAudio2VoiceCallback
+{
+public:
+ STDMETHOD_(void, OnBufferEnd)(void *pBufferContext) {
+ VoiceCBOnBufferEnd(pBufferContext);
+ }
+ STDMETHOD_(void, OnBufferStart)(void *pBufferContext) {
+ VoiceCBOnBufferStart(pBufferContext);
+ }
+ STDMETHOD_(void, OnLoopEnd)(void *pBufferContext) {
+ VoiceCBOnLoopEnd(pBufferContext);
+ }
+ STDMETHOD_(void, OnStreamEnd)() {
+ VoiceCBOnStreamEnd();
+ }
+ STDMETHOD_(void, OnVoiceError)(void *pBufferContext, HRESULT Error) {
+ VoiceCBOnVoiceError(pBufferContext, Error);
+ }
+ STDMETHOD_(void, OnVoiceProcessingPassEnd)() {
+ VoiceCBOnVoiceProcessPassEnd();
+ }
+ STDMETHOD_(void, OnVoiceProcessingPassStart)(UINT32 BytesRequired) {
+ VoiceCBOnVoiceProcessPassStart(BytesRequired);
+ }
+};
+#endif
+
+static Uint8 *
+XAUDIO2_GetDeviceBuf(_THIS)
+{
+ return this->hidden->nextbuf;
+}
+
+static void
+XAUDIO2_PlayDevice(_THIS)
+{
+ XAUDIO2_BUFFER buffer;
+ Uint8 *mixbuf = this->hidden->mixbuf;
+ Uint8 *nextbuf = this->hidden->nextbuf;
+ const int mixlen = this->hidden->mixlen;
+ IXAudio2SourceVoice *source = this->hidden->source;
+ HRESULT result = S_OK;
+
+ if (!this->enabled) { /* shutting down? */
+ return;
+ }
+
+ /* Submit the next filled buffer */
+ SDL_zero(buffer);
+ buffer.AudioBytes = mixlen;
+ buffer.pAudioData = nextbuf;
+ buffer.pContext = this;
+
+ if (nextbuf == mixbuf) {
+ nextbuf += mixlen;
+ } else {
+ nextbuf = mixbuf;
+ }
+ this->hidden->nextbuf = nextbuf;
+
+ result = IXAudio2SourceVoice_SubmitSourceBuffer(source, &buffer, NULL);
+ if (result == XAUDIO2_E_DEVICE_INVALIDATED) {
+ /* !!! FIXME: possibly disconnected or temporary lost. Recover? */
+ }
+
+ if (result != S_OK) { /* uhoh, panic! */
+ IXAudio2SourceVoice_FlushSourceBuffers(source);
+ this->enabled = 0;
+ }
+}
+
+static void
+XAUDIO2_WaitDevice(_THIS)
+{
+ if (this->enabled) {
+ SDL_SemWait(this->hidden->semaphore);
+ }
+}
+
+static void
+XAUDIO2_WaitDone(_THIS)
+{
+ IXAudio2SourceVoice *source = this->hidden->source;
+ XAUDIO2_VOICE_STATE state;
+ SDL_assert(!this->enabled); /* flag that stops playing. */
+ IXAudio2SourceVoice_Discontinuity(source);
+ IXAudio2SourceVoice_GetState(source, &state);
+ while (state.BuffersQueued > 0) {
+ SDL_SemWait(this->hidden->semaphore);
+ IXAudio2SourceVoice_GetState(source, &state);
+ }
+}
+
+
+static void
+XAUDIO2_CloseDevice(_THIS)
+{
+ if (this->hidden != NULL) {
+ IXAudio2 *ixa2 = this->hidden->ixa2;
+ IXAudio2SourceVoice *source = this->hidden->source;
+ IXAudio2MasteringVoice *mastering = this->hidden->mastering;
+
+ if (source != NULL) {
+ IXAudio2SourceVoice_Stop(source, 0, XAUDIO2_COMMIT_NOW);
+ IXAudio2SourceVoice_FlushSourceBuffers(source);
+ IXAudio2SourceVoice_DestroyVoice(source);
+ }
+ if (ixa2 != NULL) {
+ IXAudio2_StopEngine(ixa2);
+ }
+ if (mastering != NULL) {
+ IXAudio2MasteringVoice_DestroyVoice(mastering);
+ }
+ if (ixa2 != NULL) {
+ IXAudio2_Release(ixa2);
+ }
+ if (this->hidden->mixbuf != NULL) {
+ SDL_free(this->hidden->mixbuf);
+ }
+ if (this->hidden->semaphore != NULL) {
+ SDL_DestroySemaphore(this->hidden->semaphore);
+ }
+
+ SDL_free(this->hidden);
+ this->hidden = NULL;
+ }
+}
+
+static int
+XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
+{
+ HRESULT result = S_OK;
+ WAVEFORMATEX waveformat;
+ int valid_format = 0;
+ SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
+ IXAudio2 *ixa2 = NULL;
+ IXAudio2SourceVoice *source = NULL;
+#if defined(__WINRT__)
+ WCHAR devIdBuffer[256];
+ LPCWSTR devId = 0;
+#else
+ UINT32 devId = 0; /* 0 == system default device. */
+#endif
+
+#if defined(__cplusplus)
+ static SDL_XAudio2VoiceCallback callbacks;
+#else
+ static IXAudio2VoiceCallbackVtbl callbacks_vtable = {
+ VoiceCBOnVoiceProcessPassStart,
+ VoiceCBOnVoiceProcessPassEnd,
+ VoiceCBOnStreamEnd,
+ VoiceCBOnBufferStart,
+ VoiceCBOnBufferEnd,
+ VoiceCBOnLoopEnd,
+ VoiceCBOnVoiceError
+ };
+
+ static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
+#endif // ! defined(__cplusplus)
+
+#if defined(__WINRT__)
+ SDL_zero(devIdBuffer);
+#endif
+
+ if (iscapture) {
+ return SDL_SetError("XAudio2: capture devices unsupported.");
+ } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
+ return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
+ }
+ /*
+ XAUDIO2_DEBUG_CONFIGURATION debugConfig;
+ debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_FUNC_CALLS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING;
+ debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS;
+ debugConfig.LogThreadID = TRUE;
+ debugConfig.LogFileline = TRUE;
+ debugConfig.LogFunctionName = TRUE;
+ debugConfig.LogTiming = TRUE;
+ ixa2->SetDebugConfiguration(&debugConfig);
+ */
+
+#if ! defined(__WINRT__) || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ if (devname != NULL) {
+ UINT32 devcount = 0;
+ UINT32 i = 0;
+
+ if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) {
+ IXAudio2_Release(ixa2);
+ return SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed.");
+ }
+ for (i = 0; i < devcount; i++) {
+ XAUDIO2_DEVICE_DETAILS details;
+ if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
+ char *str = WIN_StringToUTF8(details.DisplayName);
+ if (str != NULL) {
+ const int match = (SDL_strcmp(str, devname) == 0);
+ SDL_free(str);
+ if (match) {
+#if defined(__WINRT__)
+ wcsncpy_s(devIdBuffer, ARRAYSIZE(devIdBuffer), details.DeviceID, _TRUNCATE);
+ devId = (LPCWSTR) &devIdBuffer;
+#else
+ devId = i;
+#endif
+ break;
+ }
+ }
+ }
+ }
+
+ if (i == devcount) {
+ IXAudio2_Release(ixa2);
+ return SDL_SetError("XAudio2: Requested device not found.");
+ }
+ }
+#endif
+
+ /* Initialize all variables that we clean on shutdown */
+ this->hidden = (struct SDL_PrivateAudioData *)
+ SDL_malloc((sizeof *this->hidden));
+ if (this->hidden == NULL) {
+ IXAudio2_Release(ixa2);
+ return SDL_OutOfMemory();
+ }
+ SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+
+ this->hidden->ixa2 = ixa2;
+ this->hidden->semaphore = SDL_CreateSemaphore(1);
+ if (this->hidden->semaphore == NULL) {
+ XAUDIO2_CloseDevice(this);
+ return SDL_SetError("XAudio2: CreateSemaphore() failed!");
+ }
+
+ while ((!valid_format) && (test_format)) {
+ switch (test_format) {
+ case AUDIO_U8:
+ case AUDIO_S16:
+ case AUDIO_S32:
+ case AUDIO_F32:
+ this->spec.format = test_format;
+ valid_format = 1;
+ break;
+ }
+ test_format = SDL_NextAudioFormat();
+ }
+
+ if (!valid_format) {
+ XAUDIO2_CloseDevice(this);
+ return SDL_SetError("XAudio2: Unsupported audio format");
+ }
+
+ /* Update the fragment size as size in bytes */
+ SDL_CalculateAudioSpec(&this->spec);
+
+ /* We feed a Source, it feeds the Mastering, which feeds the device. */
+ this->hidden->mixlen = this->spec.size;
+ this->hidden->mixbuf = (Uint8 *) SDL_malloc(2 * this->hidden->mixlen);
+ if (this->hidden->mixbuf == NULL) {
+ XAUDIO2_CloseDevice(this);
+ return SDL_OutOfMemory();
+ }
+ this->hidden->nextbuf = this->hidden->mixbuf;
+ SDL_memset(this->hidden->mixbuf, 0, 2 * this->hidden->mixlen);
+
+ /* We use XAUDIO2_DEFAULT_CHANNELS instead of this->spec.channels. On
+ Xbox360, this means 5.1 output, but on Windows, it means "figure out
+ what the system has." It might be preferable to let XAudio2 blast
+ stereo output to appropriate surround sound configurations
+ instead of clamping to 2 channels, even though we'll configure the
+ Source Voice for whatever number of channels you supply. */
+ result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
+ XAUDIO2_DEFAULT_CHANNELS,
+ this->spec.freq, 0, devId, NULL);
+ if (result != S_OK) {
+ XAUDIO2_CloseDevice(this);
+ return SDL_SetError("XAudio2: Couldn't create mastering voice");
+ }
+
+ SDL_zero(waveformat);
+ if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
+ waveformat.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
+ } else {
+ waveformat.wFormatTag = WAVE_FORMAT_PCM;
+ }
+ waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
+ waveformat.nChannels = this->spec.channels;
+ waveformat.nSamplesPerSec = this->spec.freq;
+ waveformat.nBlockAlign =
+ waveformat.nChannels * (waveformat.wBitsPerSample / 8);
+ waveformat.nAvgBytesPerSec =
+ waveformat.nSamplesPerSec * waveformat.nBlockAlign;
+ waveformat.cbSize = sizeof(waveformat);
+
+#ifdef __WINRT__
+ // DLudwig: for now, make XAudio2 do sample rate conversion, just to
+ // get the loopwave test to work.
+ //
+ // TODO, WinRT: consider removing WinRT-specific source-voice creation code from SDL_xaudio2.c
+ result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
+ 0,
+ 1.0f, &callbacks, NULL, NULL);
+#else
+ result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
+ XAUDIO2_VOICE_NOSRC |
+ XAUDIO2_VOICE_NOPITCH,
+ 1.0f, &callbacks, NULL, NULL);
+
+#endif
+ if (result != S_OK) {
+ XAUDIO2_CloseDevice(this);
+ return SDL_SetError("XAudio2: Couldn't create source voice");
+ }
+ this->hidden->source = source;
+
+ /* Start everything playing! */
+ result = IXAudio2_StartEngine(ixa2);
+ if (result != S_OK) {
+ XAUDIO2_CloseDevice(this);
+ return SDL_SetError("XAudio2: Couldn't start engine");
+ }
+
+ result = IXAudio2SourceVoice_Start(source, 0, XAUDIO2_COMMIT_NOW);
+ if (result != S_OK) {
+ XAUDIO2_CloseDevice(this);
+ return SDL_SetError("XAudio2: Couldn't start source voice");
+ }
+
+ return 0; /* good to go. */
+}
+
+static void
+XAUDIO2_Deinitialize(void)
+{
+#if defined(__WIN32__)
+ WIN_CoUninitialize();
+#endif
+}
+
+#endif /* SDL_XAUDIO2_HAS_SDK */
+
+
+static int
+XAUDIO2_Init(SDL_AudioDriverImpl * impl)
+{
+#ifndef SDL_XAUDIO2_HAS_SDK
+ SDL_SetError("XAudio2: SDL was built without XAudio2 support (old DirectX SDK).");
+ return 0; /* no XAudio2 support, ever. Update your SDK! */
+#else
+ /* XAudio2Create() is a macro that uses COM; we don't load the .dll */
+ IXAudio2 *ixa2 = NULL;
+#if defined(__WIN32__)
+ // TODO, WinRT: Investigate using CoInitializeEx here
+ if (FAILED(WIN_CoInitialize())) {
+ SDL_SetError("XAudio2: CoInitialize() failed");
+ return 0;
+ }
+#endif
+
+ if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
+#if defined(__WIN32__)
+ WIN_CoUninitialize();
+#endif
+ SDL_SetError("XAudio2: XAudio2Create() failed at initialization");
+ return 0; /* not available. */
+ }
+ IXAudio2_Release(ixa2);
+
+ /* Set the function pointers */
+ impl->DetectDevices = XAUDIO2_DetectDevices;
+ impl->OpenDevice = XAUDIO2_OpenDevice;
+ impl->PlayDevice = XAUDIO2_PlayDevice;
+ impl->WaitDevice = XAUDIO2_WaitDevice;
+ impl->WaitDone = XAUDIO2_WaitDone;
+ impl->GetDeviceBuf = XAUDIO2_GetDeviceBuf;
+ impl->CloseDevice = XAUDIO2_CloseDevice;
+ impl->Deinitialize = XAUDIO2_Deinitialize;
+
+ return 1; /* this audio target is available. */
+#endif
+}
+
+#if defined(__cplusplus)
+extern "C"
+#endif
+AudioBootStrap XAUDIO2_bootstrap = {
+ "xaudio2", "XAudio2", XAUDIO2_Init, 0
+};
+
+#endif /* SDL_AUDIO_DRIVER_XAUDIO2 */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
new file mode 100644
index 0000000..aa88fd6
--- /dev/null
+++ b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
@@ -0,0 +1,69 @@
+
+#include <xaudio2.h>
+#include "SDL_xaudio2_winrthelpers.h"
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+using Windows::Devices::Enumeration::DeviceClass;
+using Windows::Devices::Enumeration::DeviceInformation;
+using Windows::Devices::Enumeration::DeviceInformationCollection;
+#endif
+
+HRESULT IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
+{
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // There doesn't seem to be any audio device enumeration on Windows Phone.
+ // In lieu of this, just treat things as if there is one and only one
+ // audio device.
+ *devcount = 1;
+ return S_OK;
+#else
+ // TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
+ auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
+ while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
+ {
+ }
+
+ DeviceInformationCollection^ devices = operation->GetResults();
+ *devcount = devices->Size;
+ return S_OK;
+#endif
+}
+
+HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
+{
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // Windows Phone doesn't seem to have the same device enumeration APIs that
+ // Windows 8/RT has, or it doesn't have them at all. In lieu of this,
+ // just treat things as if there is one, and only one, default device.
+ if (index != 0)
+ {
+ return XAUDIO2_E_INVALID_CALL;
+ }
+
+ if (details)
+ {
+ wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE);
+ wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE);
+ }
+ return S_OK;
+#else
+ auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
+ while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
+ {
+ }
+
+ DeviceInformationCollection^ devices = operation->GetResults();
+ if (index >= devices->Size)
+ {
+ return XAUDIO2_E_INVALID_CALL;
+ }
+
+ DeviceInformation^ d = devices->GetAt(index);
+ if (details)
+ {
+ wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
+ wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
+ }
+ return S_OK;
+#endif
+}
diff --git a/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
new file mode 100644
index 0000000..a72804f
--- /dev/null
+++ b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
@@ -0,0 +1,40 @@
+
+#pragma once
+
+//
+// Re-implementation of methods removed from XAudio2 (in Windows RT):
+//
+
+typedef struct XAUDIO2_DEVICE_DETAILS
+{
+ WCHAR DeviceID[256];
+ WCHAR DisplayName[256];
+ /* Other fields exist in the pre-Windows 8 version of this struct, however
+ they weren't used by SDL, so they weren't added.
+ */
+} XAUDIO2_DEVICE_DETAILS;
+
+HRESULT IXAudio2_GetDeviceCount(IXAudio2 * unused, UINT32 * devcount);
+HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details);
+
+
+//
+// C-style macros to call XAudio2's methods in C++:
+//
+
+#define IXAudio2_CreateMasteringVoice(A, B, C, D, E, F, G) (A)->CreateMasteringVoice((B), (C), (D), (E), (F), (G))
+#define IXAudio2_CreateSourceVoice(A, B, C, D, E, F, G, H) (A)->CreateSourceVoice((B), (C), (D), (E), (F), (G), (H))
+#define IXAudio2_QueryInterface(A, B, C) (A)->QueryInterface((B), (C))
+#define IXAudio2_Release(A) (A)->Release()
+#define IXAudio2_StartEngine(A) (A)->StartEngine()
+#define IXAudio2_StopEngine(A) (A)->StopEngine()
+
+#define IXAudio2MasteringVoice_DestroyVoice(A) (A)->DestroyVoice()
+
+#define IXAudio2SourceVoice_DestroyVoice(A) (A)->DestroyVoice()
+#define IXAudio2SourceVoice_Discontinuity(A) (A)->Discontinuity()
+#define IXAudio2SourceVoice_FlushSourceBuffers(A) (A)->FlushSourceBuffers()
+#define IXAudio2SourceVoice_GetState(A, B) (A)->GetState((B))
+#define IXAudio2SourceVoice_Start(A, B, C) (A)->Start((B), (C))
+#define IXAudio2SourceVoice_Stop(A, B, C) (A)->Stop((B), (C))
+#define IXAudio2SourceVoice_SubmitSourceBuffer(A, B, C) (A)->SubmitSourceBuffer((B), (C))
diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index e69d257..2388f93 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -20,21 +20,21 @@
*/
#include "SDL_config.h"
-#ifdef __WIN32__
+#if defined(__WIN32__) || defined(__WINRT__)
#include "SDL_error.h"
#include "SDL_windows.h"
#include "SDL_assert.h"
-#include <objbase.h> /* for CoInitialize/CoUninitialize */
+#include <objbase.h> /* for CoInitialize/CoUninitialize (Win32 only) */
/* Sets an error message based on GetLastError() */
int
-WIN_SetError(const char *prefix)
+WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
{
TCHAR buffer[1024];
char *message;
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
buffer, SDL_arraysize(buffer), NULL);
message = WIN_StringToUTF8(buffer);
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
@@ -42,9 +42,24 @@ WIN_SetError(const char *prefix)
return -1;
}
+/* Sets an error message based on GetLastError() */
+int
+WIN_SetError(const char *prefix)
+{
+ return WIN_SetErrorFromHRESULT(prefix, GetLastError());
+}
+
HRESULT
WIN_CoInitialize(void)
{
+#ifdef __WINRT__
+ /* DLudwig: On WinRT, it is assumed that COM was initialized in main().
+ CoInitializeEx is available (not CoInitialize though), however
+ on WinRT, main() is typically declared with the [MTAThread]
+ attribute, which, AFAIK, should initialize COM.
+ */
+ return S_OK;
+#else
const HRESULT hr = CoInitialize(NULL);
/* S_FALSE means success, but someone else already initialized. */
@@ -54,12 +69,15 @@ WIN_CoInitialize(void)
}
return hr;
+#endif
}
void
WIN_CoUninitialize(void)
{
+#ifndef __WINRT__
CoUninitialize();
+#endif
}
#endif /* __WIN32__ */
diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h
index 440c387..ce614a9 100644
--- a/src/core/windows/SDL_windows.h
+++ b/src/core/windows/SDL_windows.h
@@ -24,6 +24,7 @@
#ifndef _INCLUDED_WINDOWS_H
#define _INCLUDED_WINDOWS_H
+#if defined(__WIN32__)
#define WIN32_LEAN_AND_MEAN
#define STRICT
#ifndef UNICODE
@@ -31,6 +32,7 @@
#endif
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
+#endif
#include <windows.h>
@@ -43,6 +45,9 @@
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
#endif
+/* Sets an error message based on a given HRESULT */
+extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
+
/* Sets an error message based on GetLastError(). Always return -1. */
extern int WIN_SetError(const char *prefix);
diff --git a/src/core/windowsrt/SDL_winrtpaths.cpp b/src/core/windowsrt/SDL_winrtpaths.cpp
new file mode 100644
index 0000000..4c10b78
--- /dev/null
+++ b/src/core/windowsrt/SDL_winrtpaths.cpp
@@ -0,0 +1,94 @@
+/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
+ TODO, WinRT: add note to SDL_winrtpaths.cpp mentioning that /ZW must be used when compiling the file
+*/
+
+#include "SDL_config.h"
+
+#ifdef __WINRT__
+
+extern "C" {
+#include "SDL_error.h"
+#include "SDL_stdinc.h"
+#include "SDL_system.h"
+#include "../windows/SDL_windows.h"
+}
+
+#include <string>
+#include <unordered_map>
+
+using namespace std;
+using namespace Windows::Storage;
+
+extern "C" const wchar_t *
+SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
+{
+ switch (pathType) {
+ case SDL_WINRT_PATH_INSTALLED_LOCATION:
+ {
+ static wstring path;
+ if (path.empty()) {
+ path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
+ }
+ return path.c_str();
+ }
+
+ case SDL_WINRT_PATH_LOCAL_FOLDER:
+ {
+ static wstring path;
+ if (path.empty()) {
+ path = ApplicationData::Current->LocalFolder->Path->Data();
+ }
+ return path.c_str();
+ }
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ case SDL_WINRT_PATH_ROAMING_FOLDER:
+ {
+ static wstring path;
+ if (path.empty()) {
+ path = ApplicationData::Current->RoamingFolder->Path->Data();
+ }
+ return path.c_str();
+ }
+
+ case SDL_WINRT_PATH_TEMP_FOLDER:
+ {
+ static wstring path;
+ if (path.empty()) {
+ path = ApplicationData::Current->TemporaryFolder->Path->Data();
+ }
+ return path.c_str();
+ }
+#endif
+
+ default:
+ break;
+ }
+
+ SDL_Unsupported();
+ return NULL;
+}
+
+extern "C" const char *
+SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
+{
+ typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
+ static UTF8PathMap utf8Paths;
+
+ UTF8PathMap::iterator searchResult = utf8Paths.find(pathType);
+ if (searchResult != utf8Paths.end()) {
+ return searchResult->second.c_str();
+ }
+
+ const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
+ if (!ucs2Path) {
+ return NULL;
+ }
+
+ char * utf8Path = WIN_StringToUTF8(ucs2Path);
+ utf8Paths[pathType] = utf8Path;
+ SDL_free(utf8Path);
+ return utf8Paths[pathType].c_str();
+}
+
+#endif /* __WINRT__ */
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index afbc39a..3a6f7db 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -1,757 +1,764 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2013 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.
-*/
-/* Need this so Linux systems define fseek64o, ftell64o and off64_t */
-#define _LARGEFILE64_SOURCE
-#include "SDL_config.h"
-
-/* This file provides a general interface for SDL to read and write
- data sources. It can easily be extended to files, memory, etc.
-*/
-
-#include "SDL_endian.h"
-#include "SDL_rwops.h"
-
-#ifdef __APPLE__
-#include "cocoa/SDL_rwopsbundlesupport.h"
-#endif /* __APPLE__ */
-
-#ifdef ANDROID
-#include "../core/android/SDL_android.h"
-#include "SDL_system.h"
-#endif
-
-#ifdef __WIN32__
-
-/* Functions to read/write Win32 API file pointers */
-
-#include "../core/windows/SDL_windows.h"
-
-#ifndef INVALID_SET_FILE_POINTER
-#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
-#endif
-
-#define READAHEAD_BUFFER_SIZE 1024
-
-static int SDLCALL
-windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
-{
- UINT old_error_mode;
- HANDLE h;
- DWORD r_right, w_right;
- DWORD must_exist, truncate;
- int a_mode;
-
- if (!context)
- return -1; /* failed (invalid call) */
-
- context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
- context->hidden.windowsio.buffer.data = NULL;
- context->hidden.windowsio.buffer.size = 0;
- context->hidden.windowsio.buffer.left = 0;
-
- /* "r" = reading, file must exist */
- /* "w" = writing, truncate existing, file may not exist */
- /* "r+"= reading or writing, file must exist */
- /* "a" = writing, append file may not exist */
- /* "a+"= append + read, file may not exist */
- /* "w+" = read, write, truncate. file may not exist */
-
- must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0;
- truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0;
- r_right = (SDL_strchr(mode, '+') != NULL
- || must_exist) ? GENERIC_READ : 0;
- a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0;
- w_right = (a_mode || SDL_strchr(mode, '+')
- || truncate) ? GENERIC_WRITE : 0;
-
- if (!r_right && !w_right) /* inconsistent mode */
- return -1; /* failed (invalid call) */
-
- context->hidden.windowsio.buffer.data =
- (char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
- if (!context->hidden.windowsio.buffer.data) {
- return SDL_OutOfMemory();
- }
- /* Do not open a dialog box if failure */
- old_error_mode =
- SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
-
- {
- LPTSTR tstr = WIN_UTF8ToString(filename);
- h = CreateFile(tstr, (w_right | r_right),
- (w_right) ? 0 : FILE_SHARE_READ, NULL,
- (must_exist | truncate | a_mode),
- FILE_ATTRIBUTE_NORMAL, NULL);
- SDL_free(tstr);
- }
-
- /* restore old behavior */
- SetErrorMode(old_error_mode);
-
- if (h == INVALID_HANDLE_VALUE) {
- SDL_free(context->hidden.windowsio.buffer.data);
- context->hidden.windowsio.buffer.data = NULL;
- SDL_SetError("Couldn't open %s", filename);
- return -2; /* failed (CreateFile) */
- }
- context->hidden.windowsio.h = h;
- context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE;
-
- return 0; /* ok */
-}
-
-static Sint64 SDLCALL
-windows_file_size(SDL_RWops * context)
-{
- LARGE_INTEGER size;
-
- if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
- return SDL_SetError("windows_file_size: invalid context/file not opened");
- }
-
- if (!GetFileSizeEx(context->hidden.windowsio.h, &size)) {
- return WIN_SetError("windows_file_size");
- }
-
- return size.QuadPart;
-}
-
-static Sint64 SDLCALL
-windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
-{
- DWORD windowswhence;
- LARGE_INTEGER windowsoffset;
-
- if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
- return SDL_SetError("windows_file_seek: invalid context/file not opened");
- }
-
- /* FIXME: We may be able to satisfy the seek within buffered data */
- if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) {
- offset -= (long)context->hidden.windowsio.buffer.left;
- }
- context->hidden.windowsio.buffer.left = 0;
-
- switch (whence) {
- case RW_SEEK_SET:
- windowswhence = FILE_BEGIN;
- break;
- case RW_SEEK_CUR:
- windowswhence = FILE_CURRENT;
- break;
- case RW_SEEK_END:
- windowswhence = FILE_END;
- break;
- default:
- return SDL_SetError("windows_file_seek: Unknown value for 'whence'");
- }
-
- windowsoffset.QuadPart = offset;
- if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, windowswhence)) {
- return WIN_SetError("windows_file_seek");
- }
- return windowsoffset.QuadPart;
-}
-
-static size_t SDLCALL
-windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
-{
- size_t total_need;
- size_t total_read = 0;
- size_t read_ahead;
- DWORD byte_read;
-
- total_need = size * maxnum;
-
- if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
- || !total_need)
- return 0;
-
- if (context->hidden.windowsio.buffer.left > 0) {
- void *data = (char *) context->hidden.windowsio.buffer.data +
- context->hidden.windowsio.buffer.size -
- context->hidden.windowsio.buffer.left;
- read_ahead =
- SDL_min(total_need, context->hidden.windowsio.buffer.left);
- SDL_memcpy(ptr, data, read_ahead);
- context->hidden.windowsio.buffer.left -= read_ahead;
-
- if (read_ahead == total_need) {
- return maxnum;
- }
- ptr = (char *) ptr + read_ahead;
- total_need -= read_ahead;
- total_read += read_ahead;
- }
-
- if (total_need < READAHEAD_BUFFER_SIZE) {
- if (!ReadFile
- (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data,
- READAHEAD_BUFFER_SIZE, &byte_read, NULL)) {
- SDL_Error(SDL_EFREAD);
- return 0;
- }
- read_ahead = SDL_min(total_need, (int) byte_read);
- SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead);
- context->hidden.windowsio.buffer.size = byte_read;
- context->hidden.windowsio.buffer.left = byte_read - read_ahead;
- total_read += read_ahead;
- } else {
- if (!ReadFile
- (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
- SDL_Error(SDL_EFREAD);
- return 0;
- }
- total_read += byte_read;
- }
- return (total_read / size);
-}
-
-static size_t SDLCALL
-windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
- size_t num)
-{
-
- size_t total_bytes;
- DWORD byte_written;
- size_t nwritten;
-
- total_bytes = size * num;
-
- if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
- || total_bytes <= 0 || !size)
- return 0;
-
- if (context->hidden.windowsio.buffer.left) {
- SetFilePointer(context->hidden.windowsio.h,
- -(LONG)context->hidden.windowsio.buffer.left, NULL,
- FILE_CURRENT);
- context->hidden.windowsio.buffer.left = 0;
- }
-
- /* if in append mode, we must go to the EOF before write */
- if (context->hidden.windowsio.append) {
- if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) ==
- INVALID_SET_FILE_POINTER) {
- SDL_Error(SDL_EFWRITE);
- return 0;
- }
- }
-
- if (!WriteFile
- (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
- SDL_Error(SDL_EFWRITE);
- return 0;
- }
-
- nwritten = byte_written / size;
- return nwritten;
-}
-
-static int SDLCALL
-windows_file_close(SDL_RWops * context)
-{
-
- if (context) {
- if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) {
- CloseHandle(context->hidden.windowsio.h);
- context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */
- }
- if (context->hidden.windowsio.buffer.data) {
- SDL_free(context->hidden.windowsio.buffer.data);
- context->hidden.windowsio.buffer.data = NULL;
- }
- SDL_FreeRW(context);
- }
- return (0);
-}
-#endif /* __WIN32__ */
-
-#ifdef HAVE_STDIO_H
-
-/* Functions to read/write stdio file pointers */
-
-static Sint64 SDLCALL
-stdio_size(SDL_RWops * context)
-{
- Sint64 pos, size;
-
- pos = SDL_RWseek(context, 0, RW_SEEK_CUR);
- if (pos < 0) {
- return -1;
- }
- size = SDL_RWseek(context, 0, RW_SEEK_END);
-
- SDL_RWseek(context, pos, RW_SEEK_SET);
- return size;
-}
-
-static Sint64 SDLCALL
-stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
-{
-#ifdef HAVE_FSEEKO64
- if (fseeko64(context->hidden.stdio.fp, (off64_t)offset, whence) == 0) {
- return ftello64(context->hidden.stdio.fp);
- }
-#elif defined(HAVE_FSEEKO)
- if (fseeko(context->hidden.stdio.fp, (off_t)offset, whence) == 0) {
- return ftello(context->hidden.stdio.fp);
- }
-#else
- if (fseek(context->hidden.stdio.fp, offset, whence) == 0) {
- return (ftell(context->hidden.stdio.fp));
- }
-#endif
- return SDL_Error(SDL_EFSEEK);
-}
-
-static size_t SDLCALL
-stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
-{
- size_t nread;
-
- nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
- if (nread == 0 && ferror(context->hidden.stdio.fp)) {
- SDL_Error(SDL_EFREAD);
- }
- return (nread);
-}
-
-static size_t SDLCALL
-stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
-{
- size_t nwrote;
-
- nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
- if (nwrote == 0 && ferror(context->hidden.stdio.fp)) {
- SDL_Error(SDL_EFWRITE);
- }
- return (nwrote);
-}
-
-static int SDLCALL
-stdio_close(SDL_RWops * context)
-{
- int status = 0;
- if (context) {
- if (context->hidden.stdio.autoclose) {
- /* WARNING: Check the return value here! */
- if (fclose(context->hidden.stdio.fp) != 0) {
- status = SDL_Error(SDL_EFWRITE);
- }
- }
- SDL_FreeRW(context);
- }
- return status;
-}
-#endif /* !HAVE_STDIO_H */
-
-/* Functions to read/write memory pointers */
-
-static Sint64 SDLCALL
-mem_size(SDL_RWops * context)
-{
- return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base);
-}
-
-static Sint64 SDLCALL
-mem_seek(SDL_RWops * context, Sint64 offset, int whence)
-{
- Uint8 *newpos;
-
- switch (whence) {
- case RW_SEEK_SET:
- newpos = context->hidden.mem.base + offset;
- break;
- case RW_SEEK_CUR:
- newpos = context->hidden.mem.here + offset;
- break;
- case RW_SEEK_END:
- newpos = context->hidden.mem.stop + offset;
- break;
- default:
- return SDL_SetError("Unknown value for 'whence'");
- }
- if (newpos < context->hidden.mem.base) {
- newpos = context->hidden.mem.base;
- }
- if (newpos > context->hidden.mem.stop) {
- newpos = context->hidden.mem.stop;
- }
- context->hidden.mem.here = newpos;
- return (Sint64)(context->hidden.mem.here - context->hidden.mem.base);
-}
-
-static size_t SDLCALL
-mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
-{
- size_t total_bytes;
- size_t mem_available;
-
- total_bytes = (maxnum * size);
- if ((maxnum <= 0) || (size <= 0)
- || ((total_bytes / maxnum) != (size_t) size)) {
- return 0;
- }
-
- mem_available = (context->hidden.mem.stop - context->hidden.mem.here);
- if (total_bytes > mem_available) {
- total_bytes = mem_available;
- }
-
- SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
- context->hidden.mem.here += total_bytes;
-
- return (total_bytes / size);
-}
-
-static size_t SDLCALL
-mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
-{
- if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) {
- num = (context->hidden.mem.stop - context->hidden.mem.here) / size;
- }
- SDL_memcpy(context->hidden.mem.here, ptr, num * size);
- context->hidden.mem.here += num * size;
- return (num);
-}
-
-static size_t SDLCALL
-mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num)
-{
- SDL_SetError("Can't write to read-only memory");
- return (0);
-}
-
-static int SDLCALL
-mem_close(SDL_RWops * context)
-{
- if (context) {
- SDL_FreeRW(context);
- }
- return (0);
-}
-
-
-/* Functions to create SDL_RWops structures from various data sources */
-
-SDL_RWops *
-SDL_RWFromFile(const char *file, const char *mode)
-{
- SDL_RWops *rwops = NULL;
- if (!file || !*file || !mode || !*mode) {
- SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
- return NULL;
- }
-#if defined(ANDROID)
-#ifdef HAVE_STDIO_H
- /* Try to open the file on the filesystem first */
- if (*file == '/') {
- FILE *fp = fopen(file, mode);
- if (fp) {
- return SDL_RWFromFP(fp, 1);
- }
- } else {
- /* Try opening it from internal storage if it's a relative path */
- char *path;
- FILE *fp;
-
- path = SDL_stack_alloc(char, PATH_MAX);
- if (path) {
- SDL_snprintf(path, PATH_MAX, "%s/%s",
- SDL_AndroidGetInternalStoragePath(), file);
- fp = fopen(path, mode);
- SDL_stack_free(path);
- if (fp) {
- return SDL_RWFromFP(fp, 1);
- }
- }
- }
-#endif /* HAVE_STDIO_H */
-
- /* Try to open the file from the asset system */
- rwops = SDL_AllocRW();
- if (!rwops)
- return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
- if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
- SDL_FreeRW(rwops);
- return NULL;
- }
- rwops->size = Android_JNI_FileSize;
- rwops->seek = Android_JNI_FileSeek;
- rwops->read = Android_JNI_FileRead;
- rwops->write = Android_JNI_FileWrite;
- rwops->close = Android_JNI_FileClose;
- rwops->type = SDL_RWOPS_JNIFILE;
-
-#elif defined(__WIN32__)
- rwops = SDL_AllocRW();
- if (!rwops)
- return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
- if (windows_file_open(rwops, file, mode) < 0) {
- SDL_FreeRW(rwops);
- return NULL;
- }
- rwops->size = windows_file_size;
- rwops->seek = windows_file_seek;
- rwops->read = windows_file_read;
- rwops->write = windows_file_write;
- rwops->close = windows_file_close;
- rwops->type = SDL_RWOPS_WINFILE;
-
-#elif HAVE_STDIO_H
- {
- #ifdef __APPLE__
- FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
- #else
- FILE *fp = fopen(file, mode);
- #endif
- if (fp == NULL) {
- SDL_SetError("Couldn't open %s", file);
- } else {
- rwops = SDL_RWFromFP(fp, 1);
- }
- }
-#else
- SDL_SetError("SDL not compiled with stdio support");
-#endif /* !HAVE_STDIO_H */
-
- return (rwops);
-}
-
-#ifdef HAVE_STDIO_H
-SDL_RWops *
-SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
-{
- SDL_RWops *rwops = NULL;
-
- rwops = SDL_AllocRW();
- if (rwops != NULL) {
- rwops->size = stdio_size;
- rwops->seek = stdio_seek;
- rwops->read = stdio_read;
- rwops->write = stdio_write;
- rwops->close = stdio_close;
- rwops->hidden.stdio.fp = fp;
- rwops->hidden.stdio.autoclose = autoclose;
- rwops->type = SDL_RWOPS_STDFILE;
- }
- return (rwops);
-}
-#else
-SDL_RWops *
-SDL_RWFromFP(void * fp, SDL_bool autoclose)
-{
- SDL_SetError("SDL not compiled with stdio support");
- return NULL;
-}
-#endif /* HAVE_STDIO_H */
-
-SDL_RWops *
-SDL_RWFromMem(void *mem, int size)
-{
- SDL_RWops *rwops = NULL;
- if (!mem) {
- SDL_InvalidParamError("mem");
- return (rwops);
- }
- if (!size) {
- SDL_InvalidParamError("size");
- return (rwops);
- }
-
- rwops = SDL_AllocRW();
- if (rwops != NULL) {
- rwops->size = mem_size;
- rwops->seek = mem_seek;
- rwops->read = mem_read;
- rwops->write = mem_write;
- rwops->close = mem_close;
- rwops->hidden.mem.base = (Uint8 *) mem;
- rwops->hidden.mem.here = rwops->hidden.mem.base;
- rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
- rwops->type = SDL_RWOPS_MEMORY;
- }
- return (rwops);
-}
-
-SDL_RWops *
-SDL_RWFromConstMem(const void *mem, int size)
-{
- SDL_RWops *rwops = NULL;
- if (!mem) {
- SDL_InvalidParamError("mem");
- return (rwops);
- }
- if (!size) {
- SDL_InvalidParamError("size");
- return (rwops);
- }
-
- rwops = SDL_AllocRW();
- if (rwops != NULL) {
- rwops->size = mem_size;
- rwops->seek = mem_seek;
- rwops->read = mem_read;
- rwops->write = mem_writeconst;
- rwops->close = mem_close;
- rwops->hidden.mem.base = (Uint8 *) mem;
- rwops->hidden.mem.here = rwops->hidden.mem.base;
- rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
- rwops->type = SDL_RWOPS_MEMORY_RO;
- }
- return (rwops);
-}
-
-SDL_RWops *
-SDL_AllocRW(void)
-{
- SDL_RWops *area;
-
- area = (SDL_RWops *) SDL_malloc(sizeof *area);
- if (area == NULL) {
- SDL_OutOfMemory();
- } else {
- area->type = SDL_RWOPS_UNKNOWN;
- }
- return (area);
-}
-
-void
-SDL_FreeRW(SDL_RWops * area)
-{
- SDL_free(area);
-}
-
-/* Functions for dynamically reading and writing endian-specific values */
-
-Uint8
-SDL_ReadU8(SDL_RWops * src)
-{
- Uint8 value = 0;
-
- SDL_RWread(src, &value, (sizeof value), 1);
- return value;
-}
-
-Uint16
-SDL_ReadLE16(SDL_RWops * src)
-{
- Uint16 value = 0;
-
- SDL_RWread(src, &value, (sizeof value), 1);
- return (SDL_SwapLE16(value));
-}
-
-Uint16
-SDL_ReadBE16(SDL_RWops * src)
-{
- Uint16 value = 0;
-
- SDL_RWread(src, &value, (sizeof value), 1);
- return (SDL_SwapBE16(value));
-}
-
-Uint32
-SDL_ReadLE32(SDL_RWops * src)
-{
- Uint32 value = 0;
-
- SDL_RWread(src, &value, (sizeof value), 1);
- return (SDL_SwapLE32(value));
-}
-
-Uint32
-SDL_ReadBE32(SDL_RWops * src)
-{
- Uint32 value = 0;
-
- SDL_RWread(src, &value, (sizeof value), 1);
- return (SDL_SwapBE32(value));
-}
-
-Uint64
-SDL_ReadLE64(SDL_RWops * src)
-{
- Uint64 value = 0;
-
- SDL_RWread(src, &value, (sizeof value), 1);
- return (SDL_SwapLE64(value));
-}
-
-Uint64
-SDL_ReadBE64(SDL_RWops * src)
-{
- Uint64 value = 0;
-
- SDL_RWread(src, &value, (sizeof value), 1);
- return (SDL_SwapBE64(value));
-}
-
-size_t
-SDL_WriteU8(SDL_RWops * dst, Uint8 value)
-{
- return (SDL_RWwrite(dst, &value, (sizeof value), 1));
-}
-
-size_t
-SDL_WriteLE16(SDL_RWops * dst, Uint16 value)
-{
- value = SDL_SwapLE16(value);
- return (SDL_RWwrite(dst, &value, (sizeof value), 1));
-}
-
-size_t
-SDL_WriteBE16(SDL_RWops * dst, Uint16 value)
-{
- value = SDL_SwapBE16(value);
- return (SDL_RWwrite(dst, &value, (sizeof value), 1));
-}
-
-size_t
-SDL_WriteLE32(SDL_RWops * dst, Uint32 value)
-{
- value = SDL_SwapLE32(value);
- return (SDL_RWwrite(dst, &value, (sizeof value), 1));
-}
-
-size_t
-SDL_WriteBE32(SDL_RWops * dst, Uint32 value)
-{
- value = SDL_SwapBE32(value);
- return (SDL_RWwrite(dst, &value, (sizeof value), 1));
-}
-
-size_t
-SDL_WriteLE64(SDL_RWops * dst, Uint64 value)
-{
- value = SDL_SwapLE64(value);
- return (SDL_RWwrite(dst, &value, (sizeof value), 1));
-}
-
-size_t
-SDL_WriteBE64(SDL_RWops * dst, Uint64 value)
-{
- value = SDL_SwapBE64(value);
- return (SDL_RWwrite(dst, &value, (sizeof value), 1));
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 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.
+*/
+/* Need this so Linux systems define fseek64o, ftell64o and off64_t */
+#define _LARGEFILE64_SOURCE
+#include "SDL_config.h"
+
+/* This file provides a general interface for SDL to read and write
+ data sources. It can easily be extended to files, memory, etc.
+*/
+
+#include "SDL_endian.h"
+#include "SDL_rwops.h"
+
+#ifdef __APPLE__
+#include "cocoa/SDL_rwopsbundlesupport.h"
+#endif /* __APPLE__ */
+
+#ifdef ANDROID
+#include "../core/android/SDL_android.h"
+#include "SDL_system.h"
+#endif
+
+#ifdef __WIN32__
+
+/* Functions to read/write Win32 API file pointers */
+
+#include "../core/windows/SDL_windows.h"
+
+#ifndef INVALID_SET_FILE_POINTER
+#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
+#endif
+
+#define READAHEAD_BUFFER_SIZE 1024
+
+static int SDLCALL
+windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
+{
+ UINT old_error_mode;
+ HANDLE h;
+ DWORD r_right, w_right;
+ DWORD must_exist, truncate;
+ int a_mode;
+
+ if (!context)
+ return -1; /* failed (invalid call) */
+
+ context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
+ context->hidden.windowsio.buffer.data = NULL;
+ context->hidden.windowsio.buffer.size = 0;
+ context->hidden.windowsio.buffer.left = 0;
+
+ /* "r" = reading, file must exist */
+ /* "w" = writing, truncate existing, file may not exist */
+ /* "r+"= reading or writing, file must exist */
+ /* "a" = writing, append file may not exist */
+ /* "a+"= append + read, file may not exist */
+ /* "w+" = read, write, truncate. file may not exist */
+
+ must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0;
+ truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0;
+ r_right = (SDL_strchr(mode, '+') != NULL
+ || must_exist) ? GENERIC_READ : 0;
+ a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0;
+ w_right = (a_mode || SDL_strchr(mode, '+')
+ || truncate) ? GENERIC_WRITE : 0;
+
+ if (!r_right && !w_right) /* inconsistent mode */
+ return -1; /* failed (invalid call) */
+
+ context->hidden.windowsio.buffer.data =
+ (char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
+ if (!context->hidden.windowsio.buffer.data) {
+ return SDL_OutOfMemory();
+ }
+ /* Do not open a dialog box if failure */
+ old_error_mode =
+ SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
+
+ {
+ LPTSTR tstr = WIN_UTF8ToString(filename);
+ h = CreateFile(tstr, (w_right | r_right),
+ (w_right) ? 0 : FILE_SHARE_READ, NULL,
+ (must_exist | truncate | a_mode),
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ SDL_free(tstr);
+ }
+
+ /* restore old behavior */
+ SetErrorMode(old_error_mode);
+
+ if (h == INVALID_HANDLE_VALUE) {
+ SDL_free(context->hidden.windowsio.buffer.data);
+ context->hidden.windowsio.buffer.data = NULL;
+ SDL_SetError("Couldn't open %s", filename);
+ return -2; /* failed (CreateFile) */
+ }
+ context->hidden.windowsio.h = h;
+ context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE;
+
+ return 0; /* ok */
+}
+
+static Sint64 SDLCALL
+windows_file_size(SDL_RWops * context)
+{
+ LARGE_INTEGER size;
+
+ if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
+ return SDL_SetError("windows_file_size: invalid context/file not opened");
+ }
+
+ if (!GetFileSizeEx(context->hidden.windowsio.h, &size)) {
+ return WIN_SetError("windows_file_size");
+ }
+
+ return size.QuadPart;
+}
+
+static Sint64 SDLCALL
+windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
+{
+ DWORD windowswhence;
+ LARGE_INTEGER windowsoffset;
+
+ if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
+ return SDL_SetError("windows_file_seek: invalid context/file not opened");
+ }
+
+ /* FIXME: We may be able to satisfy the seek within buffered data */
+ if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) {
+ offset -= (long)context->hidden.windowsio.buffer.left;
+ }
+ context->hidden.windowsio.buffer.left = 0;
+
+ switch (whence) {
+ case RW_SEEK_SET:
+ windowswhence = FILE_BEGIN;
+ break;
+ case RW_SEEK_CUR:
+ windowswhence = FILE_CURRENT;
+ break;
+ case RW_SEEK_END:
+ windowswhence = FILE_END;
+ break;
+ default:
+ return SDL_SetError("windows_file_seek: Unknown value for 'whence'");
+ }
+
+ windowsoffset.QuadPart = offset;
+ if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, windowswhence)) {
+ return WIN_SetError("windows_file_seek");
+ }
+ return windowsoffset.QuadPart;
+}
+
+static size_t SDLCALL
+windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
+{
+ size_t total_need;
+ size_t total_read = 0;
+ size_t read_ahead;
+ DWORD byte_read;
+
+ total_need = size * maxnum;
+
+ if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
+ || !total_need)
+ return 0;
+
+ if (context->hidden.windowsio.buffer.left > 0) {
+ void *data = (char *) context->hidden.windowsio.buffer.data +
+ context->hidden.windowsio.buffer.size -
+ context->hidden.windowsio.buffer.left;
+ read_ahead =
+ SDL_min(total_need, context->hidden.windowsio.buffer.left);
+ SDL_memcpy(ptr, data, read_ahead);
+ context->hidden.windowsio.buffer.left -= read_ahead;
+
+ if (read_ahead == total_need) {
+ return maxnum;
+ }
+ ptr = (char *) ptr + read_ahead;
+ total_need -= read_ahead;
+ total_read += read_ahead;
+ }
+
+ if (total_need < READAHEAD_BUFFER_SIZE) {
+ if (!ReadFile
+ (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data,
+ READAHEAD_BUFFER_SIZE, &byte_read, NULL)) {
+ SDL_Error(SDL_EFREAD);
+ return 0;
+ }
+ read_ahead = SDL_min(total_need, (int) byte_read);
+ SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead);
+ context->hidden.windowsio.buffer.size = byte_read;
+ context->hidden.windowsio.buffer.left = byte_read - read_ahead;
+ total_read += read_ahead;
+ } else {
+ if (!ReadFile
+ (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
+ SDL_Error(SDL_EFREAD);
+ return 0;
+ }
+ total_read += byte_read;
+ }
+ return (total_read / size);
+}
+
+static size_t SDLCALL
+windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
+ size_t num)
+{
+
+ size_t total_bytes;
+ DWORD byte_written;
+ size_t nwritten;
+
+ total_bytes = size * num;
+
+ if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
+ || total_bytes <= 0 || !size)
+ return 0;
+
+ if (context->hidden.windowsio.buffer.left) {
+ SetFilePointer(context->hidden.windowsio.h,
+ -(LONG)context->hidden.windowsio.buffer.left, NULL,
+ FILE_CURRENT);
+ context->hidden.windowsio.buffer.left = 0;
+ }
+
+ /* if in append mode, we must go to the EOF before write */
+ if (context->hidden.windowsio.append) {
+ if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) ==
+ INVALID_SET_FILE_POINTER) {
+ SDL_Error(SDL_EFWRITE);
+ return 0;
+ }
+ }
+
+ if (!WriteFile
+ (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
+ SDL_Error(SDL_EFWRITE);
+ return 0;
+ }
+
+ nwritten = byte_written / size;
+ return nwritten;
+}
+
+static int SDLCALL
+windows_file_close(SDL_RWops * context)
+{
+
+ if (context) {
+ if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) {
+ CloseHandle(context->hidden.windowsio.h);
+ context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */
+ }
+ if (context->hidden.windowsio.buffer.data) {
+ SDL_free(context->hidden.windowsio.buffer.data);
+ context->hidden.windowsio.buffer.data = NULL;
+ }
+ SDL_FreeRW(context);
+ }
+ return (0);
+}
+#endif /* __WIN32__ */
+
+#ifdef HAVE_STDIO_H
+
+/* Functions to read/write stdio file pointers */
+
+static Sint64 SDLCALL
+stdio_size(SDL_RWops * context)
+{
+ Sint64 pos, size;
+
+ pos = SDL_RWseek(context, 0, RW_SEEK_CUR);
+ if (pos < 0) {
+ return -1;
+ }
+ size = SDL_RWseek(context, 0, RW_SEEK_END);
+
+ SDL_RWseek(context, pos, RW_SEEK_SET);
+ return size;
+}
+
+static Sint64 SDLCALL
+stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
+{
+#ifdef HAVE_FSEEKO64
+ if (fseeko64(context->hidden.stdio.fp, (off64_t)offset, whence) == 0) {
+ return ftello64(context->hidden.stdio.fp);
+ }
+#elif defined(HAVE_FSEEKO)
+ if (fseeko(context->hidden.stdio.fp, (off_t)offset, whence) == 0) {
+ return ftello(context->hidden.stdio.fp);
+ }
+#elif defined(HAVE__FSEEKI64)
+ if (_fseeki64(context->hidden.stdio.fp, offset, whence) == 0) {
+ return _ftelli64(context->hidden.stdio.fp);
+ }
+#else
+ if (fseek(context->hidden.stdio.fp, offset, whence) == 0) {
+ return (ftell(context->hidden.stdio.fp));
+ }
+#endif
+ return SDL_Error(SDL_EFSEEK);
+}
+
+static size_t SDLCALL
+stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
+{
+ size_t nread;
+
+ nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
+ if (nread == 0 && ferror(context->hidden.stdio.fp)) {
+ SDL_Error(SDL_EFREAD);
+ }
+ return (nread);
+}
+
+static size_t SDLCALL
+stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
+{
+ size_t nwrote;
+
+ nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
+ if (nwrote == 0 && ferror(context->hidden.stdio.fp)) {
+ SDL_Error(SDL_EFWRITE);
+ }
+ return (nwrote);
+}
+
+static int SDLCALL
+stdio_close(SDL_RWops * context)
+{
+ int status = 0;
+ if (context) {
+ if (context->hidden.stdio.autoclose) {
+ /* WARNING: Check the return value here! */
+ if (fclose(context->hidden.stdio.fp) != 0) {
+ status = SDL_Error(SDL_EFWRITE);
+ }
+ }
+ SDL_FreeRW(context);
+ }
+ return status;
+}
+#endif /* !HAVE_STDIO_H */
+
+/* Functions to read/write memory pointers */
+
+static Sint64 SDLCALL
+mem_size(SDL_RWops * context)
+{
+ return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base);
+}
+
+static Sint64 SDLCALL
+mem_seek(SDL_RWops * context, Sint64 offset, int whence)
+{
+ Uint8 *newpos;
+
+ switch (whence) {
+ case RW_SEEK_SET:
+ newpos = context->hidden.mem.base + offset;
+ break;
+ case RW_SEEK_CUR:
+ newpos = context->hidden.mem.here + offset;
+ break;
+ case RW_SEEK_END:
+ newpos = context->hidden.mem.stop + offset;
+ break;
+ default:
+ return SDL_SetError("Unknown value for 'whence'");
+ }
+ if (newpos < context->hidden.mem.base) {
+ newpos = context->hidden.mem.base;
+ }
+ if (newpos > context->hidden.mem.stop) {
+ newpos = context->hidden.mem.stop;
+ }
+ context->hidden.mem.here = newpos;
+ return (Sint64)(context->hidden.mem.here - context->hidden.mem.base);
+}
+
+static size_t SDLCALL
+mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
+{
+ size_t total_bytes;
+ size_t mem_available;
+
+ total_bytes = (maxnum * size);
+ if ((maxnum <= 0) || (size <= 0)
+ || ((total_bytes / maxnum) != (size_t) size)) {
+ return 0;
+ }
+
+ mem_available = (context->hidden.mem.stop - context->hidden.mem.here);
+ if (total_bytes > mem_available) {
+ total_bytes = mem_available;
+ }
+
+ SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
+ context->hidden.mem.here += total_bytes;
+
+ return (total_bytes / size);
+}
+
+static size_t SDLCALL
+mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
+{
+ if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) {
+ num = (context->hidden.mem.stop - context->hidden.mem.here) / size;
+ }
+ SDL_memcpy(context->hidden.mem.here, ptr, num * size);
+ context->hidden.mem.here += num * size;
+ return (num);
+}
+
+static size_t SDLCALL
+mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num)
+{
+ SDL_SetError("Can't write to read-only memory");
+ return (0);
+}
+
+static int SDLCALL
+mem_close(SDL_RWops * context)
+{
+ if (context) {
+ SDL_FreeRW(context);
+ }
+ return (0);
+}
+
+
+/* Functions to create SDL_RWops structures from various data sources */
+
+SDL_RWops *
+SDL_RWFromFile(const char *file, const char *mode)
+{
+ SDL_RWops *rwops = NULL;
+ if (!file || !*file || !mode || !*mode) {
+ SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
+ return NULL;
+ }
+#if defined(ANDROID)
+#ifdef HAVE_STDIO_H
+ /* Try to open the file on the filesystem first */
+ if (*file == '/') {
+ FILE *fp = fopen(file, mode);
+ if (fp) {
+ return SDL_RWFromFP(fp, 1);
+ }
+ } else {
+ /* Try opening it from internal storage if it's a relative path */
+ char *path;
+ FILE *fp;
+
+ path = SDL_stack_alloc(char, PATH_MAX);
+ if (path) {
+ SDL_snprintf(path, PATH_MAX, "%s/%s",
+ SDL_AndroidGetInternalStoragePath(), file);
+ fp = fopen(path, mode);
+ SDL_stack_free(path);
+ if (fp) {
+ return SDL_RWFromFP(fp, 1);
+ }
+ }
+ }
+#endif /* HAVE_STDIO_H */
+
+ /* Try to open the file from the asset system */
+ rwops = SDL_AllocRW();
+ if (!rwops)
+ return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
+ if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
+ SDL_FreeRW(rwops);
+ return NULL;
+ }
+ rwops->size = Android_JNI_FileSize;
+ rwops->seek = Android_JNI_FileSeek;
+ rwops->read = Android_JNI_FileRead;
+ rwops->write = Android_JNI_FileWrite;
+ rwops->close = Android_JNI_FileClose;
+ rwops->type = SDL_RWOPS_JNIFILE;
+
+#elif defined(__WIN32__)
+ rwops = SDL_AllocRW();
+ if (!rwops)
+ return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
+ if (windows_file_open(rwops, file, mode) < 0) {
+ SDL_FreeRW(rwops);
+ return NULL;
+ }
+ rwops->size = windows_file_size;
+ rwops->seek = windows_file_seek;
+ rwops->read = windows_file_read;
+ rwops->write = windows_file_write;
+ rwops->close = windows_file_close;
+ rwops->type = SDL_RWOPS_WINFILE;
+
+#elif HAVE_STDIO_H
+ {
+ #ifdef __APPLE__
+ FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
+ #elif __WINRT__
+ FILE *fp = NULL;
+ fopen_s(&fp, file, mode);
+ #else
+ FILE *fp = fopen(file, mode);
+ #endif
+ if (fp == NULL) {
+ SDL_SetError("Couldn't open %s", file);
+ } else {
+ rwops = SDL_RWFromFP(fp, 1);
+ }
+ }
+#else
+ SDL_SetError("SDL not compiled with stdio support");
+#endif /* !HAVE_STDIO_H */
+
+ return (rwops);
+}
+
+#ifdef HAVE_STDIO_H
+SDL_RWops *
+SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
+{
+ SDL_RWops *rwops = NULL;
+
+ rwops = SDL_AllocRW();
+ if (rwops != NULL) {
+ rwops->size = stdio_size;
+ rwops->seek = stdio_seek;
+ rwops->read = stdio_read;
+ rwops->write = stdio_write;
+ rwops->close = stdio_close;
+ rwops->hidden.stdio.fp = fp;
+ rwops->hidden.stdio.autoclose = autoclose;
+ rwops->type = SDL_RWOPS_STDFILE;
+ }
+ return (rwops);
+}
+#else
+SDL_RWops *
+SDL_RWFromFP(void * fp, SDL_bool autoclose)
+{
+ SDL_SetError("SDL not compiled with stdio support");
+ return NULL;
+}
+#endif /* HAVE_STDIO_H */
+
+SDL_RWops *
+SDL_RWFromMem(void *mem, int size)
+{
+ SDL_RWops *rwops = NULL;
+ if (!mem) {
+ SDL_InvalidParamError("mem");
+ return (rwops);
+ }
+ if (!size) {
+ SDL_InvalidParamError("size");
+ return (rwops);
+ }
+
+ rwops = SDL_AllocRW();
+ if (rwops != NULL) {
+ rwops->size = mem_size;
+ rwops->seek = mem_seek;
+ rwops->read = mem_read;
+ rwops->write = mem_write;
+ rwops->close = mem_close;
+ rwops->hidden.mem.base = (Uint8 *) mem;
+ rwops->hidden.mem.here = rwops->hidden.mem.base;
+ rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
+ rwops->type = SDL_RWOPS_MEMORY;
+ }
+ return (rwops);
+}
+
+SDL_RWops *
+SDL_RWFromConstMem(const void *mem, int size)
+{
+ SDL_RWops *rwops = NULL;
+ if (!mem) {
+ SDL_InvalidParamError("mem");
+ return (rwops);
+ }
+ if (!size) {
+ SDL_InvalidParamError("size");
+ return (rwops);
+ }
+
+ rwops = SDL_AllocRW();
+ if (rwops != NULL) {
+ rwops->size = mem_size;
+ rwops->seek = mem_seek;
+ rwops->read = mem_read;
+ rwops->write = mem_writeconst;
+ rwops->close = mem_close;
+ rwops->hidden.mem.base = (Uint8 *) mem;
+ rwops->hidden.mem.here = rwops->hidden.mem.base;
+ rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
+ rwops->type = SDL_RWOPS_MEMORY_RO;
+ }
+ return (rwops);
+}
+
+SDL_RWops *
+SDL_AllocRW(void)
+{
+ SDL_RWops *area;
+
+ area = (SDL_RWops *) SDL_malloc(sizeof *area);
+ if (area == NULL) {
+ SDL_OutOfMemory();
+ } else {
+ area->type = SDL_RWOPS_UNKNOWN;
+ }
+ return (area);
+}
+
+void
+SDL_FreeRW(SDL_RWops * area)
+{
+ SDL_free(area);
+}
+
+/* Functions for dynamically reading and writing endian-specific values */
+
+Uint8
+SDL_ReadU8(SDL_RWops * src)
+{
+ Uint8 value = 0;
+
+ SDL_RWread(src, &value, (sizeof value), 1);
+ return value;
+}
+
+Uint16
+SDL_ReadLE16(SDL_RWops * src)
+{
+ Uint16 value = 0;
+
+ SDL_RWread(src, &value, (sizeof value), 1);
+ return (SDL_SwapLE16(value));
+}
+
+Uint16
+SDL_ReadBE16(SDL_RWops * src)
+{
+ Uint16 value = 0;
+
+ SDL_RWread(src, &value, (sizeof value), 1);
+ return (SDL_SwapBE16(value));
+}
+
+Uint32
+SDL_ReadLE32(SDL_RWops * src)
+{
+ Uint32 value = 0;
+
+ SDL_RWread(src, &value, (sizeof value), 1);
+ return (SDL_SwapLE32(value));
+}
+
+Uint32
+SDL_ReadBE32(SDL_RWops * src)
+{
+ Uint32 value = 0;
+
+ SDL_RWread(src, &value, (sizeof value), 1);
+ return (SDL_SwapBE32(value));
+}
+
+Uint64
+SDL_ReadLE64(SDL_RWops * src)
+{
+ Uint64 value = 0;
+
+ SDL_RWread(src, &value, (sizeof value), 1);
+ return (SDL_SwapLE64(value));
+}
+
+Uint64
+SDL_ReadBE64(SDL_RWops * src)
+{
+ Uint64 value = 0;
+
+ SDL_RWread(src, &value, (sizeof value), 1);
+ return (SDL_SwapBE64(value));
+}
+
+size_t
+SDL_WriteU8(SDL_RWops * dst, Uint8 value)
+{
+ return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+size_t
+SDL_WriteLE16(SDL_RWops * dst, Uint16 value)
+{
+ value = SDL_SwapLE16(value);
+ return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+size_t
+SDL_WriteBE16(SDL_RWops * dst, Uint16 value)
+{
+ value = SDL_SwapBE16(value);
+ return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+size_t
+SDL_WriteLE32(SDL_RWops * dst, Uint32 value)
+{
+ value = SDL_SwapLE32(value);
+ return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+size_t
+SDL_WriteBE32(SDL_RWops * dst, Uint32 value)
+{
+ value = SDL_SwapBE32(value);
+ return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+size_t
+SDL_WriteLE64(SDL_RWops * dst, Uint64 value)
+{
+ value = SDL_SwapLE64(value);
+ return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+size_t
+SDL_WriteBE64(SDL_RWops * dst, Uint64 value)
+{
+ value = SDL_SwapBE64(value);
+ return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c
index 912be05..414e591 100644
--- a/src/joystick/SDL_gamecontroller.c
+++ b/src/joystick/SDL_gamecontroller.c
@@ -1,1249 +1,1249 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2013 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_config.h"
-
-/* This is the game controller API for Simple DirectMedia Layer */
-
-#include "SDL_events.h"
-#include "SDL_assert.h"
-#include "SDL_sysjoystick.h"
-#include "SDL_hints.h"
-#include "SDL_gamecontrollerdb.h"
-
-#if !SDL_EVENTS_DISABLED
-#include "../events/SDL_events_c.h"
-#endif
-#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
-
-
-/* a list of currently opened game controllers */
-static SDL_GameController *SDL_gamecontrollers = NULL;
-
-/* keep track of the hat and mask value that transforms this hat movement into a button/axis press */
-struct _SDL_HatMapping
-{
- int hat;
- Uint8 mask;
-};
-
-#define k_nMaxReverseEntries 20
-
-/**
- * We are encoding the "HAT" as 0xhm. where h == hat ID and m == mask
- * MAX 4 hats supported
- */
-#define k_nMaxHatEntries 0x3f + 1
-
-/* our in memory mapping db between joystick objects and controller mappings*/
-struct _SDL_ControllerMapping
-{
- SDL_JoystickGUID guid;
- const char *name;
-
- /* mapping of axis/button id to controller version */
- int axes[SDL_CONTROLLER_AXIS_MAX];
- int buttonasaxis[SDL_CONTROLLER_AXIS_MAX];
-
- int buttons[SDL_CONTROLLER_BUTTON_MAX];
- int axesasbutton[SDL_CONTROLLER_BUTTON_MAX];
- struct _SDL_HatMapping hatasbutton[SDL_CONTROLLER_BUTTON_MAX];
-
- /* reverse mapping, joystick indices to buttons */
- SDL_GameControllerAxis raxes[k_nMaxReverseEntries];
- SDL_GameControllerAxis rbuttonasaxis[k_nMaxReverseEntries];
-
- SDL_GameControllerButton rbuttons[k_nMaxReverseEntries];
- SDL_GameControllerButton raxesasbutton[k_nMaxReverseEntries];
- SDL_GameControllerButton rhatasbutton[k_nMaxHatEntries];
-
-};
-
-
-/* our hard coded list of mapping support */
-typedef struct _ControllerMapping_t
-{
- SDL_JoystickGUID guid;
- char *name;
- char *mapping;
- struct _ControllerMapping_t *next;
-} ControllerMapping_t;
-
-static ControllerMapping_t *s_pSupportedControllers = NULL;
-#ifdef SDL_JOYSTICK_DINPUT
-static ControllerMapping_t *s_pXInputMapping = NULL;
-#endif
-
-/* The SDL game controller structure */
-struct _SDL_GameController
-{
- SDL_Joystick *joystick; /* underlying joystick device */
- int ref_count;
- Uint8 hatState[4]; /* the current hat state for this controller */
- struct _SDL_ControllerMapping mapping; /* the mapping object for this controller */
- struct _SDL_GameController *next; /* pointer to next game controller we have allocated */
-};
-
-
-int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value);
-int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state);
-
-/*
- * Event filter to fire controller events from joystick ones
- */
-int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event)
-{
- switch( event->type )
- {
- case SDL_JOYAXISMOTION:
- {
- SDL_GameController *controllerlist;
-
- if ( event->jaxis.axis >= k_nMaxReverseEntries ) break;
-
- controllerlist = SDL_gamecontrollers;
- while ( controllerlist )
- {
- if ( controllerlist->joystick->instance_id == event->jaxis.which )
- {
- if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) /* simple axis to axis, send it through */
- {
- SDL_GameControllerAxis axis = controllerlist->mapping.raxes[event->jaxis.axis];
- Sint16 value = event->jaxis.value;
- switch (axis)
- {
- case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
- case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
- /* Shift it to be 0 - 32767. */
- value = value / 2 + 16384;
- default:
- break;
- }
- SDL_PrivateGameControllerAxis( controllerlist, axis, value );
- }
- else if ( controllerlist->mapping.raxesasbutton[event->jaxis.axis] >= 0 ) /* simulate an axis as a button */
- {
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.raxesasbutton[event->jaxis.axis], ABS(event->jaxis.value) > 32768/2 ? SDL_PRESSED : SDL_RELEASED );
- }
- break;
- }
- controllerlist = controllerlist->next;
- }
- }
- break;
- case SDL_JOYBUTTONDOWN:
- case SDL_JOYBUTTONUP:
- {
- SDL_GameController *controllerlist;
-
- if ( event->jbutton.button >= k_nMaxReverseEntries ) break;
-
- controllerlist = SDL_gamecontrollers;
- while ( controllerlist )
- {
- if ( controllerlist->joystick->instance_id == event->jbutton.which )
- {
- if ( controllerlist->mapping.rbuttons[event->jbutton.button] >= 0 ) /* simple button as button */
- {
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rbuttons[event->jbutton.button], event->jbutton.state );
- }
- else if ( controllerlist->mapping.rbuttonasaxis[event->jbutton.button] >= 0 ) /* an button pretending to be an axis */
- {
- SDL_PrivateGameControllerAxis( controllerlist, controllerlist->mapping.rbuttonasaxis[event->jbutton.button], event->jbutton.state > 0 ? 32767 : 0 );
- }
- break;
- }
- controllerlist = controllerlist->next;
- }
- }
- break;
- case SDL_JOYHATMOTION:
- {
- SDL_GameController *controllerlist;
-
- if ( event->jhat.hat >= 4 ) break;
-
- controllerlist = SDL_gamecontrollers;
- while ( controllerlist )
- {
- if ( controllerlist->joystick->instance_id == event->jhat.which )
- {
- Uint8 bSame = controllerlist->hatState[event->jhat.hat] & event->jhat.value;
- /* Get list of removed bits (button release) */
- Uint8 bChanged = controllerlist->hatState[event->jhat.hat] ^ bSame;
- /* the hat idx in the high nibble */
- int bHighHat = event->jhat.hat << 4;
-
- if ( bChanged & SDL_HAT_DOWN )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_RELEASED );
- if ( bChanged & SDL_HAT_UP )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_RELEASED );
- if ( bChanged & SDL_HAT_LEFT )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_RELEASED );
- if ( bChanged & SDL_HAT_RIGHT )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_RELEASED );
-
- /* Get list of added bits (button press) */
- bChanged = event->jhat.value ^ bSame;
-
- if ( bChanged & SDL_HAT_DOWN )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_PRESSED );
- if ( bChanged & SDL_HAT_UP )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_PRESSED );
- if ( bChanged & SDL_HAT_LEFT )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_PRESSED );
- if ( bChanged & SDL_HAT_RIGHT )
- SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_PRESSED );
-
- /* update our state cache */
- controllerlist->hatState[event->jhat.hat] = event->jhat.value;
-
- break;
- }
- controllerlist = controllerlist->next;
- }
- }
- break;
- case SDL_JOYDEVICEADDED:
- {
- if ( SDL_IsGameController(event->jdevice.which ) )
- {
- SDL_Event deviceevent;
- deviceevent.type = SDL_CONTROLLERDEVICEADDED;
- deviceevent.cdevice.which = event->jdevice.which;
- SDL_PushEvent(&deviceevent);
- }
- }
- break;
- case SDL_JOYDEVICEREMOVED:
- {
- SDL_GameController *controllerlist = SDL_gamecontrollers;
- while ( controllerlist )
- {
- if ( controllerlist->joystick->instance_id == event->jdevice.which )
- {
- SDL_Event deviceevent;
- deviceevent.type = SDL_CONTROLLERDEVICEREMOVED;
- deviceevent.cdevice.which = event->jdevice.which;
- SDL_PushEvent(&deviceevent);
- break;
- }
- controllerlist = controllerlist->next;
- }
- }
- break;
- default:
- break;
- }
-
- return 1;
-}
-
-/*
- * Helper function to scan the mappings database for a controller with the specified GUID
- */
-ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *guid)
-{
- ControllerMapping_t *pSupportedController = s_pSupportedControllers;
- while ( pSupportedController )
- {
- if ( !SDL_memcmp( guid, &pSupportedController->guid, sizeof(*guid) ) )
- {
- return pSupportedController;
- }
- pSupportedController = pSupportedController->next;
- }
- return NULL;
-}
-
-/*
- * Helper function to determine pre-calculated offset to certain joystick mappings
- */
-ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
-{
-#ifdef SDL_JOYSTICK_DINPUT
- if ( SDL_SYS_IsXInputDeviceIndex(device_index) && s_pXInputMapping )
- {
- return s_pXInputMapping;
- }
- else
-#endif
- {
- SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID( device_index );
- return SDL_PrivateGetControllerMappingForGUID(&jGUID);
- }
-
- return NULL;
-}
-
-static const char* map_StringForControllerAxis[] = {
- "leftx",
- "lefty",
- "rightx",
- "righty",
- "lefttrigger",
- "righttrigger",
- NULL
-};
-
-/*
- * convert a string to its enum equivalent
- */
-SDL_GameControllerAxis SDL_GameControllerGetAxisFromString( const char *pchString )
-{
- int entry;
- if ( !pchString || !pchString[0] )
- return SDL_CONTROLLER_AXIS_INVALID;
-
- for ( entry = 0; map_StringForControllerAxis[entry]; ++entry)
- {
- if ( !SDL_strcasecmp( pchString, map_StringForControllerAxis[entry] ) )
- return entry;
- }
- return SDL_CONTROLLER_AXIS_INVALID;
-}
-
-/*
- * convert an enum to its string equivalent
- */
-const char* SDL_GameControllerGetStringForAxis( SDL_GameControllerAxis axis )
-{
- if (axis > SDL_CONTROLLER_AXIS_INVALID && axis < SDL_CONTROLLER_AXIS_MAX)
- {
- return map_StringForControllerAxis[axis];
- }
- return NULL;
-}
-
-static const char* map_StringForControllerButton[] = {
- "a",
- "b",
- "x",
- "y",
- "back",
- "guide",
- "start",
- "leftstick",
- "rightstick",
- "leftshoulder",
- "rightshoulder",
- "dpup",
- "dpdown",
- "dpleft",
- "dpright",
- NULL
-};
-
-/*
- * convert a string to its enum equivalent
- */
-SDL_GameControllerButton SDL_GameControllerGetButtonFromString( const char *pchString )
-{
- int entry;
- if ( !pchString || !pchString[0] )
- return SDL_CONTROLLER_BUTTON_INVALID;
-
- for ( entry = 0; map_StringForControllerButton[entry]; ++entry)
- {
- if ( !SDL_strcasecmp( pchString, map_StringForControllerButton[entry] ) )
- return entry;
- }
- return SDL_CONTROLLER_BUTTON_INVALID;
-}
-
-/*
- * convert an enum to its string equivalent
- */
-const char* SDL_GameControllerGetStringForButton( SDL_GameControllerButton axis )
-{
- if (axis > SDL_CONTROLLER_BUTTON_INVALID && axis < SDL_CONTROLLER_BUTTON_MAX)
- {
- return map_StringForControllerButton[axis];
- }
- return NULL;
-}
-
-/*
- * given a controller button name and a joystick name update our mapping structure with it
- */
-void SDL_PrivateGameControllerParseButton( const char *szGameButton, const char *szJoystickButton, struct _SDL_ControllerMapping *pMapping )
-{
- int iSDLButton = 0;
- SDL_GameControllerButton button;
- SDL_GameControllerAxis axis;
- button = SDL_GameControllerGetButtonFromString( szGameButton );
- axis = SDL_GameControllerGetAxisFromString( szGameButton );
- iSDLButton = SDL_atoi( &szJoystickButton[1] );
-
- if ( szJoystickButton[0] == 'a' )
- {
- if ( iSDLButton >= k_nMaxReverseEntries )
- {
- SDL_SetError("Axis index too large: %d", iSDLButton );
- return;
- }
- if ( axis != SDL_CONTROLLER_AXIS_INVALID )
- {
- pMapping->axes[ axis ] = iSDLButton;
- pMapping->raxes[ iSDLButton ] = axis;
- }
- else if ( button != SDL_CONTROLLER_BUTTON_INVALID )
- {
- pMapping->axesasbutton[ button ] = iSDLButton;
- pMapping->raxesasbutton[ iSDLButton ] = button;
- }
- else
- {
- SDL_assert( !"How did we get here?" );
- }
-
- }
- else if ( szJoystickButton[0] == 'b' )
- {
- if ( iSDLButton >= k_nMaxReverseEntries )
- {
- SDL_SetError("Button index too large: %d", iSDLButton );
- return;
- }
- if ( button != SDL_CONTROLLER_BUTTON_INVALID )
- {
- pMapping->buttons[ button ] = iSDLButton;
- pMapping->rbuttons[ iSDLButton ] = button;
- }
- else if ( axis != SDL_CONTROLLER_AXIS_INVALID )
- {
- pMapping->buttonasaxis[ axis ] = iSDLButton;
- pMapping->rbuttonasaxis[ iSDLButton ] = axis;
- }
- else
- {
- SDL_assert( !"How did we get here?" );
- }
- }
- else if ( szJoystickButton[0] == 'h' )
- {
- int hat = SDL_atoi( &szJoystickButton[1] );
- int mask = SDL_atoi( &szJoystickButton[3] );
- if (hat >= 4) {
- SDL_SetError("Hat index too large: %d", iSDLButton );
- }
-
- if ( button != SDL_CONTROLLER_BUTTON_INVALID )
- {
- int ridx;
- pMapping->hatasbutton[ button ].hat = hat;
- pMapping->hatasbutton[ button ].mask = mask;
- ridx = (hat << 4) | mask;
- pMapping->rhatasbutton[ ridx ] = button;
- }
- else if ( axis != SDL_CONTROLLER_AXIS_INVALID )
- {
- SDL_assert( !"Support hat as axis" );
- }
- else
- {
- SDL_assert( !"How did we get here?" );
- }
- }
-}
-
-
-/*
- * given a controller mapping string update our mapping object
- */
-static void
-SDL_PrivateGameControllerParseControllerConfigString( struct _SDL_ControllerMapping *pMapping, const char *pchString )
-{
- char szGameButton[20];
- char szJoystickButton[20];
- SDL_bool bGameButton = SDL_TRUE;
- int i = 0;
- const char *pchPos = pchString;
-
- SDL_memset( szGameButton, 0x0, sizeof(szGameButton) );
- SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) );
-
- while ( pchPos && *pchPos )
- {
- if ( *pchPos == ':' )
- {
- i = 0;
- bGameButton = SDL_FALSE;
- }
- else if ( *pchPos == ' ' )
- {
-
- }
- else if ( *pchPos == ',' )
- {
- i = 0;
- bGameButton = SDL_TRUE;
- SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping );
- SDL_memset( szGameButton, 0x0, sizeof(szGameButton) );
- SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) );
-
- }
- else if ( bGameButton )
- {
- if ( i >= sizeof(szGameButton))
- {
- SDL_SetError( "Button name too large: %s", szGameButton );
- return;
- }
- szGameButton[i] = *pchPos;
- i++;
- }
- else
- {
- if ( i >= sizeof(szJoystickButton))
- {
- SDL_SetError( "Joystick button name too large: %s", szJoystickButton );
- return;
- }
- szJoystickButton[i] = *pchPos;
- i++;
- }
- pchPos++;
- }
-
- SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping );
-
-}
-
-/*
- * Make a new button mapping struct
- */
-void SDL_PrivateLoadButtonMapping( struct _SDL_ControllerMapping *pMapping, SDL_JoystickGUID guid, const char *pchName, const char *pchMapping )
-{
- int j;
-
- pMapping->guid = guid;
- pMapping->name = pchName;
-
- /* set all the button mappings to non defaults */
- for ( j = 0; j < SDL_CONTROLLER_AXIS_MAX; j++ )
- {
- pMapping->axes[j] = -1;
- pMapping->buttonasaxis[j] = -1;
- }
- for ( j = 0; j < SDL_CONTROLLER_BUTTON_MAX; j++ )
- {
- pMapping->buttons[j] = -1;
- pMapping->axesasbutton[j] = -1;
- pMapping->hatasbutton[j].hat = -1;
- }
-
- for ( j = 0; j < k_nMaxReverseEntries; j++ )
- {
- pMapping->raxes[j] = SDL_CONTROLLER_AXIS_INVALID;
- pMapping->rbuttonasaxis[j] = SDL_CONTROLLER_AXIS_INVALID;
- pMapping->rbuttons[j] = SDL_CONTROLLER_BUTTON_INVALID;
- pMapping->raxesasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID;
- }
-
- for (j = 0; j < k_nMaxHatEntries; j++)
- {
- pMapping->rhatasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID;
- }
-
- SDL_PrivateGameControllerParseControllerConfigString( pMapping, pchMapping );
-}
-
-
-/*
- * grab the guid string from a mapping string
- */
-char *SDL_PrivateGetControllerGUIDFromMappingString( const char *pMapping )
-{
- const char *pFirstComma = SDL_strchr( pMapping, ',' );
- if ( pFirstComma )
- {
- char *pchGUID = SDL_malloc( pFirstComma - pMapping + 1 );
- if ( !pchGUID )
- {
- SDL_OutOfMemory();
- return NULL;
- }
- SDL_memcpy( pchGUID, pMapping, pFirstComma - pMapping );
- pchGUID[ pFirstComma - pMapping ] = 0;
- return pchGUID;
- }
- return NULL;
-}
-
-
-/*
- * grab the name string from a mapping string
- */
-char *SDL_PrivateGetControllerNameFromMappingString( const char *pMapping )
-{
- const char *pFirstComma, *pSecondComma;
- char *pchName;
-
- pFirstComma = SDL_strchr( pMapping, ',' );
- if ( !pFirstComma )
- return NULL;
-
- pSecondComma = SDL_strchr( pFirstComma + 1, ',' );
- if ( !pSecondComma )
- return NULL;
-
- pchName = SDL_malloc( pSecondComma - pFirstComma );
- if ( !pchName )
- {
- SDL_OutOfMemory();
- return NULL;
- }
- SDL_memcpy( pchName, pFirstComma + 1, pSecondComma - pFirstComma );
- pchName[ pSecondComma - pFirstComma - 1 ] = 0;
- return pchName;
-}
-
-
-/*
- * grab the button mapping string from a mapping string
- */
-char *SDL_PrivateGetControllerMappingFromMappingString( const char *pMapping )
-{
- const char *pFirstComma, *pSecondComma;
-
- pFirstComma = SDL_strchr( pMapping, ',' );
- if ( !pFirstComma )
- return NULL;
-
- pSecondComma = SDL_strchr( pFirstComma + 1, ',' );
- if ( !pSecondComma )
- return NULL;
-
- return SDL_strdup(pSecondComma + 1); /* mapping is everything after the 3rd comma */
-}
-
-void SDL_PrivateGameControllerRefreshMapping( ControllerMapping_t *pControllerMapping )
-{
- SDL_GameController *gamecontrollerlist = SDL_gamecontrollers;
- while ( gamecontrollerlist )
- {
- if ( !SDL_memcmp( &gamecontrollerlist->mapping.guid, &pControllerMapping->guid, sizeof(pControllerMapping->guid) ) )
- {
- SDL_Event event;
- event.type = SDL_CONTROLLERDEVICEREMAPPED;
- event.cdevice.which = gamecontrollerlist->joystick->instance_id;
- SDL_PushEvent(&event);
-
- /* Not really threadsafe. Should this lock access within SDL_GameControllerEventWatcher? */
- SDL_PrivateLoadButtonMapping(&gamecontrollerlist->mapping, pControllerMapping->guid, pControllerMapping->name, pControllerMapping->mapping);
- }
-
- gamecontrollerlist = gamecontrollerlist->next;
- }
-}
-
-/*
- * Add or update an entry into the Mappings Database
- */
-int
-SDL_GameControllerAddMapping( const char *mappingString )
-{
- char *pchGUID;
- char *pchName;
- char *pchMapping;
- SDL_JoystickGUID jGUID;
- ControllerMapping_t *pControllerMapping;
-#ifdef SDL_JOYSTICK_DINPUT
- SDL_bool is_xinput_mapping = SDL_FALSE;
-#endif
-
- pchGUID = SDL_PrivateGetControllerGUIDFromMappingString( mappingString );
- if (!pchGUID) {
- return -1;
- }
-#ifdef SDL_JOYSTICK_DINPUT
- if ( !SDL_strcasecmp( pchGUID, "xinput" ) ) {
- is_xinput_mapping = SDL_TRUE;
- }
-#endif
- jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
- SDL_free(pchGUID);
-
- pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
-
- pchName = SDL_PrivateGetControllerNameFromMappingString( mappingString );
- if (!pchName) return -1;
-
- pchMapping = SDL_PrivateGetControllerMappingFromMappingString( mappingString );
- if (!pchMapping) {
- SDL_free( pchName );
- return -1;
- }
-
- if (pControllerMapping) {
- /* Update existing mapping */
- SDL_free( pControllerMapping->name );
- pControllerMapping->name = pchName;
- SDL_free( pControllerMapping->mapping );
- pControllerMapping->mapping = pchMapping;
- /* refresh open controllers */
- SDL_PrivateGameControllerRefreshMapping( pControllerMapping );
- return 0;
- } else {
- pControllerMapping = SDL_malloc( sizeof(*pControllerMapping) );
- if (!pControllerMapping) {
- SDL_free( pchName );
- SDL_free( pchMapping );
- return SDL_OutOfMemory();
- }
-#ifdef SDL_JOYSTICK_DINPUT
- if ( is_xinput_mapping )
- {
- s_pXInputMapping = pControllerMapping;
- }
-#endif
- pControllerMapping->guid = jGUID;
- pControllerMapping->name = pchName;
- pControllerMapping->mapping = pchMapping;
- pControllerMapping->next = s_pSupportedControllers;
- s_pSupportedControllers = pControllerMapping;
- return 1;
- }
-}
-
-/*
- * Get the mapping string for this GUID
- */
-char *
-SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid )
-{
- char *pMappingString = NULL;
- ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid);
- if (mapping) {
- char pchGUID[33];
- size_t needed;
- SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID));
- /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
- needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
- pMappingString = SDL_malloc( needed );
- SDL_snprintf( pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping );
- }
- return pMappingString;
-}
-
-/*
- * Get the mapping string for this device
- */
-char *
-SDL_GameControllerMapping( SDL_GameController * gamecontroller )
-{
- return SDL_GameControllerMappingForGUID( gamecontroller->mapping.guid );
-}
-
-static void
-SDL_GameControllerLoadHints()
-{
- const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG);
- if ( hint && hint[0] ) {
- int nchHints = SDL_strlen( hint );
- char *pUserMappings = SDL_malloc( nchHints + 1 );
- char *pTempMappings = pUserMappings;
- SDL_memcpy( pUserMappings, hint, nchHints );
- while ( pUserMappings ) {
- char *pchNewLine = NULL;
-
- pchNewLine = SDL_strchr( pUserMappings, '\n' );
- if ( pchNewLine )
- *pchNewLine = '\0';
-
- SDL_GameControllerAddMapping( pUserMappings );
-
- if ( pchNewLine )
- pUserMappings = pchNewLine + 1;
- else
- pUserMappings = NULL;
- }
- SDL_free(pTempMappings);
- }
-}
-
-/*
- * Initialize the game controller system, mostly load our DB of controller config mappings
- */
-int
-SDL_GameControllerInit(void)
-{
- int i = 0;
- const char *pMappingString = NULL;
- s_pSupportedControllers = NULL;
- pMappingString = s_ControllerMappings[i];
- while ( pMappingString )
- {
- SDL_GameControllerAddMapping( pMappingString );
-
- i++;
- pMappingString = s_ControllerMappings[i];
- }
-
- /* load in any user supplied config */
- SDL_GameControllerLoadHints();
-
- /* watch for joy events and fire controller ones if needed */
- SDL_AddEventWatch( SDL_GameControllerEventWatcher, NULL );
-
- return (0);
-}
-
-
-/*
- * Get the implementation dependent name of a controller
- */
-const char *
-SDL_GameControllerNameForIndex(int device_index)
-{
- ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
- if ( pSupportedController )
- {
- return pSupportedController->name;
- }
- return NULL;
-}
-
-
-/*
- * Return 1 if the joystick at this device index is a supported controller
- */
-SDL_bool
-SDL_IsGameController(int device_index)
-{
- ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
- if ( pSupportedController )
- {
- return SDL_TRUE;
- }
-
- return SDL_FALSE;
-}
-
-/*
- * Open a controller for use - the index passed as an argument refers to
- * the N'th controller on the system. This index is the value which will
- * identify this controller in future controller events.
- *
- * This function returns a controller identifier, or NULL if an error occurred.
- */
-SDL_GameController *
-SDL_GameControllerOpen(int device_index)
-{
- SDL_GameController *gamecontroller;
- SDL_GameController *gamecontrollerlist;
- ControllerMapping_t *pSupportedController = NULL;
-
- if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
- SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
- return (NULL);
- }
-
- gamecontrollerlist = SDL_gamecontrollers;
- /* If the controller is already open, return it */
- while ( gamecontrollerlist )
- {
- if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == gamecontrollerlist->joystick->instance_id ) {
- gamecontroller = gamecontrollerlist;
- ++gamecontroller->ref_count;
- return (gamecontroller);
- }
- gamecontrollerlist = gamecontrollerlist->next;
- }
-
- /* Find a controller mapping */
- pSupportedController = SDL_PrivateGetControllerMapping(device_index);
- if ( !pSupportedController ) {
- SDL_SetError("Couldn't find mapping for device (%d)", device_index );
- return (NULL);
- }
-
- /* Create and initialize the joystick */
- gamecontroller = (SDL_GameController *) SDL_malloc((sizeof *gamecontroller));
- if (gamecontroller == NULL) {
- SDL_OutOfMemory();
- return NULL;
- }
-
- SDL_memset(gamecontroller, 0, (sizeof *gamecontroller));
- gamecontroller->joystick = SDL_JoystickOpen(device_index);
- if ( !gamecontroller->joystick ) {
- SDL_free(gamecontroller);
- return NULL;
- }
-
- SDL_PrivateLoadButtonMapping( &gamecontroller->mapping, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping );
-
- /* Add joystick to list */
- ++gamecontroller->ref_count;
- /* Link the joystick in the list */
- gamecontroller->next = SDL_gamecontrollers;
- SDL_gamecontrollers = gamecontroller;
-
- SDL_SYS_JoystickUpdate( gamecontroller->joystick );
-
- return (gamecontroller);
-}
-
-/*
- * Manually pump for controller updates.
- */
-void
-SDL_GameControllerUpdate(void)
-{
- /* Just for API completeness; the joystick API does all the work. */
- SDL_JoystickUpdate();
-}
-
-
-/*
- * Get the current state of an axis control on a controller
- */
-Sint16
-SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis)
-{
- if ( !gamecontroller )
- return 0;
-
- if (gamecontroller->mapping.axes[axis] >= 0 )
- {
- Sint16 value = ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
- switch (axis)
- {
- case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
- case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
- /* Shift it to be 0 - 32767. */
- value = value / 2 + 16384;
- default:
- break;
- }
- return value;
- }
- else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
- {
- Uint8 value;
- value = SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttonasaxis[axis] );
- if ( value > 0 )
- return 32767;
- return 0;
- }
- return 0;
-}
-
-
-/*
- * Get the current state of a button on a controller
- */
-Uint8
-SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button)
-{
- if ( !gamecontroller )
- return 0;
-
- if ( gamecontroller->mapping.buttons[button] >= 0 )
- {
- return ( SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttons[button] ) );
- }
- else if ( gamecontroller->mapping.axesasbutton[button] >= 0 )
- {
- Sint16 value;
- value = SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axesasbutton[button] );
- if ( ABS(value) > 32768/2 )
- return 1;
- return 0;
- }
- else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 )
- {
- Uint8 value;
- value = SDL_JoystickGetHat( gamecontroller->joystick, gamecontroller->mapping.hatasbutton[button].hat );
-
- if ( value & gamecontroller->mapping.hatasbutton[button].mask )
- return 1;
- return 0;
- }
-
- return 0;
-}
-
-/*
- * Return if the joystick in question is currently attached to the system,
- * \return 0 if not plugged in, 1 if still present.
- */
-SDL_bool
-SDL_GameControllerGetAttached( SDL_GameController * gamecontroller )
-{
- if ( !gamecontroller )
- return SDL_FALSE;
-
- return SDL_JoystickGetAttached(gamecontroller->joystick);
-}
-
-
-/*
- * Get the number of multi-dimensional axis controls on a joystick
- */
-const char *
-SDL_GameControllerName(SDL_GameController * gamecontroller)
-{
- if ( !gamecontroller )
- return NULL;
-
- return (gamecontroller->mapping.name);
-}
-
-
-/*
- * Get the joystick for this controller
- */
-SDL_Joystick *SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller)
-{
- if ( !gamecontroller )
- return NULL;
-
- return gamecontroller->joystick;
-}
-
-/**
- * Get the SDL joystick layer binding for this controller axis mapping
- */
-SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis)
-{
- SDL_GameControllerButtonBind bind;
- SDL_memset( &bind, 0x0, sizeof(bind) );
-
- if ( !gamecontroller || axis == SDL_CONTROLLER_AXIS_INVALID )
- return bind;
-
- if (gamecontroller->mapping.axes[axis] >= 0 )
- {
- bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS;
- bind.value.button = gamecontroller->mapping.axes[axis];
- }
- else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
- {
- bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON;
- bind.value.button = gamecontroller->mapping.buttonasaxis[axis];
- }
-
- return bind;
-}
-
-
-/**
- * Get the SDL joystick layer binding for this controller button mapping
- */
-SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button)
-{
- SDL_GameControllerButtonBind bind;
- SDL_memset( &bind, 0x0, sizeof(bind) );
-
- if ( !gamecontroller || button == SDL_CONTROLLER_BUTTON_INVALID )
- return bind;
-
- if ( gamecontroller->mapping.buttons[button] >= 0 )
- {
- bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON;
- bind.value.button = gamecontroller->mapping.buttons[button];
- }
- else if ( gamecontroller->mapping.axesasbutton[button] >= 0 )
- {
- bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS;
- bind.value.axis = gamecontroller->mapping.axesasbutton[button];
- }
- else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 )
- {
- bind.bindType = SDL_CONTROLLER_BINDTYPE_HAT;
- bind.value.hat.hat = gamecontroller->mapping.hatasbutton[button].hat;
- bind.value.hat.hat_mask = gamecontroller->mapping.hatasbutton[button].mask;
- }
-
- return bind;
-}
-
-
-/*
- * Close a joystick previously opened with SDL_JoystickOpen()
- */
-void
-SDL_GameControllerClose(SDL_GameController * gamecontroller)
-{
- SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev;
-
- if ( !gamecontroller )
- return;
-
- /* First decrement ref count */
- if (--gamecontroller->ref_count > 0) {
- return;
- }
-
- SDL_JoystickClose( gamecontroller->joystick );
-
- gamecontrollerlist = SDL_gamecontrollers;
- gamecontrollerlistprev = NULL;
- while ( gamecontrollerlist )
- {
- if (gamecontroller == gamecontrollerlist)
- {
- if ( gamecontrollerlistprev )
- {
- /* unlink this entry */
- gamecontrollerlistprev->next = gamecontrollerlist->next;
- }
- else
- {
- SDL_gamecontrollers = gamecontroller->next;
- }
-
- break;
- }
- gamecontrollerlistprev = gamecontrollerlist;
- gamecontrollerlist = gamecontrollerlist->next;
- }
-
- SDL_free(gamecontroller);
-}
-
-
-/*
- * Quit the controller subsystem
- */
-void
-SDL_GameControllerQuit(void)
-{
- ControllerMapping_t *pControllerMap;
- while ( SDL_gamecontrollers )
- {
- SDL_gamecontrollers->ref_count = 1;
- SDL_GameControllerClose(SDL_gamecontrollers);
- }
-
- while ( s_pSupportedControllers )
- {
- pControllerMap = s_pSupportedControllers;
- s_pSupportedControllers = s_pSupportedControllers->next;
- SDL_free( pControllerMap->name );
- SDL_free( pControllerMap );
- }
-
- SDL_DelEventWatch( SDL_GameControllerEventWatcher, NULL );
-
-}
-
-/*
- * Event filter to transform joystick events into appropriate game controller ones
- */
-int
-SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value)
-{
- int posted;
-
- /* translate the event, if desired */
- posted = 0;
-#if !SDL_EVENTS_DISABLED
- if (SDL_GetEventState(SDL_CONTROLLERAXISMOTION) == SDL_ENABLE) {
- SDL_Event event;
- event.type = SDL_CONTROLLERAXISMOTION;
- event.caxis.which = gamecontroller->joystick->instance_id;
- event.caxis.axis = axis;
- event.caxis.value = value;
- posted = SDL_PushEvent(&event) == 1;
- }
-#endif /* !SDL_EVENTS_DISABLED */
- return (posted);
-}
-
-
-/*
- * Event filter to transform joystick events into appropriate game controller ones
- */
-int
-SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state)
-{
- int posted;
-#if !SDL_EVENTS_DISABLED
- SDL_Event event;
-
- if ( button == SDL_CONTROLLER_BUTTON_INVALID )
- return (0);
-
- switch (state) {
- case SDL_PRESSED:
- event.type = SDL_CONTROLLERBUTTONDOWN;
- break;
- case SDL_RELEASED:
- event.type = SDL_CONTROLLERBUTTONUP;
- break;
- default:
- /* Invalid state -- bail */
- return (0);
- }
-#endif /* !SDL_EVENTS_DISABLED */
-
- /* translate the event, if desired */
- posted = 0;
-#if !SDL_EVENTS_DISABLED
- if (SDL_GetEventState(event.type) == SDL_ENABLE) {
- event.cbutton.which = gamecontroller->joystick->instance_id;
- event.cbutton.button = button;
- event.cbutton.state = state;
- posted = SDL_PushEvent(&event) == 1;
- }
-#endif /* !SDL_EVENTS_DISABLED */
- return (posted);
-}
-
-/*
- * Turn off controller events
- */
-int
-SDL_GameControllerEventState(int state)
-{
-#if SDL_EVENTS_DISABLED
- return SDL_IGNORE;
-#else
- const Uint32 event_list[] = {
- SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP,
- SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED,
- };
- unsigned int i;
-
- switch (state) {
- case SDL_QUERY:
- state = SDL_IGNORE;
- for (i = 0; i < SDL_arraysize(event_list); ++i) {
- state = SDL_EventState(event_list[i], SDL_QUERY);
- if (state == SDL_ENABLE) {
- break;
- }
- }
- break;
- default:
- for (i = 0; i < SDL_arraysize(event_list); ++i) {
- SDL_EventState(event_list[i], state);
- }
- break;
- }
- return (state);
-#endif /* SDL_EVENTS_DISABLED */
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 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_config.h"
+
+/* This is the game controller API for Simple DirectMedia Layer */
+
+#include "SDL_events.h"
+#include "SDL_assert.h"
+#include "SDL_sysjoystick.h"
+#include "SDL_hints.h"
+#include "SDL_gamecontrollerdb.h"
+
+#if !SDL_EVENTS_DISABLED
+#include "../events/SDL_events_c.h"
+#endif
+#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
+
+
+/* a list of currently opened game controllers */
+static SDL_GameController *SDL_gamecontrollers = NULL;
+
+/* keep track of the hat and mask value that transforms this hat movement into a button/axis press */
+struct _SDL_HatMapping
+{
+ int hat;
+ Uint8 mask;
+};
+
+#define k_nMaxReverseEntries 20
+
+/**
+ * We are encoding the "HAT" as 0xhm. where h == hat ID and m == mask
+ * MAX 4 hats supported
+ */
+#define k_nMaxHatEntries 0x3f + 1
+
+/* our in memory mapping db between joystick objects and controller mappings*/
+struct _SDL_ControllerMapping
+{
+ SDL_JoystickGUID guid;
+ const char *name;
+
+ /* mapping of axis/button id to controller version */
+ int axes[SDL_CONTROLLER_AXIS_MAX];
+ int buttonasaxis[SDL_CONTROLLER_AXIS_MAX];
+
+ int buttons[SDL_CONTROLLER_BUTTON_MAX];
+ int axesasbutton[SDL_CONTROLLER_BUTTON_MAX];
+ struct _SDL_HatMapping hatasbutton[SDL_CONTROLLER_BUTTON_MAX];
+
+ /* reverse mapping, joystick indices to buttons */
+ SDL_GameControllerAxis raxes[k_nMaxReverseEntries];
+ SDL_GameControllerAxis rbuttonasaxis[k_nMaxReverseEntries];
+
+ SDL_GameControllerButton rbuttons[k_nMaxReverseEntries];
+ SDL_GameControllerButton raxesasbutton[k_nMaxReverseEntries];
+ SDL_GameControllerButton rhatasbutton[k_nMaxHatEntries];
+
+};
+
+
+/* our hard coded list of mapping support */
+typedef struct _ControllerMapping_t
+{
+ SDL_JoystickGUID guid;
+ char *name;
+ char *mapping;
+ struct _ControllerMapping_t *next;
+} ControllerMapping_t;
+
+static ControllerMapping_t *s_pSupportedControllers = NULL;
+#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
+static ControllerMapping_t *s_pXInputMapping = NULL;
+#endif
+
+/* The SDL game controller structure */
+struct _SDL_GameController
+{
+ SDL_Joystick *joystick; /* underlying joystick device */
+ int ref_count;
+ Uint8 hatState[4]; /* the current hat state for this controller */
+ struct _SDL_ControllerMapping mapping; /* the mapping object for this controller */
+ struct _SDL_GameController *next; /* pointer to next game controller we have allocated */
+};
+
+
+int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value);
+int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state);
+
+/*
+ * Event filter to fire controller events from joystick ones
+ */
+int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event)
+{
+ switch( event->type )
+ {
+ case SDL_JOYAXISMOTION:
+ {
+ SDL_GameController *controllerlist;
+
+ if ( event->jaxis.axis >= k_nMaxReverseEntries ) break;
+
+ controllerlist = SDL_gamecontrollers;
+ while ( controllerlist )
+ {
+ if ( controllerlist->joystick->instance_id == event->jaxis.which )
+ {
+ if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) /* simple axis to axis, send it through */
+ {
+ SDL_GameControllerAxis axis = controllerlist->mapping.raxes[event->jaxis.axis];
+ Sint16 value = event->jaxis.value;
+ switch (axis)
+ {
+ case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
+ case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
+ /* Shift it to be 0 - 32767. */
+ value = value / 2 + 16384;
+ default:
+ break;
+ }
+ SDL_PrivateGameControllerAxis( controllerlist, axis, value );
+ }
+ else if ( controllerlist->mapping.raxesasbutton[event->jaxis.axis] >= 0 ) /* simulate an axis as a button */
+ {
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.raxesasbutton[event->jaxis.axis], ABS(event->jaxis.value) > 32768/2 ? SDL_PRESSED : SDL_RELEASED );
+ }
+ break;
+ }
+ controllerlist = controllerlist->next;
+ }
+ }
+ break;
+ case SDL_JOYBUTTONDOWN:
+ case SDL_JOYBUTTONUP:
+ {
+ SDL_GameController *controllerlist;
+
+ if ( event->jbutton.button >= k_nMaxReverseEntries ) break;
+
+ controllerlist = SDL_gamecontrollers;
+ while ( controllerlist )
+ {
+ if ( controllerlist->joystick->instance_id == event->jbutton.which )
+ {
+ if ( controllerlist->mapping.rbuttons[event->jbutton.button] >= 0 ) /* simple button as button */
+ {
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rbuttons[event->jbutton.button], event->jbutton.state );
+ }
+ else if ( controllerlist->mapping.rbuttonasaxis[event->jbutton.button] >= 0 ) /* an button pretending to be an axis */
+ {
+ SDL_PrivateGameControllerAxis( controllerlist, controllerlist->mapping.rbuttonasaxis[event->jbutton.button], event->jbutton.state > 0 ? 32767 : 0 );
+ }
+ break;
+ }
+ controllerlist = controllerlist->next;
+ }
+ }
+ break;
+ case SDL_JOYHATMOTION:
+ {
+ SDL_GameController *controllerlist;
+
+ if ( event->jhat.hat >= 4 ) break;
+
+ controllerlist = SDL_gamecontrollers;
+ while ( controllerlist )
+ {
+ if ( controllerlist->joystick->instance_id == event->jhat.which )
+ {
+ Uint8 bSame = controllerlist->hatState[event->jhat.hat] & event->jhat.value;
+ /* Get list of removed bits (button release) */
+ Uint8 bChanged = controllerlist->hatState[event->jhat.hat] ^ bSame;
+ /* the hat idx in the high nibble */
+ int bHighHat = event->jhat.hat << 4;
+
+ if ( bChanged & SDL_HAT_DOWN )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_RELEASED );
+ if ( bChanged & SDL_HAT_UP )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_RELEASED );
+ if ( bChanged & SDL_HAT_LEFT )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_RELEASED );
+ if ( bChanged & SDL_HAT_RIGHT )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_RELEASED );
+
+ /* Get list of added bits (button press) */
+ bChanged = event->jhat.value ^ bSame;
+
+ if ( bChanged & SDL_HAT_DOWN )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_DOWN], SDL_PRESSED );
+ if ( bChanged & SDL_HAT_UP )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_UP], SDL_PRESSED );
+ if ( bChanged & SDL_HAT_LEFT )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_LEFT], SDL_PRESSED );
+ if ( bChanged & SDL_HAT_RIGHT )
+ SDL_PrivateGameControllerButton( controllerlist, controllerlist->mapping.rhatasbutton[bHighHat | SDL_HAT_RIGHT], SDL_PRESSED );
+
+ /* update our state cache */
+ controllerlist->hatState[event->jhat.hat] = event->jhat.value;
+
+ break;
+ }
+ controllerlist = controllerlist->next;
+ }
+ }
+ break;
+ case SDL_JOYDEVICEADDED:
+ {
+ if ( SDL_IsGameController(event->jdevice.which ) )
+ {
+ SDL_Event deviceevent;
+ deviceevent.type = SDL_CONTROLLERDEVICEADDED;
+ deviceevent.cdevice.which = event->jdevice.which;
+ SDL_PushEvent(&deviceevent);
+ }
+ }
+ break;
+ case SDL_JOYDEVICEREMOVED:
+ {
+ SDL_GameController *controllerlist = SDL_gamecontrollers;
+ while ( controllerlist )
+ {
+ if ( controllerlist->joystick->instance_id == event->jdevice.which )
+ {
+ SDL_Event deviceevent;
+ deviceevent.type = SDL_CONTROLLERDEVICEREMOVED;
+ deviceevent.cdevice.which = event->jdevice.which;
+ SDL_PushEvent(&deviceevent);
+ break;
+ }
+ controllerlist = controllerlist->next;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 1;
+}
+
+/*
+ * Helper function to scan the mappings database for a controller with the specified GUID
+ */
+ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *guid)
+{
+ ControllerMapping_t *pSupportedController = s_pSupportedControllers;
+ while ( pSupportedController )
+ {
+ if ( !SDL_memcmp( guid, &pSupportedController->guid, sizeof(*guid) ) )
+ {
+ return pSupportedController;
+ }
+ pSupportedController = pSupportedController->next;
+ }
+ return NULL;
+}
+
+/*
+ * Helper function to determine pre-calculated offset to certain joystick mappings
+ */
+ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
+{
+#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
+ if ( SDL_SYS_IsXInputDeviceIndex(device_index) && s_pXInputMapping )
+ {
+ return s_pXInputMapping;
+ }
+ else
+#endif
+ {
+ SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID( device_index );
+ return SDL_PrivateGetControllerMappingForGUID(&jGUID);
+ }
+
+ return NULL;
+}
+
+static const char* map_StringForControllerAxis[] = {
+ "leftx",
+ "lefty",
+ "rightx",
+ "righty",
+ "lefttrigger",
+ "righttrigger",
+ NULL
+};
+
+/*
+ * convert a string to its enum equivalent
+ */
+SDL_GameControllerAxis SDL_GameControllerGetAxisFromString( const char *pchString )
+{
+ int entry;
+ if ( !pchString || !pchString[0] )
+ return SDL_CONTROLLER_AXIS_INVALID;
+
+ for ( entry = 0; map_StringForControllerAxis[entry]; ++entry)
+ {
+ if ( !SDL_strcasecmp( pchString, map_StringForControllerAxis[entry] ) )
+ return entry;
+ }
+ return SDL_CONTROLLER_AXIS_INVALID;
+}
+
+/*
+ * convert an enum to its string equivalent
+ */
+const char* SDL_GameControllerGetStringForAxis( SDL_GameControllerAxis axis )
+{
+ if (axis > SDL_CONTROLLER_AXIS_INVALID && axis < SDL_CONTROLLER_AXIS_MAX)
+ {
+ return map_StringForControllerAxis[axis];
+ }
+ return NULL;
+}
+
+static const char* map_StringForControllerButton[] = {
+ "a",
+ "b",
+ "x",
+ "y",
+ "back",
+ "guide",
+ "start",
+ "leftstick",
+ "rightstick",
+ "leftshoulder",
+ "rightshoulder",
+ "dpup",
+ "dpdown",
+ "dpleft",
+ "dpright",
+ NULL
+};
+
+/*
+ * convert a string to its enum equivalent
+ */
+SDL_GameControllerButton SDL_GameControllerGetButtonFromString( const char *pchString )
+{
+ int entry;
+ if ( !pchString || !pchString[0] )
+ return SDL_CONTROLLER_BUTTON_INVALID;
+
+ for ( entry = 0; map_StringForControllerButton[entry]; ++entry)
+ {
+ if ( !SDL_strcasecmp( pchString, map_StringForControllerButton[entry] ) )
+ return entry;
+ }
+ return SDL_CONTROLLER_BUTTON_INVALID;
+}
+
+/*
+ * convert an enum to its string equivalent
+ */
+const char* SDL_GameControllerGetStringForButton( SDL_GameControllerButton axis )
+{
+ if (axis > SDL_CONTROLLER_BUTTON_INVALID && axis < SDL_CONTROLLER_BUTTON_MAX)
+ {
+ return map_StringForControllerButton[axis];
+ }
+ return NULL;
+}
+
+/*
+ * given a controller button name and a joystick name update our mapping structure with it
+ */
+void SDL_PrivateGameControllerParseButton( const char *szGameButton, const char *szJoystickButton, struct _SDL_ControllerMapping *pMapping )
+{
+ int iSDLButton = 0;
+ SDL_GameControllerButton button;
+ SDL_GameControllerAxis axis;
+ button = SDL_GameControllerGetButtonFromString( szGameButton );
+ axis = SDL_GameControllerGetAxisFromString( szGameButton );
+ iSDLButton = SDL_atoi( &szJoystickButton[1] );
+
+ if ( szJoystickButton[0] == 'a' )
+ {
+ if ( iSDLButton >= k_nMaxReverseEntries )
+ {
+ SDL_SetError("Axis index too large: %d", iSDLButton );
+ return;
+ }
+ if ( axis != SDL_CONTROLLER_AXIS_INVALID )
+ {
+ pMapping->axes[ axis ] = iSDLButton;
+ pMapping->raxes[ iSDLButton ] = axis;
+ }
+ else if ( button != SDL_CONTROLLER_BUTTON_INVALID )
+ {
+ pMapping->axesasbutton[ button ] = iSDLButton;
+ pMapping->raxesasbutton[ iSDLButton ] = button;
+ }
+ else
+ {
+ SDL_assert( !"How did we get here?" );
+ }
+
+ }
+ else if ( szJoystickButton[0] == 'b' )
+ {
+ if ( iSDLButton >= k_nMaxReverseEntries )
+ {
+ SDL_SetError("Button index too large: %d", iSDLButton );
+ return;
+ }
+ if ( button != SDL_CONTROLLER_BUTTON_INVALID )
+ {
+ pMapping->buttons[ button ] = iSDLButton;
+ pMapping->rbuttons[ iSDLButton ] = button;
+ }
+ else if ( axis != SDL_CONTROLLER_AXIS_INVALID )
+ {
+ pMapping->buttonasaxis[ axis ] = iSDLButton;
+ pMapping->rbuttonasaxis[ iSDLButton ] = axis;
+ }
+ else
+ {
+ SDL_assert( !"How did we get here?" );
+ }
+ }
+ else if ( szJoystickButton[0] == 'h' )
+ {
+ int hat = SDL_atoi( &szJoystickButton[1] );
+ int mask = SDL_atoi( &szJoystickButton[3] );
+ if (hat >= 4) {
+ SDL_SetError("Hat index too large: %d", iSDLButton );
+ }
+
+ if ( button != SDL_CONTROLLER_BUTTON_INVALID )
+ {
+ int ridx;
+ pMapping->hatasbutton[ button ].hat = hat;
+ pMapping->hatasbutton[ button ].mask = mask;
+ ridx = (hat << 4) | mask;
+ pMapping->rhatasbutton[ ridx ] = button;
+ }
+ else if ( axis != SDL_CONTROLLER_AXIS_INVALID )
+ {
+ SDL_assert( !"Support hat as axis" );
+ }
+ else
+ {
+ SDL_assert( !"How did we get here?" );
+ }
+ }
+}
+
+
+/*
+ * given a controller mapping string update our mapping object
+ */
+static void
+SDL_PrivateGameControllerParseControllerConfigString( struct _SDL_ControllerMapping *pMapping, const char *pchString )
+{
+ char szGameButton[20];
+ char szJoystickButton[20];
+ SDL_bool bGameButton = SDL_TRUE;
+ int i = 0;
+ const char *pchPos = pchString;
+
+ SDL_memset( szGameButton, 0x0, sizeof(szGameButton) );
+ SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) );
+
+ while ( pchPos && *pchPos )
+ {
+ if ( *pchPos == ':' )
+ {
+ i = 0;
+ bGameButton = SDL_FALSE;
+ }
+ else if ( *pchPos == ' ' )
+ {
+
+ }
+ else if ( *pchPos == ',' )
+ {
+ i = 0;
+ bGameButton = SDL_TRUE;
+ SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping );
+ SDL_memset( szGameButton, 0x0, sizeof(szGameButton) );
+ SDL_memset( szJoystickButton, 0x0, sizeof(szJoystickButton) );
+
+ }
+ else if ( bGameButton )
+ {
+ if ( i >= sizeof(szGameButton))
+ {
+ SDL_SetError( "Button name too large: %s", szGameButton );
+ return;
+ }
+ szGameButton[i] = *pchPos;
+ i++;
+ }
+ else
+ {
+ if ( i >= sizeof(szJoystickButton))
+ {
+ SDL_SetError( "Joystick button name too large: %s", szJoystickButton );
+ return;
+ }
+ szJoystickButton[i] = *pchPos;
+ i++;
+ }
+ pchPos++;
+ }
+
+ SDL_PrivateGameControllerParseButton( szGameButton, szJoystickButton, pMapping );
+
+}
+
+/*
+ * Make a new button mapping struct
+ */
+void SDL_PrivateLoadButtonMapping( struct _SDL_ControllerMapping *pMapping, SDL_JoystickGUID guid, const char *pchName, const char *pchMapping )
+{
+ int j;
+
+ pMapping->guid = guid;
+ pMapping->name = pchName;
+
+ /* set all the button mappings to non defaults */
+ for ( j = 0; j < SDL_CONTROLLER_AXIS_MAX; j++ )
+ {
+ pMapping->axes[j] = -1;
+ pMapping->buttonasaxis[j] = -1;
+ }
+ for ( j = 0; j < SDL_CONTROLLER_BUTTON_MAX; j++ )
+ {
+ pMapping->buttons[j] = -1;
+ pMapping->axesasbutton[j] = -1;
+ pMapping->hatasbutton[j].hat = -1;
+ }
+
+ for ( j = 0; j < k_nMaxReverseEntries; j++ )
+ {
+ pMapping->raxes[j] = SDL_CONTROLLER_AXIS_INVALID;
+ pMapping->rbuttonasaxis[j] = SDL_CONTROLLER_AXIS_INVALID;
+ pMapping->rbuttons[j] = SDL_CONTROLLER_BUTTON_INVALID;
+ pMapping->raxesasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID;
+ }
+
+ for (j = 0; j < k_nMaxHatEntries; j++)
+ {
+ pMapping->rhatasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID;
+ }
+
+ SDL_PrivateGameControllerParseControllerConfigString( pMapping, pchMapping );
+}
+
+
+/*
+ * grab the guid string from a mapping string
+ */
+char *SDL_PrivateGetControllerGUIDFromMappingString( const char *pMapping )
+{
+ const char *pFirstComma = SDL_strchr( pMapping, ',' );
+ if ( pFirstComma )
+ {
+ char *pchGUID = SDL_malloc( pFirstComma - pMapping + 1 );
+ if ( !pchGUID )
+ {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ SDL_memcpy( pchGUID, pMapping, pFirstComma - pMapping );
+ pchGUID[ pFirstComma - pMapping ] = 0;
+ return pchGUID;
+ }
+ return NULL;
+}
+
+
+/*
+ * grab the name string from a mapping string
+ */
+char *SDL_PrivateGetControllerNameFromMappingString( const char *pMapping )
+{
+ const char *pFirstComma, *pSecondComma;
+ char *pchName;
+
+ pFirstComma = SDL_strchr( pMapping, ',' );
+ if ( !pFirstComma )
+ return NULL;
+
+ pSecondComma = SDL_strchr( pFirstComma + 1, ',' );
+ if ( !pSecondComma )
+ return NULL;
+
+ pchName = SDL_malloc( pSecondComma - pFirstComma );
+ if ( !pchName )
+ {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ SDL_memcpy( pchName, pFirstComma + 1, pSecondComma - pFirstComma );
+ pchName[ pSecondComma - pFirstComma - 1 ] = 0;
+ return pchName;
+}
+
+
+/*
+ * grab the button mapping string from a mapping string
+ */
+char *SDL_PrivateGetControllerMappingFromMappingString( const char *pMapping )
+{
+ const char *pFirstComma, *pSecondComma;
+
+ pFirstComma = SDL_strchr( pMapping, ',' );
+ if ( !pFirstComma )
+ return NULL;
+
+ pSecondComma = SDL_strchr( pFirstComma + 1, ',' );
+ if ( !pSecondComma )
+ return NULL;
+
+ return SDL_strdup(pSecondComma + 1); /* mapping is everything after the 3rd comma */
+}
+
+void SDL_PrivateGameControllerRefreshMapping( ControllerMapping_t *pControllerMapping )
+{
+ SDL_GameController *gamecontrollerlist = SDL_gamecontrollers;
+ while ( gamecontrollerlist )
+ {
+ if ( !SDL_memcmp( &gamecontrollerlist->mapping.guid, &pControllerMapping->guid, sizeof(pControllerMapping->guid) ) )
+ {
+ SDL_Event event;
+ event.type = SDL_CONTROLLERDEVICEREMAPPED;
+ event.cdevice.which = gamecontrollerlist->joystick->instance_id;
+ SDL_PushEvent(&event);
+
+ /* Not really threadsafe. Should this lock access within SDL_GameControllerEventWatcher? */
+ SDL_PrivateLoadButtonMapping(&gamecontrollerlist->mapping, pControllerMapping->guid, pControllerMapping->name, pControllerMapping->mapping);
+ }
+
+ gamecontrollerlist = gamecontrollerlist->next;
+ }
+}
+
+/*
+ * Add or update an entry into the Mappings Database
+ */
+int
+SDL_GameControllerAddMapping( const char *mappingString )
+{
+ char *pchGUID;
+ char *pchName;
+ char *pchMapping;
+ SDL_JoystickGUID jGUID;
+ ControllerMapping_t *pControllerMapping;
+#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
+ SDL_bool is_xinput_mapping = SDL_FALSE;
+#endif
+
+ pchGUID = SDL_PrivateGetControllerGUIDFromMappingString( mappingString );
+ if (!pchGUID) {
+ return -1;
+ }
+#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
+ if ( !SDL_strcasecmp( pchGUID, "xinput" ) ) {
+ is_xinput_mapping = SDL_TRUE;
+ }
+#endif
+ jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
+ SDL_free(pchGUID);
+
+ pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
+
+ pchName = SDL_PrivateGetControllerNameFromMappingString( mappingString );
+ if (!pchName) return -1;
+
+ pchMapping = SDL_PrivateGetControllerMappingFromMappingString( mappingString );
+ if (!pchMapping) {
+ SDL_free( pchName );
+ return -1;
+ }
+
+ if (pControllerMapping) {
+ /* Update existing mapping */
+ SDL_free( pControllerMapping->name );
+ pControllerMapping->name = pchName;
+ SDL_free( pControllerMapping->mapping );
+ pControllerMapping->mapping = pchMapping;
+ /* refresh open controllers */
+ SDL_PrivateGameControllerRefreshMapping( pControllerMapping );
+ return 0;
+ } else {
+ pControllerMapping = SDL_malloc( sizeof(*pControllerMapping) );
+ if (!pControllerMapping) {
+ SDL_free( pchName );
+ SDL_free( pchMapping );
+ return SDL_OutOfMemory();
+ }
+#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
+ if ( is_xinput_mapping )
+ {
+ s_pXInputMapping = pControllerMapping;
+ }
+#endif
+ pControllerMapping->guid = jGUID;
+ pControllerMapping->name = pchName;
+ pControllerMapping->mapping = pchMapping;
+ pControllerMapping->next = s_pSupportedControllers;
+ s_pSupportedControllers = pControllerMapping;
+ return 1;
+ }
+}
+
+/*
+ * Get the mapping string for this GUID
+ */
+char *
+SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid )
+{
+ char *pMappingString = NULL;
+ ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid);
+ if (mapping) {
+ char pchGUID[33];
+ size_t needed;
+ SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID));
+ /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
+ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
+ pMappingString = SDL_malloc( needed );
+ SDL_snprintf( pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping );
+ }
+ return pMappingString;
+}
+
+/*
+ * Get the mapping string for this device
+ */
+char *
+SDL_GameControllerMapping( SDL_GameController * gamecontroller )
+{
+ return SDL_GameControllerMappingForGUID( gamecontroller->mapping.guid );
+}
+
+static void
+SDL_GameControllerLoadHints()
+{
+ const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG);
+ if ( hint && hint[0] ) {
+ int nchHints = SDL_strlen( hint );
+ char *pUserMappings = SDL_malloc( nchHints + 1 );
+ char *pTempMappings = pUserMappings;
+ SDL_memcpy( pUserMappings, hint, nchHints );
+ while ( pUserMappings ) {
+ char *pchNewLine = NULL;
+
+ pchNewLine = SDL_strchr( pUserMappings, '\n' );
+ if ( pchNewLine )
+ *pchNewLine = '\0';
+
+ SDL_GameControllerAddMapping( pUserMappings );
+
+ if ( pchNewLine )
+ pUserMappings = pchNewLine + 1;
+ else
+ pUserMappings = NULL;
+ }
+ SDL_free(pTempMappings);
+ }
+}
+
+/*
+ * Initialize the game controller system, mostly load our DB of controller config mappings
+ */
+int
+SDL_GameControllerInit(void)
+{
+ int i = 0;
+ const char *pMappingString = NULL;
+ s_pSupportedControllers = NULL;
+ pMappingString = s_ControllerMappings[i];
+ while ( pMappingString )
+ {
+ SDL_GameControllerAddMapping( pMappingString );
+
+ i++;
+ pMappingString = s_ControllerMappings[i];
+ }
+
+ /* load in any user supplied config */
+ SDL_GameControllerLoadHints();
+
+ /* watch for joy events and fire controller ones if needed */
+ SDL_AddEventWatch( SDL_GameControllerEventWatcher, NULL );
+
+ return (0);
+}
+
+
+/*
+ * Get the implementation dependent name of a controller
+ */
+const char *
+SDL_GameControllerNameForIndex(int device_index)
+{
+ ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
+ if ( pSupportedController )
+ {
+ return pSupportedController->name;
+ }
+ return NULL;
+}
+
+
+/*
+ * Return 1 if the joystick at this device index is a supported controller
+ */
+SDL_bool
+SDL_IsGameController(int device_index)
+{
+ ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
+ if ( pSupportedController )
+ {
+ return SDL_TRUE;
+ }
+
+ return SDL_FALSE;
+}
+
+/*
+ * Open a controller for use - the index passed as an argument refers to
+ * the N'th controller on the system. This index is the value which will
+ * identify this controller in future controller events.
+ *
+ * This function returns a controller identifier, or NULL if an error occurred.
+ */
+SDL_GameController *
+SDL_GameControllerOpen(int device_index)
+{
+ SDL_GameController *gamecontroller;
+ SDL_GameController *gamecontrollerlist;
+ ControllerMapping_t *pSupportedController = NULL;
+
+ if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) {
+ SDL_SetError("There are %d joysticks available", SDL_NumJoysticks());
+ return (NULL);
+ }
+
+ gamecontrollerlist = SDL_gamecontrollers;
+ /* If the controller is already open, return it */
+ while ( gamecontrollerlist )
+ {
+ if ( SDL_SYS_GetInstanceIdOfDeviceIndex(device_index) == gamecontrollerlist->joystick->instance_id ) {
+ gamecontroller = gamecontrollerlist;
+ ++gamecontroller->ref_count;
+ return (gamecontroller);
+ }
+ gamecontrollerlist = gamecontrollerlist->next;
+ }
+
+ /* Find a controller mapping */
+ pSupportedController = SDL_PrivateGetControllerMapping(device_index);
+ if ( !pSupportedController ) {
+ SDL_SetError("Couldn't find mapping for device (%d)", device_index );
+ return (NULL);
+ }
+
+ /* Create and initialize the joystick */
+ gamecontroller = (SDL_GameController *) SDL_malloc((sizeof *gamecontroller));
+ if (gamecontroller == NULL) {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+
+ SDL_memset(gamecontroller, 0, (sizeof *gamecontroller));
+ gamecontroller->joystick = SDL_JoystickOpen(device_index);
+ if ( !gamecontroller->joystick ) {
+ SDL_free(gamecontroller);
+ return NULL;
+ }
+
+ SDL_PrivateLoadButtonMapping( &gamecontroller->mapping, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping );
+
+ /* Add joystick to list */
+ ++gamecontroller->ref_count;
+ /* Link the joystick in the list */
+ gamecontroller->next = SDL_gamecontrollers;
+ SDL_gamecontrollers = gamecontroller;
+
+ SDL_SYS_JoystickUpdate( gamecontroller->joystick );
+
+ return (gamecontroller);
+}
+
+/*
+ * Manually pump for controller updates.
+ */
+void
+SDL_GameControllerUpdate(void)
+{
+ /* Just for API completeness; the joystick API does all the work. */
+ SDL_JoystickUpdate();
+}
+
+
+/*
+ * Get the current state of an axis control on a controller
+ */
+Sint16
+SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis)
+{
+ if ( !gamecontroller )
+ return 0;
+
+ if (gamecontroller->mapping.axes[axis] >= 0 )
+ {
+ Sint16 value = ( SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axes[axis]) );
+ switch (axis)
+ {
+ case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
+ case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
+ /* Shift it to be 0 - 32767. */
+ value = value / 2 + 16384;
+ default:
+ break;
+ }
+ return value;
+ }
+ else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
+ {
+ Uint8 value;
+ value = SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttonasaxis[axis] );
+ if ( value > 0 )
+ return 32767;
+ return 0;
+ }
+ return 0;
+}
+
+
+/*
+ * Get the current state of a button on a controller
+ */
+Uint8
+SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button)
+{
+ if ( !gamecontroller )
+ return 0;
+
+ if ( gamecontroller->mapping.buttons[button] >= 0 )
+ {
+ return ( SDL_JoystickGetButton( gamecontroller->joystick, gamecontroller->mapping.buttons[button] ) );
+ }
+ else if ( gamecontroller->mapping.axesasbutton[button] >= 0 )
+ {
+ Sint16 value;
+ value = SDL_JoystickGetAxis( gamecontroller->joystick, gamecontroller->mapping.axesasbutton[button] );
+ if ( ABS(value) > 32768/2 )
+ return 1;
+ return 0;
+ }
+ else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 )
+ {
+ Uint8 value;
+ value = SDL_JoystickGetHat( gamecontroller->joystick, gamecontroller->mapping.hatasbutton[button].hat );
+
+ if ( value & gamecontroller->mapping.hatasbutton[button].mask )
+ return 1;
+ return 0;
+ }
+
+ return 0;
+}
+
+/*
+ * Return if the joystick in question is currently attached to the system,
+ * \return 0 if not plugged in, 1 if still present.
+ */
+SDL_bool
+SDL_GameControllerGetAttached( SDL_GameController * gamecontroller )
+{
+ if ( !gamecontroller )
+ return SDL_FALSE;
+
+ return SDL_JoystickGetAttached(gamecontroller->joystick);
+}
+
+
+/*
+ * Get the number of multi-dimensional axis controls on a joystick
+ */
+const char *
+SDL_GameControllerName(SDL_GameController * gamecontroller)
+{
+ if ( !gamecontroller )
+ return NULL;
+
+ return (gamecontroller->mapping.name);
+}
+
+
+/*
+ * Get the joystick for this controller
+ */
+SDL_Joystick *SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller)
+{
+ if ( !gamecontroller )
+ return NULL;
+
+ return gamecontroller->joystick;
+}
+
+/**
+ * Get the SDL joystick layer binding for this controller axis mapping
+ */
+SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis)
+{
+ SDL_GameControllerButtonBind bind;
+ SDL_memset( &bind, 0x0, sizeof(bind) );
+
+ if ( !gamecontroller || axis == SDL_CONTROLLER_AXIS_INVALID )
+ return bind;
+
+ if (gamecontroller->mapping.axes[axis] >= 0 )
+ {
+ bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS;
+ bind.value.button = gamecontroller->mapping.axes[axis];
+ }
+ else if (gamecontroller->mapping.buttonasaxis[axis] >= 0 )
+ {
+ bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON;
+ bind.value.button = gamecontroller->mapping.buttonasaxis[axis];
+ }
+
+ return bind;
+}
+
+
+/**
+ * Get the SDL joystick layer binding for this controller button mapping
+ */
+SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button)
+{
+ SDL_GameControllerButtonBind bind;
+ SDL_memset( &bind, 0x0, sizeof(bind) );
+
+ if ( !gamecontroller || button == SDL_CONTROLLER_BUTTON_INVALID )
+ return bind;
+
+ if ( gamecontroller->mapping.buttons[button] >= 0 )
+ {
+ bind.bindType = SDL_CONTROLLER_BINDTYPE_BUTTON;
+ bind.value.button = gamecontroller->mapping.buttons[button];
+ }
+ else if ( gamecontroller->mapping.axesasbutton[button] >= 0 )
+ {
+ bind.bindType = SDL_CONTROLLER_BINDTYPE_AXIS;
+ bind.value.axis = gamecontroller->mapping.axesasbutton[button];
+ }
+ else if ( gamecontroller->mapping.hatasbutton[button].hat >= 0 )
+ {
+ bind.bindType = SDL_CONTROLLER_BINDTYPE_HAT;
+ bind.value.hat.hat = gamecontroller->mapping.hatasbutton[button].hat;
+ bind.value.hat.hat_mask = gamecontroller->mapping.hatasbutton[button].mask;
+ }
+
+ return bind;
+}
+
+
+/*
+ * Close a joystick previously opened with SDL_JoystickOpen()
+ */
+void
+SDL_GameControllerClose(SDL_GameController * gamecontroller)
+{
+ SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev;
+
+ if ( !gamecontroller )
+ return;
+
+ /* First decrement ref count */
+ if (--gamecontroller->ref_count > 0) {
+ return;
+ }
+
+ SDL_JoystickClose( gamecontroller->joystick );
+
+ gamecontrollerlist = SDL_gamecontrollers;
+ gamecontrollerlistprev = NULL;
+ while ( gamecontrollerlist )
+ {
+ if (gamecontroller == gamecontrollerlist)
+ {
+ if ( gamecontrollerlistprev )
+ {
+ /* unlink this entry */
+ gamecontrollerlistprev->next = gamecontrollerlist->next;
+ }
+ else
+ {
+ SDL_gamecontrollers = gamecontroller->next;
+ }
+
+ break;
+ }
+ gamecontrollerlistprev = gamecontrollerlist;
+ gamecontrollerlist = gamecontrollerlist->next;
+ }
+
+ SDL_free(gamecontroller);
+}
+
+
+/*
+ * Quit the controller subsystem
+ */
+void
+SDL_GameControllerQuit(void)
+{
+ ControllerMapping_t *pControllerMap;
+ while ( SDL_gamecontrollers )
+ {
+ SDL_gamecontrollers->ref_count = 1;
+ SDL_GameControllerClose(SDL_gamecontrollers);
+ }
+
+ while ( s_pSupportedControllers )
+ {
+ pControllerMap = s_pSupportedControllers;
+ s_pSupportedControllers = s_pSupportedControllers->next;
+ SDL_free( pControllerMap->name );
+ SDL_free( pControllerMap );
+ }
+
+ SDL_DelEventWatch( SDL_GameControllerEventWatcher, NULL );
+
+}
+
+/*
+ * Event filter to transform joystick events into appropriate game controller ones
+ */
+int
+SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value)
+{
+ int posted;
+
+ /* translate the event, if desired */
+ posted = 0;
+#if !SDL_EVENTS_DISABLED
+ if (SDL_GetEventState(SDL_CONTROLLERAXISMOTION) == SDL_ENABLE) {
+ SDL_Event event;
+ event.type = SDL_CONTROLLERAXISMOTION;
+ event.caxis.which = gamecontroller->joystick->instance_id;
+ event.caxis.axis = axis;
+ event.caxis.value = value;
+ posted = SDL_PushEvent(&event) == 1;
+ }
+#endif /* !SDL_EVENTS_DISABLED */
+ return (posted);
+}
+
+
+/*
+ * Event filter to transform joystick events into appropriate game controller ones
+ */
+int
+SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state)
+{
+ int posted;
+#if !SDL_EVENTS_DISABLED
+ SDL_Event event;
+
+ if ( button == SDL_CONTROLLER_BUTTON_INVALID )
+ return (0);
+
+ switch (state) {
+ case SDL_PRESSED:
+ event.type = SDL_CONTROLLERBUTTONDOWN;
+ break;
+ case SDL_RELEASED:
+ event.type = SDL_CONTROLLERBUTTONUP;
+ break;
+ default:
+ /* Invalid state -- bail */
+ return (0);
+ }
+#endif /* !SDL_EVENTS_DISABLED */
+
+ /* translate the event, if desired */
+ posted = 0;
+#if !SDL_EVENTS_DISABLED
+ if (SDL_GetEventState(event.type) == SDL_ENABLE) {
+ event.cbutton.which = gamecontroller->joystick->instance_id;
+ event.cbutton.button = button;
+ event.cbutton.state = state;
+ posted = SDL_PushEvent(&event) == 1;
+ }
+#endif /* !SDL_EVENTS_DISABLED */
+ return (posted);
+}
+
+/*
+ * Turn off controller events
+ */
+int
+SDL_GameControllerEventState(int state)
+{
+#if SDL_EVENTS_DISABLED
+ return SDL_IGNORE;
+#else
+ const Uint32 event_list[] = {
+ SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP,
+ SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED,
+ };
+ unsigned int i;
+
+ switch (state) {
+ case SDL_QUERY:
+ state = SDL_IGNORE;
+ for (i = 0; i < SDL_arraysize(event_list); ++i) {
+ state = SDL_EventState(event_list[i], SDL_QUERY);
+ if (state == SDL_ENABLE) {
+ break;
+ }
+ }
+ break;
+ default:
+ for (i = 0; i < SDL_arraysize(event_list); ++i) {
+ SDL_EventState(event_list[i], state);
+ }
+ break;
+ }
+ return (state);
+#endif /* SDL_EVENTS_DISABLED */
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h
index 4a5019e..f75aabc 100644
--- a/src/joystick/SDL_sysjoystick.h
+++ b/src/joystick/SDL_sysjoystick.h
@@ -108,7 +108,7 @@ extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index);
/* Function to return the stable GUID for a opened joystick */
extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick);
-#ifdef SDL_JOYSTICK_DINPUT
+#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
/* Function to get the current instance id of the joystick located at device_index */
extern SDL_bool SDL_SYS_IsXInputDeviceIndex( int device_index );
#endif
diff --git a/src/joystick/windowsrt/SDL_xinputjoystick.c b/src/joystick/windowsrt/SDL_xinputjoystick.c
new file mode 100644
index 0000000..6b3e59f
--- /dev/null
+++ b/src/joystick/windowsrt/SDL_xinputjoystick.c
@@ -0,0 +1,435 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 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_config.h"
+
+#if SDL_JOYSTICK_XINPUT
+
+/* SDL_xinputjoystick.c implements an XInput-only joystick and game controller
+ backend that is suitable for use on WinRT. SDL's DirectInput backend, also
+ XInput-capable, was not used as DirectInput is not available on WinRT (or,
+ at least, it isn't a public API). Some portions of this XInput backend
+ may copy parts of the XInput-using code from the DirectInput backend.
+ Refactoring the common parts into one location may be good to-do at some
+ point.
+
+ TODO, WinRT: add hotplug support for XInput based game controllers
+*/
+
+#include "SDL_joystick.h"
+#include "../SDL_sysjoystick.h"
+#include "../SDL_joystick_c.h"
+#include "SDL_events.h"
+#include "../../events/SDL_events_c.h"
+
+#include <Windows.h>
+#include <Xinput.h>
+
+struct joystick_hwdata {
+ //Uint8 bXInputHaptic; // Supports force feedback via XInput.
+ DWORD userIndex; // The XInput device index, in the range [0, XUSER_MAX_COUNT-1] (probably [0,3]).
+ XINPUT_STATE XInputState; // the last-read in XInputState, kept around to compare old and new values
+ SDL_bool isDeviceConnected; // was the device connected (on the last polling, or during backend-initialization)?
+ SDL_bool isDeviceRemovalEventPending; // was the device removed, and is the associated removal event pending?
+};
+
+/* Keep track of data on all XInput devices, regardless of whether or not
+ they've been opened (via SDL_JoystickOpen).
+ */
+static struct joystick_hwdata g_XInputData[XUSER_MAX_COUNT];
+
+/* Function to scan the system for joysticks.
+ * It should return 0, or -1 on an unrecoverable fatal error.
+ */
+int
+SDL_SYS_JoystickInit(void)
+{
+ HRESULT result = S_OK;
+ XINPUT_STATE tempXInputState;
+ int i;
+
+ SDL_zero(g_XInputData);
+
+ /* Make initial notes on whether or not devices are connected (or not).
+ */
+ for (i = 0; i < XUSER_MAX_COUNT; ++i) {
+ result = XInputGetState(i, &tempXInputState);
+ if (result == ERROR_SUCCESS) {
+ g_XInputData[i].isDeviceConnected = SDL_TRUE;
+ }
+ }
+
+ return (0);
+}
+
+int SDL_SYS_NumJoysticks()
+{
+ int joystickCount = 0;
+ DWORD i;
+
+ /* Iterate through each possible XInput device and see if something
+ was connected (at joystick init, or during the last polling).
+ */
+ for (i = 0; i < XUSER_MAX_COUNT; ++i) {
+ if (g_XInputData[i].isDeviceConnected) {
+ ++joystickCount;
+ }
+ }
+
+ return joystickCount;
+}
+
+void SDL_SYS_JoystickDetect()
+{
+ DWORD i;
+ XINPUT_STATE tempXInputState;
+ HRESULT result;
+ SDL_Event event;
+
+ /* Iterate through each possible XInput device, seeing if any devices
+ have been connected, or if they were removed.
+ */
+ for (i = 0; i < XUSER_MAX_COUNT; ++i) {
+ /* See if any new devices are connected. */
+ if (!g_XInputData[i].isDeviceConnected && !g_XInputData[i].isDeviceRemovalEventPending) {
+ result = XInputGetState(i, &tempXInputState);
+ if (result == ERROR_SUCCESS) {
+ /* Yup, a device is connected. Mark the device as connected,
+ then tell others about it (via an SDL_JOYDEVICEADDED event.)
+ */
+ g_XInputData[i].isDeviceConnected = SDL_TRUE;
+
+#if !SDL_EVENTS_DISABLED
+ SDL_zero(event);
+ event.type = SDL_JOYDEVICEADDED;
+
+ if (SDL_GetEventState(event.type) == SDL_ENABLE) {
+ event.jdevice.which = i;
+ if ((SDL_EventOK == NULL)
+ || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
+ SDL_PushEvent(&event);
+ }
+ }
+#endif
+ }
+ } else if (g_XInputData[i].isDeviceRemovalEventPending) {
+ /* A device was previously marked as removed (by
+ SDL_SYS_JoystickUpdate). Tell others about the device removal.
+ */
+
+ g_XInputData[i].isDeviceRemovalEventPending = SDL_FALSE;
+
+#if !SDL_EVENTS_DISABLED
+ SDL_zero(event);
+ event.type = SDL_JOYDEVICEREMOVED;
+
+ if (SDL_GetEventState(event.type) == SDL_ENABLE) {
+ event.jdevice.which = i; //joystick->hwdata->userIndex;
+ if ((SDL_EventOK == NULL)
+ || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
+ SDL_PushEvent(&event);
+ }
+ }
+#endif
+ }
+ }
+}
+
+SDL_bool SDL_SYS_JoystickNeedsPolling()
+{
+ /* Since XInput, or WinRT, provides any events to indicate when a game
+ controller gets connected, and instead indicates device availability
+ solely through polling, we'll poll (for new devices).
+ */
+ return SDL_TRUE;
+}
+
+/* Internal function to retreive device capabilities.
+ This function will return an SDL-standard value of 0 on success
+ (a device is connected, and data on it was retrieved), or -1
+ on failure (no device was connected, or some other error
+ occurred. SDL_SetError() will be invoked to set an appropriate
+ error message.
+ */
+static int
+SDL_XInput_GetDeviceCapabilities(int device_index, XINPUT_CAPABILITIES * pDeviceCaps)
+{
+ HRESULT dwResult;
+
+ /* Make sure that the device index is a valid one. If not, return to the
+ caller with an error.
+ */
+ if (device_index < 0 || device_index >= XUSER_MAX_COUNT) {
+ return SDL_SetError("invalid/unavailable device index");
+ }
+
+ /* See if a device exists, and if so, what its capabilities are. If a
+ device is not available, return to the caller with an error.
+ */
+ switch ((dwResult = XInputGetCapabilities(device_index, 0, pDeviceCaps))) {
+ case ERROR_SUCCESS:
+ /* A device is available, and its capabilities were retrieved! */
+ return 0;
+ case ERROR_DEVICE_NOT_CONNECTED:
+ return SDL_SetError("no device is connected at joystick index, %d", device_index);
+ default:
+ return SDL_SetError("an unknown error occurred when retrieving info on a device at joystick index, %d", device_index);
+ }
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *
+SDL_SYS_JoystickNameForDeviceIndex(int device_index)
+{
+ XINPUT_CAPABILITIES deviceCaps;
+
+ if (SDL_XInput_GetDeviceCapabilities(device_index, &deviceCaps) != 0) {
+ /* Uh oh. Device capabilities couldn't be retrieved. Return to the
+ caller. SDL_SetError() has already been invoked (with relevant
+ information).
+ */
+ return NULL;
+ }
+
+ switch (deviceCaps.SubType) {
+ default:
+ if (deviceCaps.Type == XINPUT_DEVTYPE_GAMEPAD) {
+ return "Undefined game controller";
+ } else {
+ return "Undefined controller";
+ }
+ case XINPUT_DEVSUBTYPE_UNKNOWN:
+ if (deviceCaps.Type == XINPUT_DEVTYPE_GAMEPAD) {
+ return "Unknown game controller";
+ } else {
+ return "Unknown controller";
+ }
+ case XINPUT_DEVSUBTYPE_GAMEPAD:
+ return "Gamepad controller";
+ case XINPUT_DEVSUBTYPE_WHEEL:
+ return "Racing wheel controller";
+ case XINPUT_DEVSUBTYPE_ARCADE_STICK:
+ return "Arcade stick controller";
+ case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
+ return "Flight stick controller";
+ case XINPUT_DEVSUBTYPE_DANCE_PAD:
+ return "Dance pad controller";
+ case XINPUT_DEVSUBTYPE_GUITAR:
+ return "Guitar controller";
+ case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE:
+ return "Guitar controller, Alternate";
+ case XINPUT_DEVSUBTYPE_GUITAR_BASS:
+ return "Guitar controller, Bass";
+ case XINPUT_DEVSUBTYPE_DRUM_KIT:
+ return "Drum controller";
+ case XINPUT_DEVSUBTYPE_ARCADE_PAD:
+ return "Arcade pad controller";
+ }
+}
+
+/* Function to perform the mapping from device index to the instance id for this index */
+SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
+{
+ return device_index;
+}
+
+/* Function to open a joystick for use.
+ The joystick to open is specified by the index field of the joystick.
+ This should fill the nbuttons and naxes fields of the joystick structure.
+ It returns 0, or -1 if there is an error.
+ */
+int
+SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
+{
+ XINPUT_CAPABILITIES deviceCaps;
+
+ if (SDL_XInput_GetDeviceCapabilities(device_index, &deviceCaps) != 0) {
+ /* Uh oh. Device capabilities couldn't be retrieved. Return to the
+ caller. SDL_SetError() has already been invoked (with relevant
+ information).
+ */
+ return -1;
+ }
+
+ /* For now, only game pads are supported. If the device is something other
+ than that, return an error to the caller.
+ */
+ if (deviceCaps.Type != XINPUT_DEVTYPE_GAMEPAD) {
+ return SDL_SetError("a device is connected (at joystick index, %d), but it is of an unknown device type (deviceCaps.Flags=%ul)",
+ device_index, (unsigned int)deviceCaps.Flags);
+ }
+
+ /* Create the joystick data structure */
+ joystick->instance_id = device_index;
+ joystick->hwdata = &g_XInputData[device_index];
+
+ // The XInput API has a hard coded button/axis mapping, so we just match it
+ joystick->naxes = 6;
+ joystick->nbuttons = 15;
+ joystick->nballs = 0;
+ joystick->nhats = 0;
+
+ /* We're done! */
+ return (0);
+}
+
+/* Function to determine is this joystick is attached to the system right now */
+SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
+{
+ return joystick->hwdata->isDeviceConnected;
+}
+
+/* Function to return > 0 if a bit array of buttons differs after applying a mask
+*/
+static int ButtonChanged( int ButtonsNow, int ButtonsPrev, int ButtonMask )
+{
+ return ( ButtonsNow & ButtonMask ) != ( ButtonsPrev & ButtonMask );
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+void
+SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
+{
+ HRESULT result;
+
+ /* Before polling for new data, make note of the old data */
+ XINPUT_STATE prevXInputState = joystick->hwdata->XInputState;
+
+ /* Poll for new data */
+ result = XInputGetState(joystick->hwdata->userIndex, &joystick->hwdata->XInputState);
+ if (result == ERROR_DEVICE_NOT_CONNECTED) {
+ if (joystick->hwdata->isDeviceConnected) {
+ joystick->hwdata->isDeviceConnected = SDL_FALSE;
+ joystick->hwdata->isDeviceRemovalEventPending = SDL_TRUE;
+ /* TODO, WinRT: make sure isDeviceRemovalEventPending gets cleared as appropriate, and that quick re-plugs don't cause trouble */
+ }
+ return;
+ }
+
+ /* Make sure the device is marked as connected */
+ joystick->hwdata->isDeviceConnected = SDL_TRUE;
+
+ // only fire events if the data changed from last time
+ if ( joystick->hwdata->XInputState.dwPacketNumber != 0
+ && joystick->hwdata->XInputState.dwPacketNumber != prevXInputState.dwPacketNumber )
+ {
+ XINPUT_STATE *pXInputState = &joystick->hwdata->XInputState;
+ XINPUT_STATE *pXInputStatePrev = &prevXInputState;
+
+ SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX );
+ SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-1*pXInputState->Gamepad.sThumbLY-1) );
+ SDL_PrivateJoystickAxis(joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX );
+ SDL_PrivateJoystickAxis(joystick, 3, (Sint16)(-1*pXInputState->Gamepad.sThumbRY-1) );
+ SDL_PrivateJoystickAxis(joystick, 4, (Sint16)((int)pXInputState->Gamepad.bLeftTrigger*32767/255) );
+ SDL_PrivateJoystickAxis(joystick, 5, (Sint16)((int)pXInputState->Gamepad.bRightTrigger*32767/255) );
+
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_UP ) )
+ SDL_PrivateJoystickButton(joystick, 0, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_DOWN ) )
+ SDL_PrivateJoystickButton(joystick, 1, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_LEFT ) )
+ SDL_PrivateJoystickButton(joystick, 2, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_RIGHT ) )
+ SDL_PrivateJoystickButton(joystick, 3, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_START ) )
+ SDL_PrivateJoystickButton(joystick, 4, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_START ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_BACK ) )
+ SDL_PrivateJoystickButton(joystick, 5, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_BACK ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_THUMB ) )
+ SDL_PrivateJoystickButton(joystick, 6, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_THUMB ) )
+ SDL_PrivateJoystickButton(joystick, 7, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_SHOULDER ) )
+ SDL_PrivateJoystickButton(joystick, 8, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_SHOULDER ) )
+ SDL_PrivateJoystickButton(joystick, 9, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_A ) )
+ SDL_PrivateJoystickButton(joystick, 10, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_A ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_B ) )
+ SDL_PrivateJoystickButton(joystick, 11, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_B ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_X ) )
+ SDL_PrivateJoystickButton(joystick, 12, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_X ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_Y ) )
+ SDL_PrivateJoystickButton(joystick, 13, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_Y ? SDL_PRESSED : SDL_RELEASED );
+ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, 0x400 ) )
+ SDL_PrivateJoystickButton(joystick, 14, pXInputState->Gamepad.wButtons & 0x400 ? SDL_PRESSED : SDL_RELEASED ); // 0x400 is the undocumented code for the guide button
+ }
+}
+
+/* Function to close a joystick after use */
+void
+SDL_SYS_JoystickClose(SDL_Joystick * joystick)
+{
+ /* Clear cached button data on the joystick */
+ SDL_zero(joystick->hwdata->XInputState);
+
+ /* There's need to free 'hwdata', as it's a pointer to a global array.
+ The field will be cleared anyways, just to indicate that it's not
+ currently needed.
+ */
+ joystick->hwdata = NULL;
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void
+SDL_SYS_JoystickQuit(void)
+{
+ return;
+}
+
+SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
+{
+ SDL_JoystickGUID guid;
+ // the GUID is just the first 16 chars of the name for now
+ const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
+ SDL_zero( guid );
+ SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
+ return guid;
+}
+
+
+SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
+{
+ SDL_JoystickGUID guid;
+ // the GUID is just the first 16 chars of the name for now
+ const char *name = joystick->name;
+ SDL_zero( guid );
+ SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
+ return guid;
+}
+
+SDL_bool SDL_SYS_IsXInputDeviceIndex(int device_index)
+{
+ /* The XInput-capable DirectInput joystick backend implements the same
+ function (SDL_SYS_IsXInputDeviceIndex), however in that case, not all
+ joystick devices are XInput devices. In this case, with the
+ WinRT-enabled XInput-only backend, all "joystick" devices are XInput
+ devices.
+ */
+ return SDL_TRUE;
+}
+
+#endif /* SDL_JOYSTICK_XINPUT */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c
index 21e7a6c..44506ec 100644
--- a/src/loadso/windows/SDL_sysloadso.c
+++ b/src/loadso/windows/SDL_sysloadso.c
@@ -33,7 +33,15 @@ void *
SDL_LoadObject(const char *sofile)
{
LPTSTR tstr = WIN_UTF8ToString(sofile);
+#ifdef __WINRT__
+ /* WinRT only publically supports LoadPackagedLibrary() for loading .dll
+ files. LoadLibrary() is a private API, and not available for apps
+ (that can be published to MS' Windows Store.)
+ */
+ void *handle = (void *) LoadPackagedLibrary(tstr, 0);
+#else
void *handle = (void *) LoadLibrary(tstr);
+#endif
SDL_free(tstr);
/* Generate an error message if all loads failed */
diff --git a/src/main/windowsrt/SDL_winrt_main.cpp b/src/main/windowsrt/SDL_winrt_main.cpp
new file mode 100644
index 0000000..9cc046d
--- /dev/null
+++ b/src/main/windowsrt/SDL_winrt_main.cpp
@@ -0,0 +1,14 @@
+
+//#include "pch.h"
+
+// The app's C-style main will be passed into SDL.dll as a function
+// pointer, and called at the appropriate time.
+typedef int (*SDLmain_MainFunction)(int, char **);
+extern __declspec(dllimport) int SDL_WinRT_RunApplication(SDLmain_MainFunction mainFunction);
+extern "C" int SDL_main(int, char **);
+
+[Platform::MTAThread]
+int main(Platform::Array<Platform::String^>^)
+{
+ return SDL_WinRT_RunApplication(SDL_main);
+}
diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h
index f06ee1d..1050465 100644
--- a/src/render/SDL_sysrender.h
+++ b/src/render/SDL_sysrender.h
@@ -166,6 +166,9 @@ struct SDL_RenderDriver
#if SDL_VIDEO_RENDER_D3D
extern SDL_RenderDriver D3D_RenderDriver;
#endif
+#if SDL_VIDEO_RENDER_D3D11
+extern SDL_RenderDriver D3D11_RenderDriver;
+#endif
#if SDL_VIDEO_RENDER_OGL
extern SDL_RenderDriver GL_RenderDriver;
#endif
diff --git a/src/render/direct3d11/SDL_D3D11_PixelShader_FixedColor.hlsl b/src/render/direct3d11/SDL_D3D11_PixelShader_FixedColor.hlsl
new file mode 100644
index 0000000..84de709
--- /dev/null
+++ b/src/render/direct3d11/SDL_D3D11_PixelShader_FixedColor.hlsl
@@ -0,0 +1,12 @@
+
+struct PixelShaderInput
+{
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+};
+
+float4 main(PixelShaderInput input) : SV_TARGET
+{
+ return input.color;
+}
diff --git a/src/render/direct3d11/SDL_D3D11_PixelShader_TextureColored.hlsl b/src/render/direct3d11/SDL_D3D11_PixelShader_TextureColored.hlsl
new file mode 100644
index 0000000..503b4fd
--- /dev/null
+++ b/src/render/direct3d11/SDL_D3D11_PixelShader_TextureColored.hlsl
@@ -0,0 +1,14 @@
+Texture2D theTexture : register(t0);
+SamplerState theSampler : register(s0);
+
+struct PixelShaderInput
+{
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+};
+
+float4 main(PixelShaderInput input) : SV_TARGET
+{
+ return theTexture.Sample(theSampler, input.tex) * input.color;
+}
diff --git a/src/render/direct3d11/SDL_D3D11_VertexShader_Default.hlsl b/src/render/direct3d11/SDL_D3D11_VertexShader_Default.hlsl
new file mode 100644
index 0000000..b5cac4f
--- /dev/null
+++ b/src/render/direct3d11/SDL_D3D11_VertexShader_Default.hlsl
@@ -0,0 +1,41 @@
+
+#pragma pack_matrix( row_major )
+
+cbuffer SDL_VertexShaderConstants : register(b0)
+{
+ matrix model;
+ matrix view;
+ matrix projection;
+};
+
+struct VertexShaderInput
+{
+ float3 pos : POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+};
+
+struct VertexShaderOutput
+{
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+};
+
+VertexShaderOutput main(VertexShaderInput input)
+{
+ VertexShaderOutput output;
+ float4 pos = float4(input.pos, 1.0f);
+
+ // Transform the vertex position into projected space.
+ pos = mul(pos, model);
+ pos = mul(pos, view);
+ pos = mul(pos, projection);
+ output.pos = pos;
+
+ // Pass through texture coordinates and color values without transformation
+ output.tex = input.tex;
+ output.color = input.color;
+
+ return output;
+}
diff --git a/src/render/direct3d11/SDL_render_d3d11.cpp b/src/render/direct3d11/SDL_render_d3d11.cpp
new file mode 100644
index 0000000..ed741c2
--- /dev/null
+++ b/src/render/direct3d11/SDL_render_d3d11.cpp
@@ -0,0 +1,1807 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
+
+#ifdef __WINRT__
+#include <windows.ui.core.h>
+#include <windows.foundation.h>
+#endif
+
+extern "C" {
+#include "../../core/windows/SDL_windows.h"
+//#include "SDL_hints.h"
+//#include "SDL_loadso.h"
+#include "SDL_system.h"
+#include "SDL_syswm.h"
+#include "../SDL_sysrender.h"
+#include "SDL_log.h"
+#include "../../video/SDL_sysvideo.h"
+//#include "stdio.h"
+}
+
+#include <fstream>
+#include <string>
+#include <vector>
+
+#include "SDL_render_d3d11_cpp.h"
+
+using namespace DirectX;
+using namespace Microsoft::WRL;
+using namespace std;
+
+#ifdef __WINRT__
+using namespace Windows::Graphics::Display;
+using namespace Windows::UI::Core;
+#endif
+
+/* Direct3D 11.1 renderer implementation */
+
+static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
+static void D3D11_WindowEvent(SDL_Renderer * renderer,
+ const SDL_WindowEvent *event);
+static int D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * rect, const void *srcPixels,
+ int srcPitch);
+static int D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * rect, void **pixels, int *pitch);
+static void D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
+static int D3D11_UpdateViewport(SDL_Renderer * renderer);
+static int D3D11_RenderClear(SDL_Renderer * renderer);
+static int D3D11_RenderDrawPoints(SDL_Renderer * renderer,
+ const SDL_FPoint * points, int count);
+static int D3D11_RenderDrawLines(SDL_Renderer * renderer,
+ const SDL_FPoint * points, int count);
+static int D3D11_RenderFillRects(SDL_Renderer * renderer,
+ const SDL_FRect * rects, int count);
+static int D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect);
+static int D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect,
+ const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
+static int D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+ Uint32 format, void * pixels, int pitch);
+static void D3D11_RenderPresent(SDL_Renderer * renderer);
+static void D3D11_DestroyTexture(SDL_Renderer * renderer,
+ SDL_Texture * texture);
+static void D3D11_DestroyRenderer(SDL_Renderer * renderer);
+
+/* Direct3D 11.1 Internal Functions */
+HRESULT D3D11_CreateDeviceResources(SDL_Renderer * renderer);
+HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer);
+HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer);
+HRESULT D3D11_HandleDeviceLost(SDL_Renderer * renderer);
+
+extern "C" SDL_RenderDriver D3D11_RenderDriver = {
+ D3D11_CreateRenderer,
+ {
+ "direct3d 11.1",
+ (
+ SDL_RENDERER_ACCELERATED |
+ SDL_RENDERER_PRESENTVSYNC |
+ SDL_RENDERER_TARGETTEXTURE
+ ), // flags. see SDL_RendererFlags
+ 2, // num_texture_formats
+ { // texture_formats
+ SDL_PIXELFORMAT_RGB888,
+ SDL_PIXELFORMAT_ARGB8888
+ },
+ 0, // max_texture_width: will be filled in later
+ 0 // max_texture_height: will be filled in later
+ }
+};
+
+
+static Uint32
+DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) {
+ switch (dxgiFormat) {
+ case DXGI_FORMAT_B8G8R8A8_UNORM:
+ return SDL_PIXELFORMAT_ARGB8888;
+ case DXGI_FORMAT_B8G8R8X8_UNORM:
+ return SDL_PIXELFORMAT_RGB888;
+ default:
+ return SDL_PIXELFORMAT_UNKNOWN;
+ }
+}
+
+static DXGI_FORMAT
+SDLPixelFormatToDXGIFormat(Uint32 sdlFormat)
+{
+ switch (sdlFormat) {
+ case SDL_PIXELFORMAT_ARGB8888:
+ return DXGI_FORMAT_B8G8R8A8_UNORM;
+ case SDL_PIXELFORMAT_RGB888:
+ return DXGI_FORMAT_B8G8R8X8_UNORM;
+ default:
+ return DXGI_FORMAT_UNKNOWN;
+ }
+}
+
+
+//typedef struct
+//{
+// float x, y, z;
+// DWORD color;
+// float u, v;
+//} Vertex;
+
+SDL_Renderer *
+D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+ SDL_Renderer *renderer;
+ D3D11_RenderData *data;
+
+ renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+ if (!renderer) {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ SDL_zerop(renderer);
+
+ data = new D3D11_RenderData; // Use the C++ 'new' operator to make sure the struct's members initialize using C++ rules
+ if (!data) {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ data->featureLevel = (D3D_FEATURE_LEVEL) 0;
+ data->windowSizeInDIPs = XMFLOAT2(0, 0);
+ data->renderTargetSize = XMFLOAT2(0, 0);
+
+ renderer->WindowEvent = D3D11_WindowEvent;
+ renderer->CreateTexture = D3D11_CreateTexture;
+ renderer->UpdateTexture = D3D11_UpdateTexture;
+ renderer->LockTexture = D3D11_LockTexture;
+ renderer->UnlockTexture = D3D11_UnlockTexture;
+ renderer->SetRenderTarget = D3D11_SetRenderTarget;
+ renderer->UpdateViewport = D3D11_UpdateViewport;
+ renderer->RenderClear = D3D11_RenderClear;
+ renderer->RenderDrawPoints = D3D11_RenderDrawPoints;
+ renderer->RenderDrawLines = D3D11_RenderDrawLines;
+ renderer->RenderFillRects = D3D11_RenderFillRects;
+ renderer->RenderCopy = D3D11_RenderCopy;
+ renderer->RenderCopyEx = D3D11_RenderCopyEx;
+ renderer->RenderReadPixels = D3D11_RenderReadPixels;
+ renderer->RenderPresent = D3D11_RenderPresent;
+ renderer->DestroyTexture = D3D11_DestroyTexture;
+ renderer->DestroyRenderer = D3D11_DestroyRenderer;
+ renderer->info = D3D11_RenderDriver.info;
+ renderer->driverdata = data;
+
+ // HACK: make sure the SDL_Renderer references the SDL_Window data now, in
+ // order to give init functions access to the underlying window handle:
+ renderer->window = window;
+
+ /* Initialize Direct3D resources */
+ if (FAILED(D3D11_CreateDeviceResources(renderer))) {
+ D3D11_DestroyRenderer(renderer);
+ return NULL;
+ }
+ if (FAILED(D3D11_CreateWindowSizeDependentResources(renderer))) {
+ D3D11_DestroyRenderer(renderer);
+ return NULL;
+ }
+
+ // TODO, WinRT: fill in renderer->info.texture_formats where appropriate
+
+ return renderer;
+}
+
+static void
+D3D11_DestroyRenderer(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ if (data) {
+ delete data;
+ data = NULL;
+ }
+}
+
+static bool
+D3D11_ReadFileContents(const wstring & fileName, vector<char> & out)
+{
+ ifstream in(fileName, ios::in | ios::binary);
+ if (!in) {
+ return false;
+ }
+
+ in.seekg(0, ios::end);
+ out.resize((size_t) in.tellg());
+ in.seekg(0, ios::beg);
+ in.read(&out[0], out.size());
+ return in.good();
+}
+
+static bool
+D3D11_ReadShaderContents(const wstring & shaderName, vector<char> & out)
+{
+ wstring fileName;
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+ fileName = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_INSTALLED_LOCATION);
+ fileName += L"\\SDL_VS2012_WinRT\\";
+#elif WINAPI_FAMILY == WINAPI_PHONE_APP
+ fileName = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_INSTALLED_LOCATION);
+ fileName += L"\\";
+#endif
+ // WinRT, TODO: test Direct3D 11.1 shader loading on Win32
+ fileName += shaderName;
+ return D3D11_ReadFileContents(fileName, out);
+}
+
+static HRESULT
+D3D11_LoadPixelShader(SDL_Renderer * renderer,
+ const wstring & shaderName,
+ ID3D11PixelShader ** shaderOutput)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ HRESULT result = S_OK;
+ vector<char> fileData;
+
+ if (!D3D11_ReadShaderContents(shaderName, fileData)) {
+ SDL_SetError("Unable to open SDL's pixel shader file.");
+ return E_FAIL;
+ }
+
+ result = data->d3dDevice->CreatePixelShader(
+ &fileData[0],
+ fileData.size(),
+ nullptr,
+ shaderOutput
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ return S_OK;
+}
+
+static HRESULT
+D3D11_CreateBlendMode(SDL_Renderer * renderer,
+ BOOL enableBlending,
+ D3D11_BLEND srcBlend,
+ D3D11_BLEND destBlend,
+ ID3D11BlendState ** blendStateOutput)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ HRESULT result = S_OK;
+
+ D3D11_BLEND_DESC blendDesc;
+ memset(&blendDesc, 0, sizeof(blendDesc));
+ blendDesc.AlphaToCoverageEnable = FALSE;
+ blendDesc.IndependentBlendEnable = FALSE;
+ blendDesc.RenderTarget[0].BlendEnable = enableBlending;
+ blendDesc.RenderTarget[0].SrcBlend = srcBlend;
+ blendDesc.RenderTarget[0].DestBlend = destBlend;
+ blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
+ blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
+ blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
+ blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
+ blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
+ result = data->d3dDevice->CreateBlendState(&blendDesc, blendStateOutput);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ return S_OK;
+}
+
+// Create resources that depend on the device.
+HRESULT
+D3D11_CreateDeviceResources(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+
+ // This flag adds support for surfaces with a different color channel ordering
+ // than the API default. It is required for compatibility with Direct2D.
+ UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
+
+#if defined(_DEBUG)
+ // If the project is in a debug build, enable debugging via SDK Layers with this flag.
+ creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
+#endif
+
+ // This array defines the set of DirectX hardware feature levels this app will support.
+ // Note the ordering should be preserved.
+ // Don't forget to declare your application's minimum required feature level in its
+ // description. All applications are assumed to support 9.1 unless otherwise stated.
+ D3D_FEATURE_LEVEL featureLevels[] =
+ {
+ D3D_FEATURE_LEVEL_11_1,
+ D3D_FEATURE_LEVEL_11_0,
+ D3D_FEATURE_LEVEL_10_1,
+ D3D_FEATURE_LEVEL_10_0,
+ D3D_FEATURE_LEVEL_9_3,
+ D3D_FEATURE_LEVEL_9_2,
+ D3D_FEATURE_LEVEL_9_1
+ };
+
+ // Create the Direct3D 11 API device object and a corresponding context.
+ ComPtr<ID3D11Device> device;
+ ComPtr<ID3D11DeviceContext> context;
+ HRESULT result = S_OK;
+ result = D3D11CreateDevice(
+ nullptr, // Specify nullptr to use the default adapter.
+ D3D_DRIVER_TYPE_HARDWARE,
+ nullptr,
+ creationFlags, // Set set debug and Direct2D compatibility flags.
+ featureLevels, // List of feature levels this app can support.
+ ARRAYSIZE(featureLevels),
+ D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
+ &device, // Returns the Direct3D device created.
+ &data->featureLevel, // Returns feature level of device created.
+ &context // Returns the device immediate context.
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ // Get the Direct3D 11.1 API device and context interfaces.
+ Microsoft::WRL::ComPtr<ID3D11Device1> d3dDevice1;
+ result = device.As(&(data->d3dDevice));
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ result = context.As(&data->d3dContext);
+ if (FAILED(result)) {
+ return result;
+ }
+
+ //
+ // Make note of the maximum texture size
+ // Max texture sizes are documented on MSDN, at:
+ // http://msdn.microsoft.com/en-us/library/windows/apps/ff476876.aspx
+ //
+ switch (data->d3dDevice->GetFeatureLevel()) {
+ case D3D_FEATURE_LEVEL_11_1:
+ case D3D_FEATURE_LEVEL_11_0:
+ renderer->info.max_texture_width = renderer->info.max_texture_height = 16384;
+ break;
+
+ case D3D_FEATURE_LEVEL_10_1:
+ case D3D_FEATURE_LEVEL_10_0:
+ renderer->info.max_texture_width = renderer->info.max_texture_height = 8192;
+ break;
+
+ case D3D_FEATURE_LEVEL_9_3:
+ renderer->info.max_texture_width = renderer->info.max_texture_height = 4096;
+ break;
+
+ case D3D_FEATURE_LEVEL_9_2:
+ case D3D_FEATURE_LEVEL_9_1:
+ renderer->info.max_texture_width = renderer->info.max_texture_height = 2048;
+ break;
+ }
+
+ //
+ // Load in SDL's one and only vertex shader:
+ //
+ vector<char> fileData;
+ if (!D3D11_ReadShaderContents(L"SDL_D3D11_VertexShader_Default.cso", fileData)) {
+ SDL_SetError("Unable to open SDL's vertex shader file.");
+ return E_FAIL;
+ }
+
+ result = data->d3dDevice->CreateVertexShader(
+ &fileData[0],
+ fileData.size(),
+ nullptr,
+ &data->vertexShader
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ //
+ // Create an input layout for SDL's vertex shader:
+ //
+ const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
+ {
+ { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
+
+ result = data->d3dDevice->CreateInputLayout(
+ vertexDesc,
+ ARRAYSIZE(vertexDesc),
+ &fileData[0],
+ fileData.size(),
+ &data->inputLayout
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ //
+ // Load in SDL's pixel shaders
+ //
+ result = D3D11_LoadPixelShader(renderer, L"SDL_D3D11_PixelShader_TextureColored.cso", &data->texturePixelShader);
+ if (FAILED(result)) {
+ // D3D11_LoadPixelShader will have aleady set the SDL error
+ return result;
+ }
+
+ result = D3D11_LoadPixelShader(renderer, L"SDL_D3D11_PixelShader_FixedColor.cso", &data->colorPixelShader);
+ if (FAILED(result)) {
+ // D3D11_LoadPixelShader will have aleady set the SDL error
+ return result;
+ }
+
+ //
+ // Setup space to hold vertex shader constants:
+ //
+ CD3D11_BUFFER_DESC constantBufferDesc(sizeof(SDL_VertexShaderConstants), D3D11_BIND_CONSTANT_BUFFER);
+ result = data->d3dDevice->CreateBuffer(
+ &constantBufferDesc,
+ nullptr,
+ &data->vertexShaderConstants
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ //
+ // Make sure that the vertex buffer, if already created, gets freed.
+ // It will be recreated later.
+ //
+ data->vertexBuffer = nullptr;
+
+ //
+ // Create a sampler to use when drawing textures:
+ //
+ D3D11_SAMPLER_DESC samplerDesc;
+ samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
+ samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
+ samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
+ samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
+ samplerDesc.MipLODBias = 0.0f;
+ samplerDesc.MaxAnisotropy = 1;
+ samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
+ samplerDesc.BorderColor[0] = 0.0f;
+ samplerDesc.BorderColor[1] = 0.0f;
+ samplerDesc.BorderColor[2] = 0.0f;
+ samplerDesc.BorderColor[3] = 0.0f;
+ samplerDesc.MinLOD = 0.0f;
+ samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
+ result = data->d3dDevice->CreateSamplerState(
+ &samplerDesc,
+ &data->mainSampler
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ //
+ // Setup the Direct3D rasterizer
+ //
+ D3D11_RASTERIZER_DESC rasterDesc;
+ memset(&rasterDesc, 0, sizeof(rasterDesc));
+ rasterDesc.AntialiasedLineEnable = false;
+ rasterDesc.CullMode = D3D11_CULL_NONE;
+ rasterDesc.DepthBias = 0;
+ rasterDesc.DepthBiasClamp = 0.0f;
+ rasterDesc.DepthClipEnable = true;
+ rasterDesc.FillMode = D3D11_FILL_SOLID;
+ rasterDesc.FrontCounterClockwise = false;
+ rasterDesc.MultisampleEnable = false;
+ rasterDesc.ScissorEnable = false;
+ rasterDesc.SlopeScaledDepthBias = 0.0f;
+ result = data->d3dDevice->CreateRasterizerState(&rasterDesc, &data->mainRasterizer);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ //
+ // Create blending states:
+ //
+ result = D3D11_CreateBlendMode(
+ renderer,
+ TRUE,
+ D3D11_BLEND_SRC_ALPHA,
+ D3D11_BLEND_INV_SRC_ALPHA,
+ &data->blendModeBlend);
+ if (FAILED(result)) {
+ // D3D11_CreateBlendMode will set the SDL error, if it fails
+ return result;
+ }
+
+ result = D3D11_CreateBlendMode(
+ renderer,
+ TRUE,
+ D3D11_BLEND_SRC_ALPHA,
+ D3D11_BLEND_ONE,
+ &data->blendModeAdd);
+ if (FAILED(result)) {
+ // D3D11_CreateBlendMode will set the SDL error, if it fails
+ return result;
+ }
+
+ result = D3D11_CreateBlendMode(
+ renderer,
+ TRUE,
+ D3D11_BLEND_ZERO,
+ D3D11_BLEND_SRC_COLOR,
+ &data->blendModeMod);
+ if (FAILED(result)) {
+ // D3D11_CreateBlendMode will set the SDL error, if it fails
+ return result;
+ }
+
+ //
+ // All done!
+ //
+ return S_OK;
+}
+
+#ifdef __WINRT__
+
+static ABI::Windows::UI::Core::ICoreWindow *
+D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
+{
+ SDL_Window * sdlWindow = renderer->window;
+ if ( ! renderer->window ) {
+ return nullptr;
+ }
+
+ SDL_SysWMinfo sdlWindowInfo;
+ SDL_VERSION(&sdlWindowInfo.version);
+ if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) {
+ return nullptr;
+ }
+
+ if (sdlWindowInfo.subsystem != SDL_SYSWM_WINDOWSRT) {
+ return nullptr;
+ }
+
+ if ( ! sdlWindowInfo.info.winrt.window ) {
+ return nullptr;
+ }
+
+ ABI::Windows::UI::Core::ICoreWindow * coreWindow = nullptr;
+ if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) {
+ return nullptr;
+ }
+
+ return coreWindow;
+}
+
+// Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
+static float
+D3D11_ConvertDipsToPixels(float dips)
+{
+ static const float dipsPerInch = 96.0f;
+ return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
+}
+#endif
+
+// Initialize all resources that change when the window's size changes.
+// WinRT, TODO: get D3D11_CreateWindowSizeDependentResources working on Win32
+HRESULT
+D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ HRESULT result = S_OK;
+ ABI::Windows::UI::Core::ICoreWindow * coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer);
+
+ // Store the window bounds so the next time we get a SizeChanged event we can
+ // avoid rebuilding everything if the size is identical.
+ ABI::Windows::Foundation::Rect coreWindowBounds;
+ result = coreWindow->get_Bounds(&coreWindowBounds);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__", Get Window Bounds", result);
+ return result;
+ }
+
+ data->windowSizeInDIPs.x = coreWindowBounds.Width;
+ data->windowSizeInDIPs.y = coreWindowBounds.Height;
+
+ // Calculate the necessary swap chain and render target size in pixels.
+ float windowWidth = D3D11_ConvertDipsToPixels(data->windowSizeInDIPs.x);
+ float windowHeight = D3D11_ConvertDipsToPixels(data->windowSizeInDIPs.y);
+
+ // The width and height of the swap chain must be based on the window's
+ // landscape-oriented width and height. If the window is in a portrait
+ // orientation, the dimensions must be reversed.
+ data->orientation = DisplayProperties::CurrentOrientation;
+ const bool swapDimensions =
+ data->orientation == DisplayOrientations::Portrait ||
+ data->orientation == DisplayOrientations::PortraitFlipped;
+ data->renderTargetSize.x = swapDimensions ? windowHeight : windowWidth;
+ data->renderTargetSize.y = swapDimensions ? windowWidth : windowHeight;
+
+ if(data->swapChain != nullptr)
+ {
+ // If the swap chain already exists, resize it.
+ result = data->swapChain->ResizeBuffers(
+ 2, // Double-buffered swap chain.
+ static_cast<UINT>(data->renderTargetSize.x),
+ static_cast<UINT>(data->renderTargetSize.y),
+ DXGI_FORMAT_B8G8R8A8_UNORM,
+ 0
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+ }
+ else
+ {
+ // Otherwise, create a new one using the same adapter as the existing Direct3D device.
+ DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
+ swapChainDesc.Width = static_cast<UINT>(data->renderTargetSize.x); // Match the size of the window.
+ swapChainDesc.Height = static_cast<UINT>(data->renderTargetSize.y);
+ swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
+ swapChainDesc.Stereo = false;
+ swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
+ swapChainDesc.SampleDesc.Quality = 0;
+ swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+ swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ swapChainDesc.Scaling = DXGI_SCALING_STRETCH; // On phone, only stretch and aspect-ratio stretch scaling are allowed.
+ swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // On phone, no swap effects are supported.
+#else
+ swapChainDesc.Scaling = DXGI_SCALING_NONE;
+ swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
+#endif
+ swapChainDesc.Flags = 0;
+
+ ComPtr<IDXGIDevice1> dxgiDevice;
+ result = data->d3dDevice.As(&dxgiDevice);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ ComPtr<IDXGIAdapter> dxgiAdapter;
+ result = dxgiDevice->GetAdapter(&dxgiAdapter);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ ComPtr<IDXGIFactory2> dxgiFactory;
+ result = dxgiAdapter->GetParent(
+ __uuidof(IDXGIFactory2),
+ &dxgiFactory
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ IUnknown * coreWindowAsIUnknown = nullptr;
+ result = coreWindow->QueryInterface(&coreWindowAsIUnknown);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", CoreWindow to IUnknown", result);
+ return result;
+ }
+
+ result = dxgiFactory->CreateSwapChainForCoreWindow(
+ data->d3dDevice.Get(),
+ coreWindowAsIUnknown,
+ &swapChainDesc,
+ nullptr, // Allow on all displays.
+ &data->swapChain
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ // Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
+ // ensures that the application will only render after each VSync, minimizing power consumption.
+ result = dxgiDevice->SetMaximumFrameLatency(1);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+ }
+
+ // Set the proper orientation for the swap chain, and generate the
+ // 3D matrix transformation for rendering to the rotated swap chain.
+ DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
+ switch (data->orientation)
+ {
+ case DisplayOrientations::Landscape:
+ rotation = DXGI_MODE_ROTATION_IDENTITY;
+ break;
+
+ case DisplayOrientations::Portrait:
+ rotation = DXGI_MODE_ROTATION_ROTATE270;
+ break;
+
+ case DisplayOrientations::LandscapeFlipped:
+ rotation = DXGI_MODE_ROTATION_ROTATE180;
+ break;
+
+ case DisplayOrientations::PortraitFlipped:
+ rotation = DXGI_MODE_ROTATION_ROTATE90;
+ break;
+
+ default:
+ throw ref new Platform::FailureException();
+ }
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ // TODO, WinRT: Windows Phone does not have the IDXGISwapChain1::SetRotation method. Check if an alternative is available, or needed.
+ result = data->swapChain->SetRotation(rotation);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+#endif
+
+ // Create a render target view of the swap chain back buffer.
+ ComPtr<ID3D11Texture2D> backBuffer;
+ result = data->swapChain->GetBuffer(
+ 0,
+ __uuidof(ID3D11Texture2D),
+ &backBuffer
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ result = data->d3dDevice->CreateRenderTargetView(
+ backBuffer.Get(),
+ nullptr,
+ &data->mainRenderTargetView
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ if (D3D11_UpdateViewport(renderer) != 0) {
+ // D3D11_UpdateViewport will set the SDL error if it fails.
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+
+// This method is called when the window's size changes.
+HRESULT
+D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ HRESULT result = S_OK;
+ ABI::Windows::UI::Core::ICoreWindow * coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer);
+ ABI::Windows::Foundation::Rect coreWindowBounds;
+
+ result = coreWindow->get_Bounds(&coreWindowBounds);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", Get Window Bounds", result);
+ return result;
+ }
+
+ if (coreWindowBounds.Width != data->windowSizeInDIPs.x ||
+ coreWindowBounds.Height != data->windowSizeInDIPs.y ||
+ data->orientation != DisplayProperties::CurrentOrientation)
+ {
+ ID3D11RenderTargetView* nullViews[] = {nullptr};
+ data->d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
+ data->mainRenderTargetView = nullptr;
+ data->d3dContext->Flush();
+ result = D3D11_CreateWindowSizeDependentResources(renderer);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+ }
+
+ return S_OK;
+}
+
+HRESULT
+D3D11_HandleDeviceLost(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ HRESULT result = S_OK;
+
+ // Reset these member variables to ensure that D3D11_UpdateForWindowSizeChange recreates all resources.
+ data->windowSizeInDIPs.x = 0;
+ data->windowSizeInDIPs.y = 0;
+ data->swapChain = nullptr;
+
+ result = D3D11_CreateDeviceResources(renderer);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ result = D3D11_UpdateForWindowSizeChange(renderer);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return result;
+ }
+
+ return S_OK;
+}
+
+static void
+D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+ //D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+
+ if (event->event == SDL_WINDOWEVENT_RESIZED) {
+ D3D11_UpdateForWindowSizeChange(renderer);
+ }
+}
+
+static int
+D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ D3D11_TextureData *textureData;
+ HRESULT result;
+ DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format);
+ if (textureFormat == SDL_PIXELFORMAT_UNKNOWN) {
+ SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified",
+ __FUNCTION__, texture->format);
+ return -1;
+ }
+
+ textureData = new D3D11_TextureData;
+ if (!textureData) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ textureData->pixelFormat = SDL_AllocFormat(texture->format);
+ textureData->lockedTexturePosition = XMINT2(0, 0);
+
+ texture->driverdata = textureData;
+
+ D3D11_TEXTURE2D_DESC textureDesc = {0};
+ textureDesc.Width = texture->w;
+ textureDesc.Height = texture->h;
+ textureDesc.MipLevels = 1;
+ textureDesc.ArraySize = 1;
+ textureDesc.Format = textureFormat;
+ textureDesc.SampleDesc.Count = 1;
+ textureDesc.SampleDesc.Quality = 0;
+ textureDesc.MiscFlags = 0;
+
+ if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+ textureDesc.Usage = D3D11_USAGE_DYNAMIC;
+ textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ } else {
+ textureDesc.Usage = D3D11_USAGE_DEFAULT;
+ textureDesc.CPUAccessFlags = 0;
+ }
+
+ if (texture->access == SDL_TEXTUREACCESS_TARGET) {
+ textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+ } else {
+ textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+ }
+
+#if 0
+ // Fill the texture with a non-black color, for debugging purposes:
+ const int numPixels = textureDesc.Width * textureDesc.Height;
+ const int pixelSizeInBytes = textureData->pixelFormat->BytesPerPixel;
+ std::vector<uint8> initialTexturePixels(numPixels * pixelSizeInBytes, 0x00);
+ for (int i = 0; i < (numPixels * pixelSizeInBytes); i += pixelSizeInBytes) {
+ initialTexturePixels[i+0] = 0xff;
+ initialTexturePixels[i+1] = 0xff;
+ initialTexturePixels[i+2] = 0x00;
+ initialTexturePixels[i+3] = 0xff;
+ }
+ D3D11_SUBRESOURCE_DATA initialTextureData = {0};
+ initialTextureData.pSysMem = (void *)&(initialTexturePixels[0]);
+ initialTextureData.SysMemPitch = textureDesc.Width * pixelSizeInBytes;
+ initialTextureData.SysMemSlicePitch = numPixels * pixelSizeInBytes;
+#endif
+
+ result = rendererData->d3dDevice->CreateTexture2D(
+ &textureDesc,
+ NULL, // &initialTextureData,
+ &textureData->mainTexture
+ );
+ if (FAILED(result)) {
+ D3D11_DestroyTexture(renderer, texture);
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return -1;
+ }
+
+ if (texture->access & SDL_TEXTUREACCESS_TARGET) {
+ D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
+ renderTargetViewDesc.Format = textureDesc.Format;
+ renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
+ renderTargetViewDesc.Texture2D.MipSlice = 0;
+
+ result = rendererData->d3dDevice->CreateRenderTargetView(
+ textureData->mainTexture.Get(),
+ &renderTargetViewDesc,
+ &textureData->mainTextureRenderTargetView);
+ if (FAILED(result)) {
+ D3D11_DestroyTexture(renderer, texture);
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return -1;
+ }
+ }
+
+ D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
+ resourceViewDesc.Format = textureDesc.Format;
+ resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+ resourceViewDesc.Texture2D.MostDetailedMip = 0;
+ resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
+ result = rendererData->d3dDevice->CreateShaderResourceView(
+ textureData->mainTexture.Get(),
+ &resourceViewDesc,
+ &textureData->mainTextureResourceView
+ );
+ if (FAILED(result)) {
+ D3D11_DestroyTexture(renderer, texture);
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return -1;
+ }
+
+ return 0;
+}
+
+static void
+D3D11_DestroyTexture(SDL_Renderer * renderer,
+ SDL_Texture * texture)
+{
+ D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
+
+ if (textureData) {
+ if (textureData->pixelFormat) {
+ SDL_FreeFormat(textureData->pixelFormat);
+ textureData->pixelFormat = NULL;
+ }
+
+ delete textureData;
+ texture->driverdata = NULL;
+ }
+}
+
+static int
+D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * rect, const void * srcPixels,
+ int srcPitch)
+{
+ // Lock the texture, retrieving a buffer to write pixel data to:
+ void * destPixels = NULL;
+ int destPitch = 0;
+ if (D3D11_LockTexture(renderer, texture, rect, &destPixels, &destPitch) != 0) {
+ // An error is already set. Attach some info to it, then return to
+ // the caller.
+ std::string errorMessage = string(__FUNCTION__ ", Lock Texture Failed: ") + SDL_GetError();
+ SDL_SetError(errorMessage.c_str());
+ return -1;
+ }
+
+ // Copy pixel data to the locked texture's memory:
+ for (int y = 0; y < rect->h; ++y) {
+ memcpy(
+ ((Uint8 *)destPixels) + (destPitch * y),
+ ((Uint8 *)srcPixels) + (srcPitch * y),
+ srcPitch
+ );
+ }
+
+ // Commit the texture's memory back to Direct3D:
+ D3D11_UnlockTexture(renderer, texture);
+
+ // Return to the caller:
+ return 0;
+}
+
+static int
+D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * rect, void **pixels, int *pitch)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
+ HRESULT result = S_OK;
+
+ if (textureData->stagingTexture) {
+ SDL_SetError("texture is already locked");
+ return -1;
+ }
+
+ // Create a 'staging' texture, which will be used to write to a portion
+ // of the main texture. This is necessary, as Direct3D 11.1 does not
+ // have the ability to write a CPU-bound pixel buffer to a rectangular
+ // subrect of a texture. Direct3D 11.1 can, however, write a pixel
+ // buffer to an entire texture, hence the use of a staging texture.
+ D3D11_TEXTURE2D_DESC stagingTextureDesc;
+ textureData->mainTexture->GetDesc(&stagingTextureDesc);
+ stagingTextureDesc.Width = rect->w;
+ stagingTextureDesc.Height = rect->h;
+ stagingTextureDesc.BindFlags = 0;
+ stagingTextureDesc.MiscFlags = 0;
+ stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
+ stagingTextureDesc.Usage = D3D11_USAGE_STAGING;
+ result = rendererData->d3dDevice->CreateTexture2D(
+ &stagingTextureDesc,
+ NULL,
+ &textureData->stagingTexture);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", Create Staging Texture", result);
+ return -1;
+ }
+
+ // Get a write-only pointer to data in the staging texture:
+ D3D11_MAPPED_SUBRESOURCE textureMemory = {0};
+ result = rendererData->d3dContext->Map(
+ textureData->stagingTexture.Get(),
+ D3D11CalcSubresource(0, 0, 0),
+ D3D11_MAP_WRITE,
+ 0,
+ &textureMemory
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", Map Staging Texture", result);
+ textureData->stagingTexture = nullptr;
+ return -1;
+ }
+
+ // Make note of where the staging texture will be written to (on a
+ // call to SDL_UnlockTexture):
+ textureData->lockedTexturePosition = XMINT2(rect->x, rect->y);
+
+ // Make sure the caller has information on the texture's pixel buffer,
+ // then return:
+ *pixels = textureMemory.pData;
+ *pitch = textureMemory.RowPitch;
+ return 0;
+}
+
+static void
+D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
+
+ // Commit the pixel buffer's changes back to the staging texture:
+ rendererData->d3dContext->Unmap(
+ textureData->stagingTexture.Get(),
+ 0);
+
+ // Copy the staging texture's contents back to the main texture:
+ rendererData->d3dContext->CopySubresourceRegion(
+ textureData->mainTexture.Get(),
+ D3D11CalcSubresource(0, 0, 0),
+ textureData->lockedTexturePosition.x,
+ textureData->lockedTexturePosition.y,
+ 0,
+ textureData->stagingTexture.Get(),
+ D3D11CalcSubresource(0, 0, 0),
+ NULL);
+
+ // Clean up and return:
+ textureData->stagingTexture = nullptr;
+ textureData->lockedTexturePosition = XMINT2(0, 0);
+}
+
+static int
+D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+
+ if (texture == NULL) {
+ rendererData->currentOffscreenRenderTargetView = nullptr;
+ return 0;
+ }
+
+ D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
+
+ if (!textureData->mainTextureRenderTargetView) {
+ std::string errorMessage = string(__FUNCTION__) + ": specified texture is not a render target";
+ SDL_SetError(errorMessage.c_str());
+ return -1;
+ }
+
+ rendererData->currentOffscreenRenderTargetView = textureData->mainTextureRenderTargetView;
+
+ return 0;
+}
+
+static int
+D3D11_UpdateViewport(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+
+ if (renderer->viewport.w == 0 || renderer->viewport.h == 0) {
+ // If the viewport is empty, assume that it is because
+ // SDL_CreateRenderer is calling it, and will call it again later
+ // with a non-empty viewport.
+ return 0;
+ }
+
+ switch (data->orientation)
+ {
+ case DisplayOrientations::Landscape:
+ data->vertexShaderConstantsData.projection = XMFLOAT4X4( // 0-degree Z-rotation
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ );
+ break;
+
+ case DisplayOrientations::Portrait:
+ data->vertexShaderConstantsData.projection = XMFLOAT4X4( // 90-degree Z-rotation
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ -1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ );
+ break;
+
+ case DisplayOrientations::LandscapeFlipped:
+ data->vertexShaderConstantsData.projection = XMFLOAT4X4( // 180-degree Z-rotation
+ -1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ );
+ break;
+
+ case DisplayOrientations::PortraitFlipped:
+ data->vertexShaderConstantsData.projection = XMFLOAT4X4( // 270-degree Z-rotation
+ 0.0f, -1.0f, 0.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
+ );
+ break;
+
+ default:
+ SDL_SetError("An unknown DisplayOrientation is being used");
+ return -1;
+ }
+
+ //
+ // Update the view matrix
+ //
+ float viewportWidth = (float) renderer->viewport.w;
+ float viewportHeight = (float) renderer->viewport.h;
+ XMStoreFloat4x4(&data->vertexShaderConstantsData.view,
+ XMMatrixMultiply(
+ XMMatrixScaling(2.0f / viewportWidth, 2.0f / viewportHeight, 1.0f),
+ XMMatrixMultiply(
+ XMMatrixTranslation(-1, -1, 0),
+ XMMatrixRotationX(XM_PI)
+ )));
+#if 0
+ data->vertexShaderConstantsData.view = XMMatrixIdentity();
+#endif
+
+ //
+ // Reset the model matrix
+ //
+ XMStoreFloat4x4(&data->vertexShaderConstantsData.model, XMMatrixIdentity());
+
+ //
+ // Update the Direct3D viewport, which seems to be aligned to the
+ // swap buffer's coordinate space, which is always in landscape:
+ //
+ SDL_FRect orientationAlignedViewport;
+ const bool swapDimensions =
+ data->orientation == DisplayOrientations::Portrait ||
+ data->orientation == DisplayOrientations::PortraitFlipped;
+ if (swapDimensions) {
+ orientationAlignedViewport.x = (float) renderer->viewport.y;
+ orientationAlignedViewport.y = (float) renderer->viewport.x;
+ orientationAlignedViewport.w = (float) renderer->viewport.h;
+ orientationAlignedViewport.h = (float) renderer->viewport.w;
+ } else {
+ orientationAlignedViewport.x = (float) renderer->viewport.x;
+ orientationAlignedViewport.y = (float) renderer->viewport.y;
+ orientationAlignedViewport.w = (float) renderer->viewport.w;
+ orientationAlignedViewport.h = (float) renderer->viewport.h;
+ }
+ // WinRT, TODO: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped)
+
+ D3D11_VIEWPORT viewport;
+ memset(&viewport, 0, sizeof(viewport));
+ viewport.TopLeftX = orientationAlignedViewport.x;
+ viewport.TopLeftY = orientationAlignedViewport.y;
+ viewport.Width = orientationAlignedViewport.w;
+ viewport.Height = orientationAlignedViewport.h;
+ viewport.MinDepth = 0.0f;
+ viewport.MaxDepth = 1.0f;
+ data->d3dContext->RSSetViewports(1, &viewport);
+
+#if 0
+ SDL_Log("%s, oav={%.0f,%.0f,%.0f,%.0f}, rend={%.0f,%.0f}\n",
+ __FUNCTION__,
+ orientationAlignedViewport.x,
+ orientationAlignedViewport.y,
+ orientationAlignedViewport.w,
+ orientationAlignedViewport.h,
+ data->renderTargetSize.x,
+ data->renderTargetSize.y);
+#endif
+
+ return 0;
+}
+
+static ComPtr<ID3D11RenderTargetView> &
+D3D11_GetCurrentRenderTargetView(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ if (data->currentOffscreenRenderTargetView) {
+ return data->currentOffscreenRenderTargetView;
+ } else {
+ return data->mainRenderTargetView;
+ }
+}
+
+static int
+D3D11_RenderClear(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+ const float colorRGBA[] = {
+ (renderer->r / 255.0f),
+ (renderer->g / 255.0f),
+ (renderer->b / 255.0f),
+ (renderer->a / 255.0f)
+ };
+ data->d3dContext->ClearRenderTargetView(
+ D3D11_GetCurrentRenderTargetView(renderer).Get(),
+ colorRGBA
+ );
+ return 0;
+}
+
+static int
+D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
+ const void * vertexData, unsigned int dataSizeInBytes)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ HRESULT result = S_OK;
+ D3D11_BUFFER_DESC vertexBufferDesc;
+
+ if (rendererData->vertexBuffer) {
+ rendererData->vertexBuffer->GetDesc(&vertexBufferDesc);
+ } else {
+ memset(&vertexBufferDesc, 0, sizeof(vertexBufferDesc));
+ }
+
+ if (vertexBufferDesc.ByteWidth >= dataSizeInBytes) {
+ rendererData->d3dContext->UpdateSubresource(rendererData->vertexBuffer.Get(), 0, NULL, vertexData, dataSizeInBytes, 0);
+ } else {
+ vertexBufferDesc.ByteWidth = dataSizeInBytes;
+ vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
+
+ D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
+ vertexBufferData.pSysMem = vertexData;
+ vertexBufferData.SysMemPitch = 0;
+ vertexBufferData.SysMemSlicePitch = 0;
+
+ result = rendererData->d3dDevice->CreateBuffer(
+ &vertexBufferDesc,
+ &vertexBufferData,
+ &rendererData->vertexBuffer
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, result);
+ return -1;
+ }
+ }
+
+ UINT stride = sizeof(VertexPositionColor);
+ UINT offset = 0;
+ rendererData->d3dContext->IASetVertexBuffers(
+ 0,
+ 1,
+ rendererData->vertexBuffer.GetAddressOf(),
+ &stride,
+ &offset
+ );
+
+ return 0;
+}
+
+static void
+D3D11_RenderStartDrawOp(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+
+ rendererData->d3dContext->OMSetRenderTargets(
+ 1,
+ D3D11_GetCurrentRenderTargetView(renderer).GetAddressOf(),
+ nullptr
+ );
+}
+
+static void
+D3D11_RenderSetBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ switch (blendMode) {
+ case SDL_BLENDMODE_BLEND:
+ rendererData->d3dContext->OMSetBlendState(rendererData->blendModeBlend.Get(), 0, 0xFFFFFFFF);
+ break;
+ case SDL_BLENDMODE_ADD:
+ rendererData->d3dContext->OMSetBlendState(rendererData->blendModeAdd.Get(), 0, 0xFFFFFFFF);
+ break;
+ case SDL_BLENDMODE_MOD:
+ rendererData->d3dContext->OMSetBlendState(rendererData->blendModeMod.Get(), 0, 0xFFFFFFFF);
+ break;
+ case SDL_BLENDMODE_NONE:
+ rendererData->d3dContext->OMSetBlendState(NULL, 0, 0xFFFFFFFF);
+ break;
+ }
+}
+
+static void
+D3D11_SetPixelShader(SDL_Renderer * renderer,
+ ID3D11PixelShader * shader,
+ ID3D11ShaderResourceView * shaderResource,
+ ID3D11SamplerState * sampler)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ rendererData->d3dContext->PSSetShader(shader, nullptr, 0);
+ rendererData->d3dContext->PSSetShaderResources(0, 1, &shaderResource);
+ rendererData->d3dContext->PSSetSamplers(0, 1, &sampler);
+}
+
+static void
+D3D11_RenderFinishDrawOp(SDL_Renderer * renderer,
+ D3D11_PRIMITIVE_TOPOLOGY primitiveTopology,
+ UINT vertexCount)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+
+ rendererData->d3dContext->UpdateSubresource(
+ rendererData->vertexShaderConstants.Get(),
+ 0,
+ NULL,
+ &rendererData->vertexShaderConstantsData,
+ 0,
+ 0
+ );
+
+ rendererData->d3dContext->IASetPrimitiveTopology(primitiveTopology);
+ rendererData->d3dContext->IASetInputLayout(rendererData->inputLayout.Get());
+ rendererData->d3dContext->VSSetShader(rendererData->vertexShader.Get(), nullptr, 0);
+ rendererData->d3dContext->VSSetConstantBuffers(0, 1, rendererData->vertexShaderConstants.GetAddressOf());
+ rendererData->d3dContext->RSSetState(rendererData->mainRasterizer.Get());
+ rendererData->d3dContext->Draw(vertexCount, 0);
+}
+
+static int
+D3D11_RenderDrawPoints(SDL_Renderer * renderer,
+ const SDL_FPoint * points, int count)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ float r, g, b, a;
+
+ r = (float)(renderer->r / 255.0f);
+ g = (float)(renderer->g / 255.0f);
+ b = (float)(renderer->b / 255.0f);
+ a = (float)(renderer->a / 255.0f);
+
+ vector<VertexPositionColor> vertices;
+ vertices.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ VertexPositionColor v = {XMFLOAT3(points[i].x, points[i].y, 0.0f), XMFLOAT2(0.0f, 0.0f), XMFLOAT4(r, g, b, a)};
+ vertices.push_back(v);
+ }
+
+ D3D11_RenderStartDrawOp(renderer);
+ D3D11_RenderSetBlendMode(renderer, renderer->blendMode);
+ if (D3D11_UpdateVertexBuffer(renderer, &vertices[0], vertices.size() * sizeof(VertexPositionColor)) != 0) {
+ return -1;
+ }
+
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->colorPixelShader.Get(),
+ nullptr,
+ nullptr);
+
+ D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, vertices.size());
+
+ return 0;
+}
+
+static int
+D3D11_RenderDrawLines(SDL_Renderer * renderer,
+ const SDL_FPoint * points, int count)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ float r, g, b, a;
+
+ r = (float)(renderer->r / 255.0f);
+ g = (float)(renderer->g / 255.0f);
+ b = (float)(renderer->b / 255.0f);
+ a = (float)(renderer->a / 255.0f);
+
+ vector<VertexPositionColor> vertices;
+ vertices.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ VertexPositionColor v = {XMFLOAT3(points[i].x, points[i].y, 0.0f), XMFLOAT2(0.0f, 0.0f), XMFLOAT4(r, g, b, a)};
+ vertices.push_back(v);
+ }
+
+ D3D11_RenderStartDrawOp(renderer);
+ D3D11_RenderSetBlendMode(renderer, renderer->blendMode);
+ if (D3D11_UpdateVertexBuffer(renderer, &vertices[0], vertices.size() * sizeof(VertexPositionColor)) != 0) {
+ return -1;
+ }
+
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->colorPixelShader.Get(),
+ nullptr,
+ nullptr);
+
+ D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, vertices.size());
+
+ return 0;
+}
+
+static int
+D3D11_RenderFillRects(SDL_Renderer * renderer,
+ const SDL_FRect * rects, int count)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ float r, g, b, a;
+
+ r = (float)(renderer->r / 255.0f);
+ g = (float)(renderer->g / 255.0f);
+ b = (float)(renderer->b / 255.0f);
+ a = (float)(renderer->a / 255.0f);
+
+#if 0
+ // Set up a test pattern:
+ SDL_FRect _rects[] = {
+ {-1.1f, 1.1f, 1.1f, -1.1f},
+ {-1.0f, 1.0f, 1.0f, -1.0f}, // red
+ {0.0f, 1.0f, 1.0f, -1.0f}, // green
+ {-1.0f, 0.0f, 1.0f, -1.0f}, // blue
+ {0.0f, 0.0f, 1.0f, -1.0f} // white
+ };
+ count = sizeof(_rects) / sizeof(SDL_FRect);
+#define rects _rects
+#endif
+
+ for (int i = 0; i < count; ++i) {
+ D3D11_RenderStartDrawOp(renderer);
+ D3D11_RenderSetBlendMode(renderer, renderer->blendMode);
+
+#if 0
+ // Set colors for the test pattern:
+ a = 1.0f;
+ switch (i) {
+ case 0: r = 1.0f; g = 1.0f; b = 0.0f; break;
+ case 1: r = 1.0f; g = 0.0f; b = 0.0f; break;
+ case 2: r = 0.0f; g = 1.0f; b = 0.0f; break;
+ case 3: r = 0.0f; g = 0.0f; b = 1.0f; break;
+ case 4: r = 1.0f; g = 1.0f; b = 1.0f; break;
+ }
+#endif
+
+ VertexPositionColor vertices[] = {
+ {XMFLOAT3(rects[i].x, rects[i].y, 0.0f), XMFLOAT2(0.0f, 0.0f), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(rects[i].x, rects[i].y + rects[i].h, 0.0f), XMFLOAT2(0.0f, 0.0f), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(rects[i].x + rects[i].w, rects[i].y, 0.0f), XMFLOAT2(0.0f, 0.0f), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(rects[i].x + rects[i].w, rects[i].y + rects[i].h, 0.0f), XMFLOAT2(0.0f, 0.0f), XMFLOAT4(r, g, b, a)},
+ };
+ if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
+ return -1;
+ }
+
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->colorPixelShader.Get(),
+ nullptr,
+ nullptr);
+
+ D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
+ }
+
+ return 0;
+}
+
+static int
+D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
+
+ D3D11_RenderStartDrawOp(renderer);
+ D3D11_RenderSetBlendMode(renderer, texture->blendMode);
+
+ float minu = (float) srcrect->x / texture->w;
+ float maxu = (float) (srcrect->x + srcrect->w) / texture->w;
+ float minv = (float) srcrect->y / texture->h;
+ float maxv = (float) (srcrect->y + srcrect->h) / texture->h;
+
+ float r = 1.0f;
+ float g = 1.0f;
+ float b = 1.0f;
+ float a = 1.0f;
+ if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
+ r = (float)(texture->r / 255.0f);
+ g = (float)(texture->g / 255.0f);
+ b = (float)(texture->b / 255.0f);
+ }
+ if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
+ a = (float)(texture->a / 255.0f);
+ }
+
+ VertexPositionColor vertices[] = {
+ {XMFLOAT3(dstrect->x, dstrect->y, 0.0f), XMFLOAT2(minu, minv), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(dstrect->x, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(minu, maxv), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(dstrect->x + dstrect->w, dstrect->y, 0.0f), XMFLOAT2(maxu, minv), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(dstrect->x + dstrect->w, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(maxu, maxv), XMFLOAT4(r, g, b, a)},
+ };
+ if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
+ return -1;
+ }
+
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->texturePixelShader.Get(),
+ textureData->mainTextureResourceView.Get(),
+ rendererData->mainSampler.Get());
+
+ D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
+
+ return 0;
+}
+
+static int
+D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect,
+ const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip)
+{
+ D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
+ D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
+
+ D3D11_RenderStartDrawOp(renderer);
+ D3D11_RenderSetBlendMode(renderer, texture->blendMode);
+
+ float minu = (float) srcrect->x / texture->w;
+ float maxu = (float) (srcrect->x + srcrect->w) / texture->w;
+ float minv = (float) srcrect->y / texture->h;
+ float maxv = (float) (srcrect->y + srcrect->h) / texture->h;
+
+ float r = 1.0f;
+ float g = 1.0f;
+ float b = 1.0f;
+ float a = 1.0f;
+ if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
+ r = (float)(texture->r / 255.0f);
+ g = (float)(texture->g / 255.0f);
+ b = (float)(texture->b / 255.0f);
+ }
+ if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
+ a = (float)(texture->a / 255.0f);
+ }
+
+ if (flip & SDL_FLIP_HORIZONTAL) {
+ float tmp = maxu;
+ maxu = minu;
+ minu = tmp;
+ }
+ if (flip & SDL_FLIP_VERTICAL) {
+ float tmp = maxv;
+ maxv = minv;
+ minv = tmp;
+ }
+
+ XMFLOAT4X4 oldModelMatrix = rendererData->vertexShaderConstantsData.model;
+ XMStoreFloat4x4(
+ &rendererData->vertexShaderConstantsData.model,
+ XMMatrixMultiply(
+ XMMatrixRotationZ((float)(XM_PI * (float) angle / 180.0f)),
+ XMMatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0)
+ ));
+
+ const float minx = -center->x;
+ const float maxx = dstrect->w - center->x;
+ const float miny = -center->y;
+ const float maxy = dstrect->h - center->y;
+
+ VertexPositionColor vertices[] = {
+ {XMFLOAT3(minx, miny, 0.0f), XMFLOAT2(minu, minv), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(minx, maxy, 0.0f), XMFLOAT2(minu, maxv), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(maxx, miny, 0.0f), XMFLOAT2(maxu, minv), XMFLOAT4(r, g, b, a)},
+ {XMFLOAT3(maxx, maxy, 0.0f), XMFLOAT2(maxu, maxv), XMFLOAT4(r, g, b, a)},
+ };
+ if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
+ return -1;
+ }
+
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->texturePixelShader.Get(),
+ textureData->mainTextureResourceView.Get(),
+ rendererData->mainSampler.Get());
+
+ D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
+
+ rendererData->vertexShaderConstantsData.model = oldModelMatrix;
+
+ return 0;
+}
+
+static int
+D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+ Uint32 format, void * pixels, int pitch)
+{
+ D3D11_RenderData * data = (D3D11_RenderData *) renderer->driverdata;
+ HRESULT result = S_OK;
+
+ // Retrieve a pointer to the back buffer:
+ ComPtr<ID3D11Texture2D> backBuffer;
+ result = data->swapChain->GetBuffer(
+ 0,
+ __uuidof(ID3D11Texture2D),
+ &backBuffer
+ );
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", Get Back Buffer", result);
+ return -1;
+ }
+
+ // Create a staging texture to copy the screen's data to:
+ ComPtr<ID3D11Texture2D> stagingTexture;
+ D3D11_TEXTURE2D_DESC stagingTextureDesc;
+ backBuffer->GetDesc(&stagingTextureDesc);
+ stagingTextureDesc.Width = rect->w;
+ stagingTextureDesc.Height = rect->h;
+ stagingTextureDesc.BindFlags = 0;
+ stagingTextureDesc.MiscFlags = 0;
+ stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
+ stagingTextureDesc.Usage = D3D11_USAGE_STAGING;
+ result = data->d3dDevice->CreateTexture2D(
+ &stagingTextureDesc,
+ NULL,
+ &stagingTexture);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", Create Staging Texture", result);
+ return -1;
+ }
+
+ // Copy the desired portion of the back buffer to the staging texture:
+ D3D11_BOX srcBox;
+ srcBox.left = rect->x;
+ srcBox.right = rect->x + rect->w;
+ srcBox.top = rect->y;
+ srcBox.bottom = rect->y + rect->h;
+ srcBox.front = 0;
+ srcBox.back = 1;
+ data->d3dContext->CopySubresourceRegion(
+ stagingTexture.Get(),
+ D3D11CalcSubresource(0, 0, 0),
+ 0, 0, 0,
+ backBuffer.Get(),
+ D3D11CalcSubresource(0, 0, 0),
+ &srcBox);
+
+ // Map the staging texture's data to CPU-accessible memory:
+ D3D11_MAPPED_SUBRESOURCE textureMemory = {0};
+ result = data->d3dContext->Map(
+ stagingTexture.Get(),
+ D3D11CalcSubresource(0, 0, 0),
+ D3D11_MAP_READ,
+ 0,
+ &textureMemory);
+ if (FAILED(result)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__ ", Map Staging Texture to CPU Memory", result);
+ return -1;
+ }
+
+ // Copy the data into the desired buffer, converting pixels to the
+ // desired format at the same time:
+ if (SDL_ConvertPixels(
+ rect->w, rect->h,
+ DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
+ textureMemory.pData,
+ textureMemory.RowPitch,
+ format,
+ pixels,
+ pitch) != 0)
+ {
+ // When SDL_ConvertPixels fails, it'll have already set the format.
+ // Get the error message, and attach some extra data to it.
+ std::string errorMessage = string(__FUNCTION__ ", Convert Pixels failed: ") + SDL_GetError();
+ SDL_SetError(errorMessage.c_str());
+ return -1;
+ }
+
+ // Unmap the texture:
+ data->d3dContext->Unmap(
+ stagingTexture.Get(),
+ D3D11CalcSubresource(0, 0, 0));
+
+ // All done. The staging texture will be cleaned up in it's container
+ // ComPtr<>'s destructor.
+ return 0;
+}
+
+static void
+D3D11_RenderPresent(SDL_Renderer * renderer)
+{
+ D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // The first argument instructs DXGI to block until VSync, putting the application
+ // to sleep until the next VSync. This ensures we don't waste any cycles rendering
+ // frames that will never be displayed to the screen.
+ HRESULT hr = data->swapChain->Present(1, 0);
+#else
+ // The application may optionally specify "dirty" or "scroll"
+ // rects to improve efficiency in certain scenarios.
+ // This option is not available on Windows Phone 8, to note.
+ DXGI_PRESENT_PARAMETERS parameters = {0};
+ parameters.DirtyRectsCount = 0;
+ parameters.pDirtyRects = nullptr;
+ parameters.pScrollRect = nullptr;
+ parameters.pScrollOffset = nullptr;
+
+ // The first argument instructs DXGI to block until VSync, putting the application
+ // to sleep until the next VSync. This ensures we don't waste any cycles rendering
+ // frames that will never be displayed to the screen.
+ HRESULT hr = data->swapChain->Present1(1, 0, ¶meters);
+#endif
+
+ // Discard the contents of the render target.
+ // This is a valid operation only when the existing contents will be entirely
+ // overwritten. If dirty or scroll rects are used, this call should be removed.
+ data->d3dContext->DiscardView(data->mainRenderTargetView.Get());
+
+ // If the device was removed either by a disconnect or a driver upgrade, we
+ // must recreate all device resources.
+ //
+ // TODO, WinRT: consider throwing an exception if D3D11_RenderPresent fails, especially if there is a way to salvedge debug info from users' machines
+ if (hr == DXGI_ERROR_DEVICE_REMOVED)
+ {
+ hr = D3D11_HandleDeviceLost(renderer);
+ if (FAILED(hr)) {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, hr);
+ }
+ }
+ else
+ {
+ WIN_SetErrorFromHRESULT(__FUNCTION__, hr);
+ }
+}
+
+#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/direct3d11/SDL_render_d3d11_cpp.h b/src/render/direct3d11/SDL_render_d3d11_cpp.h
new file mode 100644
index 0000000..14fc612
--- /dev/null
+++ b/src/render/direct3d11/SDL_render_d3d11_cpp.h
@@ -0,0 +1,84 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#include <D3D11_1.h>
+#include <DirectXMath.h>
+#include <wrl/client.h>
+#include <vector>
+
+struct SDL_VertexShaderConstants
+{
+ DirectX::XMFLOAT4X4 model;
+ DirectX::XMFLOAT4X4 view;
+ DirectX::XMFLOAT4X4 projection;
+};
+
+typedef struct
+{
+ Microsoft::WRL::ComPtr<ID3D11Device1> d3dDevice;
+ Microsoft::WRL::ComPtr<ID3D11DeviceContext1> d3dContext;
+ Microsoft::WRL::ComPtr<IDXGISwapChain1> swapChain;
+ Microsoft::WRL::ComPtr<ID3D11RenderTargetView> mainRenderTargetView;
+ Microsoft::WRL::ComPtr<ID3D11RenderTargetView> currentOffscreenRenderTargetView;
+ Microsoft::WRL::ComPtr<ID3D11InputLayout> inputLayout;
+ Microsoft::WRL::ComPtr<ID3D11Buffer> vertexBuffer;
+ Microsoft::WRL::ComPtr<ID3D11VertexShader> vertexShader;
+ Microsoft::WRL::ComPtr<ID3D11PixelShader> texturePixelShader;
+ Microsoft::WRL::ComPtr<ID3D11PixelShader> colorPixelShader;
+ Microsoft::WRL::ComPtr<ID3D11BlendState> blendModeBlend;
+ Microsoft::WRL::ComPtr<ID3D11BlendState> blendModeAdd;
+ Microsoft::WRL::ComPtr<ID3D11BlendState> blendModeMod;
+ Microsoft::WRL::ComPtr<ID3D11SamplerState> mainSampler;
+ Microsoft::WRL::ComPtr<ID3D11RasterizerState> mainRasterizer;
+ D3D_FEATURE_LEVEL featureLevel;
+
+ // Vertex buffer constants:
+ SDL_VertexShaderConstants vertexShaderConstantsData;
+ Microsoft::WRL::ComPtr<ID3D11Buffer> vertexShaderConstants;
+
+ // Cached renderer properties.
+ DirectX::XMFLOAT2 windowSizeInDIPs;
+ DirectX::XMFLOAT2 renderTargetSize;
+ Windows::Graphics::Display::DisplayOrientations orientation;
+
+ // Transform used for display orientation.
+ DirectX::XMFLOAT4X4 orientationTransform3D;
+} D3D11_RenderData;
+
+typedef struct
+{
+ Microsoft::WRL::ComPtr<ID3D11Texture2D> mainTexture;
+ Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> mainTextureResourceView;
+ Microsoft::WRL::ComPtr<ID3D11RenderTargetView> mainTextureRenderTargetView;
+ SDL_PixelFormat * pixelFormat;
+ Microsoft::WRL::ComPtr<ID3D11Texture2D> stagingTexture;
+ DirectX::XMINT2 lockedTexturePosition;
+} D3D11_TextureData;
+
+struct VertexPositionColor
+{
+ DirectX::XMFLOAT3 pos;
+ DirectX::XMFLOAT2 tex;
+ DirectX::XMFLOAT4 color;
+};
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h
index 1971ded..90d9b57 100644
--- a/src/thread/SDL_thread_c.h
+++ b/src/thread/SDL_thread_c.h
@@ -36,6 +36,8 @@
#include "windows/SDL_systhread_c.h"
#elif SDL_THREAD_PSP
#include "psp/SDL_systhread_c.h"
+#elif SDL_THREAD_STDCPP
+#include "stdcpp/SDL_systhread_c.h"
#else
#error Need thread implementation for this platform
#include "generic/SDL_systhread_c.h"
diff --git a/src/thread/stdcpp/SDL_syscond.cpp b/src/thread/stdcpp/SDL_syscond.cpp
new file mode 100644
index 0000000..4ca1d96
--- /dev/null
+++ b/src/thread/stdcpp/SDL_syscond.cpp
@@ -0,0 +1,183 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+extern "C" {
+#include "SDL_thread.h"
+}
+
+#include <chrono>
+#include <condition_variable>
+#include <exception>
+#include <ratio>
+
+#include "SDL_sysmutex_c.h"
+
+struct SDL_cond
+{
+ std::condition_variable_any cpp_cond;
+};
+
+/* Create a condition variable */
+extern "C"
+SDL_cond *
+SDL_CreateCond(void)
+{
+ /* Allocate and initialize the condition variable */
+ try {
+ SDL_cond * cond = new SDL_cond;
+ return cond;
+ } catch (std::exception & ex) {
+ SDL_SetError("unable to create C++ condition variable: %s", ex.what());
+ return NULL;
+ } catch (...) {
+ SDL_SetError("unable to create C++ condition variable due to an unknown exception");
+ return NULL;
+ }
+}
+
+/* Destroy a condition variable */
+extern "C"
+void
+SDL_DestroyCond(SDL_cond * cond)
+{
+ if (cond) {
+ try {
+ delete cond;
+ } catch (...) {
+ // catch any and all exceptions, just in case something happens
+ }
+ }
+}
+
+/* Restart one of the threads that are waiting on the condition variable */
+extern "C"
+int
+SDL_CondSignal(SDL_cond * cond)
+{
+ if (!cond) {
+ SDL_SetError("Passed a NULL condition variable");
+ return -1;
+ }
+
+ try {
+ cond->cpp_cond.notify_one();
+ return 0;
+ } catch (...) {
+ // catch any and all exceptions, just in case something happens
+ SDL_SetError("unable to signal C++ condition variable due to an unknown exception");
+ return -1;
+ }
+}
+
+/* Restart all threads that are waiting on the condition variable */
+extern "C"
+int
+SDL_CondBroadcast(SDL_cond * cond)
+{
+ if (!cond) {
+ SDL_SetError("Passed a NULL condition variable");
+ return -1;
+ }
+
+ try {
+ cond->cpp_cond.notify_all();
+ return 0;
+ } catch (...) {
+ // catch any and all exceptions, just in case something happens
+ SDL_SetError("unable to broadcast C++ condition variable due to an unknown exception");
+ return -1;
+ }
+}
+
+/* Wait on the condition variable for at most 'ms' milliseconds.
+ The mutex must be locked before entering this function!
+ The mutex is unlocked during the wait, and locked again after the wait.
+
+Typical use:
+
+Thread A:
+ SDL_LockMutex(lock);
+ while ( ! condition ) {
+ SDL_CondWait(cond, lock);
+ }
+ SDL_UnlockMutex(lock);
+
+Thread B:
+ SDL_LockMutex(lock);
+ ...
+ condition = true;
+ ...
+ SDL_CondSignal(cond);
+ SDL_UnlockMutex(lock);
+ */
+extern "C"
+int
+SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
+{
+ if (!cond) {
+ SDL_SetError("Passed a NULL condition variable");
+ return -1;
+ }
+
+ if (!mutex) {
+ SDL_SetError("Passed a NULL mutex variable");
+ return -1;
+ }
+
+ try {
+ std::unique_lock<std::recursive_mutex> cpp_lock(mutex->cpp_mutex, std::defer_lock_t());
+ if (ms == SDL_MUTEX_MAXWAIT) {
+ cond->cpp_cond.wait(
+ cpp_lock
+ );
+ cpp_lock.release();
+ return 0;
+ } else {
+ auto wait_result = cond->cpp_cond.wait_for(
+ cpp_lock,
+ std::chrono::duration<Uint32, std::milli>(ms)
+ );
+ cpp_lock.release();
+ if (wait_result == std::cv_status::timeout) {
+ return SDL_MUTEX_TIMEDOUT;
+ } else {
+ return 0;
+ }
+ }
+ } catch (std::exception & ex) {
+ SDL_SetError("unable to wait on C++ condition variable: %s", ex.what());
+ return -1;
+ } catch (...) {
+ SDL_SetError("unable to lock wait on C++ condition variable due to an unknown exception");
+ return -1;
+ }
+}
+
+/* Wait on the condition variable forever */
+extern "C"
+int
+SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
+{
+ return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp
new file mode 100644
index 0000000..e43b255
--- /dev/null
+++ b/src/thread/stdcpp/SDL_sysmutex.cpp
@@ -0,0 +1,113 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+extern "C" {
+#include "SDL_thread.h"
+#include "SDL_systhread_c.h"
+#include "SDL_log.h"
+}
+
+#include <exception>
+
+#include "SDL_sysmutex_c.h"
+#include <Windows.h>
+
+
+/* Create a mutex */
+extern "C"
+SDL_mutex *
+SDL_CreateMutex(void)
+{
+ /* Allocate and initialize the mutex */
+ try {
+ SDL_mutex * mutex = new SDL_mutex;
+ return mutex;
+ } catch (std::exception & ex) {
+ SDL_SetError("unable to create C++ mutex: %s", ex.what());
+ return NULL;
+ } catch (...) {
+ SDL_SetError("unable to create C++ mutex due to an unknown exception");
+ return NULL;
+ }
+}
+
+/* Free the mutex */
+extern "C"
+void
+SDL_DestroyMutex(SDL_mutex * mutex)
+{
+ if (mutex) {
+ try {
+ delete mutex;
+ } catch (...) {
+ // catch any and all exceptions, just in case something happens
+ }
+ }
+}
+
+/* Lock the semaphore */
+extern "C"
+int
+SDL_mutexP(SDL_mutex * mutex)
+{
+ SDL_threadID threadID = SDL_ThreadID();
+ DWORD realThreadID = GetCurrentThreadId();
+ if (mutex == NULL) {
+ SDL_SetError("Passed a NULL mutex");
+ return -1;
+ }
+
+ try {
+ mutex->cpp_mutex.lock();
+ return 0;
+ } catch (std::exception & ex) {
+ SDL_SetError("unable to lock C++ mutex: %s", ex.what());
+ return -1;
+ } catch (...) {
+ SDL_SetError("unable to lock C++ mutex due to an unknown exception");
+ return -1;
+ }
+}
+
+/* Unlock the mutex */
+extern "C"
+int
+SDL_mutexV(SDL_mutex * mutex)
+{
+ SDL_threadID threadID = SDL_ThreadID();
+ DWORD realThreadID = GetCurrentThreadId();
+ if (mutex == NULL) {
+ SDL_SetError("Passed a NULL mutex");
+ return -1;
+ }
+
+ try {
+ mutex->cpp_mutex.unlock();
+ return 0;
+ } catch (...) {
+ // catch any and all exceptions, just in case something happens.
+ SDL_SetError("unable to unlock C++ mutex due to an unknown exception");
+ return -1;
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/stdcpp/SDL_sysmutex_c.h b/src/thread/stdcpp/SDL_sysmutex_c.h
new file mode 100644
index 0000000..500e57d
--- /dev/null
+++ b/src/thread/stdcpp/SDL_sysmutex_c.h
@@ -0,0 +1,30 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#include <mutex>
+
+struct SDL_mutex
+{
+ std::recursive_mutex cpp_mutex;
+};
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp
new file mode 100644
index 0000000..fd4cdaf
--- /dev/null
+++ b/src/thread/stdcpp/SDL_systhread.cpp
@@ -0,0 +1,124 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+/* Thread management routines for SDL */
+
+extern "C" {
+#include "SDL_thread.h"
+#include "../SDL_systhread.h"
+#include "../SDL_thread_c.h"
+#include "SDL_log.h"
+}
+
+#include <mutex>
+#include <thread>
+
+// HACK: Mimic C++11's thread_local keyword on Visual C++ 2012 (aka. VC++ 11)
+// TODO: make sure this hack doesn't get used if and when Visual C++ supports
+// the official, 'thread_local' keyword.
+#ifdef _MSC_VER
+#define thread_local __declspec(thread)
+// Documentation for __declspec(thread) can be found online at:
+// http://msdn.microsoft.com/en-us/library/2s9wt68x.aspx
+#endif
+
+static void
+RunThread(void *args)
+{
+ SDL_RunThread(args);
+}
+
+extern "C"
+int
+SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
+{
+ try {
+ std::thread cpp_thread(RunThread, args);
+ thread->handle = (void *) new std::thread(std::move(cpp_thread));
+ return 0;
+ } catch (std::exception & ex) {
+ SDL_SetError("unable to create a C++ thread: %s", ex.what());
+ return -1;
+ } catch (...) {
+ SDL_SetError("unable to create a C++ thread due to an unknown exception");
+ return -1;
+ }
+}
+
+extern "C"
+void
+SDL_SYS_SetupThread(const char *name)
+{
+ // Make sure a thread ID gets assigned ASAP, for debugging purposes:
+ SDL_ThreadID();
+ return;
+}
+
+extern "C"
+SDL_threadID
+SDL_ThreadID(void)
+{
+ static thread_local SDL_threadID current_thread_id = 0;
+ static SDL_threadID next_thread_id = 1;
+ static std::mutex next_thread_id_mutex;
+
+ if (current_thread_id == 0) {
+ std::lock_guard<std::mutex> lock(next_thread_id_mutex);
+ current_thread_id = next_thread_id;
+ ++next_thread_id;
+ }
+
+ return current_thread_id;
+}
+
+extern "C"
+int
+SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
+{
+ // Thread priorities do not look to be settable via C++11's thread
+ // interface, at least as of this writing (Nov 2012). std::thread does
+ // provide access to the OS' native handle, however, and some form of
+ // priority-setting could, in theory, be done through this interface.
+ return (0);
+}
+
+extern "C"
+void
+SDL_SYS_WaitThread(SDL_Thread * thread)
+{
+ if ( ! thread) {
+ return;
+ }
+
+ try {
+ std::thread * cpp_thread = (std::thread *) thread->handle;
+ if (cpp_thread->joinable()) {
+ cpp_thread->join();
+ }
+ } catch (...) {
+ // Catch any exceptions, just in case.
+ // Report nothing, as SDL_WaitThread does not seem to offer a means
+ // to report errors to its callers.
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/thread/stdcpp/SDL_systhread_c.h b/src/thread/stdcpp/SDL_systhread_c.h
new file mode 100644
index 0000000..4a060c9
--- /dev/null
+++ b/src/thread/stdcpp/SDL_systhread_c.h
@@ -0,0 +1,26 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+/* For a thread handle, use a void pointer to a std::thread */
+typedef void * SYS_ThreadHandle;
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 4973648..e149b8a 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -343,6 +343,9 @@ extern VideoBootStrap DirectFB_bootstrap;
#if SDL_VIDEO_DRIVER_WINDOWS
extern VideoBootStrap WINDOWS_bootstrap;
#endif
+#if SDL_VIDEO_DRIVER_WINRT
+extern VideoBootStrap WINRT_bootstrap;
+#endif
#if SDL_VIDEO_DRIVER_BWINDOW
extern VideoBootStrap BWINDOW_bootstrap;
#endif
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index bab6c6c..1404ba0 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -64,6 +64,9 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_WINDOWS
&WINDOWS_bootstrap,
#endif
+#if SDL_VIDEO_DRIVER_WINRT
+ &WINRT_bootstrap,
+#endif
#if SDL_VIDEO_DRIVER_BWINDOW
&BWINDOW_bootstrap,
#endif
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index b3f7ac9..0285b6b 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -202,7 +202,7 @@ UIKit_CreateWindow(_THIS, SDL_Window *window)
if (external) {
[uiwindow setScreen:data->uiscreen];
}
-
+
if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
[uiwindow release];
return -1;
@@ -301,10 +301,12 @@ SDL_bool
UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
{
UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow;
+ UIViewController *uiviewcontroller = ((SDL_WindowData *) window->driverdata)->viewcontroller;
if (info->version.major <= SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_UIKIT;
info->info.uikit.window = uiwindow;
+ info->info.uikit.viewcontroller = uiviewcontroller;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d\n",
diff --git a/src/video/windowsrt/SDL_WinRTApp.cpp b/src/video/windowsrt/SDL_WinRTApp.cpp
new file mode 100644
index 0000000..a807bda
--- /dev/null
+++ b/src/video/windowsrt/SDL_WinRTApp.cpp
@@ -0,0 +1,978 @@
+
+#include <string>
+#include <unordered_map>
+#include <sstream>
+
+#include "ppltasks.h"
+
+extern "C" {
+#include "SDL_assert.h"
+#include "SDL_events.h"
+#include "SDL_hints.h"
+#include "SDL_log.h"
+#include "SDL_stdinc.h"
+#include "SDL_render.h"
+#include "../SDL_sysvideo.h"
+#include "../../SDL_hints_c.h"
+#include "../../events/scancodes_windows.h"
+#include "../../events/SDL_mouse_c.h"
+#include "../../events/SDL_keyboard_c.h"
+#include "../../events/SDL_windowevents_c.h"
+#include "../../render/SDL_sysrender.h"
+}
+
+#include "SDL_winrtvideo.h"
+#include "SDL_WinRTApp.h"
+
+using namespace concurrency;
+using namespace std;
+using namespace Windows::ApplicationModel;
+using namespace Windows::ApplicationModel::Core;
+using namespace Windows::ApplicationModel::Activation;
+using namespace Windows::Devices::Input;
+using namespace Windows::Graphics::Display;
+using namespace Windows::Foundation;
+using namespace Windows::System;
+using namespace Windows::UI::Core;
+using namespace Windows::UI::Input;
+
+// Compile-time debugging options:
+// To enable, uncomment; to disable, comment them out.
+//#define LOG_POINTER_EVENTS 1
+//#define LOG_WINDOW_EVENTS 1
+//#define LOG_ORIENTATION_EVENTS 1
+
+
+// HACK, DLudwig: The C-style main() will get loaded via the app's
+// WinRT-styled main(), which is part of SDLmain_for_WinRT.cpp.
+// This seems wrong on some level, but does seem to work.
+typedef int (*SDL_WinRT_MainFunction)(int, char **);
+static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
+
+// HACK, DLudwig: record a reference to the global, Windows RT 'app'/view.
+// SDL/WinRT will use this throughout its code.
+//
+// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
+// non-global, such as something created inside
+// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
+// SDL_CreateWindow().
+SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
+
+ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
+{
+public:
+ virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
+};
+
+IFrameworkView^ SDLApplicationSource::CreateView()
+{
+ // TODO, WinRT: see if this function (CreateView) can ever get called
+ // more than once. For now, just prevent it from ever assigning
+ // SDL_WinRTGlobalApp more than once.
+ SDL_assert(!SDL_WinRTGlobalApp);
+ SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
+ if (!SDL_WinRTGlobalApp)
+ {
+ SDL_WinRTGlobalApp = app;
+ }
+ return app;
+}
+
+__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
+{
+ SDL_WinRT_main = mainFunction;
+ auto direct3DApplicationSource = ref new SDLApplicationSource();
+ CoreApplication::Run(direct3DApplicationSource);
+ return 0;
+}
+
+static void WINRT_SetDisplayOrientationsPreference(const char *name, const char *oldValue, const char *newValue)
+{
+ SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
+
+ // Start with no orientation flags, then add each in as they're parsed
+ // from newValue.
+ unsigned int orientationFlags = 0;
+ std::istringstream tokenizer(newValue);
+ while (!tokenizer.eof()) {
+ std::string orientationName;
+ std::getline(tokenizer, orientationName, ' ');
+ if (orientationName == "LandscapeLeft") {
+ orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
+ } else if (orientationName == "LandscapeRight") {
+ orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
+ } else if (orientationName == "Portrait") {
+ orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
+ } else if (orientationName == "PortraitUpsideDown") {
+ orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
+ }
+ }
+
+ // If no valid orientation flags were specified, use a reasonable set of defaults:
+ if (!orientationFlags) {
+ // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
+ orientationFlags = (unsigned int) ( \
+ DisplayOrientations::Landscape |
+ DisplayOrientations::LandscapeFlipped |
+ DisplayOrientations::Portrait |
+ DisplayOrientations::PortraitFlipped);
+ }
+
+ // Set the orientation/rotation preferences. Please note that this does
+ // not constitute a 100%-certain lock of a given set of possible
+ // orientations. According to Microsoft's documentation on Windows RT [1]
+ // when a device is not capable of being rotated, Windows may ignore
+ // the orientation preferences, and stick to what the device is capable of
+ // displaying.
+ //
+ // [1] Documentation on the 'InitialRotationPreference' setting for a
+ // Windows app's manifest file describes how some orientation/rotation
+ // preferences may be ignored. See
+ // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
+ // for details. Microsoft's "Display orientation sample" also gives an
+ // outline of how Windows treats device rotation
+ // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
+ DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
+}
+
+SDL_WinRTApp::SDL_WinRTApp() :
+ m_windowClosed(false),
+ m_windowVisible(true),
+ m_sdlWindowData(NULL),
+ m_sdlVideoDevice(NULL),
+ m_useRelativeMouseMode(false)
+{
+}
+
+void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
+{
+ applicationView->Activated +=
+ ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
+
+ CoreApplication::Suspending +=
+ ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
+
+ CoreApplication::Resuming +=
+ ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
+
+ DisplayProperties::OrientationChanged +=
+ ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
+
+ // Register the hint, SDL_HINT_ORIENTATIONS, with SDL. This needs to be
+ // done before the hint's callback is registered (as of Feb 22, 2013),
+ // otherwise the hint callback won't get registered.
+ //
+ // WinRT, TODO: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
+ SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown");
+ SDL_RegisterHintChangedCb(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference);
+}
+
+void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
+{
+#if LOG_ORIENTATION_EVENTS==1
+ CoreWindow^ window = CoreWindow::GetForCurrentThread();
+ if (window) {
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ window->Bounds.Width,
+ window->Bounds.Height);
+ } else {
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences);
+ }
+#endif
+}
+
+void SDL_WinRTApp::SetWindow(CoreWindow^ window)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ window->Bounds.Width,
+ window->Bounds.Height);
+#endif
+
+ window->SizeChanged +=
+ ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
+
+ window->VisibilityChanged +=
+ ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
+
+ window->Closed +=
+ ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
+#endif
+
+ window->PointerPressed +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
+
+ window->PointerReleased +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
+
+ window->PointerWheelChanged +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
+
+ window->PointerMoved +=
+ ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ // Retrieves relative-only mouse movements:
+ Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
+ ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
+#endif
+
+ window->KeyDown +=
+ ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
+
+ window->KeyUp +=
+ ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
+}
+
+void SDL_WinRTApp::Load(Platform::String^ entryPoint)
+{
+}
+
+void SDL_WinRTApp::Run()
+{
+ if (SDL_WinRT_main)
+ {
+ // TODO, WinRT: pass the C-style main() a reasonably realistic
+ // representation of command line arguments.
+ int argc = 0;
+ char **argv = NULL;
+ SDL_WinRT_main(argc, argv);
+ }
+}
+
+void SDL_WinRTApp::PumpEvents()
+{
+ if (!m_windowClosed)
+ {
+ if (m_windowVisible)
+ {
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
+ }
+ else
+ {
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
+ }
+ }
+}
+
+void SDL_WinRTApp::Uninitialize()
+{
+}
+
+void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, m_sdlWindowData?=%s\n",
+ __FUNCTION__,
+ args->Size.Width, args->Size.Height,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ (m_sdlWindowData ? "yes" : "no"));
+#endif
+
+ if (m_sdlWindowData) {
+ // Make the new window size be the one true fullscreen mode.
+ // This change was done, in part, to allow the Direct3D 11.1 renderer
+ // to receive window-resize events as a device rotates.
+ // Before, rotating a device from landscape, to portrait, and then
+ // back to landscape would cause the Direct3D 11.1 swap buffer to
+ // not get resized appropriately. SDL would, on the rotation from
+ // landscape to portrait, re-resize the SDL window to it's initial
+ // size (landscape). On the subsequent rotation, SDL would drop the
+ // window-resize event as it appeared the SDL window didn't change
+ // size, and the Direct3D 11.1 renderer wouldn't resize its swap
+ // chain.
+ //
+ // TODO, WinRT: consider dropping old display modes after the fullscreen window changes size (from rotations, etc.)
+ m_sdlWindowData->sdlWindow->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
+ SDL_AddDisplayMode(&m_sdlVideoDevice->displays[0], &m_sdlWindowData->sdlWindow->fullscreen_mode);
+
+ // HACK, Feb 19, 2013: SDL_WINDOWEVENT_RESIZED events, when sent,
+ // will attempt to fix the values of the main window's renderer's
+ // viewport. While this can be good, it does appear to be buggy,
+ // and can cause a fullscreen viewport to become corrupted. This
+ // behavior was noticed on a Surface RT while rotating the device
+ // from landscape to portrait. Oddly enough, this did not occur
+ // in the Windows Simulator.
+ //
+ // Backing up, then restoring, the main renderer's 'resized' flag
+ // seems to fix fullscreen viewport problems when rotating a
+ // Windows device.
+ //
+ // Commencing hack in 3... 2... 1...
+ SDL_Renderer * rendererForMainWindow = SDL_GetRenderer(m_sdlWindowData->sdlWindow);
+ // For now, limit the hack to when the Direct3D 11.1 is getting used:
+ const bool usingD3D11Renderer = \
+ (rendererForMainWindow != NULL) &&
+ (SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
+ SDL_bool wasD3D11RendererResized = SDL_FALSE;
+ if (usingD3D11Renderer) {
+ wasD3D11RendererResized = rendererForMainWindow->resized;
+ }
+
+ // Send the window-resize event to the rest of SDL, and to apps:
+ const int windowWidth = (int) ceil(args->Size.Width);
+ const int windowHeight = (int) ceil(args->Size.Height);
+ SDL_SendWindowEvent(
+ m_sdlWindowData->sdlWindow,
+ SDL_WINDOWEVENT_RESIZED,
+ windowWidth,
+ windowHeight);
+
+ // Viewport hack, part two:
+ if (usingD3D11Renderer) {
+ rendererForMainWindow->resized = wasD3D11RendererResized;
+ }
+ }
+}
+
+void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, visible?=%s, m_sdlWindowData?=%s\n",
+ __FUNCTION__,
+ (args->Visible ? "yes" : "no"),
+ (m_sdlWindowData ? "yes" : "no"));
+#endif
+
+ m_windowVisible = args->Visible;
+ if (m_sdlWindowData) {
+ SDL_bool wasSDLWindowSurfaceValid = m_sdlWindowData->sdlWindow->surface_valid;
+
+ if (args->Visible) {
+ SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
+ } else {
+ SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
+ }
+
+ // HACK: Prevent SDL's window-hide handling code, which currently
+ // triggers a fake window resize (possibly erronously), from
+ // marking the SDL window's surface as invalid.
+ //
+ // A better solution to this probably involves figuring out if the
+ // fake window resize can be prevented.
+ m_sdlWindowData->sdlWindow->surface_valid = wasSDLWindowSurfaceValid;
+ }
+}
+
+void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s\n", __FUNCTION__);
+#endif
+ m_windowClosed = true;
+}
+
+static Uint8
+WINRT_GetSDLButtonForPointerPoint(PointerPoint ^ pt)
+{
+ switch (pt->Properties->PointerUpdateKind)
+ {
+ case PointerUpdateKind::LeftButtonPressed:
+ case PointerUpdateKind::LeftButtonReleased:
+ return SDL_BUTTON_LEFT;
+
+ case PointerUpdateKind::RightButtonPressed:
+ case PointerUpdateKind::RightButtonReleased:
+ return SDL_BUTTON_RIGHT;
+
+ case PointerUpdateKind::MiddleButtonPressed:
+ case PointerUpdateKind::MiddleButtonReleased:
+ return SDL_BUTTON_MIDDLE;
+
+ case PointerUpdateKind::XButton1Pressed:
+ case PointerUpdateKind::XButton1Released:
+ return SDL_BUTTON_X1;
+
+ case PointerUpdateKind::XButton2Pressed:
+ case PointerUpdateKind::XButton2Released:
+ return SDL_BUTTON_X2;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static const char *
+WINRT_ConvertPointerUpdateKindToString(PointerUpdateKind kind)
+{
+ switch (kind)
+ {
+ case PointerUpdateKind::Other:
+ return "Other";
+ case PointerUpdateKind::LeftButtonPressed:
+ return "LeftButtonPressed";
+ case PointerUpdateKind::LeftButtonReleased:
+ return "LeftButtonReleased";
+ case PointerUpdateKind::RightButtonPressed:
+ return "RightButtonPressed";
+ case PointerUpdateKind::RightButtonReleased:
+ return "RightButtonReleased";
+ case PointerUpdateKind::MiddleButtonPressed:
+ return "MiddleButtonPressed";
+ case PointerUpdateKind::MiddleButtonReleased:
+ return "MiddleButtonReleased";
+ case PointerUpdateKind::XButton1Pressed:
+ return "XButton1Pressed";
+ case PointerUpdateKind::XButton1Released:
+ return "XButton1Released";
+ case PointerUpdateKind::XButton2Pressed:
+ return "XButton2Pressed";
+ case PointerUpdateKind::XButton2Released:
+ return "XButton2Released";
+ }
+
+ return "";
+}
+
+static void
+WINRT_LogPointerEvent(const string & header, PointerEventArgs ^ args, Point transformedPoint)
+{
+ PointerPoint ^ pt = args->CurrentPoint;
+ SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, PointerUpdateKind=%s\n",
+ header.c_str(),
+ pt->Position.X, pt->Position.Y,
+ transformedPoint.X, transformedPoint.Y,
+ pt->Properties->MouseWheelDelta,
+ pt->FrameId,
+ pt->PointerId,
+ WINRT_ConvertPointerUpdateKindToString(args->CurrentPoint->Properties->PointerUpdateKind));
+}
+
+void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("mouse down", args, TransformCursor(args->CurrentPoint->Position));
+#endif
+
+ if (m_sdlWindowData) {
+ Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
+ if (button) {
+ SDL_SendMouseButton(m_sdlWindowData->sdlWindow, 0, SDL_PRESSED, button);
+ }
+ }
+}
+
+void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("mouse up", args, TransformCursor(args->CurrentPoint->Position));
+#endif
+
+ if (m_sdlWindowData) {
+ Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
+ if (button) {
+ SDL_SendMouseButton(m_sdlWindowData->sdlWindow, 0, SDL_RELEASED, button);
+ }
+ }
+}
+
+void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("wheel changed", args, TransformCursor(args->CurrentPoint->Position));
+#endif
+
+ if (m_sdlWindowData) {
+ // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
+ short motion = args->CurrentPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
+ SDL_SendMouseWheel(m_sdlWindowData->sdlWindow, 0, 0, motion);
+ }
+}
+
+static inline int _lround(float arg) {
+ if (arg >= 0.0f) {
+ return (int)floor(arg + 0.5f);
+ } else {
+ return (int)ceil(arg - 0.5f);
+ }
+}
+
+void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
+{
+ if (m_sdlWindowData && m_useRelativeMouseMode) {
+ // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
+ // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
+ // MouseDelta field often reports very large values. More information
+ // on this can be found at the following pages on MSDN:
+ // - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
+ // - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
+ //
+ // The values do not appear to be as large when running on some systems,
+ // most notably a Surface RT. Furthermore, the values returned by
+ // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
+ // method, do not ever appear to be large, even when MouseEventArgs'
+ // MouseDelta is reporting to the contrary.
+ //
+ // On systems with the large-values behavior, it appears that the values
+ // get reported as if the screen's size is 65536 units in both the X and Y
+ // dimensions. This can be viewed by using Windows' now-private, "Raw Input"
+ // APIs. (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
+ //
+ // MSDN's documentation on MouseEventArgs' MouseDelta field (at
+ // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
+ // does not seem to indicate (to me) that its values should be so large. It
+ // says that its values should be a "change in screen location". I could
+ // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see:
+ // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
+ // indicates that these values are in DIPs, which is the same unit used
+ // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
+ // property. See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
+ // for details.)
+ //
+ // To note, PointerMoved events are sent a 'RawPosition' value (via the
+ // CurrentPoint property in MouseEventArgs), however these do not seem
+ // to exhibit the same large-value behavior.
+ //
+ // The values passed via PointerMoved events can't always be used for relative
+ // mouse motion, unfortunately. Its values are bound to the cursor's position,
+ // which stops when it hits one of the screen's edges. This can be a problem in
+ // first person shooters, whereby it is normal for mouse motion to travel far
+ // along any one axis for a period of time. MouseMoved events do not have the
+ // screen-bounding limitation, and can be used regardless of where the system's
+ // cursor is.
+ //
+ // One possible workaround would be to programmatically set the cursor's
+ // position to the screen's center (when SDL's relative mouse mode is enabled),
+ // however Windows RT does not yet seem to have the ability to set the cursor's
+ // position via a public API. Win32 did this via an API call, SetCursorPos,
+ // however WinRT makes this function be private. Apps that use it won't get
+ // approved for distribution in the Windows Store. I've yet to be able to find
+ // a suitable, store-friendly counterpart for WinRT.
+ //
+ // There may be some room for a workaround whereby OnPointerMoved's values
+ // are compared to the values from OnMouseMoved in order to detect
+ // when this bug is active. A suitable transformation could then be made to
+ // OnMouseMoved's values. For now, however, the system-reported values are sent
+ // to SDL with minimal transformation: from native screen coordinates (in DIPs)
+ // to SDL window coordinates.
+ //
+ const Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
+ const Point mouseDeltaInSDLWindowCoords = TransformCursor(mouseDeltaInDIPs);
+ SDL_SendMouseMotion(
+ m_sdlWindowData->sdlWindow,
+ 0,
+ 1,
+ _lround(mouseDeltaInSDLWindowCoords.X),
+ _lround(mouseDeltaInSDLWindowCoords.Y));
+ }
+}
+
+// Applies necessary geometric transformations to raw cursor positions:
+Point SDL_WinRTApp::TransformCursor(Point rawPosition)
+{
+ if ( ! m_sdlWindowData || ! m_sdlWindowData->sdlWindow ) {
+ return rawPosition;
+ }
+ CoreWindow ^ nativeWindow = CoreWindow::GetForCurrentThread();
+ Point outputPosition;
+ outputPosition.X = rawPosition.X * (((float32)m_sdlWindowData->sdlWindow->w) / nativeWindow->Bounds.Width);
+ outputPosition.Y = rawPosition.Y * (((float32)m_sdlWindowData->sdlWindow->h) / nativeWindow->Bounds.Height);
+ return outputPosition;
+}
+
+void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer moved", args, TransformCursor(args->CurrentPoint->Position));
+#endif
+
+ if (m_sdlWindowData && ! m_useRelativeMouseMode)
+ {
+ Point transformedPoint = TransformCursor(args->CurrentPoint->Position);
+ SDL_SendMouseMotion(m_sdlWindowData->sdlWindow, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
+ }
+}
+
+static SDL_Scancode WinRT_Official_Keycodes[] = {
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2
+ SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6
+ SDL_SCANCODE_UNKNOWN, // -- 7
+ SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8
+ SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9
+ SDL_SCANCODE_UNKNOWN, // -- 10
+ SDL_SCANCODE_UNKNOWN, // -- 11
+ SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12
+ SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13
+ SDL_SCANCODE_UNKNOWN, // -- 14
+ SDL_SCANCODE_UNKNOWN, // -- 15
+ SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16
+ SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17
+ SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18
+ SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19
+ SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21
+ SDL_SCANCODE_UNKNOWN, // -- 22
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25
+ SDL_SCANCODE_UNKNOWN, // -- 26
+ SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?)
+ SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32
+ SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33
+ SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34
+ SDL_SCANCODE_END, // VirtualKey.End -- 35
+ SDL_SCANCODE_HOME, // VirtualKey.Home -- 36
+ SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37
+ SDL_SCANCODE_UP, // VirtualKey.Up -- 38
+ SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39
+ SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40
+ SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?)
+ SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44
+ SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45
+ SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46
+ SDL_SCANCODE_HELP, // VirtualKey.Help -- 47
+ SDL_SCANCODE_0, // VirtualKey.Number0 -- 48
+ SDL_SCANCODE_1, // VirtualKey.Number1 -- 49
+ SDL_SCANCODE_2, // VirtualKey.Number2 -- 50
+ SDL_SCANCODE_3, // VirtualKey.Number3 -- 51
+ SDL_SCANCODE_4, // VirtualKey.Number4 -- 52
+ SDL_SCANCODE_5, // VirtualKey.Number5 -- 53
+ SDL_SCANCODE_6, // VirtualKey.Number6 -- 54
+ SDL_SCANCODE_7, // VirtualKey.Number7 -- 55
+ SDL_SCANCODE_8, // VirtualKey.Number8 -- 56
+ SDL_SCANCODE_9, // VirtualKey.Number9 -- 57
+ SDL_SCANCODE_UNKNOWN, // -- 58
+ SDL_SCANCODE_UNKNOWN, // -- 59
+ SDL_SCANCODE_UNKNOWN, // -- 60
+ SDL_SCANCODE_UNKNOWN, // -- 61
+ SDL_SCANCODE_UNKNOWN, // -- 62
+ SDL_SCANCODE_UNKNOWN, // -- 63
+ SDL_SCANCODE_UNKNOWN, // -- 64
+ SDL_SCANCODE_A, // VirtualKey.A -- 65
+ SDL_SCANCODE_B, // VirtualKey.B -- 66
+ SDL_SCANCODE_C, // VirtualKey.C -- 67
+ SDL_SCANCODE_D, // VirtualKey.D -- 68
+ SDL_SCANCODE_E, // VirtualKey.E -- 69
+ SDL_SCANCODE_F, // VirtualKey.F -- 70
+ SDL_SCANCODE_G, // VirtualKey.G -- 71
+ SDL_SCANCODE_H, // VirtualKey.H -- 72
+ SDL_SCANCODE_I, // VirtualKey.I -- 73
+ SDL_SCANCODE_J, // VirtualKey.J -- 74
+ SDL_SCANCODE_K, // VirtualKey.K -- 75
+ SDL_SCANCODE_L, // VirtualKey.L -- 76
+ SDL_SCANCODE_M, // VirtualKey.M -- 77
+ SDL_SCANCODE_N, // VirtualKey.N -- 78
+ SDL_SCANCODE_O, // VirtualKey.O -- 79
+ SDL_SCANCODE_P, // VirtualKey.P -- 80
+ SDL_SCANCODE_Q, // VirtualKey.Q -- 81
+ SDL_SCANCODE_R, // VirtualKey.R -- 82
+ SDL_SCANCODE_S, // VirtualKey.S -- 83
+ SDL_SCANCODE_T, // VirtualKey.T -- 84
+ SDL_SCANCODE_U, // VirtualKey.U -- 85
+ SDL_SCANCODE_V, // VirtualKey.V -- 86
+ SDL_SCANCODE_W, // VirtualKey.W -- 87
+ SDL_SCANCODE_X, // VirtualKey.X -- 88
+ SDL_SCANCODE_Y, // VirtualKey.Y -- 89
+ SDL_SCANCODE_Z, // VirtualKey.Z -- 90
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?)
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?)
+ SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93
+ SDL_SCANCODE_UNKNOWN, // -- 94
+ SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95
+ SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96
+ SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97
+ SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98
+ SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99
+ SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100
+ SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101
+ SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102
+ SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103
+ SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104
+ SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105
+ SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106
+ SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108
+ SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109
+ SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?)
+ SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111
+ SDL_SCANCODE_F1, // VirtualKey.F1 -- 112
+ SDL_SCANCODE_F2, // VirtualKey.F2 -- 113
+ SDL_SCANCODE_F3, // VirtualKey.F3 -- 114
+ SDL_SCANCODE_F4, // VirtualKey.F4 -- 115
+ SDL_SCANCODE_F5, // VirtualKey.F5 -- 116
+ SDL_SCANCODE_F6, // VirtualKey.F6 -- 117
+ SDL_SCANCODE_F7, // VirtualKey.F7 -- 118
+ SDL_SCANCODE_F8, // VirtualKey.F8 -- 119
+ SDL_SCANCODE_F9, // VirtualKey.F9 -- 120
+ SDL_SCANCODE_F10, // VirtualKey.F10 -- 121
+ SDL_SCANCODE_F11, // VirtualKey.F11 -- 122
+ SDL_SCANCODE_F12, // VirtualKey.F12 -- 123
+ SDL_SCANCODE_F13, // VirtualKey.F13 -- 124
+ SDL_SCANCODE_F14, // VirtualKey.F14 -- 125
+ SDL_SCANCODE_F15, // VirtualKey.F15 -- 126
+ SDL_SCANCODE_F16, // VirtualKey.F16 -- 127
+ SDL_SCANCODE_F17, // VirtualKey.F17 -- 128
+ SDL_SCANCODE_F18, // VirtualKey.F18 -- 129
+ SDL_SCANCODE_F19, // VirtualKey.F19 -- 130
+ SDL_SCANCODE_F20, // VirtualKey.F20 -- 131
+ SDL_SCANCODE_F21, // VirtualKey.F21 -- 132
+ SDL_SCANCODE_F22, // VirtualKey.F22 -- 133
+ SDL_SCANCODE_F23, // VirtualKey.F23 -- 134
+ SDL_SCANCODE_F24, // VirtualKey.F24 -- 135
+ SDL_SCANCODE_UNKNOWN, // -- 136
+ SDL_SCANCODE_UNKNOWN, // -- 137
+ SDL_SCANCODE_UNKNOWN, // -- 138
+ SDL_SCANCODE_UNKNOWN, // -- 139
+ SDL_SCANCODE_UNKNOWN, // -- 140
+ SDL_SCANCODE_UNKNOWN, // -- 141
+ SDL_SCANCODE_UNKNOWN, // -- 142
+ SDL_SCANCODE_UNKNOWN, // -- 143
+ SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144
+ SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145
+ SDL_SCANCODE_UNKNOWN, // -- 146
+ SDL_SCANCODE_UNKNOWN, // -- 147
+ SDL_SCANCODE_UNKNOWN, // -- 148
+ SDL_SCANCODE_UNKNOWN, // -- 149
+ SDL_SCANCODE_UNKNOWN, // -- 150
+ SDL_SCANCODE_UNKNOWN, // -- 151
+ SDL_SCANCODE_UNKNOWN, // -- 152
+ SDL_SCANCODE_UNKNOWN, // -- 153
+ SDL_SCANCODE_UNKNOWN, // -- 154
+ SDL_SCANCODE_UNKNOWN, // -- 155
+ SDL_SCANCODE_UNKNOWN, // -- 156
+ SDL_SCANCODE_UNKNOWN, // -- 157
+ SDL_SCANCODE_UNKNOWN, // -- 158
+ SDL_SCANCODE_UNKNOWN, // -- 159
+ SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160
+ SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161
+ SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162
+ SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163
+ SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164
+ SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165
+};
+
+static std::unordered_map<int, SDL_Scancode> WinRT_Unofficial_Keycodes;
+
+static SDL_Scancode
+TranslateKeycode(int keycode)
+{
+ if (WinRT_Unofficial_Keycodes.empty()) {
+ /* Set up a table of undocumented (by Microsoft), WinRT-specific,
+ key codes: */
+ // TODO, WinRT: move content declarations of WinRT_Unofficial_Keycodes into a C++11 initializer list, when possible
+ WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_GRAVE;
+ WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_BACKSLASH;
+ }
+
+ /* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
+ http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
+ If that fails, fall back to a Win32 virtual key.
+ */
+ // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
+ //SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode);
+ SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
+ if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) {
+ scancode = WinRT_Official_Keycodes[keycode];
+ }
+ if (scancode == SDL_SCANCODE_UNKNOWN) {
+ if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) {
+ scancode = WinRT_Unofficial_Keycodes[keycode];
+ }
+ }
+ if (scancode == SDL_SCANCODE_UNKNOWN) {
+ if (keycode < SDL_arraysize(windows_scancode_table)) {
+ scancode = windows_scancode_table[keycode];
+ }
+ }
+ if (scancode == SDL_SCANCODE_UNKNOWN) {
+ SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
+ }
+ return scancode;
+}
+
+void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+ SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
+#if 0
+ SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
+ SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
+ (args->Handled ? "1" : "0"),
+ (args->KeyStatus.IsExtendedKey ? "1" : "0"),
+ (args->KeyStatus.IsKeyReleased ? "1" : "0"),
+ (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
+ args->KeyStatus.RepeatCount,
+ args->KeyStatus.ScanCode,
+ (args->KeyStatus.WasKeyDown ? "1" : "0"),
+ args->VirtualKey,
+ sdlScancode,
+ SDL_GetScancodeName(sdlScancode),
+ keycode,
+ SDL_GetKeyName(keycode));
+ //args->Handled = true;
+ //VirtualKey vkey = args->VirtualKey;
+#endif
+ SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode);
+}
+
+void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+ SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
+#if 0
+ SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
+ SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
+ (args->Handled ? "1" : "0"),
+ (args->KeyStatus.IsExtendedKey ? "1" : "0"),
+ (args->KeyStatus.IsKeyReleased ? "1" : "0"),
+ (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
+ args->KeyStatus.RepeatCount,
+ args->KeyStatus.ScanCode,
+ (args->KeyStatus.WasKeyDown ? "1" : "0"),
+ args->VirtualKey,
+ sdlScancode,
+ SDL_GetScancodeName(sdlScancode),
+ keycode,
+ SDL_GetKeyName(keycode));
+ //args->Handled = true;
+#endif
+ SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode);
+}
+
+void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
+{
+ CoreWindow::GetForCurrentThread()->Activate();
+}
+
+static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
+{
+ if (event->type == SDL_WINDOWEVENT)
+ {
+ switch (event->window.event)
+ {
+ case SDL_WINDOWEVENT_MINIMIZED:
+ case SDL_WINDOWEVENT_RESTORED:
+ // Return 0 to indicate that the event should be removed from the
+ // event queue:
+ return 0;
+ default:
+ break;
+ }
+ }
+
+ // Return 1 to indicate that the event should stay in the event queue:
+ return 1;
+}
+
+void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
+{
+ // Save app state asynchronously after requesting a deferral. Holding a deferral
+ // indicates that the application is busy performing suspending operations. Be
+ // aware that a deferral may not be held indefinitely. After about five seconds,
+ // the app will be forced to exit.
+ SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
+ create_task([this, deferral]()
+ {
+ // Send a window-minimized event immediately to observers.
+ // CoreDispatcher::ProcessEvents, which is the backbone on which
+ // SDL_WinRTApp::PumpEvents is built, will not return to its caller
+ // once it sends out a suspend event. Any events posted to SDL's
+ // event queue won't get received until the WinRT app is resumed.
+ // SDL_AddEventWatch() may be used to receive app-suspend events on
+ // WinRT.
+ //
+ // In order to prevent app-suspend events from being received twice:
+ // first via a callback passed to SDL_AddEventWatch, and second via
+ // SDL's event queue, the event will be sent to SDL, then immediately
+ // removed from the queue.
+ if (m_sdlWindowData)
+ {
+ SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
+ SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
+ }
+ deferral->Complete();
+ });
+}
+
+void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
+{
+ // Restore any data or state that was unloaded on suspend. By default, data
+ // and state are persisted when resuming from suspend. Note that this event
+ // does not occur if the app was previously terminated.
+ if (m_sdlWindowData)
+ {
+ SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
+
+ // Remove the app-resume event from the queue, as is done with the
+ // app-suspend event.
+ //
+ // TODO, WinRT: consider posting this event to the queue even though
+ // its counterpart, the app-suspend event, effectively has to be
+ // processed immediately.
+ SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
+ }
+}
+
+SDL_DisplayMode SDL_WinRTApp::GetMainDisplayMode()
+{
+ // Create an empty, zeroed-out display mode:
+ SDL_DisplayMode mode;
+ SDL_zero(mode);
+
+ // Fill in most fields:
+ mode.format = SDL_PIXELFORMAT_RGB888;
+ mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
+ mode.driverdata = NULL;
+
+ // Calculate the display size given the window size, taking into account
+ // the current display's DPI:
+ const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
+ const float dipsPerInch = 96.0f;
+ mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
+ mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
+
+ return mode;
+}
+
+const SDL_WindowData * SDL_WinRTApp::GetSDLWindowData() const
+{
+ return m_sdlWindowData;
+}
+
+bool SDL_WinRTApp::HasSDLWindowData() const
+{
+ return (m_sdlWindowData != NULL);
+}
+
+void SDL_WinRTApp::SetRelativeMouseMode(bool enable)
+{
+ m_useRelativeMouseMode = enable;
+}
+
+void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData * windowData)
+{
+ m_sdlWindowData = windowData;
+}
+
+void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
+{
+ m_sdlVideoDevice = videoDevice;
+}
diff --git a/src/video/windowsrt/SDL_WinRTApp.h b/src/video/windowsrt/SDL_WinRTApp.h
new file mode 100644
index 0000000..cd0c379
--- /dev/null
+++ b/src/video/windowsrt/SDL_WinRTApp.h
@@ -0,0 +1,52 @@
+#pragma once
+
+struct SDL_WindowData;
+
+ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
+{
+public:
+ SDL_WinRTApp();
+
+ // IFrameworkView Methods.
+ virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
+ virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
+ virtual void Load(Platform::String^ entryPoint);
+ virtual void Run();
+ virtual void Uninitialize();
+
+internal:
+ // SDL-specific methods
+ SDL_DisplayMode GetMainDisplayMode();
+ void PumpEvents();
+ const SDL_WindowData * GetSDLWindowData() const;
+ bool HasSDLWindowData() const;
+ void SetRelativeMouseMode(bool enable);
+ void SetSDLWindowData(const SDL_WindowData * windowData);
+ void SetSDLVideoDevice(const SDL_VideoDevice * videoDevice);
+ Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
+
+protected:
+ // Event Handlers.
+ void OnOrientationChanged(Platform::Object^ sender);
+ void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
+ void OnLogicalDpiChanged(Platform::Object^ sender);
+ void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
+ void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
+ void OnResuming(Platform::Object^ sender, Platform::Object^ args);
+ void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
+ void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
+ void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
+ void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
+ void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
+
+private:
+ bool m_windowClosed;
+ bool m_windowVisible;
+ const SDL_WindowData* m_sdlWindowData;
+ const SDL_VideoDevice* m_sdlVideoDevice;
+ bool m_useRelativeMouseMode;
+};
diff --git a/src/video/windowsrt/SDL_winrtevents.cpp b/src/video/windowsrt/SDL_winrtevents.cpp
new file mode 100644
index 0000000..f445b8b
--- /dev/null
+++ b/src/video/windowsrt/SDL_winrtevents.cpp
@@ -0,0 +1,41 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#if SDL_VIDEO_DRIVER_WINRT
+
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_winrtvideo.h"
+#include "SDL_winrtevents_c.h"
+#include "SDL_WinRTApp.h"
+
+extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
+
+void
+WINRT_PumpEvents(_THIS)
+{
+ SDL_WinRTGlobalApp->PumpEvents();
+}
+
+#endif /* SDL_VIDEO_DRIVER_WINRT */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/windowsrt/SDL_winrtevents_c.h b/src/video/windowsrt/SDL_winrtevents_c.h
new file mode 100644
index 0000000..afbd686
--- /dev/null
+++ b/src/video/windowsrt/SDL_winrtevents_c.h
@@ -0,0 +1,27 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#include "SDL_winrtvideo.h"
+
+extern void WINRT_PumpEvents(_THIS);
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/windowsrt/SDL_winrtmouse.cpp b/src/video/windowsrt/SDL_winrtmouse.cpp
new file mode 100644
index 0000000..e0450c6
--- /dev/null
+++ b/src/video/windowsrt/SDL_winrtmouse.cpp
@@ -0,0 +1,149 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#if SDL_VIDEO_DRIVER_WINRT
+
+extern "C" {
+#include "SDL_assert.h"
+#include "../../events/SDL_mouse_c.h"
+#include "../SDL_sysvideo.h"
+}
+
+#include "SDL_WinRTApp.h"
+#include "SDL_winrtmouse.h"
+
+using namespace Windows::UI::Core;
+using Windows::UI::Core::CoreCursor;
+
+extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
+
+
+static SDL_Cursor *
+WINRT_CreateSystemCursor(SDL_SystemCursor id)
+{
+ SDL_Cursor *cursor;
+ CoreCursorType cursorType = CoreCursorType::Arrow;
+
+ switch(id)
+ {
+ default:
+ SDL_assert(0);
+ return NULL;
+ case SDL_SYSTEM_CURSOR_ARROW: cursorType = CoreCursorType::Arrow; break;
+ case SDL_SYSTEM_CURSOR_IBEAM: cursorType = CoreCursorType::IBeam; break;
+ case SDL_SYSTEM_CURSOR_WAIT: cursorType = CoreCursorType::Wait; break;
+ case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break;
+ case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break;
+ case SDL_SYSTEM_CURSOR_SIZENWSE: cursorType = CoreCursorType::SizeNorthwestSoutheast; break;
+ case SDL_SYSTEM_CURSOR_SIZENESW: cursorType = CoreCursorType::SizeNortheastSouthwest; break;
+ case SDL_SYSTEM_CURSOR_SIZEWE: cursorType = CoreCursorType::SizeWestEast; break;
+ case SDL_SYSTEM_CURSOR_SIZENS: cursorType = CoreCursorType::SizeNorthSouth; break;
+ case SDL_SYSTEM_CURSOR_SIZEALL: cursorType = CoreCursorType::SizeAll; break;
+ case SDL_SYSTEM_CURSOR_NO: cursorType = CoreCursorType::UniversalNo; break;
+ case SDL_SYSTEM_CURSOR_HAND: cursorType = CoreCursorType::Hand; break;
+ }
+
+ cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
+ if (cursor) {
+ /* Create a pointer to a COM reference to a cursor. The extra
+ pointer is used (on top of the COM reference) to allow the cursor
+ to be referenced by the SDL_cursor's driverdata field, which is
+ a void pointer.
+ */
+ CoreCursor ^* theCursor = new CoreCursor^(nullptr);
+ *theCursor = ref new CoreCursor(cursorType, 0);
+ cursor->driverdata = (void *) theCursor;
+ } else {
+ SDL_OutOfMemory();
+ }
+
+ return cursor;
+}
+
+static SDL_Cursor *
+WINRT_CreateDefaultCursor()
+{
+ return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+}
+
+static void
+WINRT_FreeCursor(SDL_Cursor * cursor)
+{
+ if (cursor->driverdata) {
+ CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
+ *theCursor = nullptr; // Release the COM reference to the CoreCursor
+ delete theCursor; // Delete the pointer to the COM reference
+ }
+ SDL_free(cursor);
+}
+
+static int
+WINRT_ShowCursor(SDL_Cursor * cursor)
+{
+ if (cursor) {
+ CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
+ CoreWindow::GetForCurrentThread()->PointerCursor = *theCursor;
+ } else {
+ CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
+ }
+ return 0;
+}
+
+static int
+WINRT_SetRelativeMouseMode(SDL_bool enabled)
+{
+ SDL_WinRTGlobalApp->SetRelativeMouseMode(enabled ? true : false);
+ return 0;
+}
+
+void
+WINRT_InitMouse(_THIS)
+{
+ SDL_Mouse *mouse = SDL_GetMouse();
+
+ /* DLudwig, Dec 3, 2012: Windows RT does not currently provide APIs for
+ the following features, AFAIK:
+ - custom cursors (multiple system cursors are, however, available)
+ - programmatically moveable cursors
+ */
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ //mouse->CreateCursor = WINRT_CreateCursor;
+ mouse->CreateSystemCursor = WINRT_CreateSystemCursor;
+ mouse->ShowCursor = WINRT_ShowCursor;
+ mouse->FreeCursor = WINRT_FreeCursor;
+ //mouse->WarpMouse = WINRT_WarpMouse;
+ mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode;
+
+ SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
+#endif
+}
+
+void
+WINRT_QuitMouse(_THIS)
+{
+}
+
+#endif /* SDL_VIDEO_DRIVER_WINRT */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/windowsrt/SDL_winrtmouse.h b/src/video/windowsrt/SDL_winrtmouse.h
new file mode 100644
index 0000000..50bdbe2
--- /dev/null
+++ b/src/video/windowsrt/SDL_winrtmouse.h
@@ -0,0 +1,31 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#ifndef _SDL_windowsmouse_h
+#define _SDL_windowsmouse_h
+
+extern void WINRT_InitMouse(_THIS);
+extern void WINRT_QuitMouse(_THIS);
+
+#endif /* _SDL_windowsmouse_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/windowsrt/SDL_winrtvideo.cpp b/src/video/windowsrt/SDL_winrtvideo.cpp
new file mode 100644
index 0000000..7a459fb
--- /dev/null
+++ b/src/video/windowsrt/SDL_winrtvideo.cpp
@@ -0,0 +1,262 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#if SDL_VIDEO_DRIVER_WINRT
+
+/* WinRT SDL video driver implementation
+
+ Initial work on this was done by David Ludwig (dludwig@pobox.com), and
+ was based off of SDL's "dummy" video driver.
+ */
+
+extern "C" {
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "../SDL_sysvideo.h"
+#include "../SDL_pixels_c.h"
+#include "../../events/SDL_events_c.h"
+#include "../../render/SDL_sysrender.h"
+#include "SDL_syswm.h"
+}
+
+#include "SDL_WinRTApp.h"
+#include "SDL_winrtvideo.h"
+#include "SDL_winrtevents_c.h"
+#include "SDL_winrtmouse.h"
+
+using namespace Windows::UI::Core;
+
+/* On Windows, windows.h defines CreateWindow */
+#ifdef CreateWindow
+#undef CreateWindow
+#endif
+
+extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
+
+#define WINRTVID_DRIVER_NAME "winrt"
+
+/* Initialization/Query functions */
+static int WINRT_VideoInit(_THIS);
+static int WINRT_InitModes(_THIS);
+static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
+static void WINRT_VideoQuit(_THIS);
+
+/* Window functions */
+static int WINRT_CreateWindow(_THIS, SDL_Window * window);
+static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
+static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
+
+/* WinRT driver bootstrap functions */
+
+static int
+WINRT_Available(void)
+{
+ return (1);
+}
+
+static void
+WINRT_DeleteDevice(SDL_VideoDevice * device)
+{
+ SDL_WinRTGlobalApp->SetSDLVideoDevice(NULL);
+ SDL_free(device);
+}
+
+static SDL_VideoDevice *
+WINRT_CreateDevice(int devindex)
+{
+ SDL_VideoDevice *device;
+
+ /* Initialize all variables that we clean on shutdown */
+ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
+ if (!device) {
+ SDL_OutOfMemory();
+ if (device) {
+ SDL_free(device);
+ }
+ return (0);
+ }
+
+ /* Set the function pointers */
+ device->VideoInit = WINRT_VideoInit;
+ device->VideoQuit = WINRT_VideoQuit;
+ device->CreateWindow = WINRT_CreateWindow;
+ device->DestroyWindow = WINRT_DestroyWindow;
+ device->SetDisplayMode = WINRT_SetDisplayMode;
+ device->PumpEvents = WINRT_PumpEvents;
+ //device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
+ //device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
+ //device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
+ device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
+ device->free = WINRT_DeleteDevice;
+
+ SDL_WinRTGlobalApp->SetSDLVideoDevice(device);
+
+ return device;
+}
+
+VideoBootStrap WINRT_bootstrap = {
+ WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
+ WINRT_Available, WINRT_CreateDevice
+};
+
+int
+WINRT_VideoInit(_THIS)
+{
+ // TODO, WinRT: consider adding a hack to wait (here) for the app's orientation to finish getting set (before the initial display mode is set up)
+
+ if (WINRT_InitModes(_this) < 0) {
+ return -1;
+ }
+ WINRT_InitMouse(_this);
+
+ return 0;
+}
+
+static int
+WINRT_InitModes(_THIS)
+{
+ SDL_DisplayMode mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
+ if (SDL_AddBasicVideoDisplay(&mode) < 0) {
+ return -1;
+ }
+
+ SDL_AddDisplayMode(&_this->displays[0], &mode);
+ return 0;
+}
+
+static int
+WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
+{
+ return 0;
+}
+
+void
+WINRT_VideoQuit(_THIS)
+{
+ WINRT_QuitMouse(_this);
+}
+
+int
+WINRT_CreateWindow(_THIS, SDL_Window * window)
+{
+ // Make sure that only one window gets created, at least until multimonitor
+ // support is added.
+ if (SDL_WinRTGlobalApp->HasSDLWindowData())
+ {
+ SDL_SetError("WinRT only supports one window");
+ return -1;
+ }
+
+ SDL_WindowData *data = new SDL_WindowData;
+ if (!data) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+ window->driverdata = data;
+ data->sdlWindow = window;
+ data->coreWindow = CoreWindow::GetForCurrentThread();
+
+ /* Make sure the window is considered to be positioned at {0,0},
+ and is considered fullscreen, shown, and the like.
+ */
+ window->x = 0;
+ window->y = 0;
+ window->flags =
+ SDL_WINDOW_FULLSCREEN |
+ SDL_WINDOW_SHOWN |
+ SDL_WINDOW_BORDERLESS |
+ SDL_WINDOW_MAXIMIZED |
+ SDL_WINDOW_INPUT_GRABBED;
+
+ /* HACK from DLudwig: The following line of code prevents
+ SDL_CreateWindow and SDL_UpdateFullscreenMode from trying to resize
+ the window after the call to WINRT_CreateWindow returns.
+
+ This hack should allow a window to be created in virtually any size,
+ and more importantly, it allows a window's framebuffer, as created and
+ retrieved via SDL_GetWindowSurface, to be in any size. This can be
+ utilized by apps centered around software rendering, such as ports
+ of older apps. The app can have SDL create a framebuffer in any size
+ it chooses. SDL will scale the framebuffer to the native
+ screen size on the GPU (via SDL_UpdateWindowSurface).
+ */
+ _this->displays[0].fullscreen_window = window;
+
+ /* Further prevent any display resizing, and make sure SDL_GetWindowDisplayMode
+ can report the correct size of windows, by creating a new display
+ mode in the requested size. To note, if the window is being created in
+ the device's native screen size, SDL_AddDisplayMode will do nothing.
+ */
+ window->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
+ window->fullscreen_mode.w = window->w;
+ window->fullscreen_mode.h = window->h;
+ SDL_AddDisplayMode(&_this->displays[0], &window->fullscreen_mode);
+
+ /* TODO: Consider removing custom display modes in WINRT_DestroyWindow. */
+
+ /* Make sure the WinRT app's IFramworkView can post events on
+ behalf of SDL:
+ */
+ SDL_WinRTGlobalApp->SetSDLWindowData(data);
+
+ /* All done! */
+ return 0;
+}
+
+void
+WINRT_DestroyWindow(_THIS, SDL_Window * window)
+{
+ SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
+
+ if (SDL_WinRTGlobalApp->HasSDLWindowData() &&
+ SDL_WinRTGlobalApp->GetSDLWindowData()->sdlWindow == window)
+ {
+ SDL_WinRTGlobalApp->SetSDLWindowData(NULL);
+ }
+
+ if (data) {
+ // Delete the internal window data:
+ delete data;
+ data = NULL;
+ }
+}
+
+SDL_bool
+WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
+{
+ SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
+
+ if (info->version.major <= SDL_MAJOR_VERSION) {
+ info->subsystem = SDL_SYSWM_WINDOWSRT;
+ info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
+ return SDL_TRUE;
+ } else {
+ SDL_SetError("Application not compiled with SDL %d.%d\n",
+ SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ return SDL_FALSE;
+ }
+ return SDL_FALSE;
+}
+
+#endif /* SDL_VIDEO_DRIVER_WINRT */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/windowsrt/SDL_winrtvideo.h b/src/video/windowsrt/SDL_winrtvideo.h
new file mode 100644
index 0000000..4418754
--- /dev/null
+++ b/src/video/windowsrt/SDL_winrtvideo.h
@@ -0,0 +1,40 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 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_config.h"
+
+#ifndef _SDL_winrtvideo_h
+#define _SDL_winrtvideo_h
+
+extern "C" {
+#include "../SDL_sysvideo.h"
+}
+
+#include <agile.h>
+
+struct SDL_WindowData
+{
+ SDL_Window *sdlWindow;
+ Platform::Agile<Windows::UI::Core::CoreWindow> coreWindow;
+};
+
+#endif /* _SDL_winrtvideo_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/test/loopwave.c b/test/loopwave.c
index 22b0559..de8329a 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -79,6 +79,7 @@ int
main(int argc, char *argv[])
{
int i;
+ char filename[4096];
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
@@ -86,12 +87,14 @@ main(int argc, char *argv[])
return (1);
}
- if (argv[1] == NULL) {
- argv[1] = "sample.wav";
+ if (argc >= 1) {
+ SDL_strlcpy(filename, argv[1], sizeof(filename));
+ } else {
+ SDL_strlcpy(filename, "sample.wav", sizeof(filename));
}
/* Load the wave file into memory */
- if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
- fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
+ if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
+ fprintf(stderr, "Couldn't load %s: %s\n", filename, SDL_GetError());
quit(1);
}