Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep work for NKRO report separation #22268

Merged
merged 5 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion keyboards/annepro2/annepro2_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,5 @@ static void ap2_ble_extra(report_extra_t *report) {
static void ap2_ble_keyboard(report_keyboard_t *report) {
sdPut(&SD1, 0x0);
sdWrite(&SD1, ble_mcu_send_report, sizeof(ble_mcu_send_report));
sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE);
sdWrite(&SD1, (uint8_t *)report, KEYBOARD_REPORT_SIZE);
}
13 changes: 6 additions & 7 deletions keyboards/bioi/bluetooth_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ void bluetooth_send_keyboard(report_keyboard_t *report)

send_str(PSTR("AT+BLEKEYBOARDCODE="));

for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++)
{
send_bytes(report->raw[i]);
if (i < (KEYBOARD_EPSIZE - 1))
{
send_str(PSTR("-"));
}
send_bytes(report->mods);
send_str(PSTR("-"));
send_bytes(0);
for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
send_str(PSTR("-"));
send_bytes(report->keys[i]);
}

send_str(PSTR("\r\n"));
Expand Down
2 changes: 1 addition & 1 deletion keyboards/sawnsprojects/okayu/stm32f072/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#define WS2812_SPI SPID1
#define WS2812_SPI_DRIVER SPID1
#define WS2812_SPI_MOSI_PAL_MODE 5
#define WS2812_SPI_SCK_PIN B13
#define WS2812_SPI_SCK_PAL_MODE 5
2 changes: 1 addition & 1 deletion keyboards/sawnsprojects/okayu/stm32f103/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#define WS2812_SPI SPID2
#define WS2812_SPI_DRIVER SPID2
#define WS2812_SPI_MOSI_PAL_MODE 5
#define WS2812_SPI_SCK_PIN B13
#define WS2812_SPI_SCK_PAL_MODE 5
2 changes: 1 addition & 1 deletion keyboards/sawnsprojects/okayu/stm32f303/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#define WS2812_SPI SPID1
#define WS2812_SPI_DRIVER SPID1
#define WS2812_SPI_MOSI_PAL_MODE 5
#define WS2812_SPI_SCK_PIN B13
#define WS2812_SPI_SCK_PAL_MODE 5
8 changes: 4 additions & 4 deletions platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ uint32_t eeprom_read_dword(const uint32_t *addr) {
*
* FIXME: needs doc
*/
void eeprom_read_block(void *buf, const void *addr, uint32_t len) {
void eeprom_read_block(void *buf, const void *addr, size_t len) {
uint32_t offset = (uint32_t)addr;
uint8_t *dest = (uint8_t *)buf;
uint32_t end = offset + len;
Expand Down Expand Up @@ -271,7 +271,7 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value) {
*
* FIXME: needs doc
*/
void eeprom_write_block(const void *buf, void *addr, uint32_t len) {
void eeprom_write_block(const void *buf, void *addr, size_t len) {
uint32_t offset = (uint32_t)addr;
const uint8_t *src = (const uint8_t *)buf;

Expand Down Expand Up @@ -480,7 +480,7 @@ uint32_t eeprom_read_dword(const uint32_t *addr) {
return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24);
}

void eeprom_read_block(void *buf, const void *addr, uint32_t len) {
void eeprom_read_block(void *buf, const void *addr, size_t len) {
const uint8_t *p = (const uint8_t *)addr;
uint8_t * dest = (uint8_t *)buf;
while (len--) {
Expand All @@ -506,7 +506,7 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value) {
eeprom_write_byte(p, value >> 24);
}

void eeprom_write_block(const void *buf, void *addr, uint32_t len) {
void eeprom_write_block(const void *buf, void *addr, size_t len) {
uint8_t * p = (uint8_t *)addr;
const uint8_t *src = (const uint8_t *)buf;
while (len--) {
Expand Down
1 change: 1 addition & 0 deletions quantum/eeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <stdint.h>
#include <stdbool.h>
#include "eeprom.h"

#ifndef EECONFIG_MAGIC_NUMBER
# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE6 // When changing, decrement this value to avoid future re-init issues
Expand Down
2 changes: 2 additions & 0 deletions quantum/quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
#include "suspend.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#ifdef DEFERRED_EXEC_ENABLE
# include "deferred_exec.h"
Expand Down
8 changes: 4 additions & 4 deletions tmk_core/protocol/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ uint8_t get_first_key(report_keyboard_t* keyboard_report) {
#ifdef NKRO_ENABLE
if (keyboard_protocol && keymap_config.nkro) {
uint8_t i = 0;
for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++)
for (; i < NKRO_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++)
;
return i << 3 | biton(keyboard_report->nkro.bits[i]);
}
Expand Down Expand Up @@ -89,7 +89,7 @@ bool is_key_pressed(report_keyboard_t* keyboard_report, uint8_t key) {
}
#ifdef NKRO_ENABLE
if (keyboard_protocol && keymap_config.nkro) {
if ((key >> 3) < KEYBOARD_REPORT_BITS) {
if ((key >> 3) < NKRO_REPORT_BITS) {
return keyboard_report->nkro.bits[key >> 3] & 1 << (key & 7);
} else {
return false;
Expand Down Expand Up @@ -216,7 +216,7 @@ void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) {
* FIXME: Needs doc
*/
void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
if ((code >> 3) < KEYBOARD_REPORT_BITS) {
if ((code >> 3) < NKRO_REPORT_BITS) {
keyboard_report->nkro.bits[code >> 3] |= 1 << (code & 7);
} else {
dprintf("add_key_bit: can't add: %02X\n", code);
Expand All @@ -228,7 +228,7 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
* FIXME: Needs doc
*/
void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) {
if ((code >> 3) < KEYBOARD_REPORT_BITS) {
if ((code >> 3) < NKRO_REPORT_BITS) {
keyboard_report->nkro.bits[code >> 3] &= ~(1 << (code & 7));
} else {
dprintf("del_key_bit: can't del: %02X\n", code);
Expand Down
19 changes: 10 additions & 9 deletions tmk_core/protocol/report.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include <stdbool.h>
#include "keycode.h"
#include "util.h"

// clang-format off

Expand Down Expand Up @@ -129,10 +130,10 @@ enum desktop_usages {
#if defined(NKRO_ENABLE)
# if defined(PROTOCOL_LUFA) || defined(PROTOCOL_CHIBIOS)
# include "protocol/usb_descriptor.h"
# define KEYBOARD_REPORT_BITS (SHARED_EPSIZE - 2)
# define NKRO_REPORT_BITS (SHARED_EPSIZE - 2)
# elif defined(PROTOCOL_ARM_ATSAM)
# include "protocol/arm_atsam/usb/udi_device_epsize.h"
# define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1)
# define NKRO_REPORT_BITS (NKRO_EPSIZE - 1)
# undef NKRO_SHARED_EP
# undef MOUSE_SHARED_EP
# else
Expand Down Expand Up @@ -188,20 +189,20 @@ typedef union {
uint8_t report_id;
# endif
uint8_t mods;
uint8_t bits[KEYBOARD_REPORT_BITS];
uint8_t bits[NKRO_REPORT_BITS];
} nkro;
#endif
} __attribute__((packed)) report_keyboard_t;
} PACKED report_keyboard_t;

typedef struct {
uint8_t report_id;
uint16_t usage;
} __attribute__((packed)) report_extra_t;
} PACKED report_extra_t;

typedef struct {
uint8_t report_id;
uint32_t usage;
} __attribute__((packed)) report_programmable_button_t;
} PACKED report_programmable_button_t;

#ifdef MOUSE_EXTENDED_REPORT
typedef int16_t mouse_xy_report_t;
Expand All @@ -222,7 +223,7 @@ typedef struct {
mouse_xy_report_t y;
int8_t v;
int8_t h;
} __attribute__((packed)) report_mouse_t;
} PACKED report_mouse_t;

typedef struct {
#ifdef DIGITIZER_SHARED_EP
Expand All @@ -234,7 +235,7 @@ typedef struct {
uint8_t reserved : 5;
uint16_t x;
uint16_t y;
} __attribute__((packed)) report_digitizer_t;
} PACKED report_digitizer_t;

typedef struct {
#ifdef JOYSTICK_SHARED_EP
Expand All @@ -251,7 +252,7 @@ typedef struct {
#if JOYSTICK_BUTTON_COUNT > 0
uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1];
#endif
} __attribute__((packed)) report_joystick_t;
} PACKED report_joystick_t;

/* keycode to system usage */
static inline uint16_t KEYCODE2SYSTEM(uint8_t key) {
Expand Down
4 changes: 2 additions & 2 deletions tmk_core/protocol/usb_descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
// Keycodes
HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
HID_RI_USAGE_MINIMUM(8, 0x00),
HID_RI_USAGE_MAXIMUM(8, KEYBOARD_REPORT_BITS * 8 - 1),
HID_RI_USAGE_MAXIMUM(8, NKRO_REPORT_BITS * 8 - 1),
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_COUNT(8, KEYBOARD_REPORT_BITS * 8),
HID_RI_REPORT_COUNT(8, NKRO_REPORT_BITS * 8),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),

Expand Down
8 changes: 2 additions & 6 deletions users/brandonschlack/brandonschlack.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ void suspend_power_down_keymap(void) {}
*/
void suspend_power_down_user(void) {
#ifdef RGB_MATRIX_ENABLE
if (!g_suspend_state) {
rgb_matrix_set_suspend_state(true);
}
rgb_matrix_set_suspend_state(true);
#endif //RGB_MATRIX_ENABLE
suspend_power_down_keymap();
}
Expand All @@ -103,9 +101,7 @@ void suspend_wakeup_init_keymap(void) {}
*/
void suspend_wakeup_init_user(void) {
#ifdef RGB_MATRIX_ENABLE
if (g_suspend_state) {
rgb_matrix_set_suspend_state(false);
}
rgb_matrix_set_suspend_state(false);
#endif //RGB_MATRIX_ENABLE
suspend_wakeup_init_keymap();
}
Expand Down