aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVachounet <vachounet@live.fr>2017-07-18 19:51:09 +0200
committerwzedlare <vedatak01@gmail.com>2017-07-28 18:24:50 +0000
commit12dee13041bc113be14e454043117ee80f527943 (patch)
tree339082d46b54a8526500608f08d1a83a565d978a
parent1e4f57ddda6c321a9b980a1ce632ef051836be61 (diff)
cedric: add cmhw TouchscreenGestures feature
Change-Id: I32911e3dffcdaa6ad997a75a91e8ac10e2d7b7ea
-rw-r--r--cmhw/org/cyanogenmod/hardware/TouchscreenGestures.java89
1 files changed, 89 insertions, 0 deletions
diff --git a/cmhw/org/cyanogenmod/hardware/TouchscreenGestures.java b/cmhw/org/cyanogenmod/hardware/TouchscreenGestures.java
new file mode 100644
index 0000000..0c953be
--- /dev/null
+++ b/cmhw/org/cyanogenmod/hardware/TouchscreenGestures.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ * (C) 2017 The LineageOS 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.
+ */
+
+package org.cyanogenmod.hardware;
+
+import org.cyanogenmod.internal.util.FileUtils;
+
+import cyanogenmod.hardware.TouchscreenGesture;
+
+/**
+ * Touchscreen gestures API
+ *
+ * A device may implement several touchscreen gestures for use while
+ * the display is turned off, such as drawing alphabets and shapes.
+ * These gestures can be interpreted by userspace to activate certain
+ * actions and launch certain apps, such as to skip music tracks,
+ * to turn on the flashlight, or to launch the camera app.
+ *
+ * This *should always* be supported by the hardware directly.
+ * A lot of recent touch controllers have a firmware option for this.
+ *
+ * This API provides support for enumerating the gestures
+ * supported by the touchscreen.
+ */
+public class TouchscreenGestures {
+
+ private static final String[] GESTURE_PATHS = {
+ "/proc/touchpanel/up_swipe_enable",
+ "/proc/touchpanel/down_swipe_enable",
+ "/proc/touchpanel/left_swipe_enable",
+ "/proc/touchpanel/right_swipe_enable",
+ };
+
+ // Id, name, keycode
+ private static final TouchscreenGesture[] TOUCHSCREEN_GESTURES = {
+ new TouchscreenGesture(0, "One finger up swipe", 66),
+ new TouchscreenGesture(1, "One finger down swipe", 65),
+ new TouchscreenGesture(2, "One finger left swipe", 64),
+ new TouchscreenGesture(3, "One finger right swipe", 63),
+ };
+
+ /**
+ * Whether device supports touchscreen gestures
+ *
+ * @return boolean Supported devices must return always true
+ */
+ public static boolean isSupported() {
+ return true;
+ }
+
+ /*
+ * Get the list of available gestures. A mode has an integer
+ * identifier and a string name.
+ *
+ * It is the responsibility of the upper layers to
+ * map the name to a human-readable format or perform translation.
+ */
+ public static TouchscreenGesture[] getAvailableGestures() {
+ return TOUCHSCREEN_GESTURES;
+ }
+
+ /**
+ * This method allows to set the activation status of a gesture
+ *
+ * @param gesture The gesture to be activated
+ * state The new activation status of the gesture
+ * @return boolean Must be false if gesture is not supported
+ * or the operation failed; true in any other case.
+ */
+ public static boolean setGestureEnabled(
+ final TouchscreenGesture gesture, final boolean state) {
+ return true;
+ }
+}
+