#include "util_comm.h"
#include "matrix_manipulate.h"
#include <string.h>
+#include <tmk_core/common/eeprom.h>
#if defined(KEYBOARD_SHARED_EP) && defined(RAW_ENABLE)
#error "Enabling the KEYBOARD_SHARED_EP will make the util be unable to communicate with the firmware, because due to hidapi limiations, the util can't figure out which interface to talk to, so it hardcodes interface zero."
{
case UTIL_COMM_GET_VERSION:
response[2] = UTIL_COMM_RESPONSE_OK;
- response[3] = UTIL_COMM_VERSION;
+ response[3] = UTIL_COMM_VERSION_MAJOR;
+ response[4] = UTIL_COMM_VERSION_MID;
+ response[5] = (UTIL_COMM_VERSION_MINOR >> 8) & 0xff;
+ response[6] = (UTIL_COMM_VERSION_MINOR >> 0) & 0xff;
break;
case UTIL_COMM_DISABLE_KEYBOARD:
response[2] = UTIL_COMM_RESPONSE_OK;
}
#else
response[3] = 0;
- response[4] = CAPSENSE_HARDCODED_THRESHOLD;
+ response[4] = (CAPSENSE_HARDCODED_THRESHOLD) & 0xff;
+ response[5] = ((CAPSENSE_HARDCODED_THRESHOLD) >> 8) & 0xff;
#endif
break;
case UTIL_COMM_GET_KEYBOARD_FILENAME:
{
- response[2] = UTIL_COMM_GET_KEYBOARD_FILENAME;
+ response[2] = UTIL_COMM_RESPONSE_OK;
if (data[3] >= strlen(KEYBOARD_FILENAME) + 1)
{
response[3] = 0;
}
break;
}
+ case UTIL_COMM_ERASE_EEPROM:
+ {
+ response[2] = UTIL_COMM_RESPONSE_OK;
+ uint16_t addr;
+ for (addr=0; addr<E2END; addr += 1)
+ {
+ eeprom_update_byte((uint8_t*)addr, 0xff);
+ }
+ break;
+ }
+ case UTIL_COMM_GET_SIGNAL_VALUE:
+ {
+ response[2] = UTIL_COMM_RESPONSE_OK;
+ uint8_t col = data[3];
+ uint8_t row = data[4];
+ uint8_t count = data[5];
+ int i;
+ for (i=0;i<count;i++)
+ {
+ uint16_t value = measure_middle_keymap_coords(col, row, CAPSENSE_HARDCODED_SAMPLE_TIME, 8);
+ response[3+i*2] = value & 0xff;
+ response[3+i*2+1] = (value >> 8) & 0xff;
+ col += 1;
+ if (col >= MATRIX_COLS) {
+ col -= MATRIX_COLS;
+ row += 1;
+ }
+ if (row >= MATRIX_ROWS)
+ {
+ break;
+ }
+ }
+ break;
+ }
+ case UTIL_COMM_GET_KEYBOARD_DETAILS:
+ {
+ response[2] = UTIL_COMM_RESPONSE_OK;
+ response[3] = MATRIX_COLS;
+ response[4] = MATRIX_ROWS;
+ #if defined(CONTROLLER_IS_XWHATSIT_BEAMSPRING_REV_4)
+ response[5] = 1;
+ #elif defined(CONTROLLER_IS_XWHATSIT_MODEL_F_OR_WCASS_MODEL_F)
+ response[5] = 2;
+ #elif defined(CONTROLLER_IS_THROUGHT_HOLE_BEAMSPRING)
+ response[5] = 3;
+ #elif defined(CONTROLLER_IS_THROUGHT_HOLE_MODEL_F)
+ response[5] = 4;
+ #else
+ response[5] = 0;
+ #endif
+ response[6] = CAPSENSE_KEYBOARD_SETTLE_TIME_US;
+ response[7] = CAPSENSE_DAC_SETTLE_TIME_US;
+ response[8] = CAPSENSE_HARDCODED_SAMPLE_TIME;
+ response[9] = CAPSENSE_CAL_ENABLED;
+ break;
+ }
+ case UTIL_COMM_SHIFT_DATA:
+ {
+ response[2] = UTIL_COMM_RESPONSE_OK;
+ uint32_t shdata = (((uint32_t)(data[3])) << 0) |
+ (((uint32_t)(data[4])) << 8) |
+ (((uint32_t)(data[5])) << 16) |
+ (((uint32_t)(data[6])) << 24);
+ shift_data(shdata);
+ }
default:
break;
}
raw_hid_send(response, sizeof(response));
}
-