-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpm.c
68 lines (59 loc) · 2.26 KB
/
pm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright (c) 2012 Citrix Systems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "project.h"
/* Input values defined here because RPC tool cannot generate enum values
* from IDL yet.
*/
#define XCPMD_INPUT_SLEEP 1
#define XCPMD_INPUT_BRIGHTNESSUP 2
#define XCPMD_INPUT_BRIGHTNESSDOWN 3
static int increase_brightness_binding(void *opaque)
{
com_citrix_xenclient_xcpmd_indicate_input_(xcbus_conn, XCPMD_SERVICE, XCPMD_PATH, XCPMD_INPUT_BRIGHTNESSUP);
return 0;
}
static int decrease_brightness_binding(void *opaque)
{
com_citrix_xenclient_xcpmd_indicate_input_(xcbus_conn, XCPMD_SERVICE, XCPMD_PATH, XCPMD_INPUT_BRIGHTNESSDOWN);
return 0;
}
static int sleep_binding(void *opaque)
{
com_citrix_xenclient_xcpmd_indicate_input_(xcbus_conn, XCPMD_SERVICE, XCPMD_PATH, XCPMD_INPUT_SLEEP);
return 0;
}
int host_pmop_in_progress(void)
{
char *pmact = NULL;
int r = 0;
pmact = xenstore_read( "/xenmgr/pm-current-action" );
r = pmact != NULL;
free( pmact );
return r;
}
void pm_init(void)
{
int brightness_up[] = { KEY_BRIGHTNESSUP, -1 }; /* 225 */
int brightness_down[] = { KEY_BRIGHTNESSDOWN, -1 }; /* 224 */
int sleep[] = { KEY_SLEEP, -1 }; /* 142 */
/* install the input bindings */
input_add_binding(brightness_up, increase_brightness_binding, NULL,(void *) 0);
input_add_binding(brightness_down, decrease_brightness_binding, NULL,(void *) 0);
input_add_binding(sleep, sleep_binding, NULL,(void *) 0);
info("pm: installed brightness and sleep binding handlers.");
}