mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
hidpp: move the shared defines into a generic header
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -7,6 +7,8 @@ libratbag_la_SOURCES = \
|
||||
driver-etekcity.c \
|
||||
driver-hidpp20.c \
|
||||
driver-hidpp10.c \
|
||||
hidpp-generic.h \
|
||||
hidpp-generic.c \
|
||||
hidpp10.c \
|
||||
hidpp10.h \
|
||||
hidpp20.c \
|
||||
|
||||
50
src/hidpp-generic.c
Normal file
50
src/hidpp-generic.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* HID++ generic definitions
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on the HID++ documentation provided by Nestor Lopez Casado at:
|
||||
* https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28&usp=sharing
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "hidpp-generic.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
const char *hidpp_errors[0xFF] = {
|
||||
[0x00] = "ERR_SUCCESS",
|
||||
[0x01] = "ERR_INVALID_SUBID",
|
||||
[0x02] = "ERR_INVALID_ADDRESS",
|
||||
[0x03] = "ERR_INVALID_VALUE",
|
||||
[0x04] = "ERR_CONNECT_FAIL",
|
||||
[0x05] = "ERR_TOO_MANY_DEVICES",
|
||||
[0x06] = "ERR_ALREADY_EXISTS",
|
||||
[0x07] = "ERR_BUSY",
|
||||
[0x08] = "ERR_UNKNOWN_DEVICE",
|
||||
[0x09] = "ERR_RESOURCE_ERROR",
|
||||
[0x0A] = "ERR_REQUEST_UNAVAILABLE",
|
||||
[0x0B] = "ERR_INVALID_PARAM_VALUE",
|
||||
[0x0C] = "ERR_WRONG_PIN_CODE",
|
||||
[0x0D ... 0xFE] = NULL,
|
||||
};
|
||||
66
src/hidpp-generic.h
Normal file
66
src/hidpp-generic.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* HID++ generic definitions
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on the HID++ documentation provided by Nestor Lopez Casado at:
|
||||
* https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28&usp=sharing
|
||||
*/
|
||||
|
||||
#ifndef HIDPP_GENERIC_H
|
||||
#define HIDPP_GENERIC_H
|
||||
|
||||
#define RECEIVER_IDX 0xFF
|
||||
|
||||
#define REPORT_ID_SHORT 0x10
|
||||
#define REPORT_ID_LONG 0x11
|
||||
|
||||
#define SHORT_MESSAGE_LENGTH 7
|
||||
#define LONG_MESSAGE_LENGTH 20
|
||||
|
||||
#define SET_REGISTER_REQ 0x80
|
||||
#define SET_REGISTER_RSP 0x80
|
||||
#define GET_REGISTER_REQ 0x81
|
||||
#define GET_REGISTER_RSP 0x81
|
||||
#define SET_LONG_REGISTER_REQ 0x82
|
||||
#define SET_LONG_REGISTER_RSP 0x82
|
||||
#define GET_LONG_REGISTER_REQ 0x83
|
||||
#define GET_LONG_REGISTER_RSP 0x83
|
||||
#define __ERROR_MSG 0x8F
|
||||
|
||||
#define ERR_SUCCESS 0x00
|
||||
#define ERR_INVALID_SUBID 0x01
|
||||
#define ERR_INVALID_ADDRESS 0x02
|
||||
#define ERR_INVALID_VALUE 0x03
|
||||
#define ERR_CONNECT_FAIL 0x04
|
||||
#define ERR_TOO_MANY_DEVICES 0x05
|
||||
#define ERR_ALREADY_EXISTS 0x06
|
||||
#define ERR_BUSY 0x07
|
||||
#define ERR_UNKNOWN_DEVICE 0x08
|
||||
#define ERR_RESOURCE_ERROR 0x09
|
||||
#define ERR_REQUEST_UNAVAILABLE 0x0A
|
||||
#define ERR_INVALID_PARAM_VALUE 0x0B
|
||||
#define ERR_WRONG_PIN_CODE 0x0C
|
||||
|
||||
extern const char *hidpp_errors[0xFF];
|
||||
|
||||
#endif /* HIDPP_GENERIC_H */
|
||||
@@ -43,23 +43,6 @@
|
||||
#include "libratbag-hidraw.h"
|
||||
#include "libratbag-private.h"
|
||||
|
||||
const char *hidpp_errors[0xFF] = {
|
||||
[0x00] = "ERR_SUCCESS",
|
||||
[0x01] = "ERR_INVALID_SUBID",
|
||||
[0x02] = "ERR_INVALID_ADDRESS",
|
||||
[0x03] = "ERR_INVALID_VALUE",
|
||||
[0x04] = "ERR_CONNECT_FAIL",
|
||||
[0x05] = "ERR_TOO_MANY_DEVICES",
|
||||
[0x06] = "ERR_ALREADY_EXISTS",
|
||||
[0x07] = "ERR_BUSY",
|
||||
[0x08] = "ERR_UNKNOWN_DEVICE",
|
||||
[0x09] = "ERR_RESOURCE_ERROR",
|
||||
[0x0A] = "ERR_REQUEST_UNAVAILABLE",
|
||||
[0x0B] = "ERR_INVALID_PARAM_VALUE",
|
||||
[0x0C] = "ERR_WRONG_PIN_CODE",
|
||||
[0x0D ... 0xFE] = NULL,
|
||||
};
|
||||
|
||||
const char *device_types[0xFF] = {
|
||||
[0x00] = "Unknown",
|
||||
[0x01] = "Keyboard",
|
||||
|
||||
@@ -30,26 +30,10 @@
|
||||
#define HIDPP_10_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hidpp-generic.h"
|
||||
#include "libratbag.h"
|
||||
|
||||
#define RECEIVER_IDX 0xFF
|
||||
|
||||
#define REPORT_ID_SHORT 0x10
|
||||
#define REPORT_ID_LONG 0x11
|
||||
|
||||
#define SHORT_MESSAGE_LENGTH 7
|
||||
#define LONG_MESSAGE_LENGTH 20
|
||||
|
||||
#define SET_REGISTER_REQ 0x80
|
||||
#define SET_REGISTER_RSP 0x80
|
||||
#define GET_REGISTER_REQ 0x81
|
||||
#define GET_REGISTER_RSP 0x81
|
||||
#define SET_LONG_REGISTER_REQ 0x82
|
||||
#define SET_LONG_REGISTER_RSP 0x82
|
||||
#define GET_LONG_REGISTER_REQ 0x83
|
||||
#define GET_LONG_REGISTER_RSP 0x83
|
||||
#define __ERROR_MSG 0x8F
|
||||
|
||||
#define __CMD_HIDPP_NOTIFICATIONS 0x00
|
||||
#define FEATURE_BIT_R0_CONSUMER_SPECIFIC_CONTROL 0
|
||||
#define FEATURE_BIT_R0_POWER_KEYS 1
|
||||
@@ -185,20 +169,6 @@
|
||||
} \
|
||||
}
|
||||
|
||||
#define ERR_SUCCESS 0x00
|
||||
#define ERR_INVALID_SUBID 0x01
|
||||
#define ERR_INVALID_ADDRESS 0x02
|
||||
#define ERR_INVALID_VALUE 0x03
|
||||
#define ERR_CONNECT_FAIL 0x04
|
||||
#define ERR_TOO_MANY_DEVICES 0x05
|
||||
#define ERR_ALREADY_EXISTS 0x06
|
||||
#define ERR_BUSY 0x07
|
||||
#define ERR_UNKNOWN_DEVICE 0x08
|
||||
#define ERR_RESOURCE_ERROR 0x09
|
||||
#define ERR_REQUEST_UNAVAILABLE 0x0A
|
||||
#define ERR_INVALID_PARAM_VALUE 0x0B
|
||||
#define ERR_WRONG_PIN_CODE 0x0C
|
||||
|
||||
#define ERROR_MSG(__hidpp_msg, idx) { \
|
||||
.msg = { \
|
||||
.report_id = REPORT_ID_SHORT, \
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
#ifndef HIDPP_20_H
|
||||
#define HIDPP_20_H
|
||||
|
||||
#include "hidpp10.h"
|
||||
#include <stdint.h>
|
||||
|
||||
extern const char *hidpp_errors[0xFF];
|
||||
#include "libratbag.h"
|
||||
|
||||
#include "hidpp-generic.h"
|
||||
|
||||
struct _hidpp20_message {
|
||||
uint8_t report_id;
|
||||
|
||||
Reference in New Issue
Block a user