The Pedigree Project  0.1
HidUtils.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 HIDUTILS_H
21 #define HIDUTILS_H
22 
23 #include "pedigree/kernel/processor/types.h"
24 
26 enum HidDeviceType
27 {
28  Keyboard,
29  Mouse,
30  Joystick,
31  UnknownDevice = ~0
32 };
33 
35 namespace HidUtils
36 {
38 uint64_t getBufferField(uint8_t *pBuffer, size_t nStart, size_t nLength);
39 
41 void fixNegativeMinimum(int64_t &nMin, int64_t nMax);
42 
44 void fixNegativeValue(int64_t nMin, int64_t nMax, int64_t &nValue);
45 
48  HidDeviceType deviceType, uint16_t nUsagePage, uint16_t nUsage,
49  int64_t nRelativeValue);
50 }; // namespace HidUtils
51 
52 #endif
void sendInputToManager(HidDeviceType deviceType, uint16_t nUsagePage, uint16_t nUsage, int64_t nRelativeValue)
Sends the input to the right handler in HidInputManager or InputManager.
Definition: HidUtils.cc:83
Various utility functions used in HID.
Definition: HidUtils.h:35
void fixNegativeMinimum(int64_t &nMin, int64_t nMax)
Converts.
Definition: HidUtils.cc:42
uint64_t getBufferField(uint8_t *pBuffer, size_t nStart, size_t nLength)
Retrieves a field in a buffer.
Definition: HidUtils.cc:26
void fixNegativeValue(int64_t nMin, int64_t nMax, int64_t &nValue)
Converts.
Definition: HidUtils.cc:59