2017-10-06 17:13:08 +00:00
|
|
|
/*
|
|
|
|
Copyright 2017 Joshua Broekhuijsen <snipeye+qmk@gmail.com>
|
|
|
|
|
|
|
|
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 2 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-12-26 04:53:12 +00:00
|
|
|
#pragma once
|
2017-10-06 17:13:08 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "host.h"
|
|
|
|
#include "report.h"
|
|
|
|
|
2022-09-24 06:43:55 +00:00
|
|
|
#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
|
|
|
|
# include "pointing_device_auto_mouse.h"
|
|
|
|
#endif
|
|
|
|
|
2021-11-15 06:03:24 +00:00
|
|
|
#if defined(POINTING_DEVICE_DRIVER_adns5050)
|
|
|
|
# include "drivers/sensors/adns5050.h"
|
2022-09-24 15:44:14 +00:00
|
|
|
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
2023-04-03 02:57:19 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_pmw3320)
|
|
|
|
# include "drivers/sensors/pmw3320.h"
|
|
|
|
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
2021-11-15 06:03:24 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_adns9800)
|
|
|
|
# include "spi_master.h"
|
|
|
|
# include "drivers/sensors/adns9800.h"
|
2022-09-24 15:44:14 +00:00
|
|
|
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
2021-11-15 06:03:24 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_analog_joystick)
|
|
|
|
# include "analog.h"
|
|
|
|
# include "drivers/sensors/analog_joystick.h"
|
2022-09-24 15:44:14 +00:00
|
|
|
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
2023-11-20 16:25:35 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_azoteq_iqs5xx)
|
|
|
|
# include "i2c_master.h"
|
|
|
|
# include "drivers/sensors/azoteq_iqs5xx.h"
|
2021-11-15 06:03:24 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
|
|
|
|
# include "drivers/sensors/cirque_pinnacle.h"
|
2022-07-13 04:17:40 +00:00
|
|
|
# include "drivers/sensors/cirque_pinnacle_gestures.h"
|
|
|
|
# include "pointing_device_gestures.h"
|
2022-07-20 00:46:22 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_paw3204)
|
|
|
|
# include "drivers/sensors/paw3204.h"
|
2022-09-24 15:44:14 +00:00
|
|
|
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
2021-11-15 06:03:24 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_pimoroni_trackball)
|
|
|
|
# include "i2c_master.h"
|
|
|
|
# include "drivers/sensors/pimoroni_trackball.h"
|
|
|
|
// support for legacy pimoroni defines
|
|
|
|
# ifdef PIMORONI_TRACKBALL_INVERT_X
|
|
|
|
# define POINTING_DEVICE_INVERT_X
|
|
|
|
# endif
|
|
|
|
# ifdef PIMORONI_TRACKBALL_INVERT_Y
|
|
|
|
# define POINTING_DEVICE_INVERT_Y
|
|
|
|
# endif
|
|
|
|
# ifdef PIMORONI_TRACKBALL_ROTATE
|
|
|
|
# define POINTING_DEVICE_ROTATION_90
|
|
|
|
# endif
|
2022-09-24 15:44:14 +00:00
|
|
|
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
2022-07-14 09:50:00 +00:00
|
|
|
#elif defined(POINTING_DEVICE_DRIVER_pmw3360) || defined(POINTING_DEVICE_DRIVER_pmw3389)
|
2021-11-15 06:03:24 +00:00
|
|
|
# include "spi_master.h"
|
2022-07-14 09:50:00 +00:00
|
|
|
# include "drivers/sensors/pmw33xx_common.h"
|
2022-09-24 15:44:14 +00:00
|
|
|
# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
|
2021-11-15 06:03:24 +00:00
|
|
|
#else
|
|
|
|
void pointing_device_driver_init(void);
|
|
|
|
report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report);
|
|
|
|
uint16_t pointing_device_driver_get_cpi(void);
|
|
|
|
void pointing_device_driver_set_cpi(uint16_t cpi);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void (*init)(void);
|
|
|
|
report_mouse_t (*get_report)(report_mouse_t mouse_report);
|
|
|
|
void (*set_cpi)(uint16_t);
|
|
|
|
uint16_t (*get_cpi)(void);
|
|
|
|
} pointing_device_driver_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
POINTING_DEVICE_BUTTON1,
|
|
|
|
POINTING_DEVICE_BUTTON2,
|
|
|
|
POINTING_DEVICE_BUTTON3,
|
|
|
|
POINTING_DEVICE_BUTTON4,
|
|
|
|
POINTING_DEVICE_BUTTON5,
|
|
|
|
POINTING_DEVICE_BUTTON6,
|
|
|
|
POINTING_DEVICE_BUTTON7,
|
|
|
|
POINTING_DEVICE_BUTTON8,
|
|
|
|
} pointing_device_buttons_t;
|
|
|
|
|
2022-06-09 01:39:16 +00:00
|
|
|
#ifdef MOUSE_EXTENDED_REPORT
|
|
|
|
# define XY_REPORT_MIN INT16_MIN
|
|
|
|
# define XY_REPORT_MAX INT16_MAX
|
2024-10-06 09:26:55 +00:00
|
|
|
typedef int32_t xy_clamp_range_t;
|
2022-06-09 01:39:16 +00:00
|
|
|
#else
|
|
|
|
# define XY_REPORT_MIN INT8_MIN
|
|
|
|
# define XY_REPORT_MAX INT8_MAX
|
2024-10-06 09:26:55 +00:00
|
|
|
typedef int16_t xy_clamp_range_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WHEEL_EXTENDED_REPORT
|
|
|
|
# define HV_REPORT_MIN INT16_MIN
|
|
|
|
# define HV_REPORT_MAX INT16_MAX
|
|
|
|
typedef int32_t hv_clamp_range_t;
|
|
|
|
#else
|
|
|
|
# define HV_REPORT_MIN INT8_MIN
|
|
|
|
# define HV_REPORT_MAX INT8_MAX
|
|
|
|
typedef int16_t hv_clamp_range_t;
|
2022-06-09 01:39:16 +00:00
|
|
|
#endif
|
|
|
|
|
2019-08-30 18:19:03 +00:00
|
|
|
void pointing_device_init(void);
|
2023-03-31 01:27:39 +00:00
|
|
|
bool pointing_device_task(void);
|
|
|
|
bool pointing_device_send(void);
|
2017-10-06 17:13:08 +00:00
|
|
|
report_mouse_t pointing_device_get_report(void);
|
2022-03-08 04:16:35 +00:00
|
|
|
void pointing_device_set_report(report_mouse_t mouse_report);
|
2021-11-15 06:03:24 +00:00
|
|
|
uint16_t pointing_device_get_cpi(void);
|
|
|
|
void pointing_device_set_cpi(uint16_t cpi);
|
|
|
|
|
|
|
|
void pointing_device_init_kb(void);
|
|
|
|
void pointing_device_init_user(void);
|
|
|
|
report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report);
|
|
|
|
report_mouse_t pointing_device_task_user(report_mouse_t mouse_report);
|
|
|
|
uint8_t pointing_device_handle_buttons(uint8_t buttons, bool pressed, pointing_device_buttons_t button);
|
2021-12-27 01:05:51 +00:00
|
|
|
report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report);
|
2022-09-27 03:49:32 +00:00
|
|
|
void pointing_device_keycode_handler(uint16_t keycode, bool pressed);
|
2021-12-27 01:05:51 +00:00
|
|
|
|
|
|
|
#if defined(SPLIT_POINTING_ENABLE)
|
|
|
|
void pointing_device_set_shared_report(report_mouse_t report);
|
|
|
|
uint16_t pointing_device_get_shared_cpi(void);
|
2022-01-26 19:24:29 +00:00
|
|
|
# if !defined(POINTING_DEVICE_TASK_THROTTLE_MS)
|
|
|
|
# define POINTING_DEVICE_TASK_THROTTLE_MS 1
|
|
|
|
# endif
|
2021-12-27 01:05:51 +00:00
|
|
|
# if defined(POINTING_DEVICE_COMBINED)
|
|
|
|
void pointing_device_set_cpi_on_side(bool left, uint16_t cpi);
|
|
|
|
report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, report_mouse_t right_report);
|
|
|
|
report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report);
|
|
|
|
report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report);
|
|
|
|
report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report);
|
2022-02-12 18:29:31 +00:00
|
|
|
# endif // defined(POINTING_DEVICE_COMBINED)
|
|
|
|
#endif // defined(SPLIT_POINTING_ENABLE)
|