Mir

Merge lp:mir/0.18 into lp:mir/ubuntu

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: 3184
Merged at revision: 1251
Proposed branch: lp:mir/0.18
Merge into: lp:mir/ubuntu
Diff against target: 70000 lines (+16163/-38510)
628 files modified
3rd_party/CMakeLists.txt (+0/-8)
3rd_party/android-input/CMakeLists.txt (+1/-1)
3rd_party/android-input/android/CMakeLists.txt (+1/-23)
3rd_party/android-input/android/frameworks/base/include/androidfw/InputDevice.h (+0/-156)
3rd_party/android-input/android/frameworks/base/include/androidfw/KeyCharacterMap.h (+0/-255)
3rd_party/android-input/android/frameworks/base/include/androidfw/KeyLayoutMap.h (+0/-114)
3rd_party/android-input/android/frameworks/base/include/androidfw/Keyboard.h (+0/-125)
3rd_party/android-input/android/frameworks/base/include/androidfw/KeycodeLabels.h (+0/-320)
3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h (+0/-110)
3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h (+0/-272)
3rd_party/android-input/android/frameworks/base/include/androidfw/VirtualKeyMap.h (+0/-81)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp (+0/-1502)
3rd_party/android-input/android/frameworks/base/services/input/EventHub.h (+0/-444)
3rd_party/android-input/android/frameworks/base/services/input/GenericKeyMap.cpp (+0/-1009)
3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp (+0/-205)
3rd_party/android-input/android/frameworks/base/services/input/InputListener.cpp (+0/-183)
3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp (+0/-6356)
3rd_party/android-input/android/frameworks/base/services/input/InputReader.h (+0/-1750)
3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp (+1/-5)
3rd_party/android-input/android/frameworks/base/services/input/KeyCharacterMap.cpp (+0/-1152)
3rd_party/android-input/android/frameworks/base/services/input/KeyLayoutMap.cpp (+0/-387)
3rd_party/android-input/android/frameworks/base/services/input/Keyboard.cpp (+0/-328)
3rd_party/android-input/android/frameworks/base/services/input/PointerController.h (+0/-172)
3rd_party/android-input/android/frameworks/base/services/input/VelocityControl.cpp (+0/-110)
3rd_party/android-input/android/frameworks/base/services/input/VelocityTracker.cpp (+0/-926)
3rd_party/android-input/android/frameworks/base/services/input/VirtualKeyMap.cpp (+0/-171)
3rd_party/android-input/android/frameworks/native/libs/utils/Timers.cpp (+4/-30)
3rd_party/xcursor/CMakeLists.txt (+0/-11)
CMakeLists.txt (+15/-9)
benchmarks/CMakeLists.txt (+0/-1)
benchmarks/android-input/CMakeLists.txt (+0/-20)
benchmarks/android-input/input_reader_perf.cpp (+0/-178)
benchmarks/android-input/ntrig_input_events.h (+0/-6944)
benchmarks/frame-uniformity/touch_producing_server.cpp (+0/-1)
benchmarks/frame-uniformity/vsync_simulating_graphics_platform.cpp (+14/-14)
benchmarks/frame-uniformity/vsync_simulating_graphics_platform.h (+5/-4)
cmake/PrePush.cmake (+0/-122)
debian/changelog (+122/-0)
debian/control (+13/-10)
debian/libmirserver36.install (+1/-1)
debian/mir-client-platform-mesa-dev.install (+0/-1)
debian/mir-platform-graphics-android7.install (+1/-1)
debian/mir-platform-graphics-mesa-kms7.install (+1/-1)
debian/mir-platform-graphics-mesa-x7.install (+1/-1)
debian/mir-platform-input-evdev4.install (+1/-1)
debian/mir-test-tools.install (+1/-1)
doc/building_source_for_arm.md (+20/-2)
examples/CMakeLists.txt (+32/-0)
examples/client_helpers.cpp (+76/-8)
examples/client_helpers.h (+29/-3)
examples/cursor-theme-dump.cpp (+127/-0)
examples/fingerpaint.c (+26/-5)
examples/multi_stream.cpp (+283/-0)
examples/render_surfaces.cpp (+3/-3)
examples/server_example.cpp (+4/-0)
examples/server_example_basic_window_manager.cpp (+312/-0)
examples/server_example_basic_window_manager.h (+152/-251)
examples/server_example_canonical_window_manager.cpp (+101/-370)
examples/server_example_canonical_window_manager.h (+16/-67)
examples/server_example_cursor_images.cpp (+57/-0)
examples/server_example_cursor_images.h (+33/-0)
examples/server_example_input_device_config.cpp (+162/-0)
examples/server_example_input_device_config.h (+73/-0)
examples/server_example_tiling_window_manager.cpp (+194/-110)
examples/server_example_tiling_window_manager.h (+23/-35)
examples/server_example_window_management.cpp (+14/-24)
examples/server_example_window_management_info.cpp (+406/-0)
examples/server_example_window_management_info.h (+103/-0)
examples/xcursor.c (+4/-4)
examples/xcursor_loader.cpp (+12/-6)
examples/xcursor_loader.h (+5/-2)
include/client/mir/events/event_builders.h (+7/-1)
include/client/mir_toolkit/events/surface_output_event.h (+9/-0)
include/client/mir_toolkit/mir_buffer_stream.h (+18/-2)
include/client/mir_toolkit/mir_connection.h (+25/-0)
include/client/mir_toolkit/mir_input_device.h (+56/-0)
include/client/mir_toolkit/version.h (+1/-1)
include/common/mir/assert_module_entry_point.h (+34/-0)
include/common/mir/optional_value.h (+15/-2)
include/cookie/mir/cookie_factory.h (+1/-1)
include/platform/mir/graphics/display.h (+0/-1)
include/platform/mir/graphics/display_configuration.h (+5/-1)
include/platform/mir/graphics/event_handler_register.h (+10/-0)
include/platform/mir/graphics/platform.h (+9/-9)
include/platform/mir/input/event_builder.h (+3/-5)
include/platform/mir/input/input_device.h (+11/-0)
include/platform/mir/input/input_sink.h (+0/-5)
include/platform/mir/input/platform.h (+2/-2)
include/platform/mir/input/pointer_settings.h (+58/-0)
include/platform/mir/input/touchpad_settings.h (+46/-0)
include/server/mir/frontend/session_authorizer.h (+1/-0)
include/server/mir/frontend/session_mediator_report.h (+2/-0)
include/server/mir/input/device.h (+9/-2)
include/server/mir/input/pointer_configuration.h (+71/-0)
include/server/mir/input/touchpad_configuration.h (+82/-0)
include/server/mir/scene/depth_id.h (+0/-34)
include/server/mir/scene/null_surface_observer.h (+2/-1)
include/server/mir/scene/session.h (+1/-0)
include/server/mir/scene/surface_creation_parameters.h (+0/-4)
include/server/mir/scene/surface_observer.h (+2/-1)
include/server/mir/server.h (+25/-9)
include/server/mir/shell/abstract_shell.h (+11/-2)
include/server/mir/shell/display_configuration_controller.h (+1/-1)
include/server/mir/shell/display_layout.h (+4/-2)
include/server/mir/shell/shell.h (+7/-1)
include/server/mir/shell/shell_report.h (+89/-0)
include/server/mir/shell/shell_wrapper.h (+5/-0)
include/server/mir/shell/surface_ready_observer.h (+2/-1)
include/server/mir/shell/surface_specification.h (+2/-2)
include/server/mir/shell/surface_stack.h (+17/-17)
include/server/mir/shell/surface_stack_wrapper.h (+51/-0)
include/server/mir/shell/system_compositor_window_manager.h (+15/-1)
include/server/mir/shell/window_manager.h (+5/-0)
include/test/mir/test/doubles/fake_display.h (+68/-0)
include/test/mir/test/doubles/mock_display_configuration.h (+57/-0)
include/test/mir/test/doubles/mock_egl.h (+14/-8)
include/test/mir/test/doubles/mock_window_manager.h (+2/-0)
include/test/mir/test/doubles/null_display_configuration.h (+4/-0)
include/test/mir/test/doubles/null_platform.h (+6/-5)
include/test/mir/test/doubles/stub_cursor_image.h (+42/-0)
include/test/mir/test/doubles/stub_display_configuration.h (+16/-2)
include/test/mir/test/doubles/stub_session.h (+96/-0)
include/test/mir/test/doubles/stub_session_authorizer.h (+4/-0)
include/test/mir/test/doubles/stub_surface.h (+77/-0)
include/test/mir/test/event_matchers.h (+33/-3)
include/test/mir/test/fake_event_hub.h (+0/-177)
include/test/mir/test/wait_condition.h (+8/-3)
include/test/mir_test_framework/async_server_runner.h (+1/-3)
include/test/mir_test_framework/connected_client_with_a_surface.h (+3/-0)
include/test/mir_test_framework/declarative_placement_window_manage_policy.h (+0/-4)
include/test/mir_test_framework/executable_path.h (+1/-0)
include/test/mir_test_framework/placement_applying_shell.h (+1/-5)
include/test/mir_test_framework/server_runner.h (+6/-4)
playground/demo-shell/default_window_manager.cpp (+10/-2)
playground/demo-shell/default_window_manager.h (+5/-0)
playground/demo-shell/demo_renderer.cpp (+0/-4)
playground/demo-shell/demo_shell.cpp (+1/-5)
src/CMakeLists.txt (+1/-0)
src/client/CMakeLists.txt (+1/-0)
src/client/buffer_stream.cpp (+125/-58)
src/client/buffer_stream.h (+22/-9)
src/client/buffer_vault.cpp (+4/-4)
src/client/buffer_vault.h (+10/-3)
src/client/client_buffer_stream.h (+2/-0)
src/client/default_client_buffer_stream_factory.cpp (+14/-4)
src/client/default_client_buffer_stream_factory.h (+1/-1)
src/client/event.cpp (+6/-0)
src/client/events/event_builders.cpp (+46/-1)
src/client/input/android/android_input_receiver.cpp (+22/-23)
src/client/input/android/android_input_receiver.h (+2/-3)
src/client/mir_buffer_stream_api.cpp (+6/-0)
src/client/mir_connection.cpp (+48/-18)
src/client/mir_connection.h (+6/-1)
src/client/mir_connection_api.cpp (+15/-0)
src/client/mir_surface.cpp (+19/-0)
src/client/mir_surface.h (+3/-0)
src/client/mir_surface_api.cpp (+15/-0)
src/client/mirclient.pc.in (+1/-1)
src/client/rpc/CMakeLists.txt (+2/-0)
src/client/rpc/mir_display_server.cpp (+14/-0)
src/client/rpc/mir_display_server.h (+8/-0)
src/client/symbols.map (+19/-0)
src/common/dispatch/threaded_dispatcher.cpp (+2/-0)
src/common/logging/input_timestamp.cpp (+6/-12)
src/common/symbols.map (+0/-1)
src/cookie/CMakeLists.txt (+1/-1)
src/cookie/cookie_factory.cpp (+1/-3)
src/cookie/mircookie.pc.in (+0/-1)
src/include/common/mir/events/event_private.h (+1/-0)
src/include/common/mir/protobuf/display_server.h (+8/-0)
src/include/platform/mir/emergency_cleanup_registry.h (+4/-1)
src/include/platform/mir/graphics/egl_extensions.h (+9/-0)
src/include/platform/mir/graphics/egl_sync_fence.h (+82/-0)
src/include/platform/mir/options/configuration.h (+1/-0)
src/include/server/mir/default_server_configuration.h (+15/-42)
src/include/server/mir/frontend/client_buffers.h (+2/-0)
src/include/server/mir/frontend/display_changer.h (+3/-1)
src/include/server/mir/frontend/security_check_failed.h (+34/-0)
src/include/server/mir/frontend/shell.h (+5/-0)
src/include/server/mir/frontend/template_protobuf_message_processor.h (+5/-0)
src/include/server/mir/glib_main_loop.h (+9/-0)
src/include/server/mir/input/input_probe.h (+48/-0)
src/include/server/mir/scene/surface_observers.h (+2/-1)
src/include/server/mir/shell/basic_window_manager.h (+49/-0)
src/include/server/mir/shell/canonical_window_manager.h (+4/-0)
src/platform/CMakeLists.txt (+0/-1)
src/platform/graphics/CMakeLists.txt (+1/-0)
src/platform/graphics/egl_extensions.cpp (+19/-10)
src/platform/graphics/egl_sync_fence.cpp (+93/-0)
src/platform/graphics/platform_probe.cpp (+5/-1)
src/platform/options/default_configuration.cpp (+3/-0)
src/platform/symbols.map (+1/-17)
src/platforms/CMakeLists.txt (+13/-6)
src/platforms/android/client/CMakeLists.txt (+1/-1)
src/platforms/android/client/client_platform_factory.cpp (+3/-0)
src/platforms/android/server/CMakeLists.txt (+3/-1)
src/platforms/android/server/android_buffer_allocator.cpp (+15/-10)
src/platforms/android/server/device_quirks.cpp (+28/-15)
src/platforms/android/server/device_quirks.h (+4/-2)
src/platforms/android/server/display.cpp (+10/-6)
src/platforms/android/server/display_configuration.cpp (+6/-1)
src/platforms/android/server/display_configuration.h (+1/-0)
src/platforms/android/server/display_name.h (+11/-1)
src/platforms/android/server/fb_device.cpp (+1/-1)
src/platforms/android/server/hwc_blanking_control.cpp (+1/-1)
src/platforms/android/server/platform.cpp (+46/-34)
src/platforms/android/server/platform.h (+6/-5)
src/platforms/android/server/real_hwc_wrapper.cpp (+12/-12)
src/platforms/android/server/server_render_window.cpp (+11/-3)
src/platforms/android/server/server_render_window.h (+4/-1)
src/platforms/android/server/symbols.map.in (+1/-1)
src/platforms/common/client/mir/CMakeLists.txt (+1/-1)
src/platforms/evdev/CMakeLists.txt (+2/-3)
src/platforms/evdev/button_utils.cpp (+44/-0)
src/platforms/evdev/button_utils.h (+36/-0)
src/platforms/evdev/evdev_device_detection.cpp (+13/-12)
src/platforms/evdev/libinput_device.cpp (+198/-125)
src/platforms/evdev/libinput_device.h (+14/-9)
src/platforms/evdev/libinput_device_ptr.cpp (+8/-3)
src/platforms/evdev/libinput_device_ptr.h (+10/-2)
src/platforms/evdev/libinput_ptr.cpp (+13/-1)
src/platforms/evdev/platform.cpp (+2/-1)
src/platforms/evdev/platform_factory.cpp (+6/-1)
src/platforms/input_platform_symbols.map.in (+1/-1)
src/platforms/mesa/CMakeLists.txt (+1/-10)
src/platforms/mesa/client/CMakeLists.txt (+1/-1)
src/platforms/mesa/client/client_platform.cpp (+0/-16)
src/platforms/mesa/client/client_platform_factory.cpp (+14/-0)
src/platforms/mesa/mir-client-platform-mesa.pc.in (+0/-7)
src/platforms/mesa/server/kms/CMakeLists.txt (+5/-1)
src/platforms/mesa/server/kms/cursor.cpp (+2/-1)
src/platforms/mesa/server/kms/display.cpp (+32/-26)
src/platforms/mesa/server/kms/display.h (+17/-4)
src/platforms/mesa/server/kms/display_buffer.cpp (+10/-7)
src/platforms/mesa/server/kms/display_buffer.h (+7/-3)
src/platforms/mesa/server/kms/guest_platform.cpp (+11/-19)
src/platforms/mesa/server/kms/guest_platform.h (+4/-5)
src/platforms/mesa/server/kms/linux_virtual_terminal.cpp (+25/-24)
src/platforms/mesa/server/kms/platform.cpp (+29/-198)
src/platforms/mesa/server/kms/platform.h (+5/-6)
src/platforms/mesa/server/kms/platform_symbols.cpp (+215/-0)
src/platforms/mesa/server/kms/real_kms_display_configuration.cpp (+5/-0)
src/platforms/mesa/server/kms/real_kms_display_configuration.h (+1/-0)
src/platforms/mesa/server/kms/symbols.map.in (+1/-1)
src/platforms/mesa/server/x11/CMakeLists.txt (+12/-5)
src/platforms/mesa/server/x11/X11_resources.cpp (+3/-2)
src/platforms/mesa/server/x11/graphics/CMakeLists.txt (+6/-1)
src/platforms/mesa/server/x11/graphics/display.cpp (+1/-1)
src/platforms/mesa/server/x11/graphics/display_configuration.cpp (+12/-0)
src/platforms/mesa/server/x11/graphics/display_configuration.h (+2/-0)
src/platforms/mesa/server/x11/graphics/graphics.cpp (+12/-5)
src/platforms/mesa/server/x11/graphics/guest_platform.cpp (+5/-5)
src/platforms/mesa/server/x11/graphics/guest_platform.h (+4/-4)
src/platforms/mesa/server/x11/graphics/platform.cpp (+6/-6)
src/platforms/mesa/server/x11/graphics/platform.h (+3/-3)
src/platforms/mesa/server/x11/input/CMakeLists.txt (+6/-1)
src/platforms/mesa/server/x11/input/input.cpp (+15/-3)
src/platforms/mesa/server/x11/input/input_device.cpp (+32/-1)
src/platforms/mesa/server/x11/input/input_device.h (+8/-0)
src/platforms/mesa/server/x11/input/input_platform.cpp (+66/-69)
src/platforms/mesa/server/x11/symbols.map.in (+2/-2)
src/protobuf/mir_protobuf.proto (+10/-0)
src/protobuf/symbols.map (+40/-0)
src/renderers/gl/renderer.cpp (+48/-11)
src/server/CMakeLists.txt (+1/-2)
src/server/compositor/buffer_map.cpp (+38/-5)
src/server/compositor/buffer_map.h (+15/-4)
src/server/compositor/buffer_stream_factory.cpp (+18/-6)
src/server/compositor/buffer_stream_surfaces.cpp (+1/-1)
src/server/compositor/dropping_schedule.cpp (+5/-2)
src/server/compositor/dropping_schedule.h (+1/-1)
src/server/compositor/multi_monitor_arbiter.cpp (+23/-7)
src/server/compositor/multi_monitor_arbiter.h (+2/-0)
src/server/compositor/queueing_schedule.cpp (+2/-2)
src/server/compositor/queueing_schedule.h (+1/-1)
src/server/compositor/schedule.h (+1/-1)
src/server/compositor/stream.cpp (+43/-5)
src/server/compositor/stream.h (+17/-1)
src/server/default_emergency_cleanup.cpp (+11/-2)
src/server/default_emergency_cleanup.h (+2/-1)
src/server/default_server_configuration.cpp (+5/-0)
src/server/frontend/CMakeLists.txt (+1/-1)
src/server/frontend/default_configuration.cpp (+9/-13)
src/server/frontend/default_ipc_factory.cpp (+11/-11)
src/server/frontend/default_ipc_factory.h (+7/-1)
src/server/frontend/protobuf_message_processor.cpp (+13/-0)
src/server/frontend/security_check_failed.cpp (+24/-0)
src/server/frontend/session_mediator.cpp (+85/-30)
src/server/frontend/session_mediator.h (+19/-1)
src/server/frontend/shell_wrapper.cpp (+8/-0)
src/server/frontend/shell_wrapper.h (+5/-0)
src/server/frontend/socket_connection.cpp (+3/-1)
src/server/frontend/unauthorized_display_changer.cpp (+31/-6)
src/server/frontend/unauthorized_display_changer.h (+12/-2)
src/server/glib_main_loop.cpp (+34/-0)
src/server/graphics/default_configuration.cpp (+2/-6)
src/server/graphics/nested/display.cpp (+76/-52)
src/server/graphics/nested/display.h (+2/-0)
src/server/graphics/nested/nested_display_configuration.cpp (+29/-0)
src/server/graphics/nested/nested_display_configuration.h (+3/-1)
src/server/graphics/offscreen/display_configuration.cpp (+4/-0)
src/server/graphics/offscreen/display_configuration.h (+1/-0)
src/server/input/CMakeLists.txt (+11/-12)
src/server/input/android/CMakeLists.txt (+0/-5)
src/server/input/android/android_input_reader_policy.cpp (+0/-75)
src/server/input/android/android_input_reader_policy.h (+0/-59)
src/server/input/android/android_input_targeter.h (+0/-67)
src/server/input/android/android_input_thread.h (+0/-47)
src/server/input/android/android_pointer_controller.cpp (+0/-131)
src/server/input/android/android_pointer_controller.h (+0/-71)
src/server/input/android/default_dispatcher_policy.h (+0/-79)
src/server/input/android/dummy_android_pointer_controller.h (+0/-106)
src/server/input/android/input_reader_dispatchable.cpp (+0/-54)
src/server/input/android/input_reader_dispatchable.h (+0/-56)
src/server/input/android/input_translator.cpp (+0/-187)
src/server/input/android/input_translator.h (+0/-56)
src/server/input/android/rudimentary_input_reader_policy.cpp (+0/-51)
src/server/input/android/rudimentary_input_reader_policy.h (+0/-60)
src/server/input/black_arrow.c (+0/-480)
src/server/input/builtin_cursor_images.cpp (+21/-13)
src/server/input/builtin_cursor_images.h (+0/-10)
src/server/input/cursor_controller.cpp (+17/-7)
src/server/input/default-theme.h (+1131/-0)
src/server/input/default_configuration.cpp (+22/-130)
src/server/input/default_device.cpp (+82/-3)
src/server/input/default_device.h (+22/-4)
src/server/input/default_event_builder.cpp (+28/-16)
src/server/input/default_event_builder.h (+13/-9)
src/server/input/default_input_device_hub.cpp (+43/-67)
src/server/input/default_input_device_hub.h (+21/-12)
src/server/input/default_input_manager.cpp (+2/-18)
src/server/input/default_input_manager.h (+1/-4)
src/server/input/input_modifier_utils.cpp (+4/-18)
src/server/input/input_modifier_utils.h (+2/-6)
src/server/input/input_probe.cpp (+104/-0)
src/server/input/key_repeat_dispatcher.cpp (+5/-1)
src/server/input/key_repeat_dispatcher.h (+7/-1)
src/server/input/seat.cpp (+196/-0)
src/server/input/seat.h (+84/-0)
src/server/input/surface_input_dispatcher.cpp (+2/-1)
src/server/input/validator.cpp (+2/-1)
src/server/input/vt_filter.cpp (+16/-6)
src/server/report/default_server_configuration.cpp (+10/-0)
src/server/report/logging/CMakeLists.txt (+4/-1)
src/server/report/logging/logging_report_factory.cpp (+5/-0)
src/server/report/logging/session_mediator_report.cpp (+5/-0)
src/server/report/logging/session_mediator_report.h (+2/-0)
src/server/report/logging/shell_report.cpp (+127/-0)
src/server/report/logging/shell_report.h (+84/-0)
src/server/report/logging_report_factory.h (+1/-0)
src/server/report/lttng/lttng_report_factory.cpp (+4/-1)
src/server/report/lttng/session_mediator_report.cpp (+1/-0)
src/server/report/lttng/session_mediator_report.h (+1/-0)
src/server/report/lttng/session_mediator_report_tp.h (+1/-0)
src/server/report/lttng_report_factory.h (+1/-0)
src/server/report/null/CMakeLists.txt (+3/-1)
src/server/report/null/null_report_factory.cpp (+6/-0)
src/server/report/null/session_mediator_report.cpp (+4/-0)
src/server/report/null/session_mediator_report.h (+2/-0)
src/server/report/null/shell_report.cpp (+90/-0)
src/server/report/null/shell_report.h (+79/-0)
src/server/report/null_report_factory.h (+1/-0)
src/server/report/report_factory.h (+2/-0)
src/server/scene/CMakeLists.txt (+1/-1)
src/server/scene/application_session.cpp (+34/-8)
src/server/scene/application_session.h (+4/-3)
src/server/scene/basic_surface.cpp (+15/-6)
src/server/scene/default_configuration.cpp (+35/-32)
src/server/scene/legacy_surface_change_notification.cpp (+5/-1)
src/server/scene/legacy_surface_change_notification.h (+2/-1)
src/server/scene/mediating_display_changer.cpp (+24/-38)
src/server/scene/mediating_display_changer.h (+3/-3)
src/server/scene/null_surface_observer.cpp (+2/-1)
src/server/scene/output_properties_cache.cpp (+3/-2)
src/server/scene/output_properties_cache.h (+2/-4)
src/server/scene/session_manager.cpp (+4/-4)
src/server/scene/session_manager.h (+5/-3)
src/server/scene/surface_controller.cpp (+0/-62)
src/server/scene/surface_controller.h (+0/-63)
src/server/scene/surface_creation_parameters.cpp (+1/-10)
src/server/scene/surface_event_source.cpp (+3/-1)
src/server/scene/surface_stack.cpp (+83/-109)
src/server/scene/surface_stack.h (+5/-7)
src/server/scene/surface_stack_model.h (+0/-66)
src/server/scene/unsupported_coordinate_translator.cpp (+3/-2)
src/server/scene/unsupported_coordinate_translator.h (+11/-12)
src/server/server.cpp (+27/-19)
src/server/shell/CMakeLists.txt (+4/-1)
src/server/shell/abstract_shell.cpp (+74/-21)
src/server/shell/canonical_window_manager.cpp (+9/-0)
src/server/shell/default_configuration.cpp (+2/-1)
src/server/shell/frontend_shell.cpp (+10/-0)
src/server/shell/frontend_shell.h (+5/-0)
src/server/shell/graphics_display_layout.cpp (+2/-6)
src/server/shell/graphics_display_layout.h (+4/-4)
src/server/shell/shell_wrapper.cpp (+8/-0)
src/server/shell/surface_ready_observer.cpp (+1/-1)
src/server/shell/surface_specification.cpp (+49/-0)
src/server/shell/surface_stack_wrapper.cpp (+57/-0)
src/server/shell/system_compositor_window_manager.cpp (+52/-2)
src/server/symbols.map (+149/-68)
tests/acceptance-tests/CMakeLists.txt (+2/-1)
tests/acceptance-tests/server_configuration_wrapping.cpp (+24/-0)
tests/acceptance-tests/test_buffer_stream_arrangement.cpp (+47/-15)
tests/acceptance-tests/test_client_authorization.cpp (+1/-0)
tests/acceptance-tests/test_client_cookie.cpp (+169/-0)
tests/acceptance-tests/test_client_input.cpp (+1/-5)
tests/acceptance-tests/test_client_library.cpp (+16/-0)
tests/acceptance-tests/test_client_surface_events.cpp (+7/-3)
tests/acceptance-tests/test_client_surface_visibility.cpp (+6/-6)
tests/acceptance-tests/test_custom_window_management.cpp (+18/-3)
tests/acceptance-tests/test_debug_api.cpp (+38/-1)
tests/acceptance-tests/test_display_configuration.cpp (+186/-63)
tests/acceptance-tests/test_latency.cpp (+34/-1)
tests/acceptance-tests/test_nested_mir.cpp (+98/-83)
tests/acceptance-tests/test_session_mediator_report.cpp (+1/-0)
tests/acceptance-tests/test_surface_raise.cpp (+186/-0)
tests/acceptance-tests/test_system_compositor_window_manager.cpp (+1/-1)
tests/acceptance-tests/throwback/test_client_cursor_api.cpp (+2/-3)
tests/acceptance-tests/throwback/test_client_library_errors.cpp (+18/-0)
tests/include/mir/test/doubles/mock_android_input_dispatcher.h (+0/-64)
tests/include/mir/test/doubles/mock_buffer_bundle.h (+3/-1)
tests/include/mir/test/doubles/mock_buffer_stream.h (+2/-0)
tests/include/mir/test/doubles/mock_client_buffer_stream.h (+1/-0)
tests/include/mir/test/doubles/mock_display_changer.h (+12/-3)
tests/include/mir/test/doubles/mock_drm.h (+5/-0)
tests/include/mir/test/doubles/mock_event_handler_register.h (+71/-0)
tests/include/mir/test/doubles/mock_event_hub.h (+0/-70)
tests/include/mir/test/doubles/mock_gl.h (+1/-0)
tests/include/mir/test/doubles/mock_input_reader.h (+0/-58)
tests/include/mir/test/doubles/mock_libinput.h (+2/-0)
tests/include/mir/test/doubles/mock_main_loop.h (+22/-0)
tests/include/mir/test/doubles/mock_option.h (+45/-0)
tests/include/mir/test/doubles/mock_scene_session.h (+1/-0)
tests/include/mir/test/doubles/mock_shell.h (+2/-0)
tests/include/mir/test/doubles/mock_surface_stack.h (+7/-8)
tests/include/mir/test/doubles/mock_x11.h (+6/-4)
tests/include/mir/test/doubles/null_display_changer.h (+10/-3)
tests/include/mir/test/doubles/null_emergency_cleanup.h (+1/-0)
tests/include/mir/test/doubles/platform_factory.h (+0/-46)
tests/include/mir/test/doubles/stub_buffer.h (+12/-0)
tests/include/mir/test/doubles/stub_display_builder.h (+1/-1)
tests/include/mir/test/doubles/stub_display_server.h (+8/-0)
tests/include/mir/test/doubles/stub_legacy_input_dispatchable.h (+0/-52)
tests/include/mir/test/doubles/stub_scene_session.h (+0/-134)
tests/include/mir/test/gmock_fixes.h (+23/-0)
tests/include/mir_test_framework/fake_input_server_configuration.h (+0/-1)
tests/include/mir_test_framework/stubbed_server_configuration.h (+0/-1)
tests/integration-tests/CMakeLists.txt (+2/-4)
tests/integration-tests/client/test_mirsurface.cpp (+1/-1)
tests/integration-tests/graphics/android/test_android_hardware_sanity.cpp (+4/-0)
tests/integration-tests/graphics/mesa/CMakeLists.txt (+75/-71)
tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+2/-2)
tests/integration-tests/session_management.cpp (+7/-9)
tests/integration-tests/test_buffer_scheduling.cpp (+429/-187)
tests/integration-tests/test_client_screencast.cpp (+1/-1)
tests/integration-tests/test_display_info.cpp (+2/-2)
tests/integration-tests/test_exchange_buffer.cpp (+28/-33)
tests/integration-tests/test_large_messages.cpp (+1/-1)
tests/integration-tests/test_session.cpp (+1/-1)
tests/integration-tests/test_surface_stack_with_compositor.cpp (+7/-7)
tests/integration-tests/test_surfaceloop.cpp (+4/-4)
tests/mir_test/cross_process_sync.cpp (+30/-19)
tests/mir_test/display_config_matchers.cpp (+12/-0)
tests/mir_test_doubles/CMakeLists.txt (+1/-2)
tests/mir_test_doubles/fake_display.cpp (+90/-0)
tests/mir_test_doubles/fake_event_hub.cpp (+0/-793)
tests/mir_test_doubles/mock_drm.cpp (+23/-0)
tests/mir_test_doubles/mock_egl.cpp (+34/-3)
tests/mir_test_doubles/mock_gl.cpp (+7/-0)
tests/mir_test_doubles/mock_libinput.cpp (+10/-0)
tests/mir_test_doubles/mock_x11.cpp (+5/-1)
tests/mir_test_doubles/platform_factory.cpp (+0/-73)
tests/mir_test_framework/CMakeLists.txt (+6/-1)
tests/mir_test_framework/async_server_runner.cpp (+5/-4)
tests/mir_test_framework/connected_client_with_a_surface.cpp (+1/-1)
tests/mir_test_framework/declarative_placement_window_manage_policy.cpp (+1/-7)
tests/mir_test_framework/executable_path.cpp (+10/-0)
tests/mir_test_framework/fake_input_device_impl.cpp (+52/-33)
tests/mir_test_framework/fake_input_device_impl.h (+7/-1)
tests/mir_test_framework/fake_input_server_configuration.cpp (+0/-7)
tests/mir_test_framework/headless_in_process_server.cpp (+2/-0)
tests/mir_test_framework/input_testing_server_options.cpp (+0/-1)
tests/mir_test_framework/placement_applying_shell.cpp (+5/-10)
tests/mir_test_framework/platform_graphics_dummy.cpp (+3/-0)
tests/mir_test_framework/server_runner.cpp (+24/-16)
tests/mir_test_framework/stub_input.cpp (+7/-2)
tests/mir_test_framework/stub_input_platform.cpp (+1/-1)
tests/mir_test_framework/stub_session.cpp (+144/-0)
tests/mir_test_framework/stub_surface.cpp (+206/-0)
tests/mir_test_framework/stubbed_graphics_platform.cpp (+72/-18)
tests/mir_test_framework/stubbed_graphics_platform.h (+5/-5)
tests/mir_test_framework/stubbed_server_configuration.cpp (+0/-11)
tests/mir_test_framework/symbols-server.map.in (+1/-1)
tests/mir_test_framework/udev_recordings/laptop-keyboard-hello.evemu (+5/-81)
tests/mir_test_framework/udev_recordings/laptop-mouse-click.evemu (+136/-0)
tests/mir_test_framework/udev_recordings/laptop-mouse-motion.evemu (+153/-0)
tests/mir_test_framework/udev_recordings/laptop-mouse.ioctl (+22/-0)
tests/mir_test_framework/udev_recordings/laptop-mouse.umockdev (+128/-0)
tests/performance-tests/test_glmark2-es2-mir.cpp (+0/-9)
tests/umock-acceptance-tests/CMakeLists.txt (+1/-0)
tests/umock-acceptance-tests/test_libinput.cpp (+8/-14)
tests/unit-tests/CMakeLists.txt (+16/-35)
tests/unit-tests/android_input/CMakeLists.txt (+0/-3)
tests/unit-tests/android_input/input_reader.cpp (+0/-4814)
tests/unit-tests/android_input/sha1.cpp (+0/-46)
tests/unit-tests/android_input/test_eventhub.cpp (+0/-178)
tests/unit-tests/client/android/CMakeLists.txt (+0/-1)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+4/-46)
tests/unit-tests/client/mesa/CMakeLists.txt (+0/-1)
tests/unit-tests/client/test_buffer_vault.cpp (+15/-15)
tests/unit-tests/client/test_client_buffer_stream.cpp (+160/-20)
tests/unit-tests/client/test_client_display_conf.cpp (+2/-2)
tests/unit-tests/client/test_client_platform.cpp (+1/-1)
tests/unit-tests/client/test_probing_client_platform_factory.cpp (+1/-1)
tests/unit-tests/compositor/test_client_buffers.cpp (+53/-0)
tests/unit-tests/compositor/test_dropping_schedule.cpp (+4/-2)
tests/unit-tests/compositor/test_multi_monitor_arbiter.cpp (+36/-2)
tests/unit-tests/compositor/test_queueing_schedule.cpp (+5/-5)
tests/unit-tests/compositor/test_stream.cpp (+127/-9)
tests/unit-tests/dispatch/test_threaded_dispatcher.cpp (+17/-3)
tests/unit-tests/frontend/test_session_mediator.cpp (+156/-53)
tests/unit-tests/frontend/test_unauthorized_display_changer.cpp (+41/-18)
tests/unit-tests/graphics/CMakeLists.txt (+1/-2)
tests/unit-tests/graphics/android/CMakeLists.txt (+2/-0)
tests/unit-tests/graphics/android/test_device_detection.cpp (+85/-9)
tests/unit-tests/graphics/android/test_display.cpp (+26/-18)
tests/unit-tests/graphics/android/test_display_generic.cpp (+75/-0)
tests/unit-tests/graphics/android/test_graphics_platform.cpp (+65/-0)
tests/unit-tests/graphics/android/test_platform.cpp (+9/-4)
tests/unit-tests/graphics/android/test_server_interpreter.cpp (+51/-1)
tests/unit-tests/graphics/mesa/CMakeLists.txt (+2/-2)
tests/unit-tests/graphics/mesa/kms/CMakeLists.txt (+23/-6)
tests/unit-tests/graphics/mesa/kms/test_buffer_allocator.cpp (+10/-4)
tests/unit-tests/graphics/mesa/kms/test_cursor.cpp (+60/-31)
tests/unit-tests/graphics/mesa/kms/test_display.cpp (+31/-28)
tests/unit-tests/graphics/mesa/kms/test_display_buffer.cpp (+69/-29)
tests/unit-tests/graphics/mesa/kms/test_display_configuration.cpp (+8/-2)
tests/unit-tests/graphics/mesa/kms/test_display_generic.cpp (+82/-0)
tests/unit-tests/graphics/mesa/kms/test_display_multi_monitor.cpp (+13/-4)
tests/unit-tests/graphics/mesa/kms/test_gbm_buffer.cpp (+9/-3)
tests/unit-tests/graphics/mesa/kms/test_graphics_platform.cpp (+86/-0)
tests/unit-tests/graphics/mesa/kms/test_linux_virtual_terminal.cpp (+4/-19)
tests/unit-tests/graphics/mesa/kms/test_platform.cpp (+23/-15)
tests/unit-tests/graphics/mesa/x11/CMakeLists.txt (+23/-4)
tests/unit-tests/graphics/mesa/x11/test_display_generic.cpp (+122/-0)
tests/unit-tests/graphics/mesa/x11/test_graphics_platform.cpp (+89/-0)
tests/unit-tests/graphics/mesa/x11/test_platform.cpp (+8/-4)
tests/unit-tests/graphics/nested/test_nested_cursor.cpp (+1/-1)
tests/unit-tests/graphics/nested/test_nested_display_configuration.cpp (+35/-0)
tests/unit-tests/graphics/test_default_display_configuration_policy.cpp (+31/-61)
tests/unit-tests/graphics/test_display.cpp (+0/-265)
tests/unit-tests/graphics/test_display.h (+185/-0)
tests/unit-tests/graphics/test_egl_extensions.cpp (+40/-10)
tests/unit-tests/graphics/test_egl_sync_fence.cpp (+151/-0)
tests/unit-tests/graphics/test_graphics_platform.cpp (+0/-139)
tests/unit-tests/graphics/test_graphics_platform.h (+64/-0)
tests/unit-tests/graphics/test_overlapping_output_grouping.cpp (+5/-0)
tests/unit-tests/graphics/test_platform_prober.cpp (+14/-5)
tests/unit-tests/input/CMakeLists.txt (+8/-3)
tests/unit-tests/input/android/CMakeLists.txt (+0/-4)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+4/-0)
tests/unit-tests/input/android/test_android_input_reader_policy.cpp (+0/-79)
tests/unit-tests/input/android/test_android_pointer_controller.cpp (+0/-129)
tests/unit-tests/input/android/test_input_reader_dispatchable.cpp (+0/-51)
tests/unit-tests/input/android/test_input_translator.cpp (+0/-362)
tests/unit-tests/input/evdev/test_evdev_device_detection.cpp (+2/-2)
tests/unit-tests/input/evdev/test_libinput_device.cpp (+606/-268)
tests/unit-tests/input/test_cursor_controller.cpp (+54/-28)
tests/unit-tests/input/test_default_device.cpp (+135/-0)
tests/unit-tests/input/test_default_input_device_hub.cpp (+300/-50)
tests/unit-tests/input/test_default_input_manager.cpp (+1/-39)
tests/unit-tests/input/test_event_builders.cpp (+6/-1)
tests/unit-tests/input/test_input_platform_probing.cpp (+173/-0)
tests/unit-tests/input/test_key_repeat_dispatcher.cpp (+3/-1)
tests/unit-tests/input/test_x11_module.cpp (+81/-0)
tests/unit-tests/input/test_x11_platform.cpp (+37/-1)
tests/unit-tests/input/test_xcursor_loader.cpp (+3/-2)
tests/unit-tests/renderers/gl/test_gl_renderer.cpp (+47/-0)
tests/unit-tests/scene/CMakeLists.txt (+0/-1)
tests/unit-tests/scene/test_abstract_shell.cpp (+124/-13)
tests/unit-tests/scene/test_application_session.cpp (+38/-30)
tests/unit-tests/scene/test_basic_surface.cpp (+59/-0)
tests/unit-tests/scene/test_broadcasting_session_event_sink.cpp (+4/-4)
tests/unit-tests/scene/test_legacy_scene_change_notification.cpp (+1/-1)
tests/unit-tests/scene/test_mediating_display_changer.cpp (+70/-26)
tests/unit-tests/scene/test_prompt_session_manager.cpp (+5/-5)
tests/unit-tests/scene/test_session_manager.cpp (+8/-8)
tests/unit-tests/scene/test_surface_controller.cpp (+0/-103)
tests/unit-tests/scene/test_surface_stack.cpp (+126/-95)
tests/unit-tests/scene/test_the_session_container_implementation.cpp (+7/-7)
tests/unit-tests/test_glib_main_loop.cpp (+46/-0)
tests/unit-tests/test_mir_cookie.cpp (+1/-14)
tools/CMakeLists.txt (+0/-1)
tools/setup-partial-armhf-chroot.sh (+9/-11)
tools/valgrind_suppressions_generic (+16/-5)
tools/vera++/CMakeLists.txt (+0/-17)
tools/vera++/LICENSE_1_0.txt (+0/-23)
tools/vera++/profiles/mir_vera_profile (+0/-23)
tools/vera++/scripts/rules/DUMP.tcl (+0/-13)
tools/vera++/scripts/rules/F001.tcl (+0/-18)
tools/vera++/scripts/rules/F002.tcl (+0/-56)
tools/vera++/scripts/rules/L001.tcl (+0/-20)
tools/vera++/scripts/rules/L002.tcl (+0/-14)
tools/vera++/scripts/rules/L003.tcl (+0/-17)
tools/vera++/scripts/rules/L004.tcl (+0/-14)
tools/vera++/scripts/rules/L005.tcl (+0/-22)
tools/vera++/scripts/rules/L006.tcl (+0/-11)
tools/vera++/scripts/rules/MIR001.tcl (+0/-46)
tools/vera++/scripts/rules/T001.tcl (+0/-13)
tools/vera++/scripts/rules/T002.tcl (+0/-99)
tools/vera++/scripts/rules/T003.tcl (+0/-47)
tools/vera++/scripts/rules/T004.tcl (+0/-51)
tools/vera++/scripts/rules/T005.tcl (+0/-19)
tools/vera++/scripts/rules/T006.tcl (+0/-19)
tools/vera++/scripts/rules/T007.tcl (+0/-22)
tools/vera++/scripts/rules/T008.tcl (+0/-18)
tools/vera++/scripts/rules/T009.tcl (+0/-26)
tools/vera++/scripts/rules/T010.tcl (+0/-11)
tools/vera++/scripts/rules/T011.tcl (+0/-51)
tools/vera++/scripts/rules/T012.tcl (+0/-12)
tools/vera++/scripts/rules/T013.tcl (+0/-16)
tools/vera++/scripts/rules/T014.tcl (+0/-16)
tools/vera++/scripts/rules/T015.tcl (+0/-49)
tools/vera++/scripts/rules/T016.tcl (+0/-17)
tools/vera++/scripts/rules/T017.tcl (+0/-23)
tools/vera++/scripts/rules/T018.tcl (+0/-23)
tools/vera++/scripts/rules/T019.tcl (+0/-32)
To merge this branch: bzr merge lp:mir/0.18
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Daniel van Vugt Abstain
Alberto Aguirre (community) Abstain
Review via email: mp+279111@code.launchpad.net

Commit message

Mir release 0.18.0

Description of the change

.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Needs fixing: r3171 appears to have introduced things that should not be here:
  * Shipping both .pc files was a temporary fix for series 0.17 which we agreed would not happen in 0.18; and
  * Duplicate code accidentally introduced in surface_stack.cpp.

I think you need to revert r3171 and fix conflicts a different way.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Also needs fixing: bug 1522673

review: Needs Fixing
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

mirclient symbol stanza should not have MIR_CLIENT_unreleased, MIR_CLIENT_DETAIL_unreleased

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I'm no longer aware of anything wrong with this branch. Although there are some sanity checks I haven't got around to yet.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm, it seems the new input code in 0.18 might be causing a lot of the new test failures, not to mention is annoying to use in practice (mouse acceleration too high). Maybe we should consider fixing that up before releasing...

https://bugs.launchpad.net/mir/+bugs?field.tag=pointer-events

It's possible that simply killing the acceleration that's been introduced will solve all of them at once.

review: Needs Information
Revision history for this message
Kevin DuBois (kdub) wrote :

I guess the critical question here is whether we should block release. I'm not very familiar with this part of the code, but from chatting with Andreas on IRC today, it seems like:

The linked test failures should be using the stub input platform, so they're not related to the libinput switchover.

The pointer acceleration topic (lp: #1522295) seems like something to look into, but it hasn't affected release testing, and the pointer acceleration is also something needed by PocketDesktop.

This is a judgement call (and one from someone not very entrenched in the input code at that), but it doesn't seem like this should block the release.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> Hmm, it seems the new input code in 0.18 might be causing a lot of the new
> test failures, not to mention is annoying to use in practice (mouse
> acceleration too high). Maybe we should consider fixing that up before
> releasing...

I suggest we analyse the test failures. Those are btw not related to libinput or pointer acceleration. Since those test cases use the input-stub to simulate input events. This is the case for a few of releases. Acceleration or rather device configuration on input-stub can be tested, but the acceleration is disabled by default. The code used there just scales relative movement with a single factor which is 1.0 by default. So the cause for the failure might be somewhere else.

>
> https://bugs.launchpad.net/mir/+bugs?field.tag=pointer-events
>
> It's possible that simply killing the acceleration that's been introduced will
> solve all of them at once.

And that would reopen:
https://bugs.launchpad.net/mir/+bug/1517133

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Ok unblocking since symbol stanza has been fixed

review: Abstain
Revision history for this message
Kevin DuBois (kdub) wrote :

Blocking bug discovered during MX4 testing:
http://bugs.launchpad.net/mir/+bug/1524414

Revision history for this message
kevin gunn (kgunn72) wrote :

Complete testing on PD and windowed mode - all is good.
I'm definitely not in favor of blocking on mouse accel.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

It's just a matter of usability. Mir up to version 0.17 is nice to use with a mouse. Mir 0.18 and later however (presently) is awful. So if it motivates people to not like it, that can become an issue.

review: Abstain
Revision history for this message
Kevin DuBois (kdub) wrote :

> Blocking bug discovered during MX4 testing:
> http://bugs.launchpad.net/mir/+bug/1524414

Bug was that the driver will reset the depth buffer when adding sync fences to the stream. Reverting patch, until palatable workaround is found.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

In r3180 you forgot to rename/move egl_extensions.h back to the old location. Do we care?

Also: https://code.launchpad.net/~kdub/mir/revert-sync-factory/+merge/280293

review: Needs Information
Revision history for this message
Kevin DuBois (kdub) wrote :

I suppose it should be reprivatized for now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Please check bug 1526209. Seems to be new and only occur in Mir 0.18 and later.

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

Did a bit of checking this morning. The bug didn't seem to be reproducible on Alan's, Andreas's, Alberto's, Cemil's, and my system, once the environment variables, packages, and --vt accommodation was set up properly. After some discussion in the standup today, it seems we aren't considering 1526209 a blocker.

Revision history for this message
Kevin DuBois (kdub) wrote :

So, 1526209 doesn't seem to be a blocker in and of itself, but there is an additional blocker that the desktop session isn't starting due to confusion surrounding this option behavior changes. Branch is now blocked again

lp:mir/0.18 updated
3182. By Kevin DuBois

revert changes to vt option passing. reverts rev 3098, and fixes u8 desktop session (lp: #1526505)

Revision history for this message
Kevin DuBois (kdub) wrote :

after a fair amount of back and forth/testing, back out rev 3098 to get the u8 stack working again (fix lp: #1526505). We weren't able to reproduce lp: #1526209, but backing this out will hopefully avert/fix that problem too.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) :
review: Abstain
lp:mir/0.18 updated
3183. By Kevin DuBois

readd fix and regressions introduced in 3098

3184. By Kevin DuBois

merge in lp:~andreas-pokorny/mir/bandaid-probing-kms-when-nested, which hopefully leaves the fix for 1506707 without reintroducing the regressions

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

seems to work fine..

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '3rd_party/CMakeLists.txt'
--- 3rd_party/CMakeLists.txt 2015-06-17 05:20:42 +0000
+++ 3rd_party/CMakeLists.txt 2015-12-16 17:01:34 +0000
@@ -21,11 +21,3 @@
21 MIR_ANDROID_INPUT_COMPILE_FLAGS21 MIR_ANDROID_INPUT_COMPILE_FLAGS
22 ${MIR_ANDROID_INPUT_COMPILE_FLAGS}22 ${MIR_ANDROID_INPUT_COMPILE_FLAGS}
23 PARENT_SCOPE)23 PARENT_SCOPE)
24
25add_subdirectory(xcursor)
26list(
27 APPEND MIR_XCURSOR_INCLUDE_DIRECTORIES
28 ${CMAKE_CURRENT_SOURCE_DIR}/xcursor/
29)
30
31set(MIR_XCURSOR_INCLUDE_DIRECTORIES ${MIR_XCURSOR_INCLUDE_DIRECTORIES} PARENT_SCOPE)
3224
=== modified file '3rd_party/android-input/CMakeLists.txt'
--- 3rd_party/android-input/CMakeLists.txt 2015-02-22 07:46:25 +0000
+++ 3rd_party/android-input/CMakeLists.txt 2015-12-16 17:01:34 +0000
@@ -24,6 +24,6 @@
24 ${CMAKE_CURRENT_SOURCE_DIR}/android/hardware/libhardware_legacy/include24 ${CMAKE_CURRENT_SOURCE_DIR}/android/hardware/libhardware_legacy/include
25 ${CMAKE_CURRENT_SOURCE_DIR}/android/system/core/include25 ${CMAKE_CURRENT_SOURCE_DIR}/android/system/core/include
26 ${CMAKE_CURRENT_SOURCE_DIR}/android/system/extras/ext4_utils26 ${CMAKE_CURRENT_SOURCE_DIR}/android/system/extras/ext4_utils
27 ${CMAKE_CURRENT_SOURCE_DIR}/android/external/kernel-headers/original27 ${CMAKE_CURRENT_SOURCE_DIR}/android/external/kernel-headers
28 )28 )
29set(MIR_ANDROID_INCLUDE_DIRECTORIES ${MIR_ANDROID_INCLUDE_DIRECTORIES} PARENT_SCOPE)29set(MIR_ANDROID_INCLUDE_DIRECTORIES ${MIR_ANDROID_INCLUDE_DIRECTORIES} PARENT_SCOPE)
3030
=== modified file '3rd_party/android-input/android/CMakeLists.txt'
--- 3rd_party/android-input/android/CMakeLists.txt 2015-08-19 02:03:51 +0000
+++ 3rd_party/android-input/android/CMakeLists.txt 2015-12-16 17:01:34 +0000
@@ -1,5 +1,5 @@
1include_directories(1include_directories(
2 external/kernel-headers/original2 external/kernel-headers
3 frameworks/base/include3 frameworks/base/include
4 frameworks/native/include4 frameworks/native/include
5 hardware/libhardware_legacy/include5 hardware/libhardware_legacy/include
@@ -23,30 +23,8 @@
23 frameworks/native/libs/utils/Timers.cpp # used by KeyCharacterMap.cpp, InputReader.cpp, InputDispatcher.cpp, Looper.cpp23 frameworks/native/libs/utils/Timers.cpp # used by KeyCharacterMap.cpp, InputReader.cpp, InputDispatcher.cpp, Looper.cpp
24)24)
2525
26add_library(android-input-platform OBJECT
27 frameworks/base/services/input/EventHub.cpp
28 frameworks/base/services/input/InputDevice.cpp
29 frameworks/base/services/input/InputListener.cpp
30 frameworks/base/services/input/InputReader.cpp
31 frameworks/base/services/input/GenericKeyMap.cpp
32 frameworks/base/services/input/Keyboard.cpp
33 frameworks/base/services/input/KeyCharacterMap.cpp
34 frameworks/base/services/input/KeyLayoutMap.cpp
35 frameworks/native/libs/utils/Tokenizer.cpp
36 frameworks/base/services/input/VelocityControl.cpp
37 frameworks/base/services/input/VelocityTracker.cpp
38 frameworks/base/services/input/VirtualKeyMap.cpp
39 frameworks/native/libs/utils/FileMap.cpp
40)
41
42set_target_properties(26set_target_properties(
43 android-input-common27 android-input-common
44 PROPERTIES28 PROPERTIES
45 COMPILE_FLAGS ${ANDROID_INPUT_COMPILE_FLAGS}29 COMPILE_FLAGS ${ANDROID_INPUT_COMPILE_FLAGS}
46)30)
47
48set_target_properties(
49 android-input-platform
50 PROPERTIES
51 COMPILE_FLAGS ${ANDROID_INPUT_COMPILE_FLAGS}
52)
5331
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/InputDevice.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/InputDevice.h 2013-05-03 16:38:07 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/InputDevice.h 1970-01-01 00:00:00 +0000
@@ -1,156 +0,0 @@
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_INPUT_DEVICE_H
18#define _ANDROIDFW_INPUT_DEVICE_H
19
20
21#include <androidfw/Input.h>
22#include <androidfw/KeyCharacterMap.h>
23
24namespace android {
25
26/*
27 * Identifies a device.
28 */
29struct InputDeviceIdentifier {
30 inline InputDeviceIdentifier() :
31 bus(0), vendor(0), product(0), version(0) {
32 }
33
34 // Information provided by the kernel.
35 String8 name;
36 String8 location;
37 String8 uniqueId;
38 uint16_t bus;
39 uint16_t vendor;
40 uint16_t product;
41 uint16_t version;
42
43 // A composite input device descriptor string that uniquely identifies the device
44 // even across reboots or reconnections. The value of this field is used by
45 // upper layers of the input system to associate settings with individual devices.
46 // It is hashed from whatever kernel provided information is available.
47 // Ideally, the way this value is computed should not change between Android releases
48 // because that would invalidate persistent settings that rely on it.
49 String8 descriptor;
50};
51
52/*
53 * Describes the characteristics and capabilities of an input device.
54 */
55class InputDeviceInfo {
56public:
57 InputDeviceInfo();
58 InputDeviceInfo(const InputDeviceInfo& other);
59 ~InputDeviceInfo();
60
61 struct MotionRange {
62 int32_t axis;
63 uint32_t source;
64 float min;
65 float max;
66 float flat;
67 float fuzz;
68 };
69
70 void initialize(int32_t id, int32_t generation, const InputDeviceIdentifier& identifier,
71 const String8& alias, bool isExternal);
72
73 inline int32_t getId() const { return mId; }
74 inline int32_t getGeneration() const { return mGeneration; }
75 inline const InputDeviceIdentifier& getIdentifier() const { return mIdentifier; }
76 inline const String8& getAlias() const { return mAlias; }
77 inline const String8& getDisplayName() const {
78 return isEmpty(mAlias) ? mIdentifier.name : mAlias;
79 }
80 inline bool isExternal() const { return mIsExternal; }
81 inline uint32_t getSources() const { return mSources; }
82
83 const MotionRange* getMotionRange(int32_t axis, uint32_t source) const;
84
85 void addSource(uint32_t source);
86 void addMotionRange(int32_t axis, uint32_t source,
87 float min, float max, float flat, float fuzz);
88 void addMotionRange(const MotionRange& range);
89
90 inline void setKeyboardType(int32_t keyboardType) { mKeyboardType = keyboardType; }
91 inline int32_t getKeyboardType() const { return mKeyboardType; }
92
93 inline void setKeyCharacterMap(const sp<KeyCharacterMap>& value) {
94 mKeyCharacterMap = value;
95 }
96
97 inline sp<KeyCharacterMap> getKeyCharacterMap() const {
98 return mKeyCharacterMap;
99 }
100
101 inline void setVibrator(bool hasVibrator) { mHasVibrator = hasVibrator; }
102 inline bool hasVibrator() const { return mHasVibrator; }
103
104 inline const Vector<MotionRange>& getMotionRanges() const {
105 return mMotionRanges;
106 }
107
108private:
109 int32_t mId;
110 int32_t mGeneration;
111 InputDeviceIdentifier mIdentifier;
112 String8 mAlias;
113 bool mIsExternal;
114 uint32_t mSources;
115 int32_t mKeyboardType;
116 sp<KeyCharacterMap> mKeyCharacterMap;
117 bool mHasVibrator;
118
119 Vector<MotionRange> mMotionRanges;
120};
121
122/* Types of input device configuration files. */
123enum InputDeviceConfigurationFileType {
124 INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION = 0, /* .idc file */
125 INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_LAYOUT = 1, /* .kl file */
126 INPUT_DEVICE_CONFIGURATION_FILE_TYPE_KEY_CHARACTER_MAP = 2 /* .kcm file */
127};
128
129/*
130 * Gets the path of an input device configuration file, if one is available.
131 * Considers both system provided and user installed configuration files.
132 *
133 * The device identifier is used to construct several default configuration file
134 * names to try based on the device name, vendor, product, and version.
135 *
136 * Returns an empty string if not found.
137 */
138extern String8 getInputDeviceConfigurationFilePathByDeviceIdentifier(
139 const InputDeviceIdentifier& deviceIdentifier,
140 InputDeviceConfigurationFileType type);
141
142/*
143 * Gets the path of an input device configuration file, if one is available.
144 * Considers both system provided and user installed configuration files.
145 *
146 * The name is case-sensitive and is used to construct the filename to resolve.
147 * All characters except 'a'-'z', 'A'-'Z', '0'-'9', '-', and '_' are replaced by underscores.
148 *
149 * Returns an empty string if not found.
150 */
151extern String8 getInputDeviceConfigurationFilePathByName(
152 const String8& name, InputDeviceConfigurationFileType type);
153
154} // namespace android
155
156#endif // _ANDROIDFW_INPUT_DEVICE_H
1570
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/KeyCharacterMap.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/KeyCharacterMap.h 2015-04-28 07:54:10 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/KeyCharacterMap.h 1970-01-01 00:00:00 +0000
@@ -1,255 +0,0 @@
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_KEY_CHARACTER_MAP_H
18#define _ANDROIDFW_KEY_CHARACTER_MAP_H
19
20
21#include <stdint.h>
22
23#if HAVE_ANDROID_OS
24#include <binder/IBinder.h>
25#endif
26
27#include <androidfw/Input.h>
28#include <std/Errors.h>
29#include <std/KeyedVector.h>
30#include <std/Tokenizer.h>
31#include <std/String8.h>
32#include <std/RefBase.h>
33
34namespace android {
35
36/**
37 * Describes a mapping from Android key codes to characters.
38 * Also specifies other functions of the keyboard such as the keyboard type
39 * and key modifier semantics.
40 *
41 * This object is immutable after it has been loaded.
42 */
43class KeyCharacterMap : public RefBase {
44public:
45 enum KeyboardType {
46 KEYBOARD_TYPE_UNKNOWN = 0,
47 KEYBOARD_TYPE_NUMERIC = 1,
48 KEYBOARD_TYPE_PREDICTIVE = 2,
49 KEYBOARD_TYPE_ALPHA = 3,
50 KEYBOARD_TYPE_FULL = 4,
51 KEYBOARD_TYPE_SPECIAL_FUNCTION = 5,
52 KEYBOARD_TYPE_OVERLAY = 6
53 };
54
55 enum Format {
56 // Base keyboard layout, may contain device-specific options, such as "type" declaration.
57 FORMAT_BASE = 0,
58 // Overlay keyboard layout, more restrictive, may be published by applications,
59 // cannot override device-specific options.
60 FORMAT_OVERLAY = 1,
61 // Either base or overlay layout ok.
62 FORMAT_ANY = 2
63 };
64
65 // Substitute key code and meta state for fallback action.
66 struct FallbackAction {
67 int32_t keyCode;
68 int32_t metaState;
69 };
70
71 /* Loads a key character map from a file. */
72 static status_t load(const String8& filename, Format format, sp<KeyCharacterMap>* outMap);
73
74 /* Loads a key character map from its string contents. */
75 static status_t loadContents(const String8& filename,
76 const char* contents, Format format, sp<KeyCharacterMap>* outMap);
77
78 /* Combines a base key character map and an overlay. */
79 static sp<KeyCharacterMap> combine(const sp<KeyCharacterMap>& base,
80 const sp<KeyCharacterMap>& overlay);
81
82 /* Returns an empty key character map. */
83 static sp<KeyCharacterMap> empty();
84
85 /* Gets the keyboard type. */
86 int32_t getKeyboardType() const;
87
88 /* Gets the primary character for this key as in the label physically printed on it.
89 * Returns 0 if none (eg. for non-printing keys). */
90 char16_t getDisplayLabel(int32_t keyCode) const;
91
92 /* Gets the Unicode character for the number or symbol generated by the key
93 * when the keyboard is used as a dialing pad.
94 * Returns 0 if no number or symbol is generated.
95 */
96 char16_t getNumber(int32_t keyCode) const;
97
98 /* Gets the Unicode character generated by the key and meta key modifiers.
99 * Returns 0 if no character is generated.
100 */
101 char16_t getCharacter(int32_t keyCode, int32_t metaState) const;
102
103 /* Gets the fallback action to use by default if the application does not
104 * handle the specified key.
105 * Returns true if an action was available, false if none.
106 */
107 bool getFallbackAction(int32_t keyCode, int32_t metaState,
108 FallbackAction* outFallbackAction) const;
109
110 /* Gets the first matching Unicode character that can be generated by the key,
111 * preferring the one with the specified meta key modifiers.
112 * Returns 0 if no matching character is generated.
113 */
114 char16_t getMatch(int32_t keyCode, const char16_t* chars,
115 size_t numChars, int32_t metaState) const;
116
117 /* Gets a sequence of key events that could plausibly generate the specified
118 * character sequence. Returns false if some of the characters cannot be generated.
119 */
120 bool getEvents(int32_t deviceId, const char16_t* chars, size_t numChars,
121 Vector<KeyEvent>& outEvents) const;
122
123 /* Maps a scan code and usage code to a key code, in case this key map overrides
124 * the mapping in some way. */
125 status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t* outKeyCode) const;
126
127#if HAVE_ANDROID_OS
128 /* Reads a key map from a parcel. */
129 static sp<KeyCharacterMap> readFromParcel(Parcel* parcel);
130
131 /* Writes a key map to a parcel. */
132 void writeToParcel(Parcel* parcel) const;
133#endif
134
135protected:
136 virtual ~KeyCharacterMap();
137
138private:
139 struct Behavior {
140 Behavior();
141 Behavior(const Behavior& other);
142
143 /* The next behavior in the list, or NULL if none. */
144 Behavior* next;
145
146 /* The meta key modifiers for this behavior. */
147 int32_t metaState;
148
149 /* The character to insert. */
150 char16_t character;
151
152 /* The fallback keycode if the key is not handled. */
153 int32_t fallbackKeyCode;
154 };
155
156 struct Key {
157 Key();
158 Key(const Key& other);
159 ~Key();
160
161 /* The single character label printed on the key, or 0 if none. */
162 char16_t label;
163
164 /* The number or symbol character generated by the key, or 0 if none. */
165 char16_t number;
166
167 /* The list of key behaviors sorted from most specific to least specific
168 * meta key binding. */
169 Behavior* firstBehavior;
170 };
171
172 class Parser {
173 enum State {
174 STATE_TOP = 0,
175 STATE_KEY = 1
176 };
177
178 enum {
179 PROPERTY_LABEL = 1,
180 PROPERTY_NUMBER = 2,
181 PROPERTY_META = 3
182 };
183
184 struct Property {
185 inline Property(int32_t property = 0, int32_t metaState = 0) :
186 property(property), metaState(metaState) { }
187
188 int32_t property;
189 int32_t metaState;
190 };
191
192 KeyCharacterMap* mMap;
193 Tokenizer* mTokenizer;
194 Format mFormat;
195 State mState;
196 int32_t mKeyCode;
197
198 public:
199 Parser(KeyCharacterMap* map, Tokenizer* tokenizer, Format format);
200 ~Parser();
201 status_t parse();
202
203 private:
204 status_t parseType();
205 status_t parseMap();
206 status_t parseMapKey();
207 status_t parseKey();
208 status_t parseKeyProperty();
209 status_t finishKey(Key* key);
210 status_t parseModifier(const String8& token, int32_t* outMetaState);
211 status_t parseCharacterLiteral(char16_t* outCharacter);
212 };
213
214 KeyedVector<int32_t, Key*> mKeys;
215 int mType;
216
217 KeyedVector<int32_t, int32_t> mKeysByScanCode;
218 KeyedVector<int32_t, int32_t> mKeysByUsageCode;
219
220 KeyCharacterMap();
221 KeyCharacterMap(const KeyCharacterMap& other);
222
223 bool getKey(int32_t keyCode, const Key** outKey) const;
224 bool getKeyBehavior(int32_t keyCode, int32_t metaState,
225 const Key** outKey, const Behavior** outBehavior) const;
226 static bool matchesMetaState(int32_t eventMetaState, int32_t behaviorMetaState);
227
228 bool findKey(char16_t ch, int32_t* outKeyCode, int32_t* outMetaState) const;
229
230 static status_t load(Tokenizer* tokenizer, Format format, sp<KeyCharacterMap>* outMap);
231
232 static void addKey(Vector<KeyEvent>& outEvents,
233 int32_t deviceId, int32_t keyCode, int32_t metaState, bool down, std::chrono::nanoseconds time);
234 static void addMetaKeys(Vector<KeyEvent>& outEvents,
235 int32_t deviceId, int32_t metaState, bool down, std::chrono::nanoseconds time,
236 int32_t* currentMetaState);
237 static bool addSingleEphemeralMetaKey(Vector<KeyEvent>& outEvents,
238 int32_t deviceId, int32_t metaState, bool down, std::chrono::nanoseconds time,
239 int32_t keyCode, int32_t keyMetaState,
240 int32_t* currentMetaState);
241 static void addDoubleEphemeralMetaKey(Vector<KeyEvent>& outEvents,
242 int32_t deviceId, int32_t metaState, bool down, std::chrono::nanoseconds time,
243 int32_t leftKeyCode, int32_t leftKeyMetaState,
244 int32_t rightKeyCode, int32_t rightKeyMetaState,
245 int32_t eitherKeyMetaState,
246 int32_t* currentMetaState);
247 static void addLockedMetaKey(Vector<KeyEvent>& outEvents,
248 int32_t deviceId, int32_t metaState, std::chrono::nanoseconds time,
249 int32_t keyCode, int32_t keyMetaState,
250 int32_t* currentMetaState);
251};
252
253} // namespace android
254
255#endif // _ANDROIDFW_KEY_CHARACTER_MAP_H
2560
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/KeyLayoutMap.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/KeyLayoutMap.h 2013-05-03 16:38:07 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/KeyLayoutMap.h 1970-01-01 00:00:00 +0000
@@ -1,114 +0,0 @@
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_KEY_LAYOUT_MAP_H
18#define _ANDROIDFW_KEY_LAYOUT_MAP_H
19
20
21#include <stdint.h>
22#include <std/Errors.h>
23#include <std/KeyedVector.h>
24#include <std/Tokenizer.h>
25#include <std/RefBase.h>
26
27namespace android {
28
29struct AxisInfo {
30 enum Mode {
31 // Axis value is reported directly.
32 MODE_NORMAL = 0,
33 // Axis value should be inverted before reporting.
34 MODE_INVERT = 1,
35 // Axis value should be split into two axes
36 MODE_SPLIT = 2
37 };
38
39 // Axis mode.
40 Mode mode;
41
42 // Axis id.
43 // When split, this is the axis used for values smaller than the split position.
44 int32_t axis;
45
46 // When split, this is the axis used for values after higher than the split position.
47 int32_t highAxis;
48
49 // The split value, or 0 if not split.
50 int32_t splitValue;
51
52 // The flat value, or -1 if none.
53 int32_t flatOverride;
54
55 AxisInfo() : mode(MODE_NORMAL), axis(-1), highAxis(-1), splitValue(0), flatOverride(-1) {
56 }
57};
58
59/**
60 * Describes a mapping from keyboard scan codes and joystick axes to Android key codes and axes.
61 *
62 * This object is immutable after it has been loaded.
63 */
64class KeyLayoutMap : public RefBase {
65public:
66 static status_t load(const String8& filename, sp<KeyLayoutMap>* outMap);
67 // <mir changes>
68 static status_t load(const String8& filename, const char* contents, sp<KeyLayoutMap>* outMap);
69 // </mir changes>
70
71 status_t mapKey(int32_t scanCode, int32_t usageCode,
72 int32_t* outKeyCode, uint32_t* outFlags) const;
73 status_t findScanCodesForKey(int32_t keyCode, Vector<int32_t>* outScanCodes) const;
74
75 status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const;
76
77protected:
78 virtual ~KeyLayoutMap();
79
80private:
81 // <mir changes>
82 static status_t load(Tokenizer* tokenizer, sp<KeyLayoutMap>* outMap);
83 // </mir changes>
84 struct Key {
85 int32_t keyCode;
86 uint32_t flags;
87 };
88
89 KeyedVector<int32_t, Key> mKeysByScanCode;
90 KeyedVector<int32_t, Key> mKeysByUsageCode;
91 KeyedVector<int32_t, AxisInfo> mAxes;
92
93 KeyLayoutMap();
94
95 const Key* getKey(int32_t scanCode, int32_t usageCode) const;
96
97 class Parser {
98 KeyLayoutMap* mMap;
99 Tokenizer* mTokenizer;
100
101 public:
102 Parser(KeyLayoutMap* map, Tokenizer* tokenizer);
103 ~Parser();
104 status_t parse();
105
106 private:
107 status_t parseKey();
108 status_t parseAxis();
109 };
110};
111
112} // namespace android
113
114#endif // _ANDROIDFW_KEY_LAYOUT_MAP_H
1150
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/Keyboard.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/Keyboard.h 2013-05-03 16:38:07 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/Keyboard.h 1970-01-01 00:00:00 +0000
@@ -1,125 +0,0 @@
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_KEYBOARD_H
18#define _ANDROIDFW_KEYBOARD_H
19
20
21#include <androidfw/Input.h>
22#include <androidfw/InputDevice.h>
23#include <std/Errors.h>
24#include <std/String8.h>
25#include <std/PropertyMap.h>
26
27namespace android {
28
29enum {
30 /* Device id of the built in keyboard. */
31 DEVICE_ID_BUILT_IN_KEYBOARD = 0,
32
33 /* Device id of a generic virtual keyboard with a full layout that can be used
34 * to synthesize key events. */
35 DEVICE_ID_VIRTUAL_KEYBOARD = -1
36};
37
38class KeyLayoutMap;
39class KeyCharacterMap;
40
41/**
42 * Loads the key layout map and key character map for a keyboard device.
43 */
44class KeyMap {
45public:
46 String8 keyLayoutFile;
47 sp<KeyLayoutMap> keyLayoutMap;
48
49 String8 keyCharacterMapFile;
50 sp<KeyCharacterMap> keyCharacterMap;
51
52 KeyMap();
53 ~KeyMap();
54
55 status_t load(const InputDeviceIdentifier& deviceIdenfier,
56 const PropertyMap* deviceConfiguration);
57
58 // <mir changes>
59 status_t loadGenericMaps();
60 // </mir changes>
61
62 inline bool haveKeyLayout() const {
63 return !isEmpty(keyLayoutFile);
64 }
65
66 inline bool haveKeyCharacterMap() const {
67 return !isEmpty(keyCharacterMapFile);
68 }
69
70 inline bool isComplete() const {
71 return haveKeyLayout() && haveKeyCharacterMap();
72 }
73
74private:
75 bool probeKeyMap(const InputDeviceIdentifier& deviceIdentifier, const String8& name);
76 status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const String8& name);
77 status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier,
78 const String8& name);
79 String8 getPath(const InputDeviceIdentifier& deviceIdentifier,
80 const String8& name, InputDeviceConfigurationFileType type);
81};
82
83/**
84 * Returns true if the keyboard is eligible for use as a built-in keyboard.
85 */
86extern bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentifier,
87 const PropertyMap* deviceConfiguration, const KeyMap* keyMap);
88
89/**
90 * Gets a key code by its short form label, eg. "HOME".
91 * Returns 0 if unknown.
92 */
93extern int32_t getKeyCodeByLabel(const char* label);
94
95/**
96 * Gets a key flag by its short form label, eg. "WAKE".
97 * Returns 0 if unknown.
98 */
99extern uint32_t getKeyFlagByLabel(const char* label);
100
101/**
102 * Gets a axis by its short form label, eg. "X".
103 * Returns -1 if unknown.
104 */
105extern int32_t getAxisByLabel(const char* label);
106
107/**
108 * Gets a axis label by its id.
109 * Returns NULL if unknown.
110 */
111extern const char* getAxisLabel(int32_t axisId);
112
113/**
114 * Updates a meta state field when a key is pressed or released.
115 */
116extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
117
118/**
119 * Returns true if a key is a meta key like ALT or CAPS_LOCK.
120 */
121extern bool isMetaKey(int32_t keyCode);
122
123} // namespace android
124
125#endif // _ANDROIDFW_KEYBOARD_H
1260
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/KeycodeLabels.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/KeycodeLabels.h 2013-05-03 16:38:07 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/KeycodeLabels.h 1970-01-01 00:00:00 +0000
@@ -1,320 +0,0 @@
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_KEYCODE_LABELS_H
18#define _ANDROIDFW_KEYCODE_LABELS_H
19
20
21#include <android/keycodes.h>
22
23struct KeycodeLabel {
24 const char *literal;
25 int value;
26};
27
28static const KeycodeLabel KEYCODES[] = {
29 { "SOFT_LEFT", 1 },
30 { "SOFT_RIGHT", 2 },
31 { "HOME", 3 },
32 { "BACK", 4 },
33 { "CALL", 5 },
34 { "ENDCALL", 6 },
35 { "0", 7 },
36 { "1", 8 },
37 { "2", 9 },
38 { "3", 10 },
39 { "4", 11 },
40 { "5", 12 },
41 { "6", 13 },
42 { "7", 14 },
43 { "8", 15 },
44 { "9", 16 },
45 { "STAR", 17 },
46 { "POUND", 18 },
47 { "DPAD_UP", 19 },
48 { "DPAD_DOWN", 20 },
49 { "DPAD_LEFT", 21 },
50 { "DPAD_RIGHT", 22 },
51 { "DPAD_CENTER", 23 },
52 { "VOLUME_UP", 24 },
53 { "VOLUME_DOWN", 25 },
54 { "POWER", 26 },
55 { "CAMERA", 27 },
56 { "CLEAR", 28 },
57 { "A", 29 },
58 { "B", 30 },
59 { "C", 31 },
60 { "D", 32 },
61 { "E", 33 },
62 { "F", 34 },
63 { "G", 35 },
64 { "H", 36 },
65 { "I", 37 },
66 { "J", 38 },
67 { "K", 39 },
68 { "L", 40 },
69 { "M", 41 },
70 { "N", 42 },
71 { "O", 43 },
72 { "P", 44 },
73 { "Q", 45 },
74 { "R", 46 },
75 { "S", 47 },
76 { "T", 48 },
77 { "U", 49 },
78 { "V", 50 },
79 { "W", 51 },
80 { "X", 52 },
81 { "Y", 53 },
82 { "Z", 54 },
83 { "COMMA", 55 },
84 { "PERIOD", 56 },
85 { "ALT_LEFT", 57 },
86 { "ALT_RIGHT", 58 },
87 { "SHIFT_LEFT", 59 },
88 { "SHIFT_RIGHT", 60 },
89 { "TAB", 61 },
90 { "SPACE", 62 },
91 { "SYM", 63 },
92 { "EXPLORER", 64 },
93 { "ENVELOPE", 65 },
94 { "ENTER", 66 },
95 { "DEL", 67 },
96 { "GRAVE", 68 },
97 { "MINUS", 69 },
98 { "EQUALS", 70 },
99 { "LEFT_BRACKET", 71 },
100 { "RIGHT_BRACKET", 72 },
101 { "BACKSLASH", 73 },
102 { "SEMICOLON", 74 },
103 { "APOSTROPHE", 75 },
104 { "SLASH", 76 },
105 { "AT", 77 },
106 { "NUM", 78 },
107 { "HEADSETHOOK", 79 },
108 { "FOCUS", 80 },
109 { "PLUS", 81 },
110 { "MENU", 82 },
111 { "NOTIFICATION", 83 },
112 { "SEARCH", 84 },
113 { "MEDIA_PLAY_PAUSE", 85 },
114 { "MEDIA_STOP", 86 },
115 { "MEDIA_NEXT", 87 },
116 { "MEDIA_PREVIOUS", 88 },
117 { "MEDIA_REWIND", 89 },
118 { "MEDIA_FAST_FORWARD", 90 },
119 { "MUTE", 91 },
120 { "PAGE_UP", 92 },
121 { "PAGE_DOWN", 93 },
122 { "PICTSYMBOLS", 94 },
123 { "SWITCH_CHARSET", 95 },
124 { "BUTTON_A", 96 },
125 { "BUTTON_B", 97 },
126 { "BUTTON_C", 98 },
127 { "BUTTON_X", 99 },
128 { "BUTTON_Y", 100 },
129 { "BUTTON_Z", 101 },
130 { "BUTTON_L1", 102 },
131 { "BUTTON_R1", 103 },
132 { "BUTTON_L2", 104 },
133 { "BUTTON_R2", 105 },
134 { "BUTTON_THUMBL", 106 },
135 { "BUTTON_THUMBR", 107 },
136 { "BUTTON_START", 108 },
137 { "BUTTON_SELECT", 109 },
138 { "BUTTON_MODE", 110 },
139 { "ESCAPE", 111 },
140 { "FORWARD_DEL", 112 },
141 { "CTRL_LEFT", 113 },
142 { "CTRL_RIGHT", 114 },
143 { "CAPS_LOCK", 115 },
144 { "SCROLL_LOCK", 116 },
145 { "META_LEFT", 117 },
146 { "META_RIGHT", 118 },
147 { "FUNCTION", 119 },
148 { "SYSRQ", 120 },
149 { "BREAK", 121 },
150 { "MOVE_HOME", 122 },
151 { "MOVE_END", 123 },
152 { "INSERT", 124 },
153 { "FORWARD", 125 },
154 { "MEDIA_PLAY", 126 },
155 { "MEDIA_PAUSE", 127 },
156 { "MEDIA_CLOSE", 128 },
157 { "MEDIA_EJECT", 129 },
158 { "MEDIA_RECORD", 130 },
159 { "F1", 131 },
160 { "F2", 132 },
161 { "F3", 133 },
162 { "F4", 134 },
163 { "F5", 135 },
164 { "F6", 136 },
165 { "F7", 137 },
166 { "F8", 138 },
167 { "F9", 139 },
168 { "F10", 140 },
169 { "F11", 141 },
170 { "F12", 142 },
171 { "NUM_LOCK", 143 },
172 { "NUMPAD_0", 144 },
173 { "NUMPAD_1", 145 },
174 { "NUMPAD_2", 146 },
175 { "NUMPAD_3", 147 },
176 { "NUMPAD_4", 148 },
177 { "NUMPAD_5", 149 },
178 { "NUMPAD_6", 150 },
179 { "NUMPAD_7", 151 },
180 { "NUMPAD_8", 152 },
181 { "NUMPAD_9", 153 },
182 { "NUMPAD_DIVIDE", 154 },
183 { "NUMPAD_MULTIPLY", 155 },
184 { "NUMPAD_SUBTRACT", 156 },
185 { "NUMPAD_ADD", 157 },
186 { "NUMPAD_DOT", 158 },
187 { "NUMPAD_COMMA", 159 },
188 { "NUMPAD_ENTER", 160 },
189 { "NUMPAD_EQUALS", 161 },
190 { "NUMPAD_LEFT_PAREN", 162 },
191 { "NUMPAD_RIGHT_PAREN", 163 },
192 { "VOLUME_MUTE", 164 },
193 { "INFO", 165 },
194 { "CHANNEL_UP", 166 },
195 { "CHANNEL_DOWN", 167 },
196 { "ZOOM_IN", 168 },
197 { "ZOOM_OUT", 169 },
198 { "TV", 170 },
199 { "WINDOW", 171 },
200 { "GUIDE", 172 },
201 { "DVR", 173 },
202 { "BOOKMARK", 174 },
203 { "CAPTIONS", 175 },
204 { "SETTINGS", 176 },
205 { "TV_POWER", 177 },
206 { "TV_INPUT", 178 },
207 { "STB_POWER", 179 },
208 { "STB_INPUT", 180 },
209 { "AVR_POWER", 181 },
210 { "AVR_INPUT", 182 },
211 { "PROG_RED", 183 },
212 { "PROG_GREEN", 184 },
213 { "PROG_YELLOW", 185 },
214 { "PROG_BLUE", 186 },
215 { "APP_SWITCH", 187 },
216 { "BUTTON_1", 188 },
217 { "BUTTON_2", 189 },
218 { "BUTTON_3", 190 },
219 { "BUTTON_4", 191 },
220 { "BUTTON_5", 192 },
221 { "BUTTON_6", 193 },
222 { "BUTTON_7", 194 },
223 { "BUTTON_8", 195 },
224 { "BUTTON_9", 196 },
225 { "BUTTON_10", 197 },
226 { "BUTTON_11", 198 },
227 { "BUTTON_12", 199 },
228 { "BUTTON_13", 200 },
229 { "BUTTON_14", 201 },
230 { "BUTTON_15", 202 },
231 { "BUTTON_16", 203 },
232 { "LANGUAGE_SWITCH", 204 },
233 { "MANNER_MODE", 205 },
234 { "3D_MODE", 206 },
235 { "CONTACTS", 207 },
236 { "CALENDAR", 208 },
237 { "MUSIC", 209 },
238 { "CALCULATOR", 210 },
239 { "ZENKAKU_HANKAKU", 211 },
240 { "EISU", 212 },
241 { "MUHENKAN", 213 },
242 { "HENKAN", 214 },
243 { "KATAKANA_HIRAGANA", 215 },
244 { "YEN", 216 },
245 { "RO", 217 },
246 { "KANA", 218 },
247 { "ASSIST", 219 },
248
249 // NOTE: If you add a new keycode here you must also add it to several other files.
250 // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
251
252 { NULL, 0 }
253};
254
255// NOTE: If you edit these flags, also edit policy flags in Input.h.
256static const KeycodeLabel FLAGS[] = {
257 { "WAKE", 0x00000001 },
258 { "WAKE_DROPPED", 0x00000002 },
259 { "SHIFT", 0x00000004 },
260 { "CAPS_LOCK", 0x00000008 },
261 { "ALT", 0x00000010 },
262 { "ALT_GR", 0x00000020 },
263 { "MENU", 0x00000040 },
264 { "LAUNCHER", 0x00000080 },
265 { "VIRTUAL", 0x00000100 },
266 { "FUNCTION", 0x00000200 },
267 { NULL, 0 }
268};
269
270static const KeycodeLabel AXES[] = {
271 { "X", 0 },
272 { "Y", 1 },
273 { "PRESSURE", 2 },
274 { "SIZE", 3 },
275 { "TOUCH_MAJOR", 4 },
276 { "TOUCH_MINOR", 5 },
277 { "TOOL_MAJOR", 6 },
278 { "TOOL_MINOR", 7 },
279 { "ORIENTATION", 8 },
280 { "VSCROLL", 9 },
281 { "HSCROLL", 10 },
282 { "Z", 11 },
283 { "RX", 12 },
284 { "RY", 13 },
285 { "RZ", 14 },
286 { "HAT_X", 15 },
287 { "HAT_Y", 16 },
288 { "LTRIGGER", 17 },
289 { "RTRIGGER", 18 },
290 { "THROTTLE", 19 },
291 { "RUDDER", 20 },
292 { "WHEEL", 21 },
293 { "GAS", 22 },
294 { "BRAKE", 23 },
295 { "DISTANCE", 24 },
296 { "TILT", 25 },
297 { "GENERIC_1", 32 },
298 { "GENERIC_2", 33 },
299 { "GENERIC_3", 34 },
300 { "GENERIC_4", 35 },
301 { "GENERIC_5", 36 },
302 { "GENERIC_6", 37 },
303 { "GENERIC_7", 38 },
304 { "GENERIC_8", 39 },
305 { "GENERIC_9", 40 },
306 { "GENERIC_10", 41 },
307 { "GENERIC_11", 42 },
308 { "GENERIC_12", 43 },
309 { "GENERIC_13", 44 },
310 { "GENERIC_14", 45 },
311 { "GENERIC_15", 46 },
312 { "GENERIC_16", 47 },
313
314 // NOTE: If you add a new axis here you must also add it to several other files.
315 // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
316
317 { NULL, -1 }
318};
319
320#endif // _ANDROIDFW_KEYCODE_LABELS_H
3210
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h 2015-04-28 07:54:10 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityControl.h 1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_VELOCITY_CONTROL_H
18#define _ANDROIDFW_VELOCITY_CONTROL_H
19
20
21#include <androidfw/Input.h>
22#include <androidfw/IntSet.h>
23#include <androidfw/VelocityTracker.h>
24#include <std/Timers.h>
25
26namespace android {
27
28/*
29 * Specifies parameters that govern pointer or wheel acceleration.
30 */
31struct VelocityControlParameters {
32 // A scale factor that is multiplied with the raw velocity deltas
33 // prior to applying any other velocity control factors. The scale
34 // factor should be used to adapt the input device resolution
35 // (eg. counts per inch) to the output device resolution (eg. pixels per inch).
36 //
37 // Must be a positive value.
38 // Default is 1.0 (no scaling).
39 float scale;
40
41 // The scaled speed at which acceleration begins to be applied.
42 // This value establishes the upper bound of a low speed regime for
43 // small precise motions that are performed without any acceleration.
44 //
45 // Must be a non-negative value.
46 // Default is 0.0 (no low threshold).
47 float lowThreshold;
48
49 // The scaled speed at which maximum acceleration is applied.
50 // The difference between highThreshold and lowThreshold controls
51 // the range of speeds over which the acceleration factor is interpolated.
52 // The wider the range, the smoother the acceleration.
53 //
54 // Must be a non-negative value greater than or equal to lowThreshold.
55 // Default is 0.0 (no high threshold).
56 float highThreshold;
57
58 // The acceleration factor.
59 // When the speed is above the low speed threshold, the velocity will scaled
60 // by an interpolated value between 1.0 and this amount.
61 //
62 // Must be a positive greater than or equal to 1.0.
63 // Default is 1.0 (no acceleration).
64 float acceleration;
65
66 VelocityControlParameters() :
67 scale(1.0f), lowThreshold(0.0f), highThreshold(0.0f), acceleration(1.0f) {
68 }
69
70 VelocityControlParameters(float scale, float lowThreshold,
71 float highThreshold, float acceleration) :
72 scale(scale), lowThreshold(lowThreshold),
73 highThreshold(highThreshold), acceleration(acceleration) {
74 }
75};
76
77/*
78 * Implements mouse pointer and wheel speed control and acceleration.
79 */
80class VelocityControl {
81public:
82 VelocityControl();
83
84 /* Sets the various parameters. */
85 void setParameters(const VelocityControlParameters& parameters);
86
87 /* Resets the current movement counters to zero.
88 * This has the effect of nullifying any acceleration. */
89 void reset();
90
91 /* Translates a raw movement delta into an appropriately
92 * scaled / accelerated delta based on the current velocity. */
93 void move(std::chrono::nanoseconds eventTime, float* deltaX, float* deltaY);
94
95private:
96 // If no movements are received within this amount of time,
97 // we assume the movement has stopped and reset the movement counters.
98 static constexpr const std::chrono::nanoseconds STOP_TIME = std::chrono::nanoseconds(500 * 1000000); // 500 ms
99
100 VelocityControlParameters mParameters;
101
102 std::chrono::nanoseconds mLastMovementTime;
103 VelocityTracker::Position mRawPosition;
104 VelocityTracker mVelocityTracker;
105 IntSet mIds;
106};
107
108} // namespace android
109
110#endif // _ANDROIDFW_VELOCITY_CONTROL_H
1110
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h 2015-04-28 07:54:10 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/VelocityTracker.h 1970-01-01 00:00:00 +0000
@@ -1,272 +0,0 @@
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_VELOCITY_TRACKER_H
18#define _ANDROIDFW_VELOCITY_TRACKER_H
19
20#include <androidfw/Input.h>
21#include <androidfw/IntSet.h>
22#include <std/Timers.h>
23
24// C++ std lib
25#include <unordered_map>
26
27namespace android {
28
29class VelocityTrackerStrategy;
30
31/*
32 * Calculates the velocity of pointer movements over time.
33 */
34class VelocityTracker {
35public:
36 struct Position {
37 float x, y;
38 };
39
40 struct Estimator {
41 static const size_t MAX_DEGREE = 4;
42
43 // Estimator time base.
44 std::chrono::nanoseconds time;
45
46 // Polynomial coefficients describing motion in X and Y.
47 float xCoeff[MAX_DEGREE + 1], yCoeff[MAX_DEGREE + 1];
48
49 // Polynomial degree (number of coefficients), or zero if no information is
50 // available.
51 uint32_t degree;
52
53 // Confidence (coefficient of determination), between 0 (no fit) and 1 (perfect fit).
54 float confidence;
55
56 inline void clear() {
57 time = std::chrono::nanoseconds(0);
58 degree = 0;
59 confidence = 0;
60 for (size_t i = 0; i <= MAX_DEGREE; i++) {
61 xCoeff[i] = 0;
62 yCoeff[i] = 0;
63 }
64 }
65 };
66
67 // Creates a velocity tracker using the specified strategy.
68 // If strategy is NULL, uses the default strategy for the platform.
69 VelocityTracker(const char* strategy = NULL);
70
71 ~VelocityTracker();
72
73 // Resets the velocity tracker state.
74 void clear();
75
76 // Resets the velocity tracker state for specific pointers.
77 // Call this method when some pointers have changed and may be reusing
78 // an id that was assigned to a different pointer earlier.
79 void clearPointers(const IntSet &ids);
80
81 // Adds movement information for a set of pointers.
82 // The ids set specifies the pointer ids of the pointers whose positions
83 // are included in the movement.
84 // The positions array contains position information for each pointer in order by
85 // increasing id. Its size should be equal to the size of ids.
86 void addMovement(std::chrono::nanoseconds eventTime, const IntSet &ids, const Position* positions);
87
88 // Adds movement information for all pointers in a MotionEvent, including historical samples.
89 void addMovement(const MotionEvent* event);
90
91 // Gets the velocity of the specified pointer id in position units per second.
92 // Returns false and sets the velocity components to zero if there is
93 // insufficient movement information for the pointer.
94 bool getVelocity(uint32_t id, float* outVx, float* outVy) const;
95
96 // Gets an estimator for the recent movements of the specified pointer id.
97 // Returns false and clears the estimator if there is no information available
98 // about the pointer.
99 bool getEstimator(uint32_t id, Estimator* outEstimator) const;
100
101 // Gets the active pointer id, or -1 if none.
102 inline int32_t getActivePointerId() const { return mActivePointerId; }
103
104 // Gets a bitset containing all pointer ids from the most recent movement.
105 inline const IntSet &getCurrentPointerIds() const { return mCurrentPointerIds; }
106
107private:
108 static const char* DEFAULT_STRATEGY;
109
110 std::chrono::nanoseconds mLastEventTime;
111 IntSet mCurrentPointerIds;
112 int32_t mActivePointerId;
113 VelocityTrackerStrategy* mStrategy;
114
115 bool configureStrategy(const char* strategy);
116
117 static VelocityTrackerStrategy* createStrategy(const char* strategy);
118};
119
120
121/*
122 * Implements a particular velocity tracker algorithm.
123 */
124class VelocityTrackerStrategy {
125protected:
126 VelocityTrackerStrategy() { }
127
128public:
129 virtual ~VelocityTrackerStrategy() { }
130
131 virtual void clear() = 0;
132 virtual void clearPointers(const IntSet &ids) = 0;
133 virtual void addMovement(std::chrono::nanoseconds eventTime, const IntSet &ids,
134 const VelocityTracker::Position* positions) = 0;
135 virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const = 0;
136};
137
138
139/*
140 * Velocity tracker algorithm based on least-squares linear regression.
141 */
142class LeastSquaresVelocityTrackerStrategy : public VelocityTrackerStrategy {
143public:
144 enum Weighting {
145 // No weights applied. All data points are equally reliable.
146 WEIGHTING_NONE,
147
148 // Weight by time delta. Data points clustered together are weighted less.
149 WEIGHTING_DELTA,
150
151 // Weight such that points within a certain horizon are weighed more than those
152 // outside of that horizon.
153 WEIGHTING_CENTRAL,
154
155 // Weight such that points older than a certain amount are weighed less.
156 WEIGHTING_RECENT
157 };
158
159 // Degree must be no greater than Estimator::MAX_DEGREE.
160 LeastSquaresVelocityTrackerStrategy(uint32_t degree, Weighting weighting = WEIGHTING_NONE);
161 virtual ~LeastSquaresVelocityTrackerStrategy();
162
163 virtual void clear();
164 virtual void clearPointers(const IntSet &ids);
165 virtual void addMovement(std::chrono::nanoseconds eventTime, const IntSet &ids,
166 const VelocityTracker::Position* positions);
167 virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const;
168
169private:
170 // Sample horizon.
171 // We don't use too much history by default since we want to react to quick
172 // changes in direction.
173 static constexpr const std::chrono::nanoseconds HORIZON = std::chrono::nanoseconds(100 * 1000000); // 100 ms
174
175 // Number of samples to keep.
176 static const uint32_t HISTORY_SIZE = 20;
177
178 struct Movement {
179 std::chrono::nanoseconds eventTime;
180 IntSet ids;
181 VelocityTracker::Position positions[MAX_POINTERS];
182
183 inline const VelocityTracker::Position& getPosition(uint32_t id) const {
184 return positions[ids.indexOf(id)];
185 }
186 };
187
188 float chooseWeight(uint32_t index) const;
189
190 const uint32_t mDegree;
191 const Weighting mWeighting;
192 uint32_t mIndex;
193 Movement mMovements[HISTORY_SIZE];
194};
195
196
197/*
198 * Velocity tracker algorithm that uses an IIR filter.
199 */
200class IntegratingVelocityTrackerStrategy : public VelocityTrackerStrategy {
201public:
202 // Degree must be 1 or 2.
203 IntegratingVelocityTrackerStrategy(uint32_t degree);
204 ~IntegratingVelocityTrackerStrategy();
205
206 virtual void clear();
207 virtual void clearPointers(const IntSet &ids);
208 virtual void addMovement(std::chrono::nanoseconds eventTime, const IntSet &ids,
209 const VelocityTracker::Position* positions);
210 virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const;
211
212private:
213 // Current state estimate for a particular pointer.
214 struct State {
215 std::chrono::nanoseconds updateTime;
216 uint32_t degree;
217
218 float xpos, xvel, xaccel;
219 float ypos, yvel, yaccel;
220 };
221
222 const uint32_t mDegree;
223 IntSet mPointerIds;
224 std::unordered_map<int32_t, State> mPointerState; // maps the id of a pointer to its state
225
226 void initState(State& state, std::chrono::nanoseconds eventTime, float xpos, float ypos) const;
227 void updateState(State& state, std::chrono::nanoseconds eventTime, float xpos, float ypos) const;
228 void populateEstimator(const State& state, VelocityTracker::Estimator* outEstimator) const;
229};
230
231
232/*
233 * Velocity tracker strategy used prior to ICS.
234 */
235class LegacyVelocityTrackerStrategy : public VelocityTrackerStrategy {
236public:
237 LegacyVelocityTrackerStrategy();
238 virtual ~LegacyVelocityTrackerStrategy();
239
240 virtual void clear();
241 virtual void clearPointers(const IntSet &ids);
242 virtual void addMovement(std::chrono::nanoseconds eventTime, const IntSet &ids,
243 const VelocityTracker::Position* positions);
244 virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const;
245
246private:
247 // Oldest sample to consider when calculating the velocity.
248 static constexpr const std::chrono::nanoseconds HORIZON = std::chrono::nanoseconds(200 * 1000000); // 100 ms
249
250 // Number of samples to keep.
251 static const uint32_t HISTORY_SIZE = 20;
252
253 // The minimum duration between samples when estimating velocity.
254 static constexpr const std::chrono::nanoseconds MIN_DURATION = std::chrono::nanoseconds(10 * 1000000); // 10 ms
255
256 struct Movement {
257 std::chrono::nanoseconds eventTime;
258 IntSet ids;
259 VelocityTracker::Position positions[MAX_POINTERS];
260
261 inline const VelocityTracker::Position& getPosition(uint32_t id) const {
262 return positions[ids.indexOf(id)];
263 }
264 };
265
266 uint32_t mIndex;
267 Movement mMovements[HISTORY_SIZE];
268};
269
270} // namespace android
271
272#endif // _ANDROIDFW_VELOCITY_TRACKER_H
2730
=== removed file '3rd_party/android-input/android/frameworks/base/include/androidfw/VirtualKeyMap.h'
--- 3rd_party/android-input/android/frameworks/base/include/androidfw/VirtualKeyMap.h 2013-05-03 16:38:07 +0000
+++ 3rd_party/android-input/android/frameworks/base/include/androidfw/VirtualKeyMap.h 1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _ANDROIDFW_VIRTUAL_KEY_MAP_H
18#define _ANDROIDFW_VIRTUAL_KEY_MAP_H
19
20
21#include <stdint.h>
22
23#include <androidfw/Input.h>
24#include <std/Errors.h>
25#include <std/KeyedVector.h>
26#include <std/Tokenizer.h>
27#include <std/String8.h>
28
29namespace android {
30
31/* Describes a virtual key. */
32struct VirtualKeyDefinition {
33 int32_t scanCode;
34
35 // configured position data, specified in display coords
36 int32_t centerX;
37 int32_t centerY;
38 int32_t width;
39 int32_t height;
40};
41
42
43/**
44 * Describes a collection of virtual keys on a touch screen in terms of
45 * virtual scan codes and hit rectangles.
46 *
47 * This object is immutable after it has been loaded.
48 */
49class VirtualKeyMap {
50public:
51 ~VirtualKeyMap();
52
53 static status_t load(const String8& filename, VirtualKeyMap** outMap);
54
55 inline const Vector<VirtualKeyDefinition>& getVirtualKeys() const {
56 return mVirtualKeys;
57 }
58
59private:
60 class Parser {
61 VirtualKeyMap* mMap;
62 Tokenizer* mTokenizer;
63
64 public:
65 Parser(VirtualKeyMap* map, Tokenizer* tokenizer);
66 ~Parser();
67 status_t parse();
68
69 private:
70 bool consumeFieldDelimiterAndSkipWhitespace();
71 bool parseNextIntField(int32_t* outValue);
72 };
73
74 Vector<VirtualKeyDefinition> mVirtualKeys;
75
76 VirtualKeyMap();
77};
78
79} // namespace android
80
81#endif // _ANDROIDFW_KEY_CHARACTER_MAP_H
820
=== removed file '3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp 2015-08-19 02:03:51 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/EventHub.cpp 1970-01-01 00:00:00 +0000
@@ -1,1502 +0,0 @@
1/*
2 * Copyright (C) 2005 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "EventHub"
18
19// #define LOG_NDEBUG 0
20
21#include "EventHub.h"
22
23#define acquire_wake_lock(lock, id) {}
24#define release_wake_lock(id) {}
25
26#include "mir/input/input_report.h"
27#include "mir/udev/wrapper.h"
28
29#include <cutils/properties.h>
30#include <std/Log.h>
31#include <std/Timers.h>
32#include <std/Errors.h>
33
34#include <stdlib.h>
35#include <unistd.h>
36#include <fcntl.h>
37#include <memory.h>
38#include <errno.h>
39#include <assert.h>
40
41#include <androidfw/KeyLayoutMap.h>
42#include <androidfw/KeyCharacterMap.h>
43#include <androidfw/VirtualKeyMap.h>
44
45#include <android/keycodes.h>
46#include <boost/uuid/sha1.hpp>
47
48#include <string.h>
49#include <stdint.h>
50#include <dirent.h>
51
52#include <sys/inotify.h>
53#include <sys/epoll.h>
54#include <sys/ioctl.h>
55#include <sys/timerfd.h>
56// <mir changes>
57// Needed to build on android platform (PATH_MAX)
58#ifdef HAVE_ANDROID_OS
59#include <sys/limits.h>
60#endif
61#include <linux/limits.h>
62// </mir changes>
63
64/* this macro is used to tell if "bit" is set in "array"
65 * it selects a byte from the array, and does a boolean AND
66 * operation with a byte that only has the relevant bit set.
67 * eg. to check for the 12th bit, we do (array[1] & 1<<4)
68 */
69#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
70
71/* this macro computes the number of bytes needed to represent a bit array of the specified size */
72#define sizeof_bit_array(bits) ((bits + 7) / 8)
73
74#define INDENT " "
75#define INDENT2 " "
76#define INDENT3 " "
77
78namespace mi = mir::input;
79
80namespace android {
81
82static const char *WAKE_LOCK_ID = "KeyEvents";
83static const char *DEVICE_PATH = "/dev/input";
84
85/* return the larger integer */
86static inline int max(int v1, int v2)
87{
88 return (v1 > v2) ? v1 : v2;
89}
90
91static inline const char* toString(bool value) {
92 return value ? "true" : "false";
93}
94
95namespace detail
96{
97String8 sha1(const String8& in) {
98 boost::uuids::detail::sha1 hasher;
99 hasher.process_bytes(in.data(), in.size());
100
101 unsigned int digest[5];
102 hasher.get_digest(digest);
103
104 String8 out;
105 for(int i : digest) {
106 appendFormat(out, "%08x", i);
107 }
108
109 return out;
110}
111}
112
113using detail::sha1;
114
115static void setDescriptor(InputDeviceIdentifier& identifier) {
116 // Compute a device descriptor that uniquely identifies the device.
117 // The descriptor is assumed to be a stable identifier. Its value should not
118 // change between reboots, reconnections, firmware updates or new releases of Android.
119 // Ideally, we also want the descriptor to be short and relatively opaque.
120 String8 rawDescriptor;
121 appendFormat(rawDescriptor, ":%04x:%04x:", identifier.vendor, identifier.product);
122 if (!isEmpty(identifier.uniqueId)) {
123 rawDescriptor.append("uniqueId:");
124 rawDescriptor.append(identifier.uniqueId);
125 } if (identifier.vendor == 0 && identifier.product == 0) {
126 // If we don't know the vendor and product id, then the device is probably
127 // built-in so we need to rely on other information to uniquely identify
128 // the input device. Usually we try to avoid relying on the device name or
129 // location but for built-in input device, they are unlikely to ever change.
130 if (!isEmpty(identifier.name)) {
131 rawDescriptor.append("name:");
132 rawDescriptor.append(identifier.name);
133 } else if (!isEmpty(identifier.location)) {
134 rawDescriptor.append("location:");
135 rawDescriptor.append(identifier.location);
136 }
137 }
138 identifier.descriptor = sha1(rawDescriptor);
139 ALOGV("Created descriptor: raw=%s, cooked=%s", c_str(rawDescriptor),
140 c_str(identifier.descriptor));
141}
142
143// --- EventHub::Device ---
144
145EventHub::Device::Device(int fd, int32_t id, const String8& path,
146 const InputDeviceIdentifier& identifier) :
147 next(NULL),
148 fd(fd), id(id), path(path), identifier(identifier),
149 classes(0), configuration(NULL), virtualKeyMap(NULL),
150 ffEffectPlaying(false), ffEffectId(-1) {
151 memset(keyBitmask, 0, sizeof(keyBitmask));
152 memset(absBitmask, 0, sizeof(absBitmask));
153 memset(relBitmask, 0, sizeof(relBitmask));
154 memset(swBitmask, 0, sizeof(swBitmask));
155 memset(ledBitmask, 0, sizeof(ledBitmask));
156 memset(ffBitmask, 0, sizeof(ffBitmask));
157 memset(propBitmask, 0, sizeof(propBitmask));
158}
159
160EventHub::Device::~Device() {
161 close();
162 delete configuration;
163 delete virtualKeyMap;
164}
165
166void EventHub::Device::close() {
167 if (fd >= 0) {
168 ::close(fd);
169 fd = -1;
170 }
171}
172
173
174// --- EventHub ---
175
176const uint32_t EventHub::EPOLL_ID_UDEV;
177const uint32_t EventHub::EPOLL_ID_WAKE;
178const uint32_t EventHub::EPOLL_ID_TIMER;
179const int EventHub::EPOLL_SIZE_HINT;
180const int EventHub::EPOLL_MAX_EVENTS;
181
182EventHub::EventHub(std::shared_ptr<mi::InputReport> const& input_report) :
183 input_report(input_report),
184 device_listener{new mir::udev::Monitor{mir::udev::Context()}},
185 mBuiltInKeyboardId(NO_BUILT_IN_KEYBOARD), mNextDeviceId(1),
186 mOpeningDevices(0), mClosingDevices(0),
187 mNeedToSendFinishedDeviceScan(false),
188 mNeedToReopenDevices(false), mNeedToScanDevices(true),
189 mEpollFd{epoll_create(EPOLL_SIZE_HINT)},
190 mTimerFd{timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK|TFD_CLOEXEC)},
191 mPendingEventCount(0), mPendingEventIndex(0), mPendingUdevEvent(false) {
192 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
193
194 LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance. errno=%d", errno);
195 LOG_ALWAYS_FATAL_IF(mTimerFd < 0, "Could not create timerfd. errno=%d", errno);
196
197 device_listener->filter_by_subsystem("input");
198 device_listener->enable();
199
200
201 struct epoll_event eventItem;
202 memset(&eventItem, 0, sizeof(eventItem));
203 eventItem.events = EPOLLIN;
204 eventItem.data.u32 = EPOLL_ID_UDEV;
205 int result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, device_listener->fd(), &eventItem);
206 LOG_ALWAYS_FATAL_IF(result != 0, "Could not add Udev monitor to epoll instance. errno=%d", errno);
207
208 int wakeFds[2];
209 result = pipe(wakeFds);
210 LOG_ALWAYS_FATAL_IF(result != 0, "Could not create wake pipe. errno=%d", errno);
211
212 mWakeReadPipeFd = wakeFds[0];
213 mWakeWritePipeFd = wakeFds[1];
214
215 result = fcntl(mWakeReadPipeFd, F_SETFL, O_NONBLOCK);
216 LOG_ALWAYS_FATAL_IF(result != 0, "Could not make wake read pipe non-blocking. errno=%d",
217 errno);
218
219 result = fcntl(mWakeWritePipeFd, F_SETFL, O_NONBLOCK);
220 LOG_ALWAYS_FATAL_IF(result != 0, "Could not make wake write pipe non-blocking. errno=%d",
221 errno);
222
223 eventItem.data.u32 = EPOLL_ID_WAKE;
224 result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mWakeReadPipeFd, &eventItem);
225 LOG_ALWAYS_FATAL_IF(result != 0, "Could not add wake read pipe to epoll instance. errno=%d",
226 errno);
227
228 eventItem.data.u32 = EPOLL_ID_TIMER;
229 result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mTimerFd, &eventItem);
230 LOG_ALWAYS_FATAL_IF(result != 0, "Could not add timer fd to epoll instance. errno=%d",
231 errno);
232}
233
234EventHub::~EventHub(void) {
235 closeAllDevicesLocked();
236
237 while (mClosingDevices) {
238 Device* device = mClosingDevices;
239 mClosingDevices = device->next;
240 delete device;
241 }
242
243 ::close(mWakeReadPipeFd);
244 ::close(mWakeWritePipeFd);
245
246 release_wake_lock(WAKE_LOCK_ID);
247}
248
249InputDeviceIdentifier EventHub::getDeviceIdentifier(int32_t deviceId) const {
250 AutoMutex _l(mLock);
251 Device* device = getDeviceLocked(deviceId);
252 if (device == NULL) return InputDeviceIdentifier();
253 return device->identifier;
254}
255
256uint32_t EventHub::getDeviceClasses(int32_t deviceId) const {
257 AutoMutex _l(mLock);
258 Device* device = getDeviceLocked(deviceId);
259 if (device == NULL) return 0;
260 return device->classes;
261}
262
263void EventHub::getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const {
264 AutoMutex _l(mLock);
265 Device* device = getDeviceLocked(deviceId);
266 if (device && device->configuration) {
267 *outConfiguration = *device->configuration;
268 } else {
269 outConfiguration->clear();
270 }
271}
272
273status_t EventHub::getAbsoluteAxisInfo(int32_t deviceId, int axis,
274 RawAbsoluteAxisInfo* outAxisInfo) const {
275 outAxisInfo->clear();
276
277 if (axis >= 0 && axis <= ABS_MAX) {
278 AutoMutex _l(mLock);
279
280 Device* device = getDeviceLocked(deviceId);
281 if (device && !device->isVirtual() && test_bit(axis, device->absBitmask)) {
282 struct input_absinfo info;
283 if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
284 ALOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
285 axis, c_str(device->identifier.name), device->fd, errno);
286 return -errno;
287 }
288
289 if (info.minimum != info.maximum) {
290 outAxisInfo->valid = true;
291 outAxisInfo->minValue = info.minimum;
292 outAxisInfo->maxValue = info.maximum;
293 outAxisInfo->flat = info.flat;
294 outAxisInfo->fuzz = info.fuzz;
295 outAxisInfo->resolution = info.resolution;
296 }
297 return OK;
298 }
299 }
300 return -1;
301}
302
303bool EventHub::hasRelativeAxis(int32_t deviceId, int axis) const {
304 if (axis >= 0 && axis <= REL_MAX) {
305 AutoMutex _l(mLock);
306
307 Device* device = getDeviceLocked(deviceId);
308 if (device) {
309 return test_bit(axis, device->relBitmask);
310 }
311 }
312 return false;
313}
314
315bool EventHub::hasInputProperty(int32_t deviceId, int property) const {
316 if (property >= 0 && property <= INPUT_PROP_MAX) {
317 AutoMutex _l(mLock);
318
319 Device* device = getDeviceLocked(deviceId);
320 if (device) {
321 return test_bit(property, device->propBitmask);
322 }
323 }
324 return false;
325}
326
327int32_t EventHub::getScanCodeState(int32_t deviceId, int32_t scanCode) const {
328 if (scanCode >= 0 && scanCode <= KEY_MAX) {
329 AutoMutex _l(mLock);
330
331 Device* device = getDeviceLocked(deviceId);
332 if (device && !device->isVirtual() && test_bit(scanCode, device->keyBitmask)) {
333 uint8_t keyState[sizeof_bit_array(KEY_MAX + 1)];
334 memset(keyState, 0, sizeof(keyState));
335 if (ioctl(device->fd, EVIOCGKEY(sizeof(keyState)), keyState) >= 0) {
336 return test_bit(scanCode, keyState) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
337 }
338 }
339 }
340 return AKEY_STATE_UNKNOWN;
341}
342
343int32_t EventHub::getKeyCodeState(int32_t deviceId, int32_t keyCode) const {
344 AutoMutex _l(mLock);
345
346 Device* device = getDeviceLocked(deviceId);
347 if (device && !device->isVirtual() && device->keyMap.haveKeyLayout()) {
348 Vector<int32_t> scanCodes;
349 device->keyMap.keyLayoutMap->findScanCodesForKey(keyCode, &scanCodes);
350 if (scanCodes.size() != 0) {
351 uint8_t keyState[sizeof_bit_array(KEY_MAX + 1)];
352 memset(keyState, 0, sizeof(keyState));
353 if (ioctl(device->fd, EVIOCGKEY(sizeof(keyState)), keyState) >= 0) {
354 for (size_t i = 0; i < scanCodes.size(); i++) {
355 int32_t sc = scanCodes.itemAt(i);
356 if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, keyState)) {
357 return AKEY_STATE_DOWN;
358 }
359 }
360 return AKEY_STATE_UP;
361 }
362 }
363 }
364 return AKEY_STATE_UNKNOWN;
365}
366
367int32_t EventHub::getSwitchState(int32_t deviceId, int32_t sw) const {
368 if (sw >= 0 && sw <= SW_MAX) {
369 AutoMutex _l(mLock);
370
371 Device* device = getDeviceLocked(deviceId);
372 if (device && !device->isVirtual() && test_bit(sw, device->swBitmask)) {
373 uint8_t swState[sizeof_bit_array(SW_MAX + 1)];
374 memset(swState, 0, sizeof(swState));
375 if (ioctl(device->fd, EVIOCGSW(sizeof(swState)), swState) >= 0) {
376 return test_bit(sw, swState) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
377 }
378 }
379 }
380 return AKEY_STATE_UNKNOWN;
381}
382
383status_t EventHub::getAbsoluteAxisValue(int32_t deviceId, int32_t axis, int32_t* outValue) const {
384 *outValue = 0;
385
386 if (axis >= 0 && axis <= ABS_MAX) {
387 AutoMutex _l(mLock);
388
389 Device* device = getDeviceLocked(deviceId);
390 if (device && !device->isVirtual() && test_bit(axis, device->absBitmask)) {
391 struct input_absinfo info;
392 if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
393 ALOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
394 axis, c_str(device->identifier.name), device->fd, errno);
395 return -errno;
396 }
397
398 *outValue = info.value;
399 return OK;
400 }
401 }
402 return -1;
403}
404
405bool EventHub::markSupportedKeyCodes(int32_t deviceId, size_t numCodes,
406 const int32_t* keyCodes, uint8_t* outFlags) const {
407 AutoMutex _l(mLock);
408
409 Device* device = getDeviceLocked(deviceId);
410 if (device && device->keyMap.haveKeyLayout()) {
411 Vector<int32_t> scanCodes;
412 for (size_t codeIndex = 0; codeIndex < numCodes; codeIndex++) {
413 scanCodes.clear();
414
415 status_t err = device->keyMap.keyLayoutMap->findScanCodesForKey(
416 keyCodes[codeIndex], &scanCodes);
417 if (! err) {
418 // check the possible scan codes identified by the layout map against the
419 // map of codes actually emitted by the driver
420 for (size_t sc = 0; sc < scanCodes.size(); sc++) {
421 if (test_bit(scanCodes[sc], device->keyBitmask)) {
422 outFlags[codeIndex] = 1;
423 break;
424 }
425 }
426 }
427 }
428 return true;
429 }
430 return false;
431}
432
433status_t EventHub::mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode,
434 int32_t* outKeycode, uint32_t* outFlags) const {
435 AutoMutex _l(mLock);
436 Device* device = getDeviceLocked(deviceId);
437
438 if (device) {
439 // Check the key character map first.
440 sp<KeyCharacterMap> kcm = device->getKeyCharacterMap();
441 if (kcm != NULL) {
442 if (!kcm->mapKey(scanCode, usageCode, outKeycode)) {
443 *outFlags = 0;
444 return NO_ERROR;
445 }
446 }
447
448 // Check the key layout next.
449 if (device->keyMap.haveKeyLayout()) {
450 if (!device->keyMap.keyLayoutMap->mapKey(
451 scanCode, usageCode, outKeycode, outFlags)) {
452 return NO_ERROR;
453 }
454 }
455 }
456
457 *outKeycode = 0;
458 *outFlags = 0;
459 return NAME_NOT_FOUND;
460}
461
462status_t EventHub::mapAxis(int32_t deviceId, int32_t scanCode, AxisInfo* outAxisInfo) const {
463 AutoMutex _l(mLock);
464 Device* device = getDeviceLocked(deviceId);
465
466 if (device && device->keyMap.haveKeyLayout()) {
467 status_t err = device->keyMap.keyLayoutMap->mapAxis(scanCode, outAxisInfo);
468 if (err == NO_ERROR) {
469 return NO_ERROR;
470 }
471 }
472
473 return NAME_NOT_FOUND;
474}
475
476void EventHub::setExcludedDevices(const Vector<String8>& devices) {
477 AutoMutex _l(mLock);
478
479 mExcludedDevices = devices;
480}
481
482bool EventHub::hasScanCode(int32_t deviceId, int32_t scanCode) const {
483 AutoMutex _l(mLock);
484 Device* device = getDeviceLocked(deviceId);
485 if (device && scanCode >= 0 && scanCode <= KEY_MAX) {
486 if (test_bit(scanCode, device->keyBitmask)) {
487 return true;
488 }
489 }
490 return false;
491}
492
493bool EventHub::hasLed(int32_t deviceId, int32_t led) const {
494 AutoMutex _l(mLock);
495 Device* device = getDeviceLocked(deviceId);
496 if (device && led >= 0 && led <= LED_MAX) {
497 if (test_bit(led, device->ledBitmask)) {
498 return true;
499 }
500 }
501 return false;
502}
503
504void EventHub::setLedState(int32_t deviceId, int32_t led, bool on) {
505 AutoMutex _l(mLock);
506 Device* device = getDeviceLocked(deviceId);
507 if (device && !device->isVirtual() && led >= 0 && led <= LED_MAX) {
508 struct input_event ev;
509 ev.time.tv_sec = 0;
510 ev.time.tv_usec = 0;
511 ev.type = EV_LED;
512 ev.code = led;
513 ev.value = on ? 1 : 0;
514
515 ssize_t nWrite;
516 do {
517 nWrite = write(device->fd, &ev, sizeof(struct input_event));
518 } while (nWrite == -1 && errno == EINTR);
519 }
520}
521
522void EventHub::getVirtualKeyDefinitions(int32_t deviceId,
523 Vector<VirtualKeyDefinition>& outVirtualKeys) const {
524 outVirtualKeys.clear();
525
526 AutoMutex _l(mLock);
527 Device* device = getDeviceLocked(deviceId);
528 if (device && device->virtualKeyMap) {
529 outVirtualKeys.appendVector(device->virtualKeyMap->getVirtualKeys());
530 }
531}
532
533sp<KeyCharacterMap> EventHub::getKeyCharacterMap(int32_t deviceId) const {
534 AutoMutex _l(mLock);
535 Device* device = getDeviceLocked(deviceId);
536 if (device) {
537 return device->getKeyCharacterMap();
538 }
539 return NULL;
540}
541
542bool EventHub::setKeyboardLayoutOverlay(int32_t deviceId,
543 const sp<KeyCharacterMap>& map) {
544 AutoMutex _l(mLock);
545 Device* device = getDeviceLocked(deviceId);
546 if (device) {
547 if (map != device->overlayKeyMap) {
548 device->overlayKeyMap = map;
549 device->combinedKeyMap = KeyCharacterMap::combine(
550 device->keyMap.keyCharacterMap, map);
551 return true;
552 }
553 }
554 return false;
555}
556
557void EventHub::vibrate(int32_t deviceId, std::chrono::nanoseconds duration) {
558 AutoMutex _l(mLock);
559 Device* device = getDeviceLocked(deviceId);
560 if (device && !device->isVirtual()) {
561 ff_effect effect;
562 memset(&effect, 0, sizeof(effect));
563 effect.type = FF_RUMBLE;
564 effect.id = device->ffEffectId;
565 effect.u.rumble.strong_magnitude = 0xc000;
566 effect.u.rumble.weak_magnitude = 0xc000;
567 effect.replay.length = (duration + std::chrono::nanoseconds(999999)) / std::chrono::nanoseconds(1000000LL);
568 effect.replay.delay = 0;
569 if (ioctl(device->fd, EVIOCSFF, &effect)) {
570 ALOGW("Could not upload force feedback effect to device %s due to error %d.",
571 c_str(device->identifier.name), errno);
572 return;
573 }
574 device->ffEffectId = effect.id;
575
576 struct input_event ev;
577 ev.time.tv_sec = 0;
578 ev.time.tv_usec = 0;
579 ev.type = EV_FF;
580 ev.code = device->ffEffectId;
581 ev.value = 1;
582 if (write(device->fd, &ev, sizeof(ev)) != sizeof(ev)) {
583 ALOGW("Could not start force feedback effect on device %s due to error %d.",
584 c_str(device->identifier.name), errno);
585 return;
586 }
587 device->ffEffectPlaying = true;
588 }
589}
590
591void EventHub::cancelVibrate(int32_t deviceId) {
592 AutoMutex _l(mLock);
593 Device* device = getDeviceLocked(deviceId);
594 if (device && !device->isVirtual()) {
595 if (device->ffEffectPlaying) {
596 device->ffEffectPlaying = false;
597
598 struct input_event ev;
599 ev.time.tv_sec = 0;
600 ev.time.tv_usec = 0;
601 ev.type = EV_FF;
602 ev.code = device->ffEffectId;
603 ev.value = 0;
604 if (write(device->fd, &ev, sizeof(ev)) != sizeof(ev)) {
605 ALOGW("Could not stop force feedback effect on device %s due to error %d.",
606 c_str(device->identifier.name), errno);
607 return;
608 }
609 }
610 }
611}
612
613EventHub::Device* EventHub::getDeviceLocked(int32_t deviceId) const {
614 if (deviceId == BUILT_IN_KEYBOARD_ID) {
615 deviceId = mBuiltInKeyboardId;
616 }
617 ssize_t index = mDevices.indexOfKey(deviceId);
618 return index >= 0 ? mDevices.valueAt(index) : NULL;
619}
620
621EventHub::Device* EventHub::getDeviceByPathLocked(const char* devicePath) const {
622 for (size_t i = 0; i < mDevices.size(); i++) {
623 Device* device = mDevices.valueAt(i);
624 if (device->path == devicePath) {
625 return device;
626 }
627 }
628 return NULL;
629}
630
631size_t EventHub::getEvents(RawEvent* buffer, size_t bufferSize) {
632 ALOG_ASSERT(bufferSize >= 1);
633
634 AutoMutex _l(mLock);
635
636 struct input_event readBuffer[bufferSize];
637
638 RawEvent* event = buffer;
639 size_t capacity = bufferSize;
640 bool awoken = false;
641 for (;;) {
642 std::chrono::nanoseconds now = systemTime(SYSTEM_TIME_MONOTONIC);
643
644 // Reopen input devices if needed.
645 if (mNeedToReopenDevices) {
646 mNeedToReopenDevices = false;
647
648 ALOGI("Reopening all input devices due to a configuration change.");
649
650 closeAllDevicesLocked();
651 mNeedToScanDevices = true;
652 break; // return to the caller before we actually rescan
653 }
654
655 // Report any devices that had last been added/removed.
656 while (mClosingDevices) {
657 Device* device = mClosingDevices;
658 ALOGV("Reporting device closed: id=%d, name=%s\n",
659 device->id, c_str(device->path));
660 mClosingDevices = device->next;
661 event->when = now;
662 event->deviceId = device->id == mBuiltInKeyboardId ? BUILT_IN_KEYBOARD_ID : device->id;
663 event->type = DEVICE_REMOVED;
664 event += 1;
665 delete device;
666 mNeedToSendFinishedDeviceScan = true;
667 if (--capacity == 0) {
668 break;
669 }
670 }
671
672 if (mNeedToScanDevices) {
673 mNeedToScanDevices = false;
674 scanDevicesLocked();
675 mNeedToSendFinishedDeviceScan = true;
676 }
677
678 while (mOpeningDevices != NULL) {
679 Device* device = mOpeningDevices;
680 ALOGV("Reporting device opened: id=%d, name=%s\n",
681 device->id, c_str(device->path));
682 mOpeningDevices = device->next;
683 event->when = now;
684 event->deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id;
685 event->type = DEVICE_ADDED;
686 event += 1;
687 mNeedToSendFinishedDeviceScan = true;
688 if (--capacity == 0) {
689 break;
690 }
691 }
692
693 if (mNeedToSendFinishedDeviceScan) {
694 mNeedToSendFinishedDeviceScan = false;
695 event->when = now;
696 event->type = FINISHED_DEVICE_SCAN;
697 event += 1;
698 if (--capacity == 0) {
699 break;
700 }
701 }
702
703 // Grab the next input event.
704 bool deviceChanged = false;
705 while (mPendingEventIndex < mPendingEventCount) {
706 const struct epoll_event& eventItem = mPendingEventItems[mPendingEventIndex++];
707 if (eventItem.data.u32 == EPOLL_ID_UDEV) {
708 if (eventItem.events & EPOLLIN) {
709 mPendingUdevEvent = true;
710 } else {
711 ALOGW("Received unexpected epoll event 0x%08x for INotify.", eventItem.events);
712 }
713 continue;
714 }
715
716 if (eventItem.data.u32 == EPOLL_ID_WAKE) {
717 if (eventItem.events & EPOLLIN) {
718 ALOGV("awoken after wake()");
719 awoken = true;
720 char buffer[16];
721 ssize_t nRead;
722 do {
723 nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer));
724 } while ((nRead == -1 && errno == EINTR) || nRead == sizeof(buffer));
725 } else {
726 ALOGW("Received unexpected epoll event 0x%08x for wake read pipe.",
727 eventItem.events);
728 }
729 continue;
730 }
731
732 if (eventItem.data.u32 == EPOLL_ID_TIMER) {
733 if (eventItem.events & EPOLLIN) {
734 ALOGV("awoken after wakeIn()");
735 awoken = true;
736 uint64_t timeout_count;
737 read(mTimerFd, &timeout_count, sizeof timeout_count);
738 } else {
739 ALOGW("Received unexpected epoll event 0x%08x for wake read pipe.",
740 eventItem.events);
741 }
742 continue;
743 }
744
745 ssize_t deviceIndex = mDevices.indexOfKey(eventItem.data.u32);
746 if (deviceIndex < 0) {
747 ALOGW("Received unexpected epoll event 0x%08x for unknown device id %d.",
748 eventItem.events, eventItem.data.u32);
749 continue;
750 }
751
752 Device* device = mDevices.valueAt(deviceIndex);
753 if (eventItem.events & EPOLLIN) {
754 int32_t readSize = read(device->fd, readBuffer,
755 sizeof(struct input_event) * capacity);
756 if (readSize == 0 || (readSize < 0 && errno == ENODEV)) {
757 // Device was removed before INotify noticed.
758 ALOGW("could not get event, removed? (fd: %d size: %d bufferSize: %d "
759 "capacity: %d errno: %d)\n",
760 device->fd, readSize, bufferSize, capacity, errno);
761 deviceChanged = true;
762 closeDeviceLocked(device);
763 } else if (readSize < 0) {
764 if (errno != EAGAIN && errno != EINTR) {
765 ALOGW("could not get event (errno=%d)", errno);
766 }
767 } else if ((readSize % sizeof(struct input_event)) != 0) {
768 ALOGE("could not get event (wrong size: %d)", readSize);
769 } else {
770 int32_t deviceId = device->id == mBuiltInKeyboardId ? 0 : device->id;
771
772 size_t count = size_t(readSize) / sizeof(struct input_event);
773 for (size_t i = 0; i < count; i++) {
774 const struct input_event& iev = readBuffer[i];
775 ALOGV("%s got: t0=%d, t1=%d, type=%d, code=%d, value=%d",
776 c_str(device->path),
777 (int) iev.time.tv_sec, (int) iev.time.tv_usec,
778 iev.type, iev.code, iev.value);
779
780#ifdef HAVE_POSIX_CLOCKS
781 // Use the time specified in the event instead of the current time
782 // so that downstream code can get more accurate estimates of
783 // event dispatch latency from the time the event is enqueued onto
784 // the evdev client buffer.
785 //
786 // The event's timestamp fortuitously uses the same monotonic clock
787 // time base as the rest of Android. The kernel event device driver
788 // (drivers/input/evdev.c) obtains timestamps using ktime_get_ts().
789 // The systemTime(SYSTEM_TIME_MONOTONIC) function we use everywhere
790 // calls clock_gettime(CLOCK_MONOTONIC) which is implemented as a
791 // system call that also queries ktime_get_ts().
792 event->when = std::chrono::nanoseconds(iev.time.tv_sec) * 1000000000LL
793 + std::chrono::nanoseconds(iev.time.tv_usec) * 1000LL;
794 ALOGV("event time %lld, now %lld", event->when, now);
795#else
796 event->when = now;
797#endif
798 event->deviceId = deviceId;
799 event->type = iev.type;
800 event->code = iev.code;
801 event->value = iev.value;
802
803 input_report->received_event_from_kernel(event->when.count(), event->type, event->code, event->value);
804
805 event += 1;
806 }
807 capacity -= count;
808 if (capacity == 0) {
809 // The result buffer is full. Reset the pending event index
810 // so we will try to read the device again on the next iteration.
811 mPendingEventIndex -= 1;
812 break;
813 }
814 }
815 } else if (eventItem.events & EPOLLHUP) {
816 ALOGI("Removing device %s due to epoll hang-up event.",
817 c_str(device->identifier.name));
818 deviceChanged = true;
819 closeDeviceLocked(device);
820 } else {
821 ALOGW("Received unexpected epoll event 0x%08x for device %s.",
822 eventItem.events, c_str(device->identifier.name));
823 }
824 }
825
826 // readNotify() will modify the list of devices so this must be done after
827 // processing all other events to ensure that we read all remaining events
828 // before closing the devices.
829 if (mPendingUdevEvent && mPendingEventIndex >= mPendingEventCount) {
830 mPendingUdevEvent = false;
831 handleUdevEventsLocked();
832 deviceChanged = true;
833 }
834
835 // Report added or removed devices immediately.
836 if (deviceChanged) {
837 continue;
838 }
839
840 // Return now if we have collected any events or if we were explicitly awoken.
841 if (event != buffer || awoken) {
842 break;
843 }
844
845 // Poll for events. Mind the wake lock dance!
846 // We hold a wake lock at all times except during epoll_wait(). This works due to some
847 // subtle choreography. When a device driver has pending (unread) events, it acquires
848 // a kernel wake lock. However, once the last pending event has been read, the device
849 // driver will release the kernel wake lock. To prevent the system from going to sleep
850 // when this happens, the EventHub holds onto its own user wake lock while the client
851 // is processing events. Thus the system can only sleep if there are no events
852 // pending or currently being processed.
853 mPendingEventIndex = 0;
854
855 mLock.unlock(); // release lock before poll, must be before release_wake_lock
856 release_wake_lock(WAKE_LOCK_ID);
857
858 // non blocking call to epoll_wait - blocking happens in dispatch threads
859 int pollResult = epoll_wait(mEpollFd, mPendingEventItems, EPOLL_MAX_EVENTS, 0);
860
861 acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
862 mLock.lock(); // reacquire lock after poll, must be after acquire_wake_lock
863
864 if (pollResult == 0) {
865 // Timed out.
866 mPendingEventCount = 0;
867 break;
868 }
869
870 if (pollResult < 0) {
871 // An error occurred.
872 mPendingEventCount = 0;
873
874 // Sleep after errors to avoid locking up the system.
875 // Hopefully the error is transient.
876 if (errno != EINTR) {
877 ALOGW("poll failed (errno=%d)\n", errno);
878 usleep(100000);
879 }
880 } else {
881 // Some events occurred.
882 mPendingEventCount = size_t(pollResult);
883 }
884 }
885
886 // All done, return the number of events we read.
887 return event - buffer;
888}
889
890void EventHub::wakeIn(int32_t timeoutMillis) {
891 itimerspec delay;
892 std::memset(&delay, 0, sizeof delay);
893
894 delay.it_value.tv_sec = timeoutMillis / 1000;
895 delay.it_value.tv_nsec = (timeoutMillis % 1000) * 1000000LL;
896 timerfd_settime(mTimerFd, 0, &delay, nullptr);
897}
898
899void EventHub::wake() {
900 ALOGV("wake() called");
901
902 ssize_t nWrite;
903 do {
904 nWrite = write(mWakeWritePipeFd, "W", 1);
905 } while (nWrite == -1 && errno == EINTR);
906
907 if (nWrite != 1 && errno != EAGAIN) {
908 ALOGW("Could not write wake signal, errno=%d", errno);
909 }
910}
911
912void EventHub::scanDevicesLocked() {
913 mir::udev::Enumerator input_enumerator{std::make_shared<mir::udev::Context>()};
914
915 input_enumerator.match_subsystem("input");
916 input_enumerator.scan_devices();
917
918 for (auto& device : input_enumerator)
919 {
920 if (device.devnode() != nullptr)
921 {
922 openDeviceLocked(device.devnode());
923 }
924 }
925
926 if (mDevices.indexOfKey(VIRTUAL_KEYBOARD_ID) < 0) {
927 createVirtualKeyboardLocked();
928 }
929}
930
931void EventHub::handleUdevEventsLocked()
932{
933 device_listener->process_events([this](mir::udev::Monitor::EventType type, mir::udev::Device const& dev){
934 if (type == mir::udev::Monitor::ADDED)
935 {
936 if (dev.devnode() != nullptr)
937 {
938 openDeviceLocked(dev.devnode());
939 }
940 }
941 else if (type == mir::udev::Monitor::REMOVED)
942 {
943 if (dev.devnode() != nullptr)
944 {
945 closeDeviceByPathLocked(dev.devnode());
946 }
947 }
948 });
949}
950
951// ----------------------------------------------------------------------------
952
953static bool containsNonZeroByte(const uint8_t* array, uint32_t startIndex, uint32_t endIndex) {
954 const uint8_t* end = array + endIndex;
955 array += startIndex;
956 while (array != end) {
957 if (*(array++) != 0) {
958 return true;
959 }
960 }
961 return false;
962}
963
964static const int32_t GAMEPAD_KEYCODES[] = {
965 AKEYCODE_BUTTON_A, AKEYCODE_BUTTON_B, AKEYCODE_BUTTON_C,
966 AKEYCODE_BUTTON_X, AKEYCODE_BUTTON_Y, AKEYCODE_BUTTON_Z,
967 AKEYCODE_BUTTON_L1, AKEYCODE_BUTTON_R1,
968 AKEYCODE_BUTTON_L2, AKEYCODE_BUTTON_R2,
969 AKEYCODE_BUTTON_THUMBL, AKEYCODE_BUTTON_THUMBR,
970 AKEYCODE_BUTTON_START, AKEYCODE_BUTTON_SELECT, AKEYCODE_BUTTON_MODE,
971 AKEYCODE_BUTTON_1, AKEYCODE_BUTTON_2, AKEYCODE_BUTTON_3, AKEYCODE_BUTTON_4,
972 AKEYCODE_BUTTON_5, AKEYCODE_BUTTON_6, AKEYCODE_BUTTON_7, AKEYCODE_BUTTON_8,
973 AKEYCODE_BUTTON_9, AKEYCODE_BUTTON_10, AKEYCODE_BUTTON_11, AKEYCODE_BUTTON_12,
974 AKEYCODE_BUTTON_13, AKEYCODE_BUTTON_14, AKEYCODE_BUTTON_15, AKEYCODE_BUTTON_16,
975};
976
977status_t EventHub::openDeviceLocked(const char *devicePath) {
978 char buffer[80];
979
980 ALOGV("Opening device: %s", devicePath);
981 if (hasDeviceByPathLocked(String8(devicePath)))
982 {
983 ALOGV("Not opening device (%s), as it is already opened", devicePath);
984 return -1;
985 }
986
987 int fd = open(devicePath, O_RDWR | O_CLOEXEC);
988 if(fd < 0) {
989 ALOGE("could not open %s, %s\n", devicePath, strerror(errno));
990 return -1;
991 }
992
993 InputDeviceIdentifier identifier;
994
995 // Get device name.
996 if(ioctl(fd, EVIOCGNAME(sizeof(buffer) - 1), &buffer) < 1) {
997 //fprintf(stderr, "could not get device name for %s, %s\n", devicePath, strerror(errno));
998 } else {
999 buffer[sizeof(buffer) - 1] = '\0';
1000 setTo(identifier.name, buffer);
1001 }
1002
1003 // Check to see if the device is on our excluded list
1004 for (size_t i = 0; i < mExcludedDevices.size(); i++) {
1005 const String8& item = mExcludedDevices.itemAt(i);
1006 if (identifier.name == item) {
1007 ALOGI("ignoring event id %s driver %s\n", devicePath, c_str(item));
1008 close(fd);
1009 return -1;
1010 }
1011 }
1012
1013 // Get device driver version.
1014 int driverVersion;
1015 if(ioctl(fd, EVIOCGVERSION, &driverVersion)) {
1016 ALOGE("could not get driver version for %s, %s\n", devicePath, strerror(errno));
1017 close(fd);
1018 return -1;
1019 }
1020
1021 // Get device identifier.
1022 struct input_id inputId;
1023 if(ioctl(fd, EVIOCGID, &inputId)) {
1024 ALOGE("could not get device input id for %s, %s\n", devicePath, strerror(errno));
1025 close(fd);
1026 return -1;
1027 }
1028 identifier.bus = inputId.bustype;
1029 identifier.product = inputId.product;
1030 identifier.vendor = inputId.vendor;
1031 identifier.version = inputId.version;
1032
1033 // Get device physical location.
1034 if(ioctl(fd, EVIOCGPHYS(sizeof(buffer) - 1), &buffer) < 1) {
1035 //fprintf(stderr, "could not get location for %s, %s\n", devicePath, strerror(errno));
1036 } else {
1037 buffer[sizeof(buffer) - 1] = '\0';
1038 setTo(identifier.location, buffer);
1039 }
1040
1041 // Get device unique id.
1042 if(ioctl(fd, EVIOCGUNIQ(sizeof(buffer) - 1), &buffer) < 1) {
1043 //fprintf(stderr, "could not get idstring for %s, %s\n", devicePath, strerror(errno));
1044 } else {
1045 buffer[sizeof(buffer) - 1] = '\0';
1046 setTo(identifier.uniqueId, buffer);
1047 }
1048
1049 // Fill in the descriptor.
1050 setDescriptor(identifier);
1051
1052 // Make file descriptor non-blocking for use with poll().
1053 if (fcntl(fd, F_SETFL, O_NONBLOCK)) {
1054 ALOGE("Error %d making device file descriptor non-blocking.", errno);
1055 close(fd);
1056 return -1;
1057 }
1058
1059 // Allocate device. (The device object takes ownership of the fd at this point.)
1060 int32_t deviceId = mNextDeviceId++;
1061 Device* device = new Device(fd, deviceId, String8(devicePath), identifier);
1062
1063 ALOGV("add device %d: %s\n", deviceId, devicePath);
1064 ALOGV(" bus: %04x\n"
1065 " vendor %04x\n"
1066 " product %04x\n"
1067 " version %04x\n",
1068 identifier.bus, identifier.vendor, identifier.product, identifier.version);
1069 ALOGV(" name: \"%s\"\n", c_str(identifier.name));
1070 ALOGV(" location: \"%s\"\n", c_str(identifier.location));
1071 ALOGV(" unique id: \"%s\"\n", c_str(identifier.uniqueId));
1072 ALOGV(" descriptor: \"%s\"\n", c_str(identifier.descriptor));
1073 ALOGV(" driver: v%d.%d.%d\n",
1074 driverVersion >> 16, (driverVersion >> 8) & 0xff, driverVersion & 0xff);
1075
1076 // Load the configuration file for the device.
1077 loadConfigurationLocked(device);
1078
1079 // Figure out the kinds of events the device reports.
1080 ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(device->keyBitmask)), device->keyBitmask);
1081 ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(device->absBitmask)), device->absBitmask);
1082 ioctl(fd, EVIOCGBIT(EV_REL, sizeof(device->relBitmask)), device->relBitmask);
1083 ioctl(fd, EVIOCGBIT(EV_SW, sizeof(device->swBitmask)), device->swBitmask);
1084 ioctl(fd, EVIOCGBIT(EV_LED, sizeof(device->ledBitmask)), device->ledBitmask);
1085 ioctl(fd, EVIOCGBIT(EV_FF, sizeof(device->ffBitmask)), device->ffBitmask);
1086 ioctl(fd, EVIOCGPROP(sizeof(device->propBitmask)), device->propBitmask);
1087
1088 // See if this is a keyboard. Ignore everything in the button range except for
1089 // joystick and gamepad buttons which are handled like keyboards for the most part.
1090 bool haveKeyboardKeys = containsNonZeroByte(device->keyBitmask, 0, sizeof_bit_array(BTN_MISC))
1091 || containsNonZeroByte(device->keyBitmask, sizeof_bit_array(KEY_OK),
1092 sizeof_bit_array(KEY_MAX + 1));
1093 bool haveGamepadButtons = containsNonZeroByte(device->keyBitmask, sizeof_bit_array(BTN_MISC),
1094 sizeof_bit_array(BTN_MOUSE))
1095 || containsNonZeroByte(device->keyBitmask, sizeof_bit_array(BTN_JOYSTICK),
1096 sizeof_bit_array(BTN_DIGI));
1097 if (haveKeyboardKeys || haveGamepadButtons) {
1098 device->classes |= INPUT_DEVICE_CLASS_KEYBOARD;
1099 }
1100
1101 // See if this is a cursor device such as a trackball or mouse.
1102 if (test_bit(BTN_MOUSE, device->keyBitmask)
1103 && test_bit(REL_X, device->relBitmask)
1104 && test_bit(REL_Y, device->relBitmask)) {
1105 device->classes |= INPUT_DEVICE_CLASS_CURSOR;
1106 }
1107
1108 // See if this is a touch pad.
1109 // Is this a new modern multi-touch driver?
1110 if (test_bit(ABS_MT_POSITION_X, device->absBitmask)
1111 && test_bit(ABS_MT_POSITION_Y, device->absBitmask)) {
1112 // Some joysticks such as the PS3 controller report axes that conflict
1113 // with the ABS_MT range. Try to confirm that the device really is
1114 // a touch screen.
1115 if (test_bit(BTN_TOUCH, device->keyBitmask) || !haveGamepadButtons) {
1116 device->classes |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;
1117 }
1118 // Is this an old style single-touch driver?
1119 } else if (test_bit(BTN_TOUCH, device->keyBitmask)
1120 && test_bit(ABS_X, device->absBitmask)
1121 && test_bit(ABS_Y, device->absBitmask)) {
1122 device->classes |= INPUT_DEVICE_CLASS_TOUCH;
1123 }
1124
1125 // See if this device is a joystick.
1126 // Assumes that joysticks always have gamepad buttons in order to distinguish them
1127 // from other devices such as accelerometers that also have absolute axes.
1128 if (haveGamepadButtons) {
1129 uint32_t assumedClasses = device->classes | INPUT_DEVICE_CLASS_JOYSTICK;
1130 for (int i = 0; i <= ABS_MAX; i++) {
1131 if (test_bit(i, device->absBitmask)
1132 && (getAbsAxisUsage(i, assumedClasses) & INPUT_DEVICE_CLASS_JOYSTICK)) {
1133 device->classes = assumedClasses;
1134 break;
1135 }
1136 }
1137 }
1138
1139 // Check whether this device has switches.
1140 for (int i = 0; i <= SW_MAX; i++) {
1141 if (test_bit(i, device->swBitmask)) {
1142 device->classes |= INPUT_DEVICE_CLASS_SWITCH;
1143 break;
1144 }
1145 }
1146
1147 // Check whether this device supports the vibrator.
1148 if (test_bit(FF_RUMBLE, device->ffBitmask)) {
1149 device->classes |= INPUT_DEVICE_CLASS_VIBRATOR;
1150 }
1151
1152 // Configure virtual keys.
1153 if ((device->classes & INPUT_DEVICE_CLASS_TOUCH)) {
1154 // Load the virtual keys for the touch screen, if any.
1155 // We do this now so that we can make sure to load the keymap if necessary.
1156 status_t status = loadVirtualKeyMapLocked(device);
1157 if (!status) {
1158 device->classes |= INPUT_DEVICE_CLASS_KEYBOARD;
1159 }
1160 }
1161
1162 // Load the key map.
1163 // We need to do this for joysticks too because the key layout may specify axes.
1164 status_t keyMapStatus = NAME_NOT_FOUND;
1165 if (device->classes & (INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_JOYSTICK)) {
1166 // Load the keymap for the device.
1167 keyMapStatus = loadKeyMapLocked(device);
1168 }
1169
1170 // Configure the keyboard, gamepad or virtual keyboard.
1171 if (device->classes & INPUT_DEVICE_CLASS_KEYBOARD) {
1172 // Register the keyboard as a built-in keyboard if it is eligible.
1173 if (!keyMapStatus
1174 && mBuiltInKeyboardId == NO_BUILT_IN_KEYBOARD
1175 && isEligibleBuiltInKeyboard(device->identifier,
1176 device->configuration, &device->keyMap)) {
1177 mBuiltInKeyboardId = device->id;
1178 }
1179
1180 // 'Q' key support = cheap test of whether this is an alpha-capable kbd
1181 if (hasKeycodeLocked(device, AKEYCODE_Q)) {
1182 device->classes |= INPUT_DEVICE_CLASS_ALPHAKEY;
1183 }
1184
1185 // See if this device has a DPAD.
1186 if (hasKeycodeLocked(device, AKEYCODE_DPAD_UP) &&
1187 hasKeycodeLocked(device, AKEYCODE_DPAD_DOWN) &&
1188 hasKeycodeLocked(device, AKEYCODE_DPAD_LEFT) &&
1189 hasKeycodeLocked(device, AKEYCODE_DPAD_RIGHT) &&
1190 hasKeycodeLocked(device, AKEYCODE_DPAD_CENTER)) {
1191 device->classes |= INPUT_DEVICE_CLASS_DPAD;
1192 }
1193
1194 // See if this device has a gamepad.
1195 for (size_t i = 0; i < sizeof(GAMEPAD_KEYCODES)/sizeof(GAMEPAD_KEYCODES[0]); i++) {
1196 if (hasKeycodeLocked(device, GAMEPAD_KEYCODES[i])) {
1197 device->classes |= INPUT_DEVICE_CLASS_GAMEPAD;
1198 break;
1199 }
1200 }
1201 }
1202
1203 // If the device isn't recognized as something we handle, don't monitor it.
1204 if (device->classes == 0) {
1205 ALOGV("Dropping device: id=%d, path='%s', name='%s'",
1206 deviceId, devicePath, c_str(device->identifier.name));
1207 delete device;
1208 return -1;
1209 }
1210
1211 // Determine whether the device is external or internal.
1212 if (isExternalDeviceLocked(device)) {
1213 device->classes |= INPUT_DEVICE_CLASS_EXTERNAL;
1214 }
1215
1216 // Register with epoll.
1217 struct epoll_event eventItem;
1218 memset(&eventItem, 0, sizeof(eventItem));
1219 eventItem.events = EPOLLIN;
1220 eventItem.data.u32 = deviceId;
1221 if (epoll_ctl(mEpollFd, EPOLL_CTL_ADD, fd, &eventItem)) {
1222 ALOGE("Could not add device fd to epoll instance. errno=%d", errno);
1223 delete device;
1224 return -1;
1225 }
1226
1227 // Enable wake-lock behavior on kernels that support it.
1228 // TODO: Only need this for devices that can really wake the system.
1229 bool usingSuspendBlockIoctl = !ioctl(fd, EVIOCSSUSPENDBLOCK, 1);
1230
1231 // Tell the kernel that we want to use the monotonic clock for reporting timestamps
1232 // associated with input events. This is important because the input system
1233 // uses the timestamps extensively and assumes they were recorded using the monotonic
1234 // clock.
1235 //
1236 // In older kernel, before Linux 3.4, there was no way to tell the kernel which
1237 // clock to use to input event timestamps. The standard kernel behavior was to
1238 // record a real time timestamp, which isn't what we want. Android kernels therefore
1239 // contained a patch to the evdev_event() function in drivers/input/evdev.c to
1240 // replace the call to do_gettimeofday() with ktime_get_ts() to cause the monotonic
1241 // clock to be used instead of the real time clock.
1242 //
1243 // As of Linux 3.4, there is a new EVIOCSCLOCKID ioctl to set the desired clock.
1244 // Therefore, we no longer require the Android-specific kernel patch described above
1245 // as long as we make sure to set select the monotonic clock. We do that here.
1246 int clockId = CLOCK_MONOTONIC;
1247 bool usingClockIoctl = !ioctl(fd, EVIOCSCLOCKID, &clockId);
1248
1249 ALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=0x%x, "
1250 "configuration='%s', keyLayout='%s', keyCharacterMap='%s', builtinKeyboard=%s, "
1251 "usingSuspendBlockIoctl=%s, usingClockIoctl=%s",
1252 deviceId, fd, devicePath, c_str(device->identifier.name),
1253 device->classes,
1254 c_str(device->configurationFile),
1255 c_str(device->keyMap.keyLayoutFile),
1256 c_str(device->keyMap.keyCharacterMapFile),
1257 toString(mBuiltInKeyboardId == deviceId),
1258 toString(usingSuspendBlockIoctl), toString(usingClockIoctl));
1259
1260 addDeviceLocked(device);
1261 return 0;
1262}
1263
1264void EventHub::createVirtualKeyboardLocked() {
1265 InputDeviceIdentifier identifier;
1266 identifier.name = "Virtual";
1267 identifier.uniqueId = "<virtual>";
1268 setDescriptor(identifier);
1269
1270 Device* device = new Device(-1, VIRTUAL_KEYBOARD_ID, String8("<virtual>"), identifier);
1271 device->classes = INPUT_DEVICE_CLASS_KEYBOARD
1272 | INPUT_DEVICE_CLASS_ALPHAKEY
1273 | INPUT_DEVICE_CLASS_DPAD
1274 | INPUT_DEVICE_CLASS_VIRTUAL;
1275 loadKeyMapLocked(device);
1276 addDeviceLocked(device);
1277}
1278
1279void EventHub::addDeviceLocked(Device* device) {
1280 mDevices.add(device->id, device);
1281 device->next = mOpeningDevices;
1282 mOpeningDevices = device;
1283}
1284
1285void EventHub::loadConfigurationLocked(Device* device) {
1286 device->configurationFile = getInputDeviceConfigurationFilePathByDeviceIdentifier(
1287 device->identifier, INPUT_DEVICE_CONFIGURATION_FILE_TYPE_CONFIGURATION);
1288 if (isEmpty(device->configurationFile)) {
1289 ALOGD("No input device configuration file found for device '%s'.",
1290 c_str(device->identifier.name));
1291 } else {
1292 status_t status = PropertyMap::load(device->configurationFile,
1293 &device->configuration);
1294 if (status) {
1295 ALOGE("Error loading input device configuration file for device '%s'. "
1296 "Using default configuration.",
1297 c_str(device->identifier.name));
1298 }
1299 }
1300}
1301
1302status_t EventHub::loadVirtualKeyMapLocked(Device* device) {
1303 // The virtual key map is supplied by the kernel as a system board property file.
1304 String8 path;
1305 path.append("/sys/board_properties/virtualkeys.");
1306 path.append(device->identifier.name);
1307 if (access(c_str(path), R_OK)) {
1308 return NAME_NOT_FOUND;
1309 }
1310 return VirtualKeyMap::load(path, &device->virtualKeyMap);
1311}
1312
1313status_t EventHub::loadKeyMapLocked(Device* device) {
1314 // <mir changes>
1315 status_t status = device->keyMap.load(device->identifier, device->configuration);
1316 if (status)
1317 status = device->keyMap.loadGenericMaps();
1318
1319 return status;
1320 // </mir changes>
1321}
1322
1323bool EventHub::isExternalDeviceLocked(Device* device) {
1324 if (device->configuration) {
1325 bool value;
1326 if (device->configuration->tryGetProperty(String8("device.internal"), value)) {
1327 return !value;
1328 }
1329 }
1330 return device->identifier.bus == BUS_USB || device->identifier.bus == BUS_BLUETOOTH;
1331}
1332
1333bool EventHub::hasKeycodeLocked(Device* device, int keycode) const {
1334 if (!device->keyMap.haveKeyLayout()) {
1335 return false;
1336 }
1337
1338 Vector<int32_t> scanCodes;
1339 device->keyMap.keyLayoutMap->findScanCodesForKey(keycode, &scanCodes);
1340 const size_t N = scanCodes.size();
1341 for (size_t i=0; i<N && i<=KEY_MAX; i++) {
1342 int32_t sc = scanCodes.itemAt(i);
1343 if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, device->keyBitmask)) {
1344 return true;
1345 }
1346 }
1347
1348 return false;
1349}
1350
1351status_t EventHub::closeDeviceByPathLocked(const char *devicePath) {
1352 Device* device = getDeviceByPathLocked(devicePath);
1353 if (device) {
1354 closeDeviceLocked(device);
1355 return 0;
1356 }
1357 ALOGV("Remove device: %s not found, device may already have been removed.", devicePath);
1358 return -1;
1359}
1360
1361void EventHub::closeAllDevicesLocked() {
1362 while (mDevices.size() > 0) {
1363 closeDeviceLocked(mDevices.valueAt(mDevices.size() - 1));
1364 }
1365}
1366
1367void EventHub::closeDeviceLocked(Device* device) {
1368 ALOGI("Removed device: path=%s name=%s id=%d fd=%d classes=0x%x\n",
1369 c_str(device->path), c_str(device->identifier.name), device->id,
1370 device->fd, device->classes);
1371
1372 if (device->id == mBuiltInKeyboardId) {
1373 ALOGW("built-in keyboard device %s (id=%d) is closing! the apps will not like this",
1374 c_str(device->path), mBuiltInKeyboardId);
1375 mBuiltInKeyboardId = NO_BUILT_IN_KEYBOARD;
1376 }
1377
1378 if (!device->isVirtual()) {
1379 if (epoll_ctl(mEpollFd, EPOLL_CTL_DEL, device->fd, NULL)) {
1380 ALOGW("Could not remove device fd from epoll instance. errno=%d", errno);
1381 }
1382 }
1383
1384 mDevices.removeItem(device->id);
1385 device->close();
1386
1387 // Unlink for opening devices list if it is present.
1388 Device* pred = NULL;
1389 bool found = false;
1390 for (Device* entry = mOpeningDevices; entry != NULL; ) {
1391 if (entry == device) {
1392 found = true;
1393 break;
1394 }
1395 pred = entry;
1396 entry = entry->next;
1397 }
1398 if (found) {
1399 // Unlink the device from the opening devices list then delete it.
1400 // We don't need to tell the client that the device was closed because
1401 // it does not even know it was opened in the first place.
1402 ALOGI("Device %s was immediately closed after opening.", c_str(device->path));
1403 if (pred) {
1404 pred->next = device->next;
1405 } else {
1406 mOpeningDevices = device->next;
1407 }
1408 delete device;
1409 } else {
1410 // Link into closing devices list.
1411 // The device will be deleted later after we have informed the client.
1412 device->next = mClosingDevices;
1413 mClosingDevices = device;
1414 }
1415}
1416
1417void EventHub::requestReopenDevices() {
1418 ALOGV("requestReopenDevices() called");
1419
1420 AutoMutex _l(mLock);
1421 mNeedToReopenDevices = true;
1422}
1423
1424void EventHub::dump(String8& dump) {
1425 dump.append("Event Hub State:\n");
1426
1427 { // acquire lock
1428 AutoMutex _l(mLock);
1429
1430 appendFormat(dump, INDENT "BuiltInKeyboardId: %d\n", mBuiltInKeyboardId);
1431
1432 dump.append(INDENT "Devices:\n");
1433
1434 for (size_t i = 0; i < mDevices.size(); i++) {
1435 const Device* device = mDevices.valueAt(i);
1436 if (mBuiltInKeyboardId == device->id) {
1437 appendFormat(dump, INDENT2 "%d: %s (aka device 0 - built-in keyboard)\n",
1438 device->id, c_str(device->identifier.name));
1439 } else {
1440 appendFormat(dump, INDENT2 "%d: %s\n", device->id,
1441 c_str(device->identifier.name));
1442 }
1443 appendFormat(dump, INDENT3 "Classes: 0x%08x\n", device->classes);
1444 appendFormat(dump, INDENT3 "Path: %s\n", c_str(device->path));
1445 appendFormat(dump, INDENT3 "Descriptor: %s\n", c_str(device->identifier.descriptor));
1446 appendFormat(dump, INDENT3 "Location: %s\n", c_str(device->identifier.location));
1447 appendFormat(dump, INDENT3 "UniqueId: %s\n", c_str(device->identifier.uniqueId));
1448 appendFormat(dump, INDENT3 "Identifier: bus=0x%04x, vendor=0x%04x, "
1449 "product=0x%04x, version=0x%04x\n",
1450 device->identifier.bus, device->identifier.vendor,
1451 device->identifier.product, device->identifier.version);
1452 appendFormat(dump, INDENT3 "KeyLayoutFile: %s\n",
1453 c_str(device->keyMap.keyLayoutFile));
1454 appendFormat(dump, INDENT3 "KeyCharacterMapFile: %s\n",
1455 c_str(device->keyMap.keyCharacterMapFile));
1456 appendFormat(dump, INDENT3 "ConfigurationFile: %s\n",
1457 c_str(device->configurationFile));
1458 appendFormat(dump, INDENT3 "HaveKeyboardLayoutOverlay: %s\n",
1459 toString(device->overlayKeyMap != NULL));
1460 }
1461 } // release lock
1462}
1463
1464void EventHub::monitor() {
1465 // Acquire and release the lock to ensure that the event hub has not deadlocked.
1466 mLock.lock();
1467 mLock.unlock();
1468}
1469
1470void EventHub::flush() {
1471 static const int bufferSize = 256;
1472
1473 AutoMutex _l(mLock);
1474
1475 char readBuffer[bufferSize];
1476 int32_t readSize;
1477
1478 // Read any pending events from the input devices. Note that
1479 // the device fds are in non-blocking mode (see openDeviceLocked).
1480 for (size_t i = 0; i < mDevices.size(); i++) {
1481 const Device* device = mDevices.valueAt(i);
1482 do {
1483 readSize = read(device->fd, readBuffer, bufferSize);
1484 } while (readSize > 0);
1485 }
1486}
1487
1488bool EventHub::hasDeviceByPathLocked(String8 const& path)
1489{
1490 for (size_t i = 0; i < mDevices.size(); i++) {
1491 auto const& device = mDevices.valueAt(i);
1492 if (device->path == path) return true;
1493 }
1494 return false;
1495}
1496
1497mir::Fd EventHub::fd()
1498{
1499 return mEpollFd;
1500}
1501
1502}; // namespace android
15030
=== removed file '3rd_party/android-input/android/frameworks/base/services/input/EventHub.h'
--- 3rd_party/android-input/android/frameworks/base/services/input/EventHub.h 2015-06-17 05:20:42 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/EventHub.h 1970-01-01 00:00:00 +0000
@@ -1,444 +0,0 @@
1/*
2 * Copyright (C) 2005 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//
18#ifndef _RUNTIME_EVENT_HUB_H
19#define _RUNTIME_EVENT_HUB_H
20
21#include <androidfw/Input.h>
22#include <androidfw/InputDevice.h>
23#include <androidfw/Keyboard.h>
24#include <androidfw/KeyLayoutMap.h>
25#include <androidfw/KeyCharacterMap.h>
26#include <androidfw/VirtualKeyMap.h>
27#include <std/String8.h>
28#include <std/Mutex.h>
29#include <std/List.h>
30#include <std/Errors.h>
31#include <std/PropertyMap.h>
32#include <std/Vector.h>
33#include <std/KeyedVector.h>
34
35#include "mir/fd.h"
36
37#include <linux/input.h>
38#include <sys/epoll.h>
39
40#include <memory>
41
42namespace mir
43{
44namespace udev { class Monitor; }
45namespace input
46{
47class InputReport;
48}
49}
50
51/* Convenience constants. */
52
53#define BTN_FIRST 0x100 // first button code
54#define BTN_LAST 0x15f // last button code
55
56namespace android {
57
58enum {
59 // Device id of a special "virtual" keyboard that is always present.
60 VIRTUAL_KEYBOARD_ID = -1,
61 // Device id of the "built-in" keyboard if there is one.
62 BUILT_IN_KEYBOARD_ID = 0
63};
64
65/*
66 * A raw event as retrieved from the EventHub.
67 */
68struct RawEvent {
69 std::chrono::nanoseconds when;
70 int32_t deviceId;
71 int32_t type;
72 int32_t code;
73 int32_t value;
74};
75
76/* Describes an absolute axis. */
77struct RawAbsoluteAxisInfo {
78 bool valid; // true if the information is valid, false otherwise
79
80 int32_t minValue; // minimum value
81 int32_t maxValue; // maximum value
82 int32_t flat; // center flat position, eg. flat == 8 means center is between -8 and 8
83 int32_t fuzz; // error tolerance, eg. fuzz == 4 means value is +/- 4 due to noise
84 int32_t resolution; // resolution in units per mm or radians per mm
85
86 inline void clear() {
87 valid = false;
88 minValue = 0;
89 maxValue = 0;
90 flat = 0;
91 fuzz = 0;
92 resolution = 0;
93 }
94};
95
96/*
97 * Input device classes.
98 */
99enum {
100 /* The input device is a keyboard or has buttons. */
101 INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001,
102
103 /* The input device is an alpha-numeric keyboard (not just a dial pad). */
104 INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002,
105
106 /* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */
107 INPUT_DEVICE_CLASS_TOUCH = 0x00000004,
108
109 /* The input device is a cursor device such as a trackball or mouse. */
110 INPUT_DEVICE_CLASS_CURSOR = 0x00000008,
111
112 /* The input device is a multi-touch touchscreen. */
113 INPUT_DEVICE_CLASS_TOUCH_MT = 0x00000010,
114
115 /* The input device is a directional pad (implies keyboard, has DPAD keys). */
116 INPUT_DEVICE_CLASS_DPAD = 0x00000020,
117
118 /* The input device is a gamepad (implies keyboard, has BUTTON keys). */
119 INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040,
120
121 /* The input device has switches. */
122 INPUT_DEVICE_CLASS_SWITCH = 0x00000080,
123
124 /* The input device is a joystick (implies gamepad, has joystick absolute axes). */
125 INPUT_DEVICE_CLASS_JOYSTICK = 0x00000100,
126
127 /* The input device has a vibrator (supports FF_RUMBLE). */
128 INPUT_DEVICE_CLASS_VIBRATOR = 0x00000200,
129
130 /* The input device is virtual (not a real device, not part of UI configuration). */
131 INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000,
132
133 /* The input device is external (not built-in). */
134 INPUT_DEVICE_CLASS_EXTERNAL = 0x80000000
135};
136
137/*
138 * Gets the class that owns an axis, in cases where multiple classes might claim
139 * the same axis for different purposes.
140 */
141extern uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses);
142
143/*
144 * Grand Central Station for events.
145 *
146 * The event hub aggregates input events received across all known input
147 * devices on the system, including devices that may be emulated by the simulator
148 * environment. In addition, the event hub generates fake input events to indicate
149 * when devices are added or removed.
150 *
151 * The event hub provides a stream of input events (via the getEvent function).
152 * It also supports querying the current actual state of input devices such as identifying
153 * which keys are currently down. Finally, the event hub keeps track of the capabilities of
154 * individual input devices, such as their class and the set of key codes that they support.
155 */
156class EventHubInterface : public virtual RefBase {
157protected:
158 EventHubInterface() { }
159 virtual ~EventHubInterface() { }
160
161public:
162 // Synthetic raw event type codes produced when devices are added or removed.
163 enum {
164 // Sent when a device is added.
165 DEVICE_ADDED = 0x10000000,
166 // Sent when a device is removed.
167 DEVICE_REMOVED = 0x20000000,
168 // Sent when all added/removed devices from the most recent scan have been reported.
169 // This event is always sent at least once.
170 FINISHED_DEVICE_SCAN = 0x30000000,
171
172 FIRST_SYNTHETIC_EVENT = DEVICE_ADDED
173 };
174
175 virtual uint32_t getDeviceClasses(int32_t deviceId) const = 0;
176
177 virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const = 0;
178
179 virtual void getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const = 0;
180
181 virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
182 RawAbsoluteAxisInfo* outAxisInfo) const = 0;
183
184 virtual bool hasRelativeAxis(int32_t deviceId, int axis) const = 0;
185
186 virtual bool hasInputProperty(int32_t deviceId, int property) const = 0;
187
188 virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode,
189 int32_t* outKeycode, uint32_t* outFlags) const = 0;
190
191 virtual status_t mapAxis(int32_t deviceId, int32_t scanCode,
192 AxisInfo* outAxisInfo) const = 0;
193
194 // Sets devices that are excluded from opening.
195 // This can be used to ignore input devices for sensors.
196 virtual void setExcludedDevices(const Vector<String8>& devices) = 0;
197
198 /*
199 * Tests for available events and returns them.
200 * After returning, the EventHub holds onto a wake lock until the next call to getEvent.
201 * This ensures that the device will not go to sleep while the event is being processed.
202 * If the device needs to remain awake longer than that, then the caller is responsible
203 * for taking care of it (say, by poking the power manager user activity timer).
204 *
205 * Returns the number of events obtained.
206 */
207 virtual size_t getEvents(RawEvent* buffer, size_t bufferSize) = 0;
208
209 /*
210 * Query current input state.
211 */
212 virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const = 0;
213 virtual int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const = 0;
214 virtual int32_t getSwitchState(int32_t deviceId, int32_t sw) const = 0;
215 virtual status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis,
216 int32_t* outValue) const = 0;
217
218 /*
219 * Examine key input devices for specific framework keycode support
220 */
221 virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes, const int32_t* keyCodes,
222 uint8_t* outFlags) const = 0;
223
224 virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const = 0;
225 virtual bool hasLed(int32_t deviceId, int32_t led) const = 0;
226 virtual void setLedState(int32_t deviceId, int32_t led, bool on) = 0;
227
228 virtual void getVirtualKeyDefinitions(int32_t deviceId,
229 Vector<VirtualKeyDefinition>& outVirtualKeys) const = 0;
230
231 virtual sp<KeyCharacterMap> getKeyCharacterMap(int32_t deviceId) const = 0;
232 virtual bool setKeyboardLayoutOverlay(int32_t deviceId, const sp<KeyCharacterMap>& map) = 0;
233
234 /* Control the vibrator. */
235 virtual void vibrate(int32_t deviceId, std::chrono::nanoseconds duration) = 0;
236 virtual void cancelVibrate(int32_t deviceId) = 0;
237
238 /* Requests the EventHub to reopen all input devices on the next call to getEvents(). */
239 virtual void requestReopenDevices() = 0;
240
241 /* Wakes up getEvents() if it is blocked on a read. */
242 virtual void wake() = 0;
243
244 /* Ensures that fd() readable after given timeout */
245 virtual void wakeIn(int32_t timeout) = 0;
246
247 /* Dump EventHub state to a string. */
248 virtual void dump(String8& dump) = 0;
249
250 /* Called by the heatbeat to ensures that the reader has not deadlocked. */
251 virtual void monitor() = 0;
252
253 /* Flush all pending events not yet read from the input devices */
254 virtual void flush() = 0;
255
256 /* Epoll fd used by EventHub */
257 virtual mir::Fd fd() = 0;
258};
259
260class EventHub : public EventHubInterface
261{
262public:
263 EventHub(std::shared_ptr<mir::input::InputReport> const& input_report);
264
265 virtual uint32_t getDeviceClasses(int32_t deviceId) const;
266
267 virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const;
268
269 virtual void getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const;
270
271 virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis,
272 RawAbsoluteAxisInfo* outAxisInfo) const;
273
274 virtual bool hasRelativeAxis(int32_t deviceId, int axis) const;
275
276 virtual bool hasInputProperty(int32_t deviceId, int property) const;
277
278 virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode,
279 int32_t* outKeycode, uint32_t* outFlags) const;
280
281 virtual status_t mapAxis(int32_t deviceId, int32_t scanCode,
282 AxisInfo* outAxisInfo) const;
283
284 virtual void setExcludedDevices(const Vector<String8>& devices);
285
286 virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const;
287 virtual int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const;
288 virtual int32_t getSwitchState(int32_t deviceId, int32_t sw) const;
289 virtual status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis, int32_t* outValue) const;
290
291 virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes,
292 const int32_t* keyCodes, uint8_t* outFlags) const;
293
294 virtual size_t getEvents(RawEvent* buffer, size_t bufferSize);
295
296 virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const;
297 virtual bool hasLed(int32_t deviceId, int32_t led) const;
298 virtual void setLedState(int32_t deviceId, int32_t led, bool on);
299
300 virtual void getVirtualKeyDefinitions(int32_t deviceId,
301 Vector<VirtualKeyDefinition>& outVirtualKeys) const;
302
303 virtual sp<KeyCharacterMap> getKeyCharacterMap(int32_t deviceId) const;
304 virtual bool setKeyboardLayoutOverlay(int32_t deviceId, const sp<KeyCharacterMap>& map);
305
306 virtual void vibrate(int32_t deviceId, std::chrono::nanoseconds duration);
307 virtual void cancelVibrate(int32_t deviceId);
308
309 virtual void requestReopenDevices();
310
311 virtual void wake();
312 virtual void wakeIn(int32_t timeout);
313
314 virtual void dump(String8& dump);
315 virtual void monitor();
316 virtual void flush();
317 virtual mir::Fd fd();
318
319 virtual ~EventHub();
320
321 // Ids used for epoll notifications not associated with devices.
322 static const uint32_t EPOLL_ID_UDEV = 0x80000001;
323 static const uint32_t EPOLL_ID_WAKE = 0x80000002;
324 static const uint32_t EPOLL_ID_TIMER = 0x80000003;
325private:
326 std::shared_ptr<mir::input::InputReport> const input_report;
327
328 struct Device {
329 Device* next;
330
331 int fd; // may be -1 if device is virtual
332 const int32_t id;
333 const String8 path;
334 const InputDeviceIdentifier identifier;
335
336 uint32_t classes;
337
338 uint8_t keyBitmask[(KEY_MAX + 1) / 8];
339 uint8_t absBitmask[(ABS_MAX + 1) / 8];
340 uint8_t relBitmask[(REL_MAX + 1) / 8];
341 uint8_t swBitmask[(SW_MAX + 1) / 8];
342 uint8_t ledBitmask[(LED_MAX + 1) / 8];
343 uint8_t ffBitmask[(FF_MAX + 1) / 8];
344 uint8_t propBitmask[(INPUT_PROP_MAX + 1) / 8];
345
346 String8 configurationFile;
347 PropertyMap* configuration;
348 VirtualKeyMap* virtualKeyMap;
349 KeyMap keyMap;
350
351 sp<KeyCharacterMap> overlayKeyMap;
352 sp<KeyCharacterMap> combinedKeyMap;
353
354 bool ffEffectPlaying;
355 int16_t ffEffectId; // initially -1
356
357 Device(int fd, int32_t id, const String8& path, const InputDeviceIdentifier& identifier);
358 ~Device();
359
360 void close();
361
362 inline bool isVirtual() const { return fd < 0; }
363
364 const sp<KeyCharacterMap>& getKeyCharacterMap() const {
365 if (combinedKeyMap != NULL) {
366 return combinedKeyMap;
367 }
368 return keyMap.keyCharacterMap;
369 }
370 };
371
372 status_t openDeviceLocked(const char *devicePath);
373 void createVirtualKeyboardLocked();
374 void addDeviceLocked(Device* device);
375
376 status_t closeDeviceByPathLocked(const char *devicePath);
377 void closeDeviceLocked(Device* device);
378 void closeAllDevicesLocked();
379
380 void scanDevicesLocked();
381 void handleUdevEventsLocked();
382
383 Device* getDeviceLocked(int32_t deviceId) const;
384 Device* getDeviceByPathLocked(const char* devicePath) const;
385
386 bool hasKeycodeLocked(Device* device, int keycode) const;
387
388 void loadConfigurationLocked(Device* device);
389 status_t loadVirtualKeyMapLocked(Device* device);
390 status_t loadKeyMapLocked(Device* device);
391
392 bool isExternalDeviceLocked(Device* device);
393
394 // Protect all internal state.
395 mutable Mutex mLock;
396
397 // The actual id of the built-in keyboard, or NO_BUILT_IN_KEYBOARD if none.
398 // EventHub remaps the built-in keyboard to id 0 externally as required by the API.
399 enum {
400 // Must not conflict with any other assigned device ids, including
401 // the virtual keyboard id (-1).
402 NO_BUILT_IN_KEYBOARD = -2
403 };
404 int32_t mBuiltInKeyboardId;
405
406 int32_t mNextDeviceId;
407
408 bool hasDeviceByPathLocked(String8 const& path);
409 KeyedVector<int32_t, Device*> mDevices;
410
411 Device *mOpeningDevices;
412 Device *mClosingDevices;
413
414 bool mNeedToSendFinishedDeviceScan;
415 bool mNeedToReopenDevices;
416 bool mNeedToScanDevices;
417 Vector<String8> mExcludedDevices;
418
419 mir::Fd mEpollFd;
420 mir::Fd mTimerFd;
421 std::unique_ptr<mir::udev::Monitor> const device_listener;
422 int mWakeReadPipeFd;
423 int mWakeWritePipeFd;
424
425 // Epoll FD list size hint.
426 static const int EPOLL_SIZE_HINT = 8;
427
428 // Maximum number of signalled FDs to handle at a time.
429 static const int EPOLL_MAX_EVENTS = 16;
430
431 // The array of pending epoll events and the index of the next event to be handled.
432 struct epoll_event mPendingEventItems[EPOLL_MAX_EVENTS];
433 size_t mPendingEventCount;
434 size_t mPendingEventIndex;
435 bool mPendingUdevEvent;
436};
437
438// Made available to test
439namespace detail { String8 sha1(const String8& in); }
440
441
442} // namespace android
443
444#endif // _RUNTIME_EVENT_HUB_H
4450
=== removed file '3rd_party/android-input/android/frameworks/base/services/input/GenericKeyMap.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/GenericKeyMap.cpp 2013-02-05 17:19:57 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/GenericKeyMap.cpp 1970-01-01 00:00:00 +0000
@@ -1,1009 +0,0 @@
1// Copyright (C) 2010 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15
16#include <androidfw/GenericKeyMap.h>
17
18const char* android::GenericKeyMap::key_layout_contents()
19{
20 static const char* result =
21 "key 1 ESCAPE\n" \
22 "key 2 1\n" \
23 "key 3 2\n" \
24 "key 4 3\n" \
25 "key 5 4\n" \
26 "key 6 5\n" \
27 "key 7 6\n" \
28 "key 8 7\n" \
29 "key 9 8\n" \
30 "key 10 9\n" \
31 "key 11 0\n" \
32 "key 12 MINUS\n" \
33 "key 13 EQUALS\n" \
34 "key 14 DEL\n" \
35 "key 15 TAB\n" \
36 "key 16 Q\n" \
37 "key 17 W\n" \
38 "key 18 E\n" \
39 "key 19 R\n" \
40 "key 20 T\n" \
41 "key 21 Y\n" \
42 "key 22 U\n" \
43 "key 23 I\n" \
44 "key 24 O\n" \
45 "key 25 P\n" \
46 "key 26 LEFT_BRACKET\n" \
47 "key 27 RIGHT_BRACKET\n" \
48 "key 28 ENTER\n" \
49 "key 29 CTRL_LEFT\n" \
50 "key 30 A\n" \
51 "key 31 S\n" \
52 "key 32 D\n" \
53 "key 33 F\n" \
54 "key 34 G\n" \
55 "key 35 H\n" \
56 "key 36 J\n" \
57 "key 37 K\n" \
58 "key 38 L\n" \
59 "key 39 SEMICOLON\n" \
60 "key 40 APOSTROPHE\n" \
61 "key 41 GRAVE\n" \
62 "key 42 SHIFT_LEFT\n" \
63 "key 43 BACKSLASH\n" \
64 "key 44 Z\n" \
65 "key 45 X\n" \
66 "key 46 C\n" \
67 "key 47 V\n" \
68 "key 48 B\n" \
69 "key 49 N\n" \
70 "key 50 M\n" \
71 "key 51 COMMA\n" \
72 "key 52 PERIOD\n" \
73 "key 53 SLASH\n" \
74 "key 54 SHIFT_RIGHT\n" \
75 "key 55 NUMPAD_MULTIPLY\n" \
76 "key 56 ALT_LEFT\n" \
77 "key 57 SPACE\n" \
78 "key 58 CAPS_LOCK\n" \
79 "key 59 F1\n" \
80 "key 60 F2\n" \
81 "key 61 F3\n" \
82 "key 62 F4\n" \
83 "key 63 F5\n" \
84 "key 64 F6\n" \
85 "key 65 F7\n" \
86 "key 66 F8\n" \
87 "key 67 F9\n" \
88 "key 68 F10\n" \
89 "key 69 NUM_LOCK\n" \
90 "key 70 SCROLL_LOCK\n" \
91 "key 71 NUMPAD_7\n" \
92 "key 72 NUMPAD_8\n" \
93 "key 73 NUMPAD_9\n" \
94 "key 74 NUMPAD_SUBTRACT\n" \
95 "key 75 NUMPAD_4\n" \
96 "key 76 NUMPAD_5\n" \
97 "key 77 NUMPAD_6\n" \
98 "key 78 NUMPAD_ADD\n" \
99 "key 79 NUMPAD_1\n" \
100 "key 80 NUMPAD_2\n" \
101 "key 81 NUMPAD_3\n" \
102 "key 82 NUMPAD_0\n" \
103 "key 83 NUMPAD_DOT\n" \
104 "# key 84 (undefined)\n" \
105 "key 85 ZENKAKU_HANKAKU\n" \
106 "key 86 BACKSLASH\n" \
107 "key 87 F11\n" \
108 "key 88 F12\n" \
109 "key 89 RO\n" \
110 "# key 90 \"KEY_KATAKANA\"\n" \
111 "# key 91 \"KEY_HIRAGANA\"\n" \
112 "key 92 HENKAN\n" \
113 "key 93 KATAKANA_HIRAGANA\n" \
114 "key 94 MUHENKAN\n" \
115 "key 95 NUMPAD_COMMA\n" \
116 "key 96 NUMPAD_ENTER\n" \
117 "key 97 CTRL_RIGHT\n" \
118 "key 98 NUMPAD_DIVIDE\n" \
119 "key 99 SYSRQ\n" \
120 "key 100 ALT_RIGHT\n" \
121 "# key 101 \"KEY_LINEFEED\"\n" \
122 "key 102 MOVE_HOME\n" \
123 "key 103 DPAD_UP\n" \
124 "key 104 PAGE_UP\n" \
125 "key 105 DPAD_LEFT\n" \
126 "key 106 DPAD_RIGHT\n" \
127 "key 107 MOVE_END\n" \
128 "key 108 DPAD_DOWN\n" \
129 "key 109 PAGE_DOWN\n" \
130 "key 110 INSERT\n" \
131 "key 111 FORWARD_DEL\n" \
132 "# key 112 \"KEY_MACRO\"\n" \
133 "key 113 VOLUME_MUTE\n" \
134 "key 114 VOLUME_DOWN\n" \
135 "key 115 VOLUME_UP\n" \
136 "key 116 POWER WAKE\n" \
137 "key 117 NUMPAD_EQUALS\n" \
138 "# key 118 \"KEY_KPPLUSMINUS\"\n" \
139 "key 119 BREAK\n" \
140 "# key 120 (undefined)\n" \
141 "key 121 NUMPAD_COMMA\n" \
142 "key 122 KANA\n" \
143 "key 123 EISU\n" \
144 "key 124 YEN\n" \
145 "key 125 META_LEFT\n" \
146 "key 126 META_RIGHT\n" \
147 "key 127 MENU WAKE_DROPPED\n" \
148 "key 128 MEDIA_STOP\n" \
149 "# key 129 \"KEY_AGAIN\"\n" \
150 "# key 130 \"KEY_PROPS\"\n" \
151 "# key 131 \"KEY_UNDO\"\n" \
152 "# key 132 \"KEY_FRONT\"\n" \
153 "# key 133 \"KEY_COPY\"\n" \
154 "# key 134 \"KEY_OPEN\"\n" \
155 "# key 135 \"KEY_PASTE\"\n" \
156 "# key 136 \"KEY_FIND\"\n" \
157 "# key 137 \"KEY_CUT\"\n" \
158 "# key 138 \"KEY_HELP\"\n" \
159 "key 139 MENU WAKE_DROPPED\n" \
160 "key 140 CALCULATOR\n" \
161 "# key 141 \"KEY_SETUP\"\n" \
162 "key 142 POWER WAKE\n" \
163 "key 143 POWER WAKE\n" \
164 "# key 144 \"KEY_FILE\"\n" \
165 "# key 145 \"KEY_SENDFILE\"\n" \
166 "# key 146 \"KEY_DELETEFILE\"\n" \
167 "# key 147 \"KEY_XFER\"\n" \
168 "# key 148 \"KEY_PROG1\"\n" \
169 "# key 149 \"KEY_PROG2\"\n" \
170 "key 150 EXPLORER\n" \
171 "# key 151 \"KEY_MSDOS\"\n" \
172 "key 152 POWER WAKE\n" \
173 "# key 153 \"KEY_DIRECTION\"\n" \
174 "# key 154 \"KEY_CYCLEWINDOWS\"\n" \
175 "key 155 ENVELOPE\n" \
176 "key 156 BOOKMARK\n" \
177 "# key 157 \"KEY_COMPUTER\"\n" \
178 "key 158 BACK WAKE_DROPPED\n" \
179 "key 159 FORWARD\n" \
180 "key 160 MEDIA_CLOSE\n" \
181 "key 161 MEDIA_EJECT\n" \
182 "key 162 MEDIA_EJECT\n" \
183 "key 163 MEDIA_NEXT\n" \
184 "key 164 MEDIA_PLAY_PAUSE\n" \
185 "key 165 MEDIA_PREVIOUS\n" \
186 "key 166 MEDIA_STOP\n" \
187 "key 167 MEDIA_RECORD\n" \
188 "key 168 MEDIA_REWIND\n" \
189 "key 169 CALL\n" \
190 "# key 170 \"KEY_ISO\"\n" \
191 "key 171 MUSIC\n" \
192 "key 172 HOME\n" \
193 "# key 173 \"KEY_REFRESH\"\n" \
194 "# key 174 \"KEY_EXIT\"\n" \
195 "# key 175 \"KEY_MOVE\"\n" \
196 "# key 176 \"KEY_EDIT\"\n" \
197 "key 177 PAGE_UP\n" \
198 "key 178 PAGE_DOWN\n" \
199 "key 179 NUMPAD_LEFT_PAREN\n" \
200 "key 180 NUMPAD_RIGHT_PAREN\n" \
201 "# key 181 \"KEY_NEW\"\n" \
202 "# key 182 \"KEY_REDO\"\n" \
203 "# key 183 F13\n" \
204 "# key 184 F14\n" \
205 "# key 185 F15\n" \
206 "# key 186 F16\n" \
207 "# key 187 F17\n" \
208 "# key 188 F18\n" \
209 "# key 189 F19\n" \
210 "# key 190 F20\n" \
211 "# key 191 F21\n" \
212 "# key 192 F22\n" \
213 "# key 193 F23\n" \
214 "# key 194 F24\n" \
215 "# key 195 (undefined)\n" \
216 "# key 196 (undefined)\n" \
217 "# key 197 (undefined)\n" \
218 "# key 198 (undefined)\n" \
219 "# key 199 (undefined)\n" \
220 "key 200 MEDIA_PLAY\n" \
221 "key 201 MEDIA_PAUSE\n" \
222 "# key 202 \"KEY_PROG3\"\n" \
223 "# key 203 \"KEY_PROG4\"\n" \
224 "# key 204 (undefined)\n" \
225 "# key 205 \"KEY_SUSPEND\"\n" \
226 "# key 206 \"KEY_CLOSE\"\n" \
227 "key 207 MEDIA_PLAY\n" \
228 "key 208 MEDIA_FAST_FORWARD\n" \
229 "# key 209 \"KEY_BASSBOOST\"\n" \
230 "# key 210 \"KEY_PRINT\"\n" \
231 "# key 211 \"KEY_HP\"\n" \
232 "key 212 CAMERA\n" \
233 "key 213 MUSIC\n" \
234 "# key 214 \"KEY_QUESTION\"\n" \
235 "key 215 ENVELOPE\n" \
236 "# key 216 \"KEY_CHAT\"\n" \
237 "key 217 SEARCH\n" \
238 "# key 218 \"KEY_CONNECT\"\n" \
239 "# key 219 \"KEY_FINANCE\"\n" \
240 "# key 220 \"KEY_SPORT\"\n" \
241 "# key 221 \"KEY_SHOP\"\n" \
242 "# key 222 \"KEY_ALTERASE\"\n" \
243 "# key 223 \"KEY_CANCEL\"\n" \
244 "# key 224 \"KEY_BRIGHTNESSDOWN\"\n" \
245 "# key 225 \"KEY_BRIGHTNESSUP\"\n" \
246 "key 226 HEADSETHOOK\n" \
247 "\n" \
248 "key 256 BUTTON_1\n" \
249 "key 257 BUTTON_2\n" \
250 "key 258 BUTTON_3\n" \
251 "key 259 BUTTON_4\n" \
252 "key 260 BUTTON_5\n" \
253 "key 261 BUTTON_6\n" \
254 "key 262 BUTTON_7\n" \
255 "key 263 BUTTON_8\n" \
256 "key 264 BUTTON_9\n" \
257 "key 265 BUTTON_10\n" \
258 "key 266 BUTTON_11\n" \
259 "key 267 BUTTON_12\n" \
260 "key 268 BUTTON_13\n" \
261 "key 269 BUTTON_14\n" \
262 "key 270 BUTTON_15\n" \
263 "key 271 BUTTON_16\n" \
264 "\n" \
265 "key 288 BUTTON_1\n" \
266 "key 289 BUTTON_2\n" \
267 "key 290 BUTTON_3\n" \
268 "key 291 BUTTON_4\n" \
269 "key 292 BUTTON_5\n" \
270 "key 293 BUTTON_6\n" \
271 "key 294 BUTTON_7\n" \
272 "key 295 BUTTON_8\n" \
273 "key 296 BUTTON_9\n" \
274 "key 297 BUTTON_10\n" \
275 "key 298 BUTTON_11\n" \
276 "key 299 BUTTON_12\n" \
277 "key 300 BUTTON_13\n" \
278 "key 301 BUTTON_14\n" \
279 "key 302 BUTTON_15\n" \
280 "key 303 BUTTON_16\n" \
281 "\n" \
282 "\n" \
283 "key 304 BUTTON_A\n" \
284 "key 305 BUTTON_B\n" \
285 "key 306 BUTTON_C\n" \
286 "key 307 BUTTON_X\n" \
287 "key 308 BUTTON_Y\n" \
288 "key 309 BUTTON_Z\n" \
289 "key 310 BUTTON_L1\n" \
290 "key 311 BUTTON_R1\n" \
291 "key 312 BUTTON_L2\n" \
292 "key 313 BUTTON_R2\n" \
293 "key 314 BUTTON_SELECT\n" \
294 "key 315 BUTTON_START\n" \
295 "key 316 BUTTON_MODE\n" \
296 "key 317 BUTTON_THUMBL\n" \
297 "key 318 BUTTON_THUMBR\n" \
298 "\n" \
299 "\n" \
300 "# key 352 \"KEY_OK\"\n" \
301 "key 353 DPAD_CENTER\n" \
302 "# key 354 \"KEY_GOTO\"\n" \
303 "# key 355 \"KEY_CLEAR\"\n" \
304 "# key 356 \"KEY_POWER2\"\n" \
305 "# key 357 \"KEY_OPTION\"\n" \
306 "# key 358 \"KEY_INFO\"\n" \
307 "# key 359 \"KEY_TIME\"\n" \
308 "# key 360 \"KEY_VENDOR\"\n" \
309 "# key 361 \"KEY_ARCHIVE\"\n" \
310 "key 362 GUIDE\n" \
311 "# key 363 \"KEY_CHANNEL\"\n" \
312 "# key 364 \"KEY_FAVORITES\"\n" \
313 "# key 365 \"KEY_EPG\"\n" \
314 "key 366 DVR\n" \
315 "# key 367 \"KEY_MHP\"\n" \
316 "# key 368 \"KEY_LANGUAGE\"\n" \
317 "# key 369 \"KEY_TITLE\"\n" \
318 "# key 370 \"KEY_SUBTITLE\"\n" \
319 "# key 371 \"KEY_ANGLE\"\n" \
320 "# key 372 \"KEY_ZOOM\"\n" \
321 "# key 373 \"KEY_MODE\"\n" \
322 "# key 374 \"KEY_KEYBOARD\"\n" \
323 "# key 375 \"KEY_SCREEN\"\n" \
324 "# key 376 \"KEY_PC\"\n" \
325 "key 377 TV\n" \
326 "# key 378 \"KEY_TV2\"\n" \
327 "# key 379 \"KEY_VCR\"\n" \
328 "# key 380 \"KEY_VCR2\"\n" \
329 "# key 381 \"KEY_SAT\"\n" \
330 "# key 382 \"KEY_SAT2\"\n" \
331 "# key 383 \"KEY_CD\"\n" \
332 "# key 384 \"KEY_TAPE\"\n" \
333 "# key 385 \"KEY_RADIO\"\n" \
334 "# key 386 \"KEY_TUNER\"\n" \
335 "# key 387 \"KEY_PLAYER\"\n" \
336 "# key 388 \"KEY_TEXT\"\n" \
337 "# key 389 \"KEY_DVD\"\n" \
338 "# key 390 \"KEY_AUX\"\n" \
339 "# key 391 \"KEY_MP3\"\n" \
340 "# key 392 \"KEY_AUDIO\"\n" \
341 "# key 393 \"KEY_VIDEO\"\n" \
342 "# key 394 \"KEY_DIRECTORY\"\n" \
343 "# key 395 \"KEY_LIST\"\n" \
344 "# key 396 \"KEY_MEMO\"\n" \
345 "key 397 CALENDAR\n" \
346 "# key 398 \"KEY_RED\"\n" \
347 "# key 399 \"KEY_GREEN\"\n" \
348 "# key 400 \"KEY_YELLOW\"\n" \
349 "# key 401 \"KEY_BLUE\"\n" \
350 "key 402 CHANNEL_UP\n" \
351 "key 403 CHANNEL_DOWN\n" \
352 "# key 404 \"KEY_FIRST\"\n" \
353 "# key 405 \"KEY_LAST\"\n" \
354 "# key 406 \"KEY_AB\"\n" \
355 "# key 407 \"KEY_NEXT\"\n" \
356 "# key 408 \"KEY_RESTART\"\n" \
357 "# key 409 \"KEY_SLOW\"\n" \
358 "# key 410 \"KEY_SHUFFLE\"\n" \
359 "# key 411 \"KEY_BREAK\"\n" \
360 "# key 412 \"KEY_PREVIOUS\"\n" \
361 "# key 413 \"KEY_DIGITS\"\n" \
362 "# key 414 \"KEY_TEEN\"\n" \
363 "# key 415 \"KEY_TWEN\"\n" \
364 "key 429 CONTACTS\n" \
365 "\n" \
366 "# key 448 \"KEY_DEL_EOL\"\n" \
367 "# key 449 \"KEY_DEL_EOS\"\n" \
368 "# key 450 \"KEY_INS_LINE\"\n" \
369 "# key 451 \"KEY_DEL_LINE\"\n" \
370 "\n" \
371 "\n" \
372 "key 464 FUNCTION\n" \
373 "key 465 ESCAPE FUNCTION\n" \
374 "key 466 F1 FUNCTION\n" \
375 "key 467 F2 FUNCTION\n" \
376 "key 468 F3 FUNCTION\n" \
377 "key 469 F4 FUNCTION\n" \
378 "key 470 F5 FUNCTION\n" \
379 "key 471 F6 FUNCTION\n" \
380 "key 472 F7 FUNCTION\n" \
381 "key 473 F8 FUNCTION\n" \
382 "key 474 F9 FUNCTION\n" \
383 "key 475 F10 FUNCTION\n" \
384 "key 476 F11 FUNCTION\n" \
385 "key 477 F12 FUNCTION\n" \
386 "key 478 1 FUNCTION\n" \
387 "key 479 2 FUNCTION\n" \
388 "key 480 D FUNCTION\n" \
389 "key 481 E FUNCTION\n" \
390 "key 482 F FUNCTION\n" \
391 "key 483 S FUNCTION\n" \
392 "key 484 B FUNCTION\n" \
393 "\n" \
394 "\n" \
395 "# key 497 KEY_BRL_DOT1\n" \
396 "# key 498 KEY_BRL_DOT2\n" \
397 "# key 499 KEY_BRL_DOT3\n" \
398 "# key 500 KEY_BRL_DOT4\n" \
399 "# key 501 KEY_BRL_DOT5\n" \
400 "# key 502 KEY_BRL_DOT6\n" \
401 "# key 503 KEY_BRL_DOT7\n" \
402 "# key 504 KEY_BRL_DOT8\n" \
403 "\n" \
404 "\n" \
405 "# Joystick and game controller axes.\n" \
406 "# Axes that are not mapped will be assigned generic axis numbers by the input subsystem.\n" \
407 "axis 0x00 X\n" \
408 "axis 0x01 Y\n" \
409 "axis 0x02 Z\n" \
410 "axis 0x03 RX\n" \
411 "axis 0x04 RY\n" \
412 "axis 0x05 RZ\n" \
413 "axis 0x06 THROTTLE\n" \
414 "axis 0x07 RUDDER\n" \
415 "axis 0x08 WHEEL\n" \
416 "axis 0x09 GAS\n" \
417 "axis 0x0a BRAKE\n" \
418 "axis 0x10 HAT_X\n" \
419 "axis 0x11 HAT_Y\n";
420 return result;
421}
422
423const char* android::GenericKeyMap::keymap_contents()
424{
425 static const char* result =
426 "type FULL\n" \
427 "\n" \
428 "### Basic QWERTY keys ###\n" \
429 "\n" \
430 "key A {\n" \
431 " label: 'A'\n" \
432 " base: 'a'\n" \
433 " shift, capslock: 'A'\n" \
434 "}\n" \
435 "\n" \
436 "key B {\n" \
437 " label: 'B'\n" \
438 " base: 'b'\n" \
439 " shift, capslock: 'B'\n" \
440 "}\n" \
441 "\n" \
442 "key C {\n" \
443 " label: 'C'\n" \
444 " base: 'c'\n" \
445 " shift, capslock: 'C'\n" \
446 " alt: '\\u00e7'\n" \
447 " shift+alt: '\\u00c7'\n" \
448 "}\n" \
449 "\n" \
450 "key D {\n" \
451 " label: 'D'\n" \
452 " base: 'd'\n" \
453 " shift, capslock: 'D'\n" \
454 "}\n" \
455 "\n" \
456 "key E {\n" \
457 " label: 'E'\n" \
458 " base: 'e'\n" \
459 " shift, capslock: 'E'\n" \
460 " alt: '\\u0301'\n" \
461 "}\n" \
462 "\n" \
463 "key F {\n" \
464 " label: 'F'\n" \
465 " base: 'f'\n" \
466 " shift, capslock: 'F'\n" \
467 "}\n" \
468 "\n" \
469 "key G {\n" \
470 " label: 'G'\n" \
471 " base: 'g'\n" \
472 " shift, capslock: 'G'\n" \
473 "}\n" \
474 "\n" \
475 "key H {\n" \
476 " label: 'H'\n" \
477 " base: 'h'\n" \
478 " shift, capslock: 'H'\n" \
479 "}\n" \
480 "\n" \
481 "key I {\n" \
482 " label: 'I'\n" \
483 " base: 'i'\n" \
484 " shift, capslock: 'I'\n" \
485 " alt: '\\u0302'\n" \
486 "}\n" \
487 "\n" \
488 "key J {\n" \
489 " label: 'J'\n" \
490 " base: 'j'\n" \
491 " shift, capslock: 'J'\n" \
492 "}\n" \
493 "\n" \
494 "key K {\n" \
495 " label: 'K'\n" \
496 " base: 'k'\n" \
497 " shift, capslock: 'K'\n" \
498 "}\n" \
499 "\n" \
500 "key L {\n" \
501 " label: 'L'\n" \
502 " base: 'l'\n" \
503 " shift, capslock: 'L'\n" \
504 "}\n" \
505 "\n" \
506 "key M {\n" \
507 " label: 'M'\n" \
508 " base: 'm'\n" \
509 " shift, capslock: 'M'\n" \
510 "}\n" \
511 "\n" \
512 "key N {\n" \
513 " label: 'N'\n" \
514 " base: 'n'\n" \
515 " shift, capslock: 'N'\n" \
516 " alt: '\\u0303'\n" \
517 "}\n" \
518 "\n" \
519 "key O {\n" \
520 " label: 'O'\n" \
521 " base: 'o'\n" \
522 " shift, capslock: 'O'\n" \
523 "}\n" \
524 "\n" \
525 "key P {\n" \
526 " label: 'P'\n" \
527 " base: 'p'\n" \
528 " shift, capslock: 'P'\n" \
529 "}\n" \
530 "\n" \
531 "key Q {\n" \
532 " label: 'Q'\n" \
533 " base: 'q'\n" \
534 " shift, capslock: 'Q'\n" \
535 "}\n" \
536 "\n" \
537 "key R {\n" \
538 " label: 'R'\n" \
539 " base: 'r'\n" \
540 " shift, capslock: 'R'\n" \
541 "}\n" \
542 "\n" \
543 "key S {\n" \
544 " label: 'S'\n" \
545 " base: 's'\n" \
546 " shift, capslock: 'S'\n" \
547 " alt: '\\u00df'\n" \
548 "}\n" \
549 "\n" \
550 "key T {\n" \
551 " label: 'T'\n" \
552 " base: 't'\n" \
553 " shift, capslock: 'T'\n" \
554 "}\n" \
555 "\n" \
556 "key U {\n" \
557 " label: 'U'\n" \
558 " base: 'u'\n" \
559 " shift, capslock: 'U'\n" \
560 " alt: '\\u0308'\n" \
561 "}\n" \
562 "\n" \
563 "key V {\n" \
564 " label: 'V'\n" \
565 " base: 'v'\n" \
566 " shift, capslock: 'V'\n" \
567 "}\n" \
568 "\n" \
569 "key W {\n" \
570 " label: 'W'\n" \
571 " base: 'w'\n" \
572 " shift, capslock: 'W'\n" \
573 "}\n" \
574 "\n" \
575 "key X {\n" \
576 " label: 'X'\n" \
577 " base: 'x'\n" \
578 " shift, capslock: 'X'\n" \
579 "}\n" \
580 "\n" \
581 "key Y {\n" \
582 " label: 'Y'\n" \
583 " base: 'y'\n" \
584 " shift, capslock: 'Y'\n" \
585 "}\n" \
586 "\n" \
587 "key Z {\n" \
588 " label: 'Z'\n" \
589 " base: 'z'\n" \
590 " shift, capslock: 'Z'\n" \
591 "}\n" \
592 "\n" \
593 "key 0 {\n" \
594 " label: '0'\n" \
595 " base: '0'\n" \
596 " shift: ')'\n" \
597 "}\n" \
598 "\n" \
599 "key 1 {\n" \
600 " label: '1'\n" \
601 " base: '1'\n" \
602 " shift: '!'\n" \
603 "}\n" \
604 "\n" \
605 "key 2 {\n" \
606 " label: '2'\n" \
607 " base: '2'\n" \
608 " shift: '@'\n" \
609 "}\n" \
610 "\n" \
611 "key 3 {\n" \
612 " label: '3'\n" \
613 " base: '3'\n" \
614 " shift: '#'\n" \
615 "}\n" \
616 "\n" \
617 "key 4 {\n" \
618 " label: '4'\n" \
619 " base: '4'\n" \
620 " shift: '$'\n" \
621 "}\n" \
622 "\n" \
623 "key 5 {\n" \
624 " label: '5'\n" \
625 " base: '5'\n" \
626 " shift: '%'\n" \
627 "}\n" \
628 "\n" \
629 "key 6 {\n" \
630 " label: '6'\n" \
631 " base: '6'\n" \
632 " shift: '^'\n" \
633 " alt+shift: '\\u0302'\n" \
634 "}\n" \
635 "\n" \
636 "key 7 {\n" \
637 " label: '7'\n" \
638 " base: '7'\n" \
639 " shift: '&'\n" \
640 "}\n" \
641 "\n" \
642 "key 8 {\n" \
643 " label: '8'\n" \
644 " base: '8'\n" \
645 " shift: '*'\n" \
646 "}\n" \
647 "\n" \
648 "key 9 {\n" \
649 " label: '9'\n" \
650 " base: '9'\n" \
651 " shift: '('\n" \
652 "}\n" \
653 "\n" \
654 "key SPACE {\n" \
655 " label: ' '\n" \
656 " base: ' '\n" \
657 " alt, meta: fallback SEARCH\n" \
658 " ctrl: fallback LANGUAGE_SWITCH\n" \
659 "}\n" \
660 "\n" \
661 "key ENTER {\n" \
662 " label: '\\n'\n" \
663 " base: '\\n'\n" \
664 "}\n" \
665 "\n" \
666 "key TAB {\n" \
667 " label: '\\t'\n" \
668 " base: '\\t'\n" \
669 "}\n" \
670 "\n" \
671 "key COMMA {\n" \
672 " label: ','\n" \
673 " base: ','\n" \
674 " shift: '<'\n" \
675 "}\n" \
676 "\n" \
677 "key PERIOD {\n" \
678 " label: '.'\n" \
679 " base: '.'\n" \
680 " shift: '>'\n" \
681 "}\n" \
682 "\n" \
683 "key SLASH {\n" \
684 " label: '/'\n" \
685 " base: '/'\n" \
686 " shift: '?'\n" \
687 "}\n" \
688 "\n" \
689 "key GRAVE {\n" \
690 " label: '`'\n" \
691 " base: '`'\n" \
692 " shift: '~'\n" \
693 " alt: '\\u0300'\n" \
694 " alt+shift: '\\u0303'\n" \
695 "}\n" \
696 "\n" \
697 "key MINUS {\n" \
698 " label: '-'\n" \
699 " base: '-'\n" \
700 " shift: '_'\n" \
701 "}\n" \
702 "\n" \
703 "key EQUALS {\n" \
704 " label: '='\n" \
705 " base: '='\n" \
706 " shift: '+'\n" \
707 "}\n" \
708 "\n" \
709 "key LEFT_BRACKET {\n" \
710 " label: '['\n" \
711 " base: '['\n" \
712 " shift: '{'\n" \
713 "}\n" \
714 "\n" \
715 "key RIGHT_BRACKET {\n" \
716 " label: ']'\n" \
717 " base: ']'\n" \
718 " shift: '}'\n" \
719 "}\n" \
720 "\n" \
721 "key BACKSLASH {\n" \
722 " label: '\\\\'\n" \
723 " base: '\\\\'\n" \
724 " shift: '|'\n" \
725 "}\n" \
726 "\n" \
727 "key SEMICOLON {\n" \
728 " label: ';'\n" \
729 " base: ';'\n" \
730 " shift: ':'\n" \
731 "}\n" \
732 "\n" \
733 "key APOSTROPHE {\n" \
734 " label: '\\''\n" \
735 " base: '\\''\n" \
736 " shift: '\"'\n" \
737 "}\n" \
738 "\n" \
739 "### Numeric keypad ###\n" \
740 "\n" \
741 "key NUMPAD_0 {\n" \
742 " label: '0'\n" \
743 " base: fallback INSERT\n" \
744 " numlock: '0'\n" \
745 "}\n" \
746 "\n" \
747 "key NUMPAD_1 {\n" \
748 " label: '1'\n" \
749 " base: fallback MOVE_END\n" \
750 " numlock: '1'\n" \
751 "}\n" \
752 "\n" \
753 "key NUMPAD_2 {\n" \
754 " label: '2'\n" \
755 " base: fallback DPAD_DOWN\n" \
756 " numlock: '2'\n" \
757 "}\n" \
758 "\n" \
759 "key NUMPAD_3 {\n" \
760 " label: '3'\n" \
761 " base: fallback PAGE_DOWN\n" \
762 " numlock: '3'\n" \
763 "}\n" \
764 "\n" \
765 "key NUMPAD_4 {\n" \
766 " label: '4'\n" \
767 " base: fallback DPAD_LEFT\n" \
768 " numlock: '4'\n" \
769 "}\n" \
770 "\n" \
771 "key NUMPAD_5 {\n" \
772 " label: '5'\n" \
773 " base: fallback DPAD_CENTER\n" \
774 " numlock: '5'\n" \
775 "}\n" \
776 "\n" \
777 "key NUMPAD_6 {\n" \
778 " label: '6'\n" \
779 " base: fallback DPAD_RIGHT\n" \
780 " numlock: '6'\n" \
781 "}\n" \
782 "\n" \
783 "key NUMPAD_7 {\n" \
784 " label: '7'\n" \
785 " base: fallback MOVE_HOME\n" \
786 " numlock: '7'\n" \
787 "}\n" \
788 "\n" \
789 "key NUMPAD_8 {\n" \
790 " label: '8'\n" \
791 " base: fallback DPAD_UP\n" \
792 " numlock: '8'\n" \
793 "}\n" \
794 "\n" \
795 "key NUMPAD_9 {\n" \
796 " label: '9'\n" \
797 " base: fallback PAGE_UP\n" \
798 " numlock: '9'\n" \
799 "}\n" \
800 "\n" \
801 "key NUMPAD_LEFT_PAREN {\n" \
802 " label: '('\n" \
803 " base: '('\n" \
804 "}\n" \
805 "\n" \
806 "key NUMPAD_RIGHT_PAREN {\n" \
807 " label: ')'\n" \
808 " base: ')'\n" \
809 "}\n" \
810 "\n" \
811 "key NUMPAD_DIVIDE {\n" \
812 " label: '/'\n" \
813 " base: '/'\n" \
814 "}\n" \
815 "\n" \
816 "key NUMPAD_MULTIPLY {\n" \
817 " label: '*'\n" \
818 " base: '*'\n" \
819 "}\n" \
820 "\n" \
821 "key NUMPAD_SUBTRACT {\n" \
822 " label: '-'\n" \
823 " base: '-'\n" \
824 "}\n" \
825 "\n" \
826 "key NUMPAD_ADD {\n" \
827 " label: '+'\n" \
828 " base: '+'\n" \
829 "}\n" \
830 "\n" \
831 "key NUMPAD_DOT {\n" \
832 " label: '.'\n" \
833 " base: fallback FORWARD_DEL\n" \
834 " numlock: '.'\n" \
835 "}\n" \
836 "\n" \
837 "key NUMPAD_COMMA {\n" \
838 " label: ','\n" \
839 " base: ','\n" \
840 "}\n" \
841 "\n" \
842 "key NUMPAD_EQUALS {\n" \
843 " label: '='\n" \
844 " base: '='\n" \
845 "}\n" \
846 "\n" \
847 "key NUMPAD_ENTER {\n" \
848 " label: '\\n'\n" \
849 " base: '\\n' fallback ENTER\n" \
850 " ctrl, alt, meta: none fallback ENTER\n" \
851 "}\n" \
852 "\n" \
853 "### Special keys on phones ###\n" \
854 "\n" \
855 "key AT {\n" \
856 " label: '@'\n" \
857 " base: '@'\n" \
858 "}\n" \
859 "\n" \
860 "key STAR {\n" \
861 " label: '*'\n" \
862 " base: '*'\n" \
863 "}\n" \
864 "\n" \
865 "key POUND {\n" \
866 " label: '#'\n" \
867 " base: '#'\n" \
868 "}\n" \
869 "\n" \
870 "key PLUS {\n" \
871 " label: '+'\n" \
872 " base: '+'\n" \
873 "}\n" \
874 "\n" \
875 "### Non-printing keys ###\n" \
876 "\n" \
877 "key ESCAPE {\n" \
878 " base: fallback BACK\n" \
879 " alt, meta: fallback HOME\n" \
880 " ctrl: fallback MENU\n" \
881 "}\n" \
882 "\n" \
883 "### Gamepad buttons ###\n" \
884 "\n" \
885 "key BUTTON_A {\n" \
886 " base: fallback BACK\n" \
887 "}\n" \
888 "\n" \
889 "key BUTTON_B {\n" \
890 " base: fallback BACK\n" \
891 "}\n" \
892 "\n" \
893 "key BUTTON_C {\n" \
894 " base: fallback BACK\n" \
895 "}\n" \
896 "\n" \
897 "key BUTTON_X {\n" \
898 " base: fallback DPAD_CENTER\n" \
899 "}\n" \
900 "\n" \
901 "key BUTTON_Y {\n" \
902 " base: fallback DPAD_CENTER\n" \
903 "}\n" \
904 "\n" \
905 "key BUTTON_Z {\n" \
906 " base: fallback DPAD_CENTER\n" \
907 "}\n" \
908 "\n" \
909 "key BUTTON_L1 {\n" \
910 " base: none\n" \
911 "}\n" \
912 "\n" \
913 "key BUTTON_R1 {\n" \
914 " base: none\n" \
915 "}\n" \
916 "\n" \
917 "key BUTTON_L2 {\n" \
918 " base: none\n" \
919 "}\n" \
920 "\n" \
921 "key BUTTON_R2 {\n" \
922 " base: none\n" \
923 "}\n" \
924 "\n" \
925 "key BUTTON_THUMBL {\n" \
926 " base: fallback DPAD_CENTER\n" \
927 "}\n" \
928 "\n" \
929 "key BUTTON_THUMBR {\n" \
930 " base: fallback DPAD_CENTER\n" \
931 "}\n" \
932 "\n" \
933 "key BUTTON_START {\n" \
934 " base: fallback HOME\n" \
935 "}\n" \
936 "\n" \
937 "key BUTTON_SELECT {\n" \
938 " base: fallback MENU\n" \
939 "}\n" \
940 "\n" \
941 "key BUTTON_MODE {\n" \
942 " base: fallback MENU\n" \
943 "}\n" \
944 "\n" \
945 "key BUTTON_1 {\n" \
946 " base: fallback DPAD_CENTER\n" \
947 "}\n" \
948 "\n" \
949 "key BUTTON_2 {\n" \
950 " base: fallback DPAD_CENTER\n" \
951 "}\n" \
952 "\n" \
953 "key BUTTON_3 {\n" \
954 " base: fallback DPAD_CENTER\n" \
955 "}\n" \
956 "\n" \
957 "key BUTTON_4 {\n" \
958 " base: fallback DPAD_CENTER\n" \
959 "}\n" \
960 "\n" \
961 "key BUTTON_5 {\n" \
962 " base: fallback DPAD_CENTER\n" \
963 "}\n" \
964 "\n" \
965 "key BUTTON_6 {\n" \
966 " base: fallback DPAD_CENTER\n" \
967 "}\n" \
968 "\n" \
969 "key BUTTON_7 {\n" \
970 " base: fallback DPAD_CENTER\n" \
971 "}\n" \
972 "\n" \
973 "key BUTTON_8 {\n" \
974 " base: fallback DPAD_CENTER\n" \
975 "}\n" \
976 "\n" \
977 "key BUTTON_9 {\n" \
978 " base: fallback DPAD_CENTER\n" \
979 "}\n" \
980 "\n" \
981 "key BUTTON_10 {\n" \
982 " base: fallback DPAD_CENTER\n" \
983 "}\n" \
984 "\n" \
985 "key BUTTON_11 {\n" \
986 " base: fallback DPAD_CENTER\n" \
987 "}\n" \
988 "\n" \
989 "key BUTTON_12 {\n" \
990 " base: fallback DPAD_CENTER\n" \
991 "}\n" \
992 "\n" \
993 "key BUTTON_13 {\n" \
994 " base: fallback DPAD_CENTER\n" \
995 "}\n" \
996 "\n" \
997 "key BUTTON_14 {\n" \
998 " base: fallback DPAD_CENTER\n" \
999 "}\n" \
1000 "\n" \
1001 "key BUTTON_15 {\n" \
1002 " base: fallback DPAD_CENTER\n" \
1003 "}\n" \
1004 "\n" \
1005 "key BUTTON_16 {\n" \
1006 " base: fallback DPAD_CENTER\n" \
1007 "}";
1008 return result;
1009}
10100
=== removed file '3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp 2015-06-15 22:24:08 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputDevice.cpp 1970-01-01 00:00:00 +0000
@@ -1,205 +0,0 @@
1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "InputDevice"
18
19#include <cutils/log.h>
20#define DEBUG_PROBE 0
21
22#include <stdlib.h>
23#include <unistd.h>
24#include <ctype.h>
25
26#include <androidfw/InputDevice.h>
27
28namespace android {
29
30static const char* CONFIGURATION_FILE_DIR[] = {
31 "idc/",
32 "keylayout/",
33 "keychars/",
34};
35
36static const char* CONFIGURATION_FILE_EXTENSION[] = {
37 ".idc",
38 ".kl",
39 ".kcm",
40};
41
42static bool isValidNameChar(char ch) {
43 return isascii(ch) && (isdigit(ch) || isalpha(ch) || ch == '-' || ch == '_');
44}
45
46static void appendInputDeviceConfigurationFileRelativePath(String8& path,
47 const String8& name, InputDeviceConfigurationFileType type) {
48 path.append(CONFIGURATION_FILE_DIR[type]);
49 for (size_t i = 0; i < name.length(); i++) {
50 char ch = name[i];
51 if (!isValidNameChar(ch)) {
52 ch = '_';
53 }
54 path.append(&ch, 1);
55 }
56 path.append(CONFIGURATION_FILE_EXTENSION[type]);
57}
58
59String8 getInputDeviceConfigurationFilePathByDeviceIdentifier(
60 const InputDeviceIdentifier& deviceIdentifier,
61 InputDeviceConfigurationFileType type) {
62 if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) {
63 if (deviceIdentifier.version != 0) {
64 // Try vendor product version.
65 String8 versionPath(getInputDeviceConfigurationFilePathByName(
66 formatString8("Vendor_%04x_Product_%04x_Version_%04x",
67 deviceIdentifier.vendor, deviceIdentifier.product,
68 deviceIdentifier.version),
69 type));
70 if (!isEmpty(versionPath)) {
71 return versionPath;
72 }
73 }
74
75 // Try vendor product.
76 String8 productPath(getInputDeviceConfigurationFilePathByName(
77 formatString8("Vendor_%04x_Product_%04x",
78 deviceIdentifier.vendor, deviceIdentifier.product),
79 type));
80 if (!isEmpty(productPath)) {
81 return productPath;
82 }
83 }
84
85 // Try device name.
86 return getInputDeviceConfigurationFilePathByName(deviceIdentifier.name, type);
87}
88
89String8 getConfigurationFilePathInDirectory(String8 const& directory, String8 const& name, InputDeviceConfigurationFileType type)
90{
91 String8 path = directory;
92 appendInputDeviceConfigurationFileRelativePath(path, name, type);
93#if DEBUG_PROBE
94 ALOGD("Probing for input device configuration file: path='%s'", path.c_str());
95#endif
96 if (!access(c_str(path), R_OK)) {
97#if DEBUG_PROBE
98 ALOGD("Found");
99#endif
100 return path;
101 }
102
103 return String8();
104}
105
106String8 getInputDeviceConfigurationFilePathByName(
107 const String8& name, InputDeviceConfigurationFileType type) {
108 // Search system repository.
109 String8 path;
110 setTo(path, "/usr/share/");
111 auto result = getConfigurationFilePathInDirectory(path, name, type);
112 if (result.length())
113 return result;
114
115 {
116 const char *root_env = getenv("ANDROID_ROOT");
117 if (root_env == NULL) root_env = "";
118 setTo(path, root_env);
119 }
120 // </mir modifications>
121 path.append("/usr/");
122 result = getConfigurationFilePathInDirectory(path, name, type);
123 if (result.length())
124 return result;
125
126 // Search user repository.
127 // TODO Should only look here if not in safe mode. ( ?? ~ racarr)
128 {
129 const char *data_env = getenv("ANDROID_DATA");
130 if (data_env == NULL) data_env = "";
131 setTo(path, data_env);
132 }
133
134 path.append("/system/devices/");
135 result = getConfigurationFilePathInDirectory(path, name, type);
136 if (result.length())
137 return result;
138
139 // Not found.
140#if DEBUG_PROBE
141 ALOGD("Probe failed to find input device configuration file: name='%s', type=%d",
142 name.c_str(), type);
143#endif
144 return String8();
145}
146
147
148// --- InputDeviceInfo ---
149
150InputDeviceInfo::InputDeviceInfo() {
151 initialize(-1, -1, InputDeviceIdentifier(), String8(), false);
152}
153
154InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) :
155 mId(other.mId), mGeneration(other.mGeneration), mIdentifier(other.mIdentifier),
156 mAlias(other.mAlias), mIsExternal(other.mIsExternal), mSources(other.mSources),
157 mKeyboardType(other.mKeyboardType),
158 mKeyCharacterMap(other.mKeyCharacterMap),
159 mHasVibrator(other.mHasVibrator),
160 mMotionRanges(other.mMotionRanges) {
161}
162
163InputDeviceInfo::~InputDeviceInfo() {
164}
165
166void InputDeviceInfo::initialize(int32_t id, int32_t generation,
167 const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal) {
168 mId = id;
169 mGeneration = generation;
170 mIdentifier = identifier;
171 mAlias = alias;
172 mIsExternal = isExternal;
173 mSources = 0;
174 mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE;
175 mHasVibrator = false;
176 mMotionRanges.clear();
177}
178
179const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange(
180 int32_t axis, uint32_t source) const {
181 size_t numRanges = mMotionRanges.size();
182 for (size_t i = 0; i < numRanges; i++) {
183 const MotionRange& range = mMotionRanges.itemAt(i);
184 if (range.axis == axis && range.source == source) {
185 return &range;
186 }
187 }
188 return NULL;
189}
190
191void InputDeviceInfo::addSource(uint32_t source) {
192 mSources |= source;
193}
194
195void InputDeviceInfo::addMotionRange(int32_t axis, uint32_t source, float min, float max,
196 float flat, float fuzz) {
197 MotionRange range = { axis, source, min, max, flat, fuzz };
198 mMotionRanges.add(range);
199}
200
201void InputDeviceInfo::addMotionRange(const MotionRange& range) {
202 mMotionRanges.add(range);
203}
204
205} // namespace android
2060
=== removed file '3rd_party/android-input/android/frameworks/base/services/input/InputListener.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputListener.cpp 2015-08-17 18:33:38 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputListener.cpp 1970-01-01 00:00:00 +0000
@@ -1,183 +0,0 @@
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "InputListener"
18
19//#define LOG_NDEBUG 0
20
21#include "InputListener.h"
22
23#include <cutils/log.h>
24
25namespace android {
26
27// --- NotifyConfigurationChangedArgs ---
28
29NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(std::chrono::nanoseconds eventTime) :
30 eventTime(eventTime) {
31}
32
33NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(
34 const NotifyConfigurationChangedArgs& other) :
35 eventTime(other.eventTime) {
36}
37
38void NotifyConfigurationChangedArgs::notify(InputListenerInterface& listener) const {
39 listener.notifyConfigurationChanged(this);
40}
41
42
43// --- NotifyKeyArgs ---
44
45NotifyKeyArgs::NotifyKeyArgs(std::chrono::nanoseconds eventTime, uint64_t mac,
46 int32_t deviceId, uint32_t source, uint32_t policyFlags,
47 int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
48 int32_t metaState, std::chrono::nanoseconds downTime) :
49 eventTime(eventTime), deviceId(deviceId), source(source), policyFlags(policyFlags),
50 action(action), flags(flags), keyCode(keyCode), scanCode(scanCode),
51 metaState(metaState), downTime(downTime) {
52}
53
54NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other) :
55 eventTime(other.eventTime), mac(other.mac),
56 deviceId(other.deviceId), source(other.source),
57 policyFlags(other.policyFlags),
58 action(other.action), flags(other.flags),
59 keyCode(other.keyCode), scanCode(other.scanCode),
60 metaState(other.metaState), downTime(other.downTime) {
61}
62
63void NotifyKeyArgs::notify(InputListenerInterface& listener) const {
64 listener.notifyKey(this);
65}
66
67
68// --- NotifyMotionArgs ---
69
70NotifyMotionArgs::NotifyMotionArgs(std::chrono::nanoseconds eventTime, uint64_t mac,
71 int32_t deviceId, uint32_t source, uint32_t policyFlags,
72 int32_t action, int32_t flags, int32_t metaState, int32_t buttonState,
73 int32_t edgeFlags, uint32_t pointerCount,
74 const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
75 float xPrecision, float yPrecision, std::chrono::nanoseconds downTime) :
76 eventTime(eventTime), mac(mac), deviceId(deviceId), source(source),
77 policyFlags(policyFlags), action(action), flags(flags), metaState(metaState),
78 buttonState(buttonState), edgeFlags(edgeFlags), pointerCount(pointerCount),
79 xPrecision(xPrecision), yPrecision(yPrecision), downTime(downTime) {
80 for (uint32_t i = 0; i < pointerCount; i++) {
81 this->pointerProperties[i].copyFrom(pointerProperties[i]);
82 this->pointerCoords[i].copyFrom(pointerCoords[i]);
83 }
84}
85
86NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) :
87 eventTime(other.eventTime), mac(other.mac),
88 deviceId(other.deviceId), source(other.source),
89 policyFlags(other.policyFlags),
90 action(other.action), flags(other.flags),
91 metaState(other.metaState), buttonState(other.buttonState),
92 edgeFlags(other.edgeFlags), pointerCount(other.pointerCount),
93 xPrecision(other.xPrecision), yPrecision(other.yPrecision), downTime(other.downTime) {
94 for (uint32_t i = 0; i < pointerCount; i++) {
95 pointerProperties[i].copyFrom(other.pointerProperties[i]);
96 pointerCoords[i].copyFrom(other.pointerCoords[i]);
97 }
98}
99
100void NotifyMotionArgs::notify(InputListenerInterface& listener) const {
101 listener.notifyMotion(this);
102}
103
104
105// --- NotifySwitchArgs ---
106
107NotifySwitchArgs::NotifySwitchArgs(std::chrono::nanoseconds eventTime, uint32_t policyFlags,
108 int32_t switchCode, int32_t switchValue) :
109 eventTime(eventTime), policyFlags(policyFlags),
110 switchCode(switchCode), switchValue(switchValue) {
111}
112
113NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other) :
114 eventTime(other.eventTime), policyFlags(other.policyFlags),
115 switchCode(other.switchCode), switchValue(other.switchValue) {
116}
117
118void NotifySwitchArgs::notify(InputListenerInterface& listener) const {
119 listener.notifySwitch(this);
120}
121
122
123// --- NotifyDeviceResetArgs ---
124
125NotifyDeviceResetArgs::NotifyDeviceResetArgs(std::chrono::nanoseconds eventTime, int32_t deviceId) :
126 eventTime(eventTime), deviceId(deviceId) {
127}
128
129NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) :
130 eventTime(other.eventTime), deviceId(other.deviceId) {
131}
132
133void NotifyDeviceResetArgs::notify(InputListenerInterface& listener) const {
134 listener.notifyDeviceReset(this);
135}
136
137
138// --- QueuedInputListener ---
139
140QueuedInputListener::QueuedInputListener(const std::shared_ptr<InputListenerInterface>& innerListener) :
141 mInnerListener(innerListener) {
142}
143
144QueuedInputListener::~QueuedInputListener() {
145 size_t count = mArgsQueue.size();
146 for (size_t i = 0; i < count; i++) {
147 delete mArgsQueue[i];
148 }
149}
150
151void QueuedInputListener::notifyConfigurationChanged(
152 const NotifyConfigurationChangedArgs* args) {
153 mArgsQueue.push(new NotifyConfigurationChangedArgs(*args));
154}
155
156void QueuedInputListener::notifyKey(const NotifyKeyArgs* args) {
157 mArgsQueue.push(new NotifyKeyArgs(*args));
158}
159
160void QueuedInputListener::notifyMotion(const NotifyMotionArgs* args) {
161 mArgsQueue.push(new NotifyMotionArgs(*args));
162}
163
164void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) {
165 mArgsQueue.push(new NotifySwitchArgs(*args));
166}
167
168void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
169 mArgsQueue.push(new NotifyDeviceResetArgs(*args));
170}
171
172void QueuedInputListener::flush() {
173 size_t count = mArgsQueue.size();
174 for (size_t i = 0; i < count; i++) {
175 NotifyArgs* args = mArgsQueue[i];
176 args->notify(*mInnerListener);
177 delete args;
178 }
179 mArgsQueue.clear();
180}
181
182
183} // namespace android
1840
=== removed file '3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp'
--- 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 2015-09-24 15:42:21 +0000
+++ 3rd_party/android-input/android/frameworks/base/services/input/InputReader.cpp 1970-01-01 00:00:00 +0000
@@ -1,6356 +0,0 @@
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "InputReader"
18
19//#define LOG_NDEBUG 0
20
21// Log debug messages for each raw event received from the EventHub.
22#define DEBUG_RAW_EVENTS 0
23
24// Log debug messages about touch screen filtering hacks.
25#define DEBUG_HACKS 0
26
27// Log debug messages about virtual key processing.
28#define DEBUG_VIRTUAL_KEYS 0
29
30// Log debug messages about pointers.
31#define DEBUG_POINTERS 0
32
33// Log debug messages about pointer assignment calculations.
34#define DEBUG_POINTER_ASSIGNMENT 0
35
36// Log debug messages about gesture detection.
37#define DEBUG_GESTURES 0
38
39// Log debug messages about the vibrator.
40#define DEBUG_VIBRATOR 0
41
42#include "InputReader.h"
43
44#include <cutils/log.h>
45#include <androidfw/Keyboard.h>
46#include <androidfw/VirtualKeyMap.h>
47
48#include <android/keycodes.h>
49
50#include <std/BitSet.h>
51
52#include <stddef.h>
53#include <stdlib.h>
54#include <unistd.h>
55#include <errno.h>
56#include <limits.h>
57#include <math.h>
58
59#if DEBUG_RAW_EVENTS
60#include "InputEventPrinter.h"
61#endif
62
63#define INDENT " "
64#define INDENT2 " "
65#define INDENT3 " "
66#define INDENT4 " "
67#define INDENT5 " "
68
69namespace android {
70
71// --- Constants ---
72
73// Maximum number of slots supported when using the slot-based Multitouch Protocol B.
74static const size_t MAX_SLOTS = 32;
75
76// --- Static Functions ---
77
78template<typename T>
79inline static T min(const T& a, const T& b) {
80 return a < b ? a : b;
81}
82
83template<typename T>
84inline static void swap(T& a, T& b) {
85 T temp = a;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: