powerkey.h 10.2 KB
Newer Older
1 2 3 4 5
/**
 * @file powerkey.h
 * Headers for the power key logic for the Mode Control Entity
 * <p>
 * Copyright © 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
6
 * Copyright (C) 2014-2019 Jolla Ltd.
7 8
 * <p>
 * @author David Weinehall <david.weinehall@nokia.com>
9
 * @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * mce is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * mce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with mce.  If not, see <http://www.gnu.org/licenses/>.
 */
23 24
#ifndef POWERKEY_H_
# define POWERKEY_H_
25

26 27 28 29 30
# include <glib.h>

/* ========================================================================= *
 * Settings
 * ========================================================================= */
31

32
/** Prefix for powerkey setting keys */
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# define MCE_SETTING_POWERKEY_PATH                 "/system/osso/dsm/powerkey"

/** Power key action enable modes */
typedef enum
{
    /** Power key actions disabled */
    PWRKEY_ENABLE_NEVER         = 0,

    /** Power key actions always enabled */
    PWRKEY_ENABLE_ALWAYS        = 1,

    /** Power key actions enabled if PS is not covered */
    PWRKEY_ENABLE_NO_PROXIMITY  = 2,

    /** Power key actions enabled if PS is not covered or display is on */
    PWRKEY_ENABLE_NO_PROXIMITY2 = 3,
} pwrkey_enable_mode_t;
50

51
/** When mce should react to power key presses */
52 53 54 55 56 57 58 59 60 61 62
# define MCE_SETTING_POWERKEY_MODE                 MCE_SETTING_POWERKEY_PATH "/mode"
# define MCE_DEFAULT_POWERKEY_MODE                 1 // = PWRKEY_ENABLE_ALWAYS

typedef enum
{
    /** Pressing power key turns display off */
    PWRKEY_BLANK_TO_OFF         = 0,

    /** Pressing power key puts display to lpm state */
    PWRKEY_BLANK_TO_LPM         = 1,
} pwrkey_blanking_mode_t;
63

64
/** How power key "blank" action should behave */
65 66
# define MCE_SETTING_POWERKEY_BLANKING_MODE        MCE_SETTING_POWERKEY_PATH "/blanking_mode"
# define MCE_DEFAULT_POWERKEY_BLANKING_MODE        0 // = PWRKEY_BLANK_TO_OFF
67

68 69 70 71 72 73 74
/** How many consequent power key presses trigger proximity override
 *
 * Rapidly pressing powerkey multiple times can be used to override
 * proximity sensor covered state. Can be useful in situations where
 * faulty / dirty / otherwise misbehaving proximity sensor does not
 * allow turning display on.
 */
75 76
# define MCE_SETTING_POWERKEY_PS_OVERRIDE_COUNT    MCE_SETTING_POWERKEY_PATH "/ps_override_count"
# define MCE_DEFAULT_POWERKEY_PS_OVERRIDE_COUNT    3
77

78
/** Maximum delay between powerkey presses for ps override [ms]*/
79 80
# define MCE_SETTING_POWERKEY_PS_OVERRIDE_TIMEOUT  MCE_SETTING_POWERKEY_PATH "/ps_override_timeout"
# define MCE_DEFAULT_POWERKEY_PS_OVERRIDE_TIMEOUT  333
81

82
/** Threshold for long power key press [ms] */
83 84
# define MCE_SETTING_POWERKEY_LONG_PRESS_DELAY     MCE_SETTING_POWERKEY_PATH "/long_press_delay"
# define MCE_DEFAULT_POWERKEY_LONG_PRESS_DELAY     1500
85

86
/** Maximum wait time in between double power key presses [ms] */
87 88
# define MCE_SETTING_POWERKEY_DOUBLE_PRESS_DELAY   MCE_SETTING_POWERKEY_PATH "/double_press_delay"
# define MCE_DEFAULT_POWERKEY_DOUBLE_PRESS_DELAY   400
89

90
/** Actions to take on single power key press from display on */
91 92
# define MCE_SETTING_POWERKEY_ACTIONS_SINGLE_ON    MCE_SETTING_POWERKEY_PATH "/actions_single_on"
# define MCE_DEFAULT_POWERKEY_ACTIONS_SINGLE_ON    "blank,tklock"
93

94
/** Actions to take on double power key press from display on */
95 96
# define MCE_SETTING_POWERKEY_ACTIONS_DOUBLE_ON    MCE_SETTING_POWERKEY_PATH "/actions_double_on"
# define MCE_DEFAULT_POWERKEY_ACTIONS_DOUBLE_ON    "blank,tklock,devlock,vibrate"
97

98
/** Actions to take on long power key press from display on */
99 100
# define MCE_SETTING_POWERKEY_ACTIONS_LONG_ON      MCE_SETTING_POWERKEY_PATH "/actions_long_on"
# define MCE_DEFAULT_POWERKEY_ACTIONS_LONG_ON      "shutdown"
101

102
/** Actions to take on single power key press from display off */
103 104
# define MCE_SETTING_POWERKEY_ACTIONS_SINGLE_OFF   MCE_SETTING_POWERKEY_PATH "/actions_single_off"
# define MCE_DEFAULT_POWERKEY_ACTIONS_SINGLE_OFF   "unblank"
105

106
/** Actions to take on double power key press from display off */
107 108
# define MCE_SETTING_POWERKEY_ACTIONS_DOUBLE_OFF   MCE_SETTING_POWERKEY_PATH "/actions_double_off"
# define MCE_DEFAULT_POWERKEY_ACTIONS_DOUBLE_OFF   "unblank,tkunlock"
109

110
/** Actions to take on long power key press from display off
111 112 113 114 115 116
 *
 * Note: If kernel side reports immediately power key press + release
 *       when device is suspended, detecting long presses might not
 *       work when display is off -> leave unset by default. */
# define MCE_SETTING_POWERKEY_ACTIONS_LONG_OFF     MCE_SETTING_POWERKEY_PATH "/actions_long_off"
# define MCE_DEFAULT_POWERKEY_ACTIONS_LONG_OFF     ""
117

118
/** Actions to take on touchscreen gesture N */
119 120
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE0     MCE_SETTING_POWERKEY_PATH "/actions_gesture0"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE0     "unblank"
121

122 123
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE1     MCE_SETTING_POWERKEY_PATH "/actions_gesture1"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE1     "unblank"
124

125 126
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE2     MCE_SETTING_POWERKEY_PATH "/actions_gesture2"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE2     "unblank"
127

128 129
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE3     MCE_SETTING_POWERKEY_PATH "/actions_gesture3"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE3     "unblank"
130

131
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE4     MCE_SETTING_POWERKEY_PATH "/actions_gesture4"
132
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE4     "unblank" // GESTURE_DOUBLETAP
133

134 135
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE5     MCE_SETTING_POWERKEY_PATH "/actions_gesture5"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE5     "unblank"
136

137 138
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE6     MCE_SETTING_POWERKEY_PATH "/actions_gesture6"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE6     "unblank"
139

140 141
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE7     MCE_SETTING_POWERKEY_PATH "/actions_gesture7"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE7     "unblank"
142

143 144
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE8     MCE_SETTING_POWERKEY_PATH "/actions_gesture8"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE8     "unblank"
145

146 147
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE9     MCE_SETTING_POWERKEY_PATH "/actions_gesture9"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE9     "unblank"
148

149 150
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE10    MCE_SETTING_POWERKEY_PATH "/actions_gesture10"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE10    "unblank"
151

152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE11    MCE_SETTING_POWERKEY_PATH "/actions_gesture11"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE11    "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE12    MCE_SETTING_POWERKEY_PATH "/actions_gesture12"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE12    "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE13    MCE_SETTING_POWERKEY_PATH "/actions_gesture13"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE13    "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE14    MCE_SETTING_POWERKEY_PATH "/actions_gesture14"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE14    "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE15    MCE_SETTING_POWERKEY_PATH "/actions_gesture15"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE15    "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE16    MCE_SETTING_POWERKEY_PATH "/actions_gesture16"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE16    "unblank,tkunlock" // GESTURE_FPWAKEUP

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE17    MCE_SETTING_POWERKEY_PATH "/actions_gesture17"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE17    "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE18    MCE_SETTING_POWERKEY_PATH "/actions_gesture18"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE18    "unblank"

# define MCE_SETTING_POWERKEY_ACTIONS_GESTURE19    MCE_SETTING_POWERKEY_PATH "/actions_gesture19"
# define MCE_DEFAULT_POWERKEY_ACTIONS_GESTURE19    "unblank"

179
/** Number of configurable touchscreen gestures */
180
# define POWERKEY_ACTIONS_GESTURE_COUNT            20
181

182
/** What to send when dbus action N is taken*/
183 184
# define MCE_SETTING_POWERKEY_DBUS_ACTION1         MCE_SETTING_POWERKEY_PATH "/dbus_action1"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION1         "event1"
185

186 187
# define MCE_SETTING_POWERKEY_DBUS_ACTION2         MCE_SETTING_POWERKEY_PATH "/dbus_action2"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION2         "event2"
188

189 190
# define MCE_SETTING_POWERKEY_DBUS_ACTION3         MCE_SETTING_POWERKEY_PATH "/dbus_action3"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION3         "event3"
191

192 193
# define MCE_SETTING_POWERKEY_DBUS_ACTION4         MCE_SETTING_POWERKEY_PATH "/dbus_action4"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION4         "event4"
194

195 196
# define MCE_SETTING_POWERKEY_DBUS_ACTION5         MCE_SETTING_POWERKEY_PATH "/dbus_action5"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION5         "event5"
197

198 199
# define MCE_SETTING_POWERKEY_DBUS_ACTION6         MCE_SETTING_POWERKEY_PATH "/dbus_action6"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION6         "event6"
200

201 202 203 204 205 206 207 208 209 210 211
# define MCE_SETTING_POWERKEY_DBUS_ACTION7         MCE_SETTING_POWERKEY_PATH "/dbus_action7"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION7         "event7"

# define MCE_SETTING_POWERKEY_DBUS_ACTION8         MCE_SETTING_POWERKEY_PATH "/dbus_action8"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION8         "event8"

# define MCE_SETTING_POWERKEY_DBUS_ACTION9         MCE_SETTING_POWERKEY_PATH "/dbus_action9"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION9         "event9"

# define MCE_SETTING_POWERKEY_DBUS_ACTION10        MCE_SETTING_POWERKEY_PATH "/dbus_action10"
# define MCE_DEFAULT_POWERKEY_DBUS_ACTION10        "event10"
212 213

/** Number of configurable dbus actions */
214 215 216 217 218 219 220 221
# define POWEKEY_DBUS_ACTION_COUNT                 10

/* ========================================================================= *
 * FUNCTIONS
 * ========================================================================= */

gboolean mce_powerkey_init(void);
void     mce_powerkey_exit(void);
222

223
#endif /* POWERKEY_H_ */