/** * Copyright (c) 2017 - 2020, Nordic Semiconductor ASA * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * * 3. Neither the name of Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef APP_USBD_HID_KBD_H__ #define APP_USBD_HID_KBD_H__ #ifdef __cplusplus extern "C" { #endif #include #include #include "nrf_drv_usbd.h" #include "app_usbd_class_base.h" #include "app_usbd_hid_types.h" #include "app_usbd_hid.h" #include "app_usbd.h" #include "app_usbd_core.h" #include "app_usbd_descriptor.h" #include "app_usbd_hid_kbd_desc.h" #include "app_usbd_hid_kbd_internal.h" /** * @defgroup app_usbd_hid_kbd USB HID keyboard * @ingroup app_usbd_hid * * @brief @tagAPI52840 Module with types, definitions, and API used by the HID keyboard class. * @{ */ /** * @brief HID keyboard codes. */ typedef enum { APP_USBD_HID_KBD_A = 4, /**base; } /** * @brief Helper function to get HID keyboard from base class instance. * * @param[in] p_inst Base class instance. * * @return HID keyboard class handle. */ static inline app_usbd_hid_kbd_t const * app_usbd_hid_kbd_class_get(app_usbd_class_inst_t const * p_inst) { return (app_usbd_hid_kbd_t const *)p_inst; } /** * @brief Set HID keyboard modifier state. * * @param[in] p_kbd Keyboard instance (declared by @ref APP_USBD_HID_KBD_GLOBAL_DEF). * @param[in] modifier Type of modifier. * @param[in] state State, true active, false inactive. * * @return Standard error code. */ ret_code_t app_usbd_hid_kbd_modifier_state_set(app_usbd_hid_kbd_t const * p_kbd, app_usbd_hid_kbd_modifier_t modifier, bool state); /** * @brief Press/release HID keyboard key. * * @param[in] p_kbd Keyboard instance (declared by @ref APP_USBD_HID_KBD_GLOBAL_DEF). * @param[in] key Keyboard key code. * @param[in] press True -> key press, false -> release. * * @return Standard error code. */ ret_code_t app_usbd_hid_kbd_key_control(app_usbd_hid_kbd_t const * p_kbd, app_usbd_hid_kbd_codes_t key, bool press); /** * @brief HID Keyboard LEDs state get. * * @param[in] p_kbd Keyboard instance (declared by @ref APP_USBD_HID_KBD_GLOBAL_DEF). * @param[in] led LED code. * * @retval true LED is set. * @retval false LED is not set. */ bool app_usbd_hid_kbd_led_state_get(app_usbd_hid_kbd_t const * p_kbd, app_usbd_hid_kbd_led_t led); /** * @brief Function handling SET_PROTOCOL command. * * * @param[in] p_kbd Keyboard instance. * @param[in] ev User event. * * @return Standard error code. */ ret_code_t hid_kbd_on_set_protocol(app_usbd_hid_kbd_t const * p_kbd, app_usbd_hid_user_event_t ev); /** * @brief Function that clears HID keyboard buffers and sends an empty report. * * @param[in] p_inst Base class instance. * * @return Standard error code. */ ret_code_t hid_kbd_clear_buffer(app_usbd_class_inst_t const * p_inst); /** @} */ #ifdef __cplusplus } #endif #endif /* APP_USBD_HID_KBD_H__ */