| 1906 | } |
| 1907 | |
| 1908 | Input::Input() { |
| 1909 | singleton = this; |
| 1910 | |
| 1911 | // Parse default mappings. |
| 1912 | { |
| 1913 | int i = 0; |
| 1914 | while (DefaultControllerMappings::mappings[i]) { |
| 1915 | parse_mapping(DefaultControllerMappings::mappings[i++]); |
| 1916 | } |
| 1917 | } |
| 1918 | |
| 1919 | // If defined, parse SDL_GAMECONTROLLERCONFIG for possible new mappings/overrides. |
| 1920 | String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG"); |
| 1921 | if (!env_mapping.is_empty()) { |
| 1922 | Vector<String> entries = env_mapping.split("\n"); |
| 1923 | for (int i = 0; i < entries.size(); i++) { |
| 1924 | if (entries[i].is_empty()) { |
| 1925 | continue; |
| 1926 | } |
| 1927 | parse_mapping(entries[i]); |
| 1928 | } |
| 1929 | } |
| 1930 | |
| 1931 | String env_ignore_devices = OS::get_singleton()->get_environment("SDL_GAMECONTROLLER_IGNORE_DEVICES"); |
| 1932 | if (!env_ignore_devices.is_empty()) { |
| 1933 | Vector<String> entries = env_ignore_devices.split(","); |
| 1934 | for (int i = 0; i < entries.size(); i++) { |
| 1935 | Vector<String> vid_pid = entries[i].split("/"); |
| 1936 | |
| 1937 | if (vid_pid.size() < 2) { |
| 1938 | continue; |
| 1939 | } |
| 1940 | |
| 1941 | print_verbose(vformat("Device Ignored -- Vendor: %s Product: %s", vid_pid[0], vid_pid[1])); |
| 1942 | const uint16_t vid_unswapped = vid_pid[0].hex_to_int(); |
| 1943 | const uint16_t pid_unswapped = vid_pid[1].hex_to_int(); |
| 1944 | const uint16_t vid = BSWAP16(vid_unswapped); |
| 1945 | const uint16_t pid = BSWAP16(pid_unswapped); |
| 1946 | |
| 1947 | uint32_t full_id = (((uint32_t)vid) << 16) | ((uint16_t)pid); |
| 1948 | ignored_device_ids.insert(full_id); |
| 1949 | } |
| 1950 | } |
| 1951 | |
| 1952 | legacy_just_pressed_behavior = GLOBAL_DEF("input_devices/compatibility/legacy_just_pressed_behavior", false); |
| 1953 | if (Engine::get_singleton()->is_editor_hint()) { |
| 1954 | // Always use standard behavior in the editor. |
| 1955 | legacy_just_pressed_behavior = false; |
| 1956 | } |
| 1957 | |
| 1958 | accelerometer_enabled = GLOBAL_DEF_RST_BASIC("input_devices/sensors/enable_accelerometer", false); |
| 1959 | gravity_enabled = GLOBAL_DEF_RST_BASIC("input_devices/sensors/enable_gravity", false); |
| 1960 | gyroscope_enabled = GLOBAL_DEF_RST_BASIC("input_devices/sensors/enable_gyroscope", false); |
| 1961 | magnetometer_enabled = GLOBAL_DEF_RST_BASIC("input_devices/sensors/enable_magnetometer", false); |
| 1962 | } |
| 1963 | |
| 1964 | Input::~Input() { |
| 1965 | singleton = nullptr; |
nothing calls this directly
no test coverage detected