# Copyright 2016 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/config/features.gni") if (is_android) { import("//build/config/android/config.gni") import("//build/config/android/rules.gni") import("//third_party/jni_zero/jni_zero.gni") } component("gamepad") { output_name = "device_gamepad" sources = [ "abstract_haptic_gamepad.cc", "abstract_haptic_gamepad.h", "dualshock4_controller.cc", "dualshock4_controller.h", "gamepad_blocklist.cc", "gamepad_blocklist.h", "gamepad_consumer.cc", "gamepad_consumer.h", "gamepad_data_fetcher.cc", "gamepad_data_fetcher.h", "gamepad_data_fetcher_manager.cc", "gamepad_data_fetcher_manager.h", "gamepad_export.h", "gamepad_haptics_manager.cc", "gamepad_haptics_manager.h", "gamepad_id_list.cc", "gamepad_id_list.h", "gamepad_monitor.cc", "gamepad_monitor.h", "gamepad_pad_state_provider.cc", "gamepad_pad_state_provider.h", "gamepad_platform_data_fetcher.h", "gamepad_provider.cc", "gamepad_provider.h", "gamepad_service.cc", "gamepad_service.h", "gamepad_shared_buffer.cc", "gamepad_shared_buffer.h", "gamepad_standard_mappings.cc", "gamepad_standard_mappings.h", "gamepad_uma.cc", "gamepad_uma.h", "gamepad_user_gesture.cc", "gamepad_user_gesture.h", "hid_haptic_gamepad.cc", "hid_haptic_gamepad.h", "hid_writer.h", "normalization.h", "simulated_gamepad_data_fetcher.cc", "simulated_gamepad_data_fetcher.h", "simulated_gamepad_inputs.cc", "simulated_gamepad_inputs.h", "simulated_gamepad_params.cc", "simulated_gamepad_params.h", "xbox_hid_controller.cc", "xbox_hid_controller.h", ] deps = [ "//base", "//device/base/synchronization", "//device/gamepad/public/cpp:shared_with_blink", "//device/gamepad/public/cpp:switches", "//device/gamepad/public/mojom", "//mojo/public/cpp/system", "//third_party/abseil-cpp:absl", "//third_party/blink/public:blink_headers", ] public_deps = [ "//services/device/public/mojom" ] defines = [ "DEVICE_GAMEPAD_IMPLEMENTATION" ] if (is_win) { sources += [ "gameinput_data_fetcher.cc", "gameinput_data_fetcher.h", "gameinput_gamepad_device.cc", "gameinput_gamepad_device.h", "gamepad_standard_mappings_win.cc", "hid_writer_win.cc", "hid_writer_win.h", "raw_input_data_fetcher_win.cc", "raw_input_data_fetcher_win.h", "raw_input_gamepad_device_win.cc", "raw_input_gamepad_device_win.h", "wgi_data_fetcher_win.cc", "wgi_data_fetcher_win.h", "wgi_gamepad_device.cc", "wgi_gamepad_device.h", "xinput_data_fetcher_win.cc", "xinput_data_fetcher_win.h", "xinput_haptic_gamepad_win.cc", "xinput_haptic_gamepad_win.h", ] deps += [ "//device/base" ] libs = [ "hid.lib" ] } if (is_linux || is_chromeos) { sources += [ "gamepad_standard_mappings_linux.cc", "hid_writer_linux.cc", "hid_writer_linux.h", ] if (use_udev) { sources += [ "gamepad_device_linux.cc", "gamepad_device_linux.h", "gamepad_platform_data_fetcher_linux.cc", "gamepad_platform_data_fetcher_linux.h", "udev_gamepad_linux.cc", "udev_gamepad_linux.h", ] deps += [ "//device/udev_linux" ] } } if (is_android) { sources += [ "gamepad_platform_data_fetcher_android.cc", "gamepad_platform_data_fetcher_android.h", "haptic_gamepad_android.cc", "haptic_gamepad_android.h", ] deps += [ ":jni_headers" ] } if (!is_android && !is_fuchsia && !is_ios) { sources += [ "nintendo_controller.cc", "nintendo_controller.h", "nintendo_data_fetcher.cc", "nintendo_data_fetcher.h", ] } if (is_apple) { sources += [ "game_controller_data_fetcher_mac.h", "game_controller_data_fetcher_mac.mm", "game_controller_gamepad.h", "game_controller_gamepad.mm", "gamepad_standard_mappings_mac.mm", ] frameworks = [ "CoreFoundation.framework", "CoreHaptics.framework", "Foundation.framework", "GameController.framework", ] if (is_mac) { sources += [ "gamepad_device_mac.h", "gamepad_device_mac.mm", "gamepad_platform_data_fetcher_mac.h", "gamepad_platform_data_fetcher_mac.mm", "hid_writer_mac.cc", "hid_writer_mac.h", "xbox_controller_mac.h", "xbox_controller_mac.mm", "xbox_data_fetcher_mac.cc", "xbox_data_fetcher_mac.h", ] frameworks += [ "ForceFeedback.framework", "IOKit.framework", ] } } if (is_chromeos) { deps += [ "//chromeos/dbus/permission_broker" ] } # TODO(crbug.com/40031409): Fix code that adds exit-time destructors and # enable the diagnostic by removing this line. configs += [ "//build/config/compiler:no_exit_time_destructors" ] } static_library("test_helpers") { testonly = true sources = [ "gamepad_test_helpers.cc", "gamepad_test_helpers.h", ] public_deps = [ ":gamepad", "//base", "//base/test:test_support", "//device/gamepad/public/cpp:shared_with_blink", "//third_party/blink/public:blink_headers", ] if (is_win) { sources += [ "test_support/fake_gameinput_environment.cc", "test_support/fake_gameinput_environment.h", "test_support/fake_igameinput.cc", "test_support/fake_igameinput.h", "test_support/fake_igameinputdevice.cc", "test_support/fake_igameinputdevice.h", "test_support/fake_igameinputreading.cc", "test_support/fake_igameinputreading.h", "test_support/fake_igamepad.cc", "test_support/fake_igamepad.h", "test_support/fake_igamepad_statics.cc", "test_support/fake_igamepad_statics.h", "test_support/fake_iraw_game_controller.cc", "test_support/fake_iraw_game_controller.h", "test_support/fake_winrt_wgi_environment.cc", "test_support/fake_winrt_wgi_environment.h", "test_support/wgi_test_error_code.h", ] # TODO(crbug.com/40031409): Fix code that adds exit-time destructors and # enable the diagnostic by removing this line. configs += [ "//build/config/compiler:no_exit_time_destructors" ] } } if (is_android) { generate_jni("jni_headers") { sources = [ "android/java/src/org/chromium/device/gamepad/GamepadList.java" ] } android_library("java") { sources = [ "android/java/src/org/chromium/device/gamepad/GamepadDevice.java", "android/java/src/org/chromium/device/gamepad/GamepadList.java", "android/java/src/org/chromium/device/gamepad/GamepadMappings.java", ] deps = [ "//base:base_java", "//build/android:build_java", "//third_party/androidx:androidx_annotation_annotation_java", "//third_party/jni_zero:jni_zero_java", ] srcjar_deps = [ ":java_enums_srcjar", ":jni_headers", ] } java_cpp_enum("java_enums_srcjar") { sources = [ "gamepad_standard_mappings.h" ] } }