Skip to content

Commit

Permalink
Fix toggle mouse states
Browse files Browse the repository at this point in the history
  • Loading branch information
kareltucek committed Nov 8, 2020
1 parent a766f95 commit 1be5683
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions right/src/mouse_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ static uint32_t mouseUsbReportUpdateTime = 0;
static uint32_t mouseElapsedTime;

uint8_t ActiveMouseStates[ACTIVE_MOUSE_STATES_COUNT];

static bool toggledMouseStates[ACTIVE_MOUSE_STATES_COUNT];
uint8_t ToggledMouseStates[ACTIVE_MOUSE_STATES_COUNT];

bool CompensateDiagonalSpeed = false;

Expand Down Expand Up @@ -314,5 +313,11 @@ void MouseController_ProcessMouseActions()

void ToggleMouseState(serialized_mouse_action_t action, bool activate)
{
toggledMouseStates[action] = activate;
if (activate) {
ToggledMouseStates[action]++;
MouseController_ActivateDirectionSigns(action);
}
else{
ToggledMouseStates[action] -= ToggledMouseStates[action] > 0 ? 1 : 0;
}
}
1 change: 1 addition & 0 deletions right/src/mouse_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
extern mouse_kinetic_state_t MouseScrollState;

extern uint8_t ActiveMouseStates[ACTIVE_MOUSE_STATES_COUNT];
extern uint8_t ToggledMouseStates[ACTIVE_MOUSE_STATES_COUNT];

extern bool CompensateDiagonalSpeed;

Expand Down
2 changes: 1 addition & 1 deletion right/src/usb_report_updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static void updateActiveUsbReports(void)
Macros_ContinueMacro();
}

memset(ActiveMouseStates, 0, ACTIVE_MOUSE_STATES_COUNT);
memcpy(ActiveMouseStates, ToggledMouseStates, ACTIVE_MOUSE_STATES_COUNT);

basicScancodeIndex = 0;
mediaScancodeIndex = 0;
Expand Down

0 comments on commit 1be5683

Please sign in to comment.