~ubuntu-branches/ubuntu/precise/linux-lowlatency/precise

« back to all changes in this revision

Viewing changes to include/linux/input/sparse-keymap.h

  • Committer: Package Import Robot
  • Author(s): Alessio Igor Bogani
  • Date: 2011-10-26 11:13:05 UTC
  • Revision ID: package-import@ubuntu.com-20111026111305-tz023xykf0i6eosh
Tags: upstream-3.2.0
ImportĀ upstreamĀ versionĀ 3.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _SPARSE_KEYMAP_H
 
2
#define _SPARSE_KEYMAP_H
 
3
 
 
4
/*
 
5
 * Copyright (c) 2009 Dmitry Torokhov
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify it
 
8
 * under the terms of the GNU General Public License version 2 as published by
 
9
 * the Free Software Foundation.
 
10
 */
 
11
 
 
12
#define KE_END          0       /* Indicates end of keymap */
 
13
#define KE_KEY          1       /* Ordinary key/button */
 
14
#define KE_SW           2       /* Switch (predetermined value) */
 
15
#define KE_VSW          3       /* Switch (value supplied at runtime) */
 
16
#define KE_IGNORE       4       /* Known entry that should be ignored */
 
17
#define KE_LAST         KE_IGNORE
 
18
 
 
19
/**
 
20
 * struct key_entry - keymap entry for use in sparse keymap
 
21
 * @type: Type of the key entry (KE_KEY, KE_SW, KE_VSW, KE_END);
 
22
 *      drivers are allowed to extend the list with their own
 
23
 *      private definitions.
 
24
 * @code: Device-specific data identifying the button/switch
 
25
 * @keycode: KEY_* code assigned to a key/button
 
26
 * @sw.code: SW_* code assigned to a switch
 
27
 * @sw.value: Value that should be sent in an input even when KE_SW
 
28
 *      switch is toggled. KE_VSW switches ignore this field and
 
29
 *      expect driver to supply value for the event.
 
30
 *
 
31
 * This structure defines an entry in a sparse keymap used by some
 
32
 * input devices for which traditional table-based approach is not
 
33
 * suitable.
 
34
 */
 
35
struct key_entry {
 
36
        int type;               /* See KE_* above */
 
37
        u32 code;
 
38
        union {
 
39
                u16 keycode;            /* For KE_KEY */
 
40
                struct {                /* For KE_SW, KE_VSW */
 
41
                        u8 code;
 
42
                        u8 value;       /* For KE_SW, ignored by KE_VSW */
 
43
                } sw;
 
44
        };
 
45
};
 
46
 
 
47
struct key_entry *sparse_keymap_entry_from_scancode(struct input_dev *dev,
 
48
                                                    unsigned int code);
 
49
struct key_entry *sparse_keymap_entry_from_keycode(struct input_dev *dev,
 
50
                                                   unsigned int code);
 
51
int sparse_keymap_setup(struct input_dev *dev,
 
52
                        const struct key_entry *keymap,
 
53
                        int (*setup)(struct input_dev *, struct key_entry *));
 
54
void sparse_keymap_free(struct input_dev *dev);
 
55
 
 
56
void sparse_keymap_report_entry(struct input_dev *dev, const struct key_entry *ke,
 
57
                                unsigned int value, bool autorelease);
 
58
 
 
59
bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code,
 
60
                                unsigned int value, bool autorelease);
 
61
 
 
62
#endif /* _SPARSE_KEYMAP_H */