mirror of
https://github.com/zsa/qmk_firmware.git
synced 2026-01-11 08:02:57 +00:00
Add support for dpi configuration
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license
|
||||
#include "moonlander.h"
|
||||
#include "i2c_master.h"
|
||||
#include "i2c2_master.h"
|
||||
#include "cirque_tm040040.h"
|
||||
@@ -37,7 +38,7 @@ void pointing_device_task(void) {
|
||||
int8_t report_x = 0, report_y = 0;
|
||||
|
||||
Pinnacle_GetAbsolute(&touchData);
|
||||
ScaleData(&touchData, 1024, 1024); // Scale coordinates to arbitrary X, Y resolution
|
||||
ScaleData(&touchData, 256 * keyboard_config.dpi_config, 256 * keyboard_config.dpi_config); // Scale coordinates to arbitrary X, Y resolution
|
||||
|
||||
if (x && y && touchData.xValue && touchData.yValue) {
|
||||
report_x = (int8_t)(touchData.xValue - x);
|
||||
@@ -72,7 +73,7 @@ void pointing_device_task(void) {
|
||||
rTouchData.xValue = 0;
|
||||
rTouchData.yValue = 0;
|
||||
#endif
|
||||
process_mouse_user(&report, report_x, report_y);
|
||||
process_mouse_user(&mouse_report, report_x, report_y);
|
||||
pointing_device_set_report(mouse_report);
|
||||
pointing_device_send();
|
||||
}
|
||||
|
||||
@@ -466,6 +466,13 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
case DPI_CONFIG:
|
||||
if (record->event.pressed) {
|
||||
keyboard_config.dpi_config++;
|
||||
if (!keyboard_config.dpi_config) keyboard_config.dpi_config = 1;
|
||||
eeconfig_update_kb(keyboard_config.raw);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -478,6 +485,14 @@ void matrix_init_kb(void) {
|
||||
keyboard_config.led_level_res = 0b11;
|
||||
eeconfig_update_kb(keyboard_config.raw);
|
||||
}
|
||||
|
||||
#ifdef POINTING_DEVICE_ENABLE
|
||||
if (!keyboard_config.dpi_config) {
|
||||
keyboard_config.dpi_config = 2;
|
||||
eeconfig_update_kb(keyboard_config.raw);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
if (keyboard_config.rgb_matrix_enable) {
|
||||
rgb_matrix_set_flags(LED_FLAG_ALL);
|
||||
@@ -493,6 +508,7 @@ void eeconfig_init_kb(void) { // EEPROM is getting reset!
|
||||
keyboard_config.rgb_matrix_enable = true;
|
||||
keyboard_config.led_level = true;
|
||||
keyboard_config.led_level_res = 0b11;
|
||||
keyboard_config.dpi_config = 2;
|
||||
eeconfig_update_kb(keyboard_config.raw);
|
||||
eeconfig_init_user();
|
||||
}
|
||||
|
||||
@@ -63,16 +63,18 @@ extern bool mcp23018_leds[];
|
||||
enum planck_ez_keycodes {
|
||||
TOGGLE_LAYER_COLOR = SAFE_RANGE,
|
||||
LED_LEVEL,
|
||||
DPI_CONFIG,
|
||||
ML_SAFE_RANGE,
|
||||
};
|
||||
|
||||
typedef union {
|
||||
uint32_t raw;
|
||||
struct {
|
||||
bool disable_layer_led :1;
|
||||
bool rgb_matrix_enable :1;
|
||||
bool led_level :1;
|
||||
uint8_t led_level_res :2; // DO NOT REMOVE
|
||||
bool disable_layer_led :1;
|
||||
bool rgb_matrix_enable :1;
|
||||
bool led_level :1;
|
||||
uint8_t led_level_res :2; // DO NOT REMOVE
|
||||
uint8_t dpi_config :3;
|
||||
};
|
||||
} keyboard_config_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user