Run IWYU & format code for MouseKeys

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1126/head
Michael Richters 2 years ago
parent 5f5b715f8e
commit 150edb5fc3
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -29,7 +29,7 @@
#include "kaleidoscope/key_defs.h" // for Key, SYNTHETIC #include "kaleidoscope/key_defs.h" // for Key, SYNTHETIC
#include "kaleidoscope/keyswitch_state.h" // for keyToggledOn #include "kaleidoscope/keyswitch_state.h" // for keyToggledOn
#include "kaleidoscope/plugin/mousekeys/MouseKeyDefs.h" // for KEY_MOUSE_BUTTON, KEY_MOUS... #include "kaleidoscope/plugin/mousekeys/MouseKeyDefs.h" // for KEY_MOUSE_BUTTON, KEY_MOUS...
#include "kaleidoscope/plugin/mousekeys/MouseWrapper.h" // for MouseWrapper, wrapper, WAR... #include "kaleidoscope/plugin/mousekeys/MouseWrapper.h" // for MouseWrapper, WARP_DOWN
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
@ -37,7 +37,7 @@ namespace plugin {
#ifndef NDEPRECATED #ifndef NDEPRECATED
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
uint8_t MouseKeys::speed = 1; uint8_t MouseKeys::speed = 1;
uint16_t MouseKeys::speedDelay = 1; uint16_t MouseKeys::speedDelay = 1;
uint8_t MouseKeys::accelSpeed = 1; uint8_t MouseKeys::accelSpeed = 1;
@ -226,6 +226,7 @@ void MouseKeys::sendMouseWarpReport(const KeyEvent &event) const {
void MouseKeys::sendMouseMoveReport() const { void MouseKeys::sendMouseMoveReport() const {
int8_t dx = 0; int8_t dx = 0;
int8_t dy = 0; int8_t dy = 0;
uint8_t direction = directions_ & cursor_mask_; uint8_t direction = directions_ & cursor_mask_;
if (direction != 0) { if (direction != 0) {
@ -252,7 +253,7 @@ void MouseKeys::sendMouseMoveReport() const {
// Get the current point on the acceleration curve's x axis, translating time // Get the current point on the acceleration curve's x axis, translating time
// elapsed since mouse movement started to a value between 0 and 255. // elapsed since mouse movement started to a value between 0 and 255.
uint8_t MouseKeys::accelStep() const { uint8_t MouseKeys::accelStep() const {
uint16_t elapsed_time = Runtime.millisAtCycleStart() - cursor_start_time_; uint16_t elapsed_time = Runtime.millisAtCycleStart() - cursor_start_time_;
uint16_t accel_duration = settings_.cursor_accel_duration; uint16_t accel_duration = settings_.cursor_accel_duration;
if (elapsed_time > accel_duration) if (elapsed_time > accel_duration)
return 255; return 255;
@ -271,6 +272,7 @@ uint8_t accelFactor(uint8_t accel_step) {
return 1 + (y >> 7); return 1 + (y >> 7);
} else { } else {
uint16_t remaining_steps = 256 - accel_step; uint16_t remaining_steps = 256 - accel_step;
uint16_t y = remaining_steps * remaining_steps; uint16_t y = remaining_steps * remaining_steps;
return 255 - (y >> 7); return 255 - (y >> 7);
} }
@ -303,9 +305,9 @@ uint8_t MouseKeys::cursorDelta() const {
// difference between the starting speed and the full speed, then add the // difference between the starting speed and the full speed, then add the
// starting speed (multiplied by the full value of the scaling factor) to get // starting speed (multiplied by the full value of the scaling factor) to get
// the current speed. // the current speed.
uint8_t max_speed = settings_.cursor_base_speed; uint8_t max_speed = settings_.cursor_base_speed;
uint8_t min_speed = settings_.cursor_init_speed; uint8_t min_speed = settings_.cursor_init_speed;
uint8_t speed_range = max_speed - min_speed; uint8_t speed_range = max_speed - min_speed;
uint16_t subpixel_speed = (speed_range * accel_factor); uint16_t subpixel_speed = (speed_range * accel_factor);
subpixel_speed += (min_speed * 256); subpixel_speed += (min_speed * 256);
@ -346,6 +348,7 @@ uint8_t MouseKeys::cursorDelta() const {
void MouseKeys::sendMouseWheelReport() const { void MouseKeys::sendMouseWheelReport() const {
int8_t dh = 0; int8_t dh = 0;
int8_t dv = 0; int8_t dv = 0;
uint8_t direction = directions_ >> wheel_offset_; uint8_t direction = directions_ >> wheel_offset_;
if (direction != 0) { if (direction != 0) {

@ -22,43 +22,42 @@
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult
#include "kaleidoscope/key_defs.h" // for Key #include "kaleidoscope/key_defs.h" // for Key
#include "kaleidoscope/plugin.h" // for Plugin #include "kaleidoscope/plugin.h" // for Plugin
// ============================================================================= // =============================================================================
// Deprecated MousKeys code // Deprecated MousKeys code
#include "kaleidoscope_internal/deprecations.h" // for DEPRECATED #include "kaleidoscope_internal/deprecations.h" // for DEPRECATED
#define _DEPRECATED_MESSAGE_MOUSEKEYS_SET_SPEED_LIMIT \ #define _DEPRECATED_MESSAGE_MOUSEKEYS_SET_SPEED_LIMIT \
"The `MouseKeys.setSpeedLimit()` function is deprecated. It no longer has\n" \ "The `MouseKeys.setSpeedLimit()` function is deprecated. It no longer has\n" \
"any function, and can be safely removed." "any function, and can be safely removed."
#define _DEPRECATED_MESSAGE_MOUSEKEYS_SPEED \ #define _DEPRECATED_MESSAGE_MOUSEKEYS_SPEED \
"Direct access to the `MouseKeys.speed` variable has been deprecated.\n" \ "Direct access to the `MouseKeys.speed` variable has been deprecated.\n" \
"Please refer to the MouseKeys documentation for instructions on how to\n" \ "Please refer to the MouseKeys documentation for instructions on how to\n" \
"configure the plugin.\n" "configure the plugin.\n"
#define _DEPRECATED_MESSAGE_MOUSEKEYS_SPEED_DELAY \ #define _DEPRECATED_MESSAGE_MOUSEKEYS_SPEED_DELAY \
"Direct access to the `MouseKeys.speedDelay` variable has been deprecated.\n" \ "Direct access to the `MouseKeys.speedDelay` variable has been deprecated.\n" \
"Please refer to the MouseKeys documentation for instructions on how to\n" \ "Please refer to the MouseKeys documentation for instructions on how to\n" \
"configure the plugin.\n" "configure the plugin.\n"
#define _DEPRECATED_MESSAGE_MOUSEKEYS_ACCEL_SPEED \ #define _DEPRECATED_MESSAGE_MOUSEKEYS_ACCEL_SPEED \
"Direct access to the `MouseKeys.accelSpeed` variable has been deprecated.\n" \ "Direct access to the `MouseKeys.accelSpeed` variable has been deprecated.\n" \
"Please refer to the MouseKeys documentation for instructions on how to\n" \ "Please refer to the MouseKeys documentation for instructions on how to\n" \
"configure the plugin.\n" "configure the plugin.\n"
#define _DEPRECATED_MESSAGE_MOUSEKEYS_ACCEL_DELAY \ #define _DEPRECATED_MESSAGE_MOUSEKEYS_ACCEL_DELAY \
"Direct access to the `MouseKeys.accelDelay` variable has been deprecated.\n" \ "Direct access to the `MouseKeys.accelDelay` variable has been deprecated.\n" \
"Please refer to the MouseKeys documentation for instructions on how to\n" \ "Please refer to the MouseKeys documentation for instructions on how to\n" \
"configure the plugin.\n" "configure the plugin.\n"
#define _DEPRECATED_MESSAGE_MOUSEKEYS_WHEEL_SPEED \ #define _DEPRECATED_MESSAGE_MOUSEKEYS_WHEEL_SPEED \
"Direct access to the `MouseKeys.wheelSpeed` variable has been deprecated.\n" \ "Direct access to the `MouseKeys.wheelSpeed` variable has been deprecated.\n" \
"Please refer to the MouseKeys documentation for instructions on how to\n" \ "Please refer to the MouseKeys documentation for instructions on how to\n" \
"configure the plugin.\n" "configure the plugin.\n"
#define _DEPRECATED_MESSAGE_MOUSEKEYS_WHEEL_DELAY \ #define _DEPRECATED_MESSAGE_MOUSEKEYS_WHEEL_DELAY \
"Direct access to the `MouseKeys.wheelDelay` variable has been deprecated.\n" \ "Direct access to the `MouseKeys.wheelDelay` variable has been deprecated.\n" \
"Please refer to the MouseKeys documentation for instructions on how to\n" \ "Please refer to the MouseKeys documentation for instructions on how to\n" \
"configure the plugin.\n" "configure the plugin.\n"
@ -66,7 +65,6 @@ namespace kaleidoscope {
namespace plugin { namespace plugin {
class MouseKeys : public kaleidoscope::Plugin { class MouseKeys : public kaleidoscope::Plugin {
public: public:
#ifndef NDEPRECATED #ifndef NDEPRECATED
DEPRECATED(MOUSEKEYS_SPEED) DEPRECATED(MOUSEKEYS_SPEED)
static uint8_t speed; static uint8_t speed;
@ -201,8 +199,8 @@ class MouseKeysConfig : public Plugin {
uint16_t settings_addr_; uint16_t settings_addr_;
}; };
} // namespace plugin } // namespace plugin
} // namespace kaleidoscope } // namespace kaleidoscope
extern kaleidoscope::plugin::MouseKeys MouseKeys; extern kaleidoscope::plugin::MouseKeys MouseKeys;
extern kaleidoscope::plugin::MouseKeysConfig MouseKeysConfig; extern kaleidoscope::plugin::MouseKeysConfig MouseKeysConfig;

@ -16,7 +16,7 @@
#include "kaleidoscope/plugin/mousekeys/MouseWrapper.h" #include "kaleidoscope/plugin/mousekeys/MouseWrapper.h"
#include <stdint.h> // for uint16_t, uint8_t, int8_t #include <stdint.h> // for uint16_t, uint8_t
#include "kaleidoscope/Runtime.h" // for Runtime, Runtime_ #include "kaleidoscope/Runtime.h" // for Runtime, Runtime_
#include "kaleidoscope/device/device.h" // for Base<>::HID, VirtualProps:... #include "kaleidoscope/device/device.h" // for Base<>::HID, VirtualProps:...
@ -95,9 +95,9 @@ void MouseWrapper::warp(uint8_t warp_cmd) {
warpJump(section_left, section_top, next_height, next_width); warpJump(section_left, section_top, next_height, next_width);
} }
} // namespace mousekeys } // namespace mousekeys
mousekeys::MouseWrapper MouseWrapper; mousekeys::MouseWrapper MouseWrapper;
} // namespace plugin } // namespace plugin
} // namespace kaleidoscope } // namespace kaleidoscope

@ -16,9 +16,9 @@
#pragma once #pragma once
#include <stdint.h> // for uint8_t, uint16_t #include <stdint.h> // for uint16_t, uint8_t
#include "kaleidoscope/plugin/mousekeys/MouseWarpModes.h" #include "kaleidoscope/plugin/mousekeys/MouseWarpModes.h" // for MOUSE_WARP_GRID_2X2
// Mouse acceleration // Mouse acceleration
@ -63,9 +63,9 @@ class MouseWrapper {
void warpJump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); void warpJump(uint16_t left, uint16_t top, uint16_t height, uint16_t width);
}; };
} // namespace mousekeys } // namespace mousekeys
extern mousekeys::MouseWrapper MouseWrapper; extern mousekeys::MouseWrapper MouseWrapper;
} // namespace plugin } // namespace plugin
} // namespace kaleidoscope } // namespace kaleidoscope

Loading…
Cancel
Save