mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-24 20:32:58 +00:00
b92387b749
* Add vlukash CrKbd keymap to support trackpad adapter. The trackpad adapter uses Elite-C board that has five extra pins. Also SPI pins are taken for trackpad, keymap config updates column data pins for matrix scan. * Update vlukash keymap * Enable pointing devide, configure mouse BTN1 * Set TAPPING_TERM to 300 * Add support for the BlackBerry 8520 trackpad * Add vlukash keymap for master-right no-trackpad version * Remap backspace * Set EXTRAKEY_ENABLE = yes * Update thumb keys mappings * Set bootloader to atmel-dfu * Sync keymap * Add scrolling support * Make debug LEDS conditional * Add support for both flex and no-flex PCBs * Add readme and rename root folders * Update readme file with blog link * Fix readme file formatting * Remove ADJUST keycode, code cleanup. * Add Win key to the keymap.
79 lines
1.4 KiB
C
79 lines
1.4 KiB
C
#include "trackpad.h"
|
|
|
|
// bool isScrollingMode = false;
|
|
bool isScrollMode = false;
|
|
|
|
void pointing_device_init(void){
|
|
|
|
SPI_Init(SPI_SPEED_FCPU_DIV_8 | SPI_MODE_MASTER);
|
|
|
|
// Set as output
|
|
TP_RESET_INIT;
|
|
TP_SHUTDOWN_INIT;
|
|
TP_CS_INIT;
|
|
LVL_SHIFT_EN_INIT;
|
|
|
|
// Reset level shifter
|
|
LVL_SHIFT_EN_LO;
|
|
wait_ms(100);
|
|
LVL_SHIFT_EN_HI;
|
|
|
|
// Force a BB-8520 reset
|
|
TP_RESET_HI;
|
|
wait_ms(100);
|
|
TP_RESET_LO;
|
|
|
|
// Turn on BB-8520 trackpad
|
|
TP_SHUTDOWN_LO;
|
|
|
|
TP_CS_HI;
|
|
}
|
|
|
|
uint8_t readRegister(uint8_t address) {
|
|
uint8_t data;
|
|
|
|
TP_CS_LO;
|
|
|
|
// Read the data
|
|
SPI_TransferByte(address);
|
|
data = SPI_TransferByte(0x00);
|
|
|
|
TP_CS_HI;
|
|
|
|
return data;
|
|
}
|
|
|
|
void pointing_device_task(void){
|
|
uint8_t motion = readRegister(0x02);
|
|
|
|
// Motion has occurred on the trackpad
|
|
if (motion > 127) {
|
|
|
|
int8_t dx, dy;
|
|
|
|
if(TRACKPAD_CONNECTOR_VER == 1) {
|
|
dx = readRegister(0x03);
|
|
dy = -readRegister(0x04);
|
|
}
|
|
else {
|
|
dy = -readRegister(0x03);
|
|
dx = -readRegister(0x04);
|
|
}
|
|
|
|
report_mouse_t currentReport = pointing_device_get_report();
|
|
if (isScrollMode)
|
|
{
|
|
currentReport.h = dx/SCROLL_SPEED_DIVIDER;
|
|
currentReport.v = dy/SCROLL_SPEED_DIVIDER;
|
|
}
|
|
else
|
|
{
|
|
currentReport.x = dx * POINTER_SPEED_MULTIPLIER;
|
|
currentReport.y = dy * POINTER_SPEED_MULTIPLIER;
|
|
}
|
|
|
|
pointing_device_set_report(currentReport);
|
|
pointing_device_send();
|
|
}
|
|
}
|