From 070c1ab9384f84c16ece86ac5c094de662a8f39f Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 7 Apr 2014 23:26:05 +0200 Subject: lib: add new interfaces for HID++ communication --- lib/hidpp10.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 lib/hidpp10.h (limited to 'lib/hidpp10.h') diff --git a/lib/hidpp10.h b/lib/hidpp10.h new file mode 100644 index 0000000..f8be8b0 --- /dev/null +++ b/lib/hidpp10.h @@ -0,0 +1,64 @@ +/* + * HID++ 1.0 protocol details. + * + * Copyright (C) 2014 Peter Wu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef HIDPP_10_H +#define HIDPP_10_H +#include +#include "hidpp.h" + +#define SUB_SET_REGISTER 0x80 +#define SUB_GET_REGISTER 0x81 +#define SUB_SET_LONG_REGISTER 0x82 +#define SUB_GET_LONG_REGISTER 0x83 +#define SUB_ERROR_MSG 0x8F + +#define NOTIF_DEV_DISCONNECT 0x40 /* Device Disconnection */ +#define NOTIF_DEV_CONNECT 0x41 /* Device Connection */ +#define NOTIF_RECV_LOCK_CHANGE 0x4A /* Unifying Receiver Locking Change information */ + +#define REG_ENABLED_NOTIFS 0x00 +#define REG_CONNECTION_STATE 0x02 +/* Device Connection and Disconnection (Pairing) */ +#define REG_DEVICE_PAIRING 0xB2 +#define REG_DEVICE_ACTIVITY 0xB3 +#define REG_PAIRING_INFO 0xB5 +#define REG_VERSION_INFO 0xF1 /* undocumented */ + +/** + * Attempts to dispatch a register query. + * + * @param fd File descriptor of the hidraw device. + * @param msg[in,out] The message to be sent. If a matching response was + * received, then this will contain that response. Otherwise, + * it is unmodified. + * @param cb Function that should be called for HID++ notifications. Its + * return value is ignored. The callback must not modify msg. + * @return 0 on success, a HID++ 1.0 error code otherwise. + */ +int hidpp10_request(int fd, HidppMessage *msg, hidpp_msg_cb_t *cb, void *userdata); + +/** + * Attempts to enable/disable reporting of wireless notifications. + * + * @param fd File descriptor of the hidraw device. + * @param enabled Whether wireless notifications should be reported. + * @return 0 on success, a HID++ 1.0 error code otherwise. + */ +int hidpp10_enable_wireless_notifications(int fd, bool enabled); +#endif -- cgit v1.2.1