summaryrefslogtreecommitdiff
path: root/src/input.h
blob: 69b138ef35bc0e33455e57db2c1bde820e282c7c (plain)
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
/**
 * @file
 * @section AUTHORS
 *
 *  Authors:
 *       Eamon Walsh <ewalsh@tycho.nsa.gov>
 *
 * @section LICENSE
 *
 * This file is in the public domain.
 */

#ifndef _LINPICKER_INPUT_H_
#define _LINPICKER_INPUT_H_

#include <linux/input.h>

/* The secure attention keys */
#define LINPICK_SWITCH_SAK KEY_TAB
#define LINPICK_LABEL_SAK KEY_CAPSLOCK

struct mouse_event {
    int x, y;
    int dx, dy, dz;
};

static inline int clamp_value(int val, int max)
{
    if (val <= 0)
	return 0;
    else if (val >= max)
	return max - 1;
    else
	return val;
}

static inline int scale_value(int val, int max, int scale)
{
    if (val <= 0)
	return 0;
    else if (val >= max)
	return scale;
    else
	return (val * scale) / max;
}

int
input_initialize(int argc, char *argv[]);

void
input_shutdown(void);

#endif /* _LINPICKER_INPUT_H_ */