88 lines
1.7 KiB
C
88 lines
1.7 KiB
C
#include "app_timer.h"
|
|
#include "app_usbd.h"
|
|
#include "app_usbd_core.h"
|
|
#include "app_usbd_hid_generic.h"
|
|
extern "C"
|
|
{
|
|
#include "app_usbd_hid_mouse.h"
|
|
#include "app_usbd_hid_kbd.h"
|
|
}
|
|
#include "app_error.h"
|
|
|
|
/**
|
|
* @brief Enable USB power detection
|
|
*/
|
|
#ifndef USBD_POWER_DETECTION
|
|
#define USBD_POWER_DETECTION true
|
|
#endif
|
|
|
|
/**
|
|
* @brief Enable HID mouse class
|
|
*/
|
|
#define CONFIG_HAS_MOUSE 1
|
|
|
|
/**
|
|
* @brief Enable HID keyboard class
|
|
*/
|
|
#define CONFIG_HAS_KBD 1
|
|
|
|
/**
|
|
* @brief Mouse button count
|
|
*/
|
|
#define CONFIG_MOUSE_BUTTON_COUNT 2
|
|
|
|
/**
|
|
* @brief Mouse speed (value sent via HID when board button is pressed).
|
|
*/
|
|
#define CONFIG_MOUSE_MOVE_STEP (3)
|
|
|
|
/**
|
|
* @brief Mouse move repeat time in milliseconds
|
|
*/
|
|
#define CONFIG_MOUSE_MOVE_TIME_MS (5)
|
|
|
|
/* HID report layout */
|
|
#define BTN_MOUSE_X_POS 0
|
|
#define BTN_MOUSE_LEFT 1
|
|
|
|
/**
|
|
* @brief USB composite interfaces
|
|
*/
|
|
#define APP_USBD_INTERFACE_MOUSE 0
|
|
|
|
|
|
/**
|
|
* @brief HID generic mouse action types
|
|
*/
|
|
typedef enum {
|
|
HID_GENERIC_MOUSE_X,
|
|
HID_GENERIC_MOUSE_Y,
|
|
HID_GENERIC_MOUSE_BTN_LEFT,
|
|
HID_GENERIC_MOUSE_BTN_RIGHT,
|
|
} hid_generic_mouse_action_t;
|
|
|
|
/**
|
|
* @brief User event handler, HID mouse
|
|
*/
|
|
void hid_mouse_user_ev_handler(app_usbd_class_inst_t const * p_inst,
|
|
app_usbd_hid_user_event_t event);
|
|
|
|
/**
|
|
* @brief Timer to repeat mouse move
|
|
*/
|
|
APP_TIMER_DEF(m_mouse_move_timer);
|
|
|
|
|
|
/**
|
|
* @brief Global HID mouse instance
|
|
*/
|
|
APP_USBD_HID_MOUSE_GLOBAL_DEF(m_app_hid_mouse,
|
|
APP_USBD_INTERFACE_MOUSE,
|
|
NRF_DRV_USBD_EPIN1,
|
|
CONFIG_MOUSE_BUTTON_COUNT,
|
|
hid_mouse_user_ev_handler,
|
|
APP_USBD_HID_SUBCLASS_BOOT
|
|
);
|
|
|
|
|
|
void usbSetup(); |