Skip to content

Commit

Permalink
Mouse init procedure update, version bump to 47.2.3 (#43)
Browse files Browse the repository at this point in the history
* Rework Intellimouse init

* Revert to mouse packet rate 60 Hz

* Fix spelling error in comments

* Bump version to 47.2.3
  • Loading branch information
stefan-b-jakobsson authored Jul 2, 2024
1 parent b2407f3 commit 0e3bdda
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions setup_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static volatile uint8_t watchdogExpiryState = MOUSE_STATE_OFF;

void mouseTick() {
static uint8_t watchdog = WATCHDOG_DISABLE;
uint8_t mouse_id_prev;

// Return to OFF state if system powered down
if (!SYSTEM_POWERED && state != MOUSE_STATE_OFF) {
Expand Down Expand Up @@ -134,10 +135,12 @@ void mouseTick() {
break;

case MOUSE_STATE_INTELLI_2:
if (requestedmouse_id == 3) {
if (mouse_id == 0) {
// If mouse_id is 0, this is the 1st round of Intellimouse setup, go for ID=3
Mouse.sendPS2Command(PS2_CMD_SET_SAMPLE_RATE, 100);
}
else {
// If mouse_id is not 0, this is the 2nd round of Intellimouse setup, go for ID=4
Mouse.sendPS2Command(PS2_CMD_SET_SAMPLE_RATE, 200);
}
state = MOUSE_STATE_INTELLI_2_ACK;
Expand All @@ -158,20 +161,19 @@ void mouseTick() {

case MOUSE_STATE_INTELLI_GET_ID:
if (Mouse.available()) {
mouse_id_prev = mouse_id;
mouse_id = Mouse.next();
if (mouse_id == requestedmouse_id || (mouse_id == 0 && requestedmouse_id == 3)) {
// Setup succeded, or accept downgrade from mouse ID 3 to mouse ID 0

if (mouse_id == 0 || mouse_id == requestedmouse_id || mouse_id_prev == 3) {
// Intellimouse setup complete:
// mouse_id == 0 => Not an Intellimouse, stop here
// mouse_id == requestedmouse_id => We got the requested ID, stop here
// mouse_id_prev == 3 => This was the second round, unsuccessul config of ID=4, nothing more to do
state = MOUSE_STATE_SET_SAMPLERATE;
}
else if (mouse_id == 0 && requestedmouse_id == 4) {
// Setup failed, try to downgrade to mouse ID 3
requestedmouse_id = 3;
state = MOUSE_STATE_RESET;
}
else {
// Setup failed, try to downgrade to mouse ID 0
requestedmouse_id = 0;
state = MOUSE_STATE_RESET;
// Run Intellimouse setup again to test ID=4
state = MOUSE_STATE_INTELLI_1;
}
watchdog = WATCHDOG_DISABLE;
}
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define version_major 47
#define version_minor 2
#define version_patch 2
#define version_patch 3

0 comments on commit 0e3bdda

Please sign in to comment.