summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2015-02-13 17:31:41 -0800
committerMichael Wright <michaelwr@google.com>2015-02-23 10:45:55 -0800
commit5113aff7e2a8540cc3f6364b8c730f853784e2ff (patch)
tree423bf08dec26c32c09cd1a9af2e41a2a16cb903c
parent5d4ee176fb9b9c48505476a2200e20ecaca90353 (diff)
downloadhardware_libhardware-5113aff7e2a8540cc3f6364b8c730f853784e2ff.zip
hardware_libhardware-5113aff7e2a8540cc3f6364b8c730f853784e2ff.tar.gz
hardware_libhardware-5113aff7e2a8540cc3f6364b8c730f853784e2ff.tar.bz2
Add input HAL header.
Change-Id: Ia959dd1d1adf024459d2423fc9d59a811466e53c
-rw-r--r--include/hardware/input.h176
-rw-r--r--modules/Android.mk2
-rw-r--r--modules/input/Android.mk19
-rw-r--r--modules/input/evdev/Android.mk29
-rw-r--r--modules/input/evdev/EvdevModule.cpp66
5 files changed, 291 insertions, 1 deletions
diff --git a/include/hardware/input.h b/include/hardware/input.h
new file mode 100644
index 0000000..dad1bc0
--- /dev/null
+++ b/include/hardware/input.h
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_INCLUDE_HARDWARE_INPUT_H
+#define ANDROID_INCLUDE_HARDWARE_INPUT_H
+
+#include <hardware/hardware.h>
+#include <stdint.h>
+
+__BEGIN_DECLS
+
+#define INPUT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
+#define INPUT_HARDWARE_MODULE_ID "input"
+
+#define INPUT_INSTANCE_EVDEV "evdev"
+
+typedef enum input_bus {
+ INPUT_BUS_BT,
+ INPUT_BUS_USB,
+ INPUT_BUS_SERIAL,
+ INPUT_BUS_BUILTIN
+} input_bus_t;
+
+typedef struct input_host input_host_t;
+
+typedef struct input_device_handle input_device_handle_t;
+
+typedef struct input_device_identifier input_device_identifier_t;
+
+typedef struct input_device_definition input_device_definition_t;
+
+typedef struct input_report_definition input_report_definition_t;
+
+typedef struct input_report input_report_t;
+
+typedef struct input_collection input_collection_t;
+
+typedef enum {
+ INPUT_USAGE_TOUCHPAD_X,
+ INPUT_USAGE_TOUCHPAD_Y,
+ // etc
+} input_usage_t;
+
+typedef enum {
+ INPUT_COLLECTION_ID_TOUCH,
+ INPUT_COLLECTION_ID_KEYBOARD,
+ INPUT_COLLECTION_ID_MOUSE,
+ INPUT_COLLECTION_ID_TOUCHPAD,
+ // etc
+} input_collection_id_t;
+
+typedef struct input_message input_message_t;
+
+typedef struct input_host_callbacks {
+
+ /**
+ * Creates a device identifier with the given properties.
+ * The unique ID should be a string that precisely identifies a given piece of hardware. For
+ * example, an input device connected via Bluetooth could use its MAC address as its unique ID.
+ */
+ input_device_identifier_t* (*create_device_identifier)(input_host_t* host,
+ const char* name, int32_t product_id, int32_t vendor_id,
+ input_bus_t bus, const char* unique_id);
+
+ /**
+ * Allocates the device definition which will describe the input capabilities of a device. A
+ * device definition may be used to register as many devices as desired.
+ */
+ input_device_definition_t* (*create_device_definition)(input_host_t* host);
+
+ /**
+ * Allocate either an input report, which the HAL will use to tell the host of incoming input
+ * events, or an output report, which the host will use to tell the HAL of desired state
+ * changes (e.g. setting an LED).
+ */
+ input_report_definition_t* (*create_input_report_definition)(input_host_t* host);
+ input_report_definition_t* (*create_output_report_definition)(input_host_t* host);
+
+ /**
+ * Append the report to the given input device.
+ */
+ void (*input_device_definition_add_report)(input_host_t* host,
+ input_device_definition_t* d, input_report_definition_t* r);
+
+ /**
+ * Add a collection with the given arity and ID. A collection describes a set
+ * of logically grouped properties such as the X and Y coordinates of a single finger touch or
+ * the set of keys on a keyboard. The arity declares how many repeated instances of this
+ * collection will appear in whatever report it is attached to. The ID describes the type of
+ * grouping being represented by the collection. For example, a touchscreen capable of
+ * reporting up to 2 fingers simultaneously might have a collection with the X and Y
+ * coordinates, an arity of 2, and an ID of INPUT_COLLECTION_USAGE_TOUCHSCREEN. Any given ID
+ * may only be present once for a given report.
+ */
+ void (*input_report_definition_add_collection)(input_host_t* host,
+ input_report_definition_t* report, input_collection_id_t id, int32_t arity);
+
+ /**
+ * Declare an int usage with the given properties. The report and collection defines where the
+ * usage is being declared.
+ */
+ void (*input_report_definition_declare_usage_int)(input_host_t* host,
+ input_report_definition_t* report, input_collection_id_t id,
+ input_usage_t usage, int32_t min, int32_t max, float resolution);
+
+ /**
+ * Declare a set of boolean usages with the given properties. The report and collection
+ * defines where the usages are being declared.
+ */
+ void (*input_report_definition_declare_usages_bool)(input_host_t* host,
+ input_report_definition_t* report, input_collection_id_t id,
+ input_usage_t* usage, size_t usage_count);
+
+
+ /**
+ * Register a given input device definition. This notifies the host that an input device has
+ * been connected and gives a description of all its capabilities.
+ */
+ input_device_handle_t* (*register_device)(input_host_t* host,
+ input_device_identifier_t* id, input_device_definition_t* d);
+
+ /** Unregister the given device */
+ void (*unregister_device)(input_host_t* host, input_device_handle_t* handle);
+
+ /**
+ * Allocate a report that will contain all of the state as described by the given report.
+ */
+ input_report_t* (*input_allocate_report)(input_host_t* host, input_report_definition_t* r);
+
+ void (*report_event)(input_host_t* host, input_device_handle_t* d, input_report_t* report);
+} input_host_callbacks_t;
+
+typedef struct input_module input_module_t;
+
+struct input_module {
+ /**
+ * Common methods of the input module. This *must* be the first member
+ * of input_module as users of this structure will cast a hw_module_t
+ * to input_module pointer in contexts where it's known
+ * the hw_module_t references a input_module.
+ */
+ struct hw_module_t common;
+
+ /**
+ * Initialize the module with host callbacks. At this point the HAL should start up whatever
+ * infrastructure it needs to in order to process input events.
+ */
+ void (*init)(const input_module_t* module, input_host_t* host, input_host_callbacks_t cb);
+
+ /**
+ * Sends an output report with a new set of state the host would like the given device to
+ * assume.
+ */
+ void (*notify_report)(input_report_t* report);
+};
+
+static inline int input_open(const struct hw_module_t** module, const char* type) {
+ return hw_get_module_by_class(INPUT_HARDWARE_MODULE_ID, type, module);
+}
+
+__END_DECLS
+
+#endif /* ANDROID_INCLUDE_HARDWARE_INPUT_H */
diff --git a/modules/Android.mk b/modules/Android.mk
index 13a0b5b..9f7e5f0 100644
--- a/modules/Android.mk
+++ b/modules/Android.mk
@@ -1,4 +1,4 @@
hardware_modules := gralloc hwcomposer audio nfc nfc-nci local_time \
power usbaudio audio_remote_submix camera usbcamera consumerir sensors vibrator \
- tv_input fingerprint
+ tv_input fingerprint input
include $(call all-named-subdir-makefiles,$(hardware_modules))
diff --git a/modules/input/Android.mk b/modules/input/Android.mk
new file mode 100644
index 0000000..3011b2e
--- /dev/null
+++ b/modules/input/Android.mk
@@ -0,0 +1,19 @@
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/modules/input/evdev/Android.mk b/modules/input/evdev/Android.mk
new file mode 100644
index 0000000..ad05af3
--- /dev/null
+++ b/modules/input/evdev/Android.mk
@@ -0,0 +1,29 @@
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := input.evdev.default
+LOCAL_MODULE_RELATIVE_PATH := hw
+
+LOCAL_SRC_FILES := \
+ EvdevModule.cpp
+
+LOCAL_SHARED_LIBRARIES := liblog
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/modules/input/evdev/EvdevModule.cpp b/modules/input/evdev/EvdevModule.cpp
new file mode 100644
index 0000000..f56842a
--- /dev/null
+++ b/modules/input/evdev/EvdevModule.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "EvdevModule"
+
+#include <assert.h>
+#include <hardware/hardware.h>
+#include <hardware/input.h>
+
+namespace input {
+
+extern "C" {
+
+static int dummy_open(const hw_module_t __unused *module, const char __unused *id,
+ hw_device_t __unused **device) {
+ assert(false);
+ return 0;
+}
+
+static void input_init(const input_module_t* module,
+ input_host_t* host, input_host_callbacks_t cb) {
+ return;
+}
+
+static void input_notify_report(input_report_t* r) {
+ return;
+}
+
+static struct hw_module_methods_t input_module_methods = {
+ .open = dummy_open,
+};
+
+input_module_t HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = INPUT_MODULE_API_VERSION_1_0,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = INPUT_HARDWARE_MODULE_ID,
+ .name = "Input evdev HAL",
+ .author = "The Android Open Source Project",
+ .methods = &input_module_methods,
+ .dso = NULL,
+ .reserved = {0},
+ },
+
+ .init = input_init,
+ .notify_report = input_notify_report,
+};
+
+} // extern "C"
+
+} // namespace input