The Pedigree Project 0.1
Input.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef _INPUT_H
21#define _INPUT_H
22
23#include "pedigree/native/compiler.h"
24#include "pedigree/native/types.h"
25
26namespace Input {
28const int Key = 1;
29const int Mouse = 2;
30const int Joystick = 4;
31const int RawKey = 8;
32const int AbsoluteMouse = 32;
33const int Unknown = 255;
34
35typedef int CallbackType;
36
40struct EXPORTED_PUBLIC InputNotification {
41 CallbackType type;
42 // Keep the userspace view aligned with the kernel event payload.
43 // Event-stream reads clear this reserved metadata slot.
44 void* meta;
45
46 union {
47 struct {
48 uint64_t key;
49 } key;
50 struct {
51 ssize_t relx;
52 ssize_t rely;
53 ssize_t relz;
54
55 bool buttons[64];
56 } pointy;
57 struct {
58 uint32_t x;
59 uint32_t y;
60 ssize_t wheel;
61
62 bool buttons[64];
63 } absolute;
64 struct {
67 uint8_t scancode;
68
70 bool keyUp;
71 } rawkey;
72 } data;
73};
74
78EXPORTED_PUBLIC int openEventStream();
79
82EXPORTED_PUBLIC ssize_t readEvent(int fd, InputNotification& notification);
83
85EXPORTED_PUBLIC void inhibitEvents();
86
88EXPORTED_PUBLIC void uninhibitEvents();
89
93EXPORTED_PUBLIC void loadKeymapFromFile(const char* path);
94}; // namespace Input
95
96#endif
bool keyUp
Whether this is a keyUp event or not.
Definition Input.h:70