mirror of
https://github.com/zsa/qmk_firmware.git
synced 2026-05-04 14:55:29 +00:00
feat: allows setting the default trackball sensitivity
This commit is contained in:
@@ -19,7 +19,7 @@ const pointing_device_driver_t navigator_trackball_pointing_device_driver = {
|
|||||||
.set_cpi = navigator_trackball_set_cpi
|
.set_cpi = navigator_trackball_set_cpi
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t current_cpi = DEFAULT_CPI_TICK;
|
uint8_t current_cpi = NAVIGATOR_TRACKBALL_CPI;
|
||||||
|
|
||||||
uint8_t has_motion = 0;
|
uint8_t has_motion = 0;
|
||||||
|
|
||||||
@@ -77,58 +77,11 @@ i2c_status_t sci18is606_configure(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool paw3805ek_set_cpi(void) {
|
bool paw3805ek_set_cpi(void) {
|
||||||
uint8_t next_cpi_x = 0;
|
|
||||||
uint8_t next_cpi_y = 0;
|
|
||||||
// traverse the sequence by compairing the cpi_x value with the current cpi_x value
|
|
||||||
// set the cpi to the next value in the sequence
|
|
||||||
switch (current_cpi) {
|
|
||||||
case 1: {
|
|
||||||
next_cpi_x = CPI_X_800;
|
|
||||||
next_cpi_y = CPI_Y_800;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2: {
|
|
||||||
next_cpi_x = CPI_X_1000;
|
|
||||||
next_cpi_y = CPI_Y_1000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3: {
|
|
||||||
next_cpi_x = CPI_X_1200;
|
|
||||||
next_cpi_y = CPI_Y_1200;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 4: {
|
|
||||||
next_cpi_x = CPI_X_1600;
|
|
||||||
next_cpi_y = CPI_Y_1600;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 5: {
|
|
||||||
next_cpi_x = CPI_X_2000;
|
|
||||||
next_cpi_y = CPI_Y_2000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 6: {
|
|
||||||
next_cpi_x = CPI_X_2400;
|
|
||||||
next_cpi_y = CPI_Y_2400;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 7: {
|
|
||||||
next_cpi_x = CPI_X_3000;
|
|
||||||
next_cpi_y = CPI_Y_3000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
current_cpi = DEFAULT_CPI_TICK;
|
|
||||||
next_cpi_x = CPI_X_800;
|
|
||||||
next_cpi_y = CPI_Y_800;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
paw3805ek_reg_seq_t cpi_reg_seq[] = {
|
paw3805ek_reg_seq_t cpi_reg_seq[] = {
|
||||||
{0x09 | WRITE_REG_BIT, 0x5A}, // Disable write protection
|
{0x09 | WRITE_REG_BIT, 0x5A}, // Disable write protection
|
||||||
{0x0D | WRITE_REG_BIT, next_cpi_x},
|
{0x0D | WRITE_REG_BIT, current_cpi},
|
||||||
{0x0E | WRITE_REG_BIT, next_cpi_y},
|
{0x0E | WRITE_REG_BIT, current_cpi},
|
||||||
{0x09 | WRITE_REG_BIT, 0x00}, // Enable the write protection
|
{0x09 | WRITE_REG_BIT, 0x00}, // Enable the write protection
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -264,17 +217,20 @@ uint16_t navigator_trackball_get_cpi(void) {
|
|||||||
void restore_cpi(uint8_t cpi) {
|
void restore_cpi(uint8_t cpi) {
|
||||||
current_cpi = cpi;
|
current_cpi = cpi;
|
||||||
paw3805ek_set_cpi();
|
paw3805ek_set_cpi();
|
||||||
|
printf("restored cpi: %d\n", current_cpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void navigator_trackball_set_cpi(uint16_t cpi) {
|
void navigator_trackball_set_cpi(uint16_t cpi) {
|
||||||
if (cpi == 0) { // Decrease one tick
|
if (cpi == 0) { // Decrease one tick
|
||||||
if (current_cpi > 1) {
|
if (current_cpi > NAVIGATOR_TRACKBALL_CPI_TICK) {
|
||||||
current_cpi--;
|
current_cpi -= NAVIGATOR_TRACKBALL_CPI_TICK;
|
||||||
|
printf("decreased cpi: %d\n", current_cpi);
|
||||||
paw3805ek_set_cpi();
|
paw3805ek_set_cpi();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (current_cpi < CPI_TICKS) {
|
if (current_cpi < 255 - NAVIGATOR_TRACKBALL_CPI_TICK) {
|
||||||
current_cpi++;
|
current_cpi += NAVIGATOR_TRACKBALL_CPI_TICK;
|
||||||
|
printf("increased cpi: %d\n", current_cpi);
|
||||||
paw3805ek_set_cpi();
|
paw3805ek_set_cpi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,14 @@
|
|||||||
# define NAVIGATOR_TRACKBALL_ADDRESS 0x50
|
# define NAVIGATOR_TRACKBALL_ADDRESS 0x50
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NAVIGATOR_TRACKBALL_CPI
|
||||||
|
# define NAVIGATOR_TRACKBALL_CPI 0x3C
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NAVIGATOR_TRACKBALL_CPI_TICK
|
||||||
|
# define NAVIGATOR_TRACKBALL_CPI_TICK 5
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NAVIGATOR_TRACKBALL_TIMEOUT
|
#ifndef NAVIGATOR_TRACKBALL_TIMEOUT
|
||||||
# define NAVIGATOR_TRACKBALL_TIMEOUT 100
|
# define NAVIGATOR_TRACKBALL_TIMEOUT 100
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user