<commit_before>// Copyright 2017 <EMAIL>
// Licensed under the MIT license (http://opensource.org/licenses/MIT)

#pragma once

#include <stdint.h>
#include <stddef.h>

#include "core/util.h"
#include "core/packet.h"
#include "core/nrf24.h"
#include "core/matrix_scanner.h"

#include "core/flash.h"

#define NUM_KEYBOARD_PIPES 4

#define NRF_ADDR_LEN 5
#define AES_KEY_LEN 16

#define UNPROGRAMMED_DEVIE_ID 0xff

#define MAX_NUM_KEYBOARDS 64
#define MAX_NUM_DEVICES 64

enum {
    KEYBOARD_REPORT_MODE_AUTO = 0, // 6kro -> nkro if more than 6 keys pressed
    KEYBOARD_REPORT_MODE_NKRO = 1, // nkro
    KEYBOARD_REPORT_MODE_6KRO = 2, // 6kro
    KEYBOARD_REPORT_MODE_UPGRADE, // transitioning 6kro -> nkro
};

typedef struct device_info_t {
    uint8_t layout_id; // the keyboard layout that this device maps to
    uint8_t matrix_offset; // the component byte offset into the given keyboard
    uint8_t matrix_size; // the size of this component == ceil(rows*cols/8)
} device_info_t;

// TODO: maybe move layout and settings to start of layout_storage
typedef struct layout_info_t {
    uint8_t matrix_size;
    uint8_t layer_count;
} keyboard_info_t;

#define SETTINGS_LAYOUT_INFO_SIZE 32
#define SETTINGS_LAYOUT_INFO_OFFSET (offsetof(settings_t, layout))
typedef struct {
    uint8_t number_layouts;
    uint8_t number_devices;
    uint8_t _reserved[30]; // 32
    keyboard_info_t layouts[MAX_NUM_KEYBOARDS];
    device_info_t devices[MAX_NUM_DEVICES];
} layout_settings_t;

#define SETTINGS_RF_INFO_SIZE 64
#define SETTINGS_RF_INFO_OFFSET (offsetof(settings_t, rf))
typedef struct rf_settings_t { // 64 bytes
    uint8_t pipe_addr_0[NRF_ADDR_LEN];
    uint8_t pipe_addr_1[NRF_ADDR_LEN];
    uint8_t pipe_addr_2;
    uint8_t pipe_addr_3;
    uint8_t pipe_addr_4;
    uint8_t pipe_addr_5;
    uint8_t channel; // TODO: when using unifying, channel must be ((ch+2)%3 == 0)
                     // this should be enforced somewhere
    uint8_t arc;
    uint8_t data_rate;
    uint8_t power;
    uint8_t _reserved[13]; // padding
    uint8_t ekey[AES_KEY_LEN];<commit_msg>fix reseverd space padding on rf settings<commit_after>// Copyright 2017 <EMAIL>
// Licensed under the MIT license (http://opensource.org/licenses/MIT)

#pragma once

#include <stdint.h>
#include <stddef.h>

#include "core/util.h"
#include "core/packet.h"
#include "core/nrf24.h"
#include "core/matrix_scanner.h"

#include "core/flash.h"

#define NUM_KEYBOARD_PIPES 4

#define NRF_ADDR_LEN 5
#define AES_KEY_LEN 16

#define UNPROGRAMMED_DEVIE_ID 0xff

#define MAX_NUM_KEYBOARDS 64
#define MAX_NUM_DEVICES 64

enum {
    KEYBOARD_REPORT_MODE_AUTO = 0, // 6kro -> nkro if more than 6 keys pressed
    KEYBOARD_REPORT_MODE_NKRO = 1, // nkro
    KEYBOARD_REPORT_MODE_6KRO = 2, // 6kro
    KEYBOARD_REPORT_MODE_UPGRADE, // transitioning 6kro -> nkro
};

typedef struct device_info_t {
    uint8_t layout_id; // the keyboard layout that this device maps to
    uint8_t matrix_offset; // the component byte offset into the given keyboard
    uint8_t matrix_size; // the size of this component == ceil(rows*cols/8)
} device_info_t;

// TODO: maybe move layout and settings to start of layout_storage
typedef struct layout_info_t {
    uint8_t matrix_size;
    uint8_t layer_count;
} keyboard_info_t;

#define SETTINGS_LAYOUT_INFO_SIZE 32
#define SETTINGS_LAYOUT_INFO_OFFSET (offsetof(settings_t, layout))
typedef struct {
    uint8_t number_layouts;
    uint8_t number_devices;
    uint8_t _reserved[30]; // 32
    keyboard_info_t layouts[MAX_NUM_KEYBOARDS];
    device_info_t devices[MAX_NUM_DEVICES];
} layout_settings_t;

#define SETTINGS_RF_INFO_SIZE 64
#define SETTINGS_RF_INFO_OFFSET (offsetof(settings_t, rf))
typedef struct rf_settings_t { // 64 bytes
    uint8_t pipe_addr_0[NRF_ADDR_LEN];
    uint8_t pipe_addr_1[NRF_ADDR_LEN];
    uint8_t pipe_addr_2;
    uint8_t pipe_addr_3;
    uint8_t pipe_addr_4;
    uint8_t pipe_addr_5;
    uint8_t channel; // TODO: when using unifying, channel must be ((ch+2)%3 == 0)
                     // this should be enforced somewhere
    uint8_t arc;
    uint8_t data_rate;
    uint8_t power;
    uint8_t _reserved[14]; // padding
    uint8_t ekey[AES_KEY_LEN];
{'fraction_non_alphanumeric': 0.08349328214971209, 'fraction_numerical': 0.031190019193857964, 'mean_word_length': 4.115337423312884, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5406374', 'n_tokens_mistral': 1649, 'n_tokens_neox': 1547, 'n_words': 379}