diff --git a/core/firmware.cpp b/core/firmware.cpp index 7c2b8af..560d9bd 100644 --- a/core/firmware.cpp +++ b/core/firmware.cpp @@ -33,6 +33,9 @@ void Firmware::update() backlight.signal_failure(); } loaded_keymap = true; + + mouse_state.mouse_speed = settings.mouse_speed; + mouse_state.mouse_acceleration = settings.mouse_acceleration; } device.start_timer(); key_scanner.scan(keyboard_scan_result); diff --git a/core/keyboard/keymap.cpp b/core/keyboard/keymap.cpp index 801e0ed..f326f74 100644 --- a/core/keyboard/keymap.cpp +++ b/core/keyboard/keymap.cpp @@ -99,6 +99,8 @@ void KeyMap::read_mouse_keys(const KeyboardScanResult& scan_result, MouseState& bool middle = false; bool right = false; + mouse.accelerated = false; + for (int i = 0; i < scan_result.num_pressed; ++i) { const auto key = scan_result.pressed[i]; diff --git a/core/keyboard/keymap_loader.cpp b/core/keyboard/keymap_loader.cpp index c236860..f44d5da 100644 --- a/core/keyboard/keymap_loader.cpp +++ b/core/keyboard/keymap_loader.cpp @@ -1,7 +1,7 @@ #include "keymap_loader.h" #include "keyutils.h" #include "../util/buffer_utils.h" -#include +#include namespace core::keyboard diff --git a/core/keyboard/mouse.cpp b/core/keyboard/mouse.cpp index e038716..f7daae5 100644 --- a/core/keyboard/mouse.cpp +++ b/core/keyboard/mouse.cpp @@ -10,12 +10,12 @@ MouseMovement MouseState::get_movement() const return {}; } - const int8_t acceleration = accelerated ? MOUSE_ACCELERATION_AMOUNT : 1; + const int8_t acceleration = accelerated ? mouse_acceleration : 1; return { true, - static_cast(dx * MOUSE_MOVE_DEFAULT_SPEED * acceleration), - static_cast(dy * MOUSE_MOVE_DEFAULT_SPEED * acceleration), + static_cast(dx * mouse_speed * acceleration), + static_cast(dy * mouse_speed * acceleration), static_cast(wheel * MOUSE_WHEEL_DEFAULT_SPEED * acceleration) }; } diff --git a/core/keyboard/mouse.h b/core/keyboard/mouse.h index 80a52df..4652f8a 100644 --- a/core/keyboard/mouse.h +++ b/core/keyboard/mouse.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace core::keyboard @@ -32,10 +32,9 @@ struct MouseMovement }; -// TODO make configurable const int8_t MOUSE_ACCELERATION_AMOUNT = 2; -const int8_t MOUSE_MOVE_DEFAULT_SPEED = 1; +const int8_t MOUSE_MOVE_DEFAULT_SPEED = 5; const int8_t MOUSE_WHEEL_DEFAULT_SPEED = 1; class MouseState @@ -59,6 +58,9 @@ class MouseState wheel = 0; } + int8_t mouse_speed = MOUSE_MOVE_DEFAULT_SPEED; + int8_t mouse_acceleration = MOUSE_ACCELERATION_AMOUNT; + private: int8_t dx = 0; int8_t dy = 0; diff --git a/device.h b/device.h index 450c612..deaae84 100644 --- a/device.h +++ b/device.h @@ -22,9 +22,9 @@ enum class PinState enum class DeviceMouseButton { - LEFT = 0, - RIGHT = 1, - MIDDLE = 2, + LEFT = 1, + RIGHT = 2, + MIDDLE = 4, };