__UNTESTED CODE__ - Added some basic JSON handling to read in the JSON file and parse different values from it
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#ifndef CONFIG_HANDLING_H_
|
||||
#define CONFIG_HANDLING_H_
|
||||
|
||||
/* config_handling.h */
|
||||
#include "../include/firmware_handling.h"
|
||||
|
||||
/* Read in a config file with the specified name. */
|
||||
prog_actionP *get_config(char *conf_name);
|
||||
|
||||
#endif /* CONFIG_HANDLING_H_ */
|
||||
+25
-22
@@ -1,8 +1,11 @@
|
||||
#ifndef FIRMWARE_HANDLING_H_
|
||||
#define FIRMWARE_HANDLING_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**** DEFINES ****/
|
||||
/* Max prog_actions per key_prog */
|
||||
#define MAX_ACTION 100
|
||||
|
||||
/* Defines for key offsets */
|
||||
#define F8_KEY1 0x00005189
|
||||
#define F8_KEY2 0x00005181
|
||||
@@ -12,7 +15,6 @@
|
||||
#define F8_KEY6 0x00005182
|
||||
#define F8_KEY7 0x0000517A
|
||||
#define F8_KEY8 0x0000514A
|
||||
|
||||
/* Defines for key program code */
|
||||
#define F8_PROG1 0xD7
|
||||
#define F8_PROG2 0xD8
|
||||
@@ -33,22 +35,22 @@
|
||||
#define PROG7_OFFSET 0x0000665C
|
||||
#define PROG8_OFFSET 0x0000697C
|
||||
|
||||
typedef struct f_bffr_t* f_bffrP;
|
||||
struct f_bffr_t
|
||||
{
|
||||
/**** STRUCTS ****/
|
||||
typedef struct f_bffr_t *f_bffrP;
|
||||
struct f_bffr_t {
|
||||
char *buffer;
|
||||
int size;
|
||||
};
|
||||
|
||||
/*
|
||||
/*
|
||||
* A single macro action
|
||||
* First value is the modifiers to be hold while executing the other actions (see keycodes.h)
|
||||
* Second value is the delay between the keypresse ranging from 0.0 seconds to 3.0 seconds
|
||||
* The remaining values are the keycodes to be pressed
|
||||
* First value is the modifiers to be hold while executing the other actions
|
||||
* (see keycodes.h) Second value is the delay between the keypresse ranging from
|
||||
* 0.0 seconds to 3.0 seconds The remaining values are the keycodes to be
|
||||
* pressed
|
||||
*/
|
||||
typedef struct prog_action* prog_actionP;
|
||||
struct prog_action
|
||||
{
|
||||
typedef struct prog_action *prog_actionP;
|
||||
struct prog_action {
|
||||
uint8_t k_modifier;
|
||||
uint8_t k_delay;
|
||||
uint8_t k_action1;
|
||||
@@ -59,27 +61,28 @@ struct prog_action
|
||||
uint8_t k_action6;
|
||||
};
|
||||
|
||||
/*
|
||||
* A single macro program consisting of the offset and up to MAX_ACTION (100) actions
|
||||
/*
|
||||
* A single macro program consisting of the offset and up to MAX_ACTION (100)
|
||||
* actions
|
||||
*/
|
||||
typedef struct key_prog* key_progP;
|
||||
struct key_prog
|
||||
{
|
||||
typedef struct key_prog *key_progP;
|
||||
struct key_prog {
|
||||
int prog_offset;
|
||||
prog_actionP prog_actions[MAX_ACTION];
|
||||
};
|
||||
|
||||
/*
|
||||
* set the value "value" to the specified key "key" inside the buffer "firmware_buffer"
|
||||
* Key has to be the offset of the key to be altered.
|
||||
* Value has to be a keycode
|
||||
/*
|
||||
* set the value "value" to the specified key "key" inside the buffer
|
||||
* "firmware_buffer" Key has to be the offset of the key to be altered. Value
|
||||
* has to be a keycode
|
||||
*/
|
||||
void set_key_value(char *firmware_buffer, int key, int value);
|
||||
|
||||
void set_program(f_bffrP p_fb, key_progP kp);
|
||||
|
||||
/* reads in the firmware file into a buffer */
|
||||
f_bffrP get_firmware_buffer(char *filename);
|
||||
f_bffrP get_firmware_buffer(char *filename);
|
||||
|
||||
void write_firmware_buffer(char *filename, f_bffrP p_fb);
|
||||
|
||||
#endif /* FIRMWARE_HANDLING_H_ */
|
||||
|
||||
+26
-10
@@ -1,7 +1,30 @@
|
||||
/* keycodes taken from https://usb.org/sites/default/files/hut1_22.pdf
|
||||
* See also: https://github.com/benblazak/ergodox-firmware/blob/master/src/lib/usb/usage-page/keyboard.h
|
||||
* */
|
||||
*/
|
||||
|
||||
#ifndef KEYCODES_H_
|
||||
#define KEYCODES_H_
|
||||
|
||||
/* THESE ARE THE AVALIABLE KEYS FOR THE "MOD_KEYS" PARAMETER */
|
||||
#define MODKEY_LCTR 0x01
|
||||
#define MODKEY_LSHI 0x02
|
||||
#define MODKEY_LALT 0x03
|
||||
#define MODKEY_LWIN 0x04
|
||||
#define MODKEY_RCTR 0x05
|
||||
#define MODKEY_RSHI 0x06
|
||||
#define MODKEY_RALT 0x07
|
||||
#define MODKEY_RWIN 0x08
|
||||
#define MODKEY_RWIN_RSHI 0x09
|
||||
#define MODKEY_RWIN_RCTR 0x0A
|
||||
#define MODKEY_RWIN_RALT 0x0B
|
||||
#define MODKEY_RWIN_RCTR_RSHI 0x0C
|
||||
#define MODKEY_RCTR_RALT 0x0D
|
||||
#define MODKEY_RCTR_RSHI 0x0E
|
||||
#define MODKEY_RALT_RSHI 0x0F
|
||||
#define MODKEY_RALT_RCTR_RSHI 0x10
|
||||
|
||||
|
||||
/* THESE ARE THE AVAIRABLE KEYS FOR THE "KEYS" PARAMETER */
|
||||
#define KEY_ErrorRollOver 0x01
|
||||
#define KEY_POSTFail 0x02
|
||||
#define KEY_ErrorUndefined 0x03
|
||||
@@ -84,7 +107,6 @@
|
||||
#define KEY_LeftArrow 0x50
|
||||
#define KEY_DownArrow 0x51
|
||||
#define KEY_UpArrow 0x52
|
||||
|
||||
#define KEYPAD_NumLock_Clear 0x53
|
||||
#define KEYPAD_Slash 0x54
|
||||
#define KEYPAD_Asterisk 0x55
|
||||
@@ -102,13 +124,10 @@
|
||||
#define KEYPAD_9_PageUp 0x61
|
||||
#define KEYPAD_0_Insert 0x62
|
||||
#define KEYPAD_Period_Delete 0x63
|
||||
|
||||
#define KEY_NonUS_Backslash_Pipe 0x64
|
||||
#define KEY_Application 0x65
|
||||
#define KEY_Power 0x66
|
||||
|
||||
#define KEYPAD_Equal 0x67
|
||||
|
||||
#define KEY_F13 0x68
|
||||
#define KEY_F14 0x69
|
||||
#define KEY_F15 0x6A
|
||||
@@ -138,10 +157,8 @@
|
||||
#define KEY_LockingCapsLock 0x82
|
||||
#define KEY_LockingNumLock 0x83
|
||||
#define KEY_LockingScrollLock 0x84
|
||||
|
||||
#define KEYPAD_Comma 0x85
|
||||
#define KEYPAD_EqualSign 0x86
|
||||
|
||||
#define KEY_International1 0x87
|
||||
#define KEY_International2 0x88
|
||||
#define KEY_International3 0x89
|
||||
@@ -175,17 +192,14 @@
|
||||
// (Reserved) 0xA5..0xAF
|
||||
#define KEYPAD_00 0xB0
|
||||
#define KEYPAD_000 0xB1
|
||||
|
||||
#define KEY_ThousandsSeparator 0xB2
|
||||
#define KEY_DecimalSeparator 0xB3
|
||||
#define KEY_CurrencyUnit 0xB4
|
||||
#define KEY_CurrencySubunit 0xB5
|
||||
|
||||
#define KEYPAD_LeftParenthesis 0xB6
|
||||
#define KEYPAD_RightParenthesis 0xB7
|
||||
#define KEYPAD_LeftBrace 0xB8
|
||||
#define KEYPAD_RightBrace 0xB9
|
||||
|
||||
#define KEYPAD_Tab 0xBA
|
||||
#define KEYPAD_Backspace 0xBB
|
||||
#define KEYPAD_A 0xBC
|
||||
@@ -231,3 +245,5 @@
|
||||
#define KEY_RightShift 0xE5
|
||||
#define KEY_RightAlt 0xE6
|
||||
#define KEY_RightGUI 0xE7
|
||||
|
||||
#endif /* KEYCODES_H_ */
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "../include/keycodes.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef KEYCODE_CONV_H_
|
||||
#define KEYCODE_CONV_H_
|
||||
|
||||
typedef struct keyCode keyCode;
|
||||
struct keyCode {
|
||||
uint8_t key_code;
|
||||
const char *key_name;
|
||||
};
|
||||
|
||||
#define KEYCODE(KC) \
|
||||
{ KC, #KC }
|
||||
|
||||
uint8_t get_keycode_by_name(char *key_name);
|
||||
uint8_t get_modkeycode_by_name(char *modkey_name);
|
||||
|
||||
#endif /* KEYCODE_CONV_H_ */
|
||||
Reference in New Issue
Block a user