2022-02-16 00:41:47 +01:00
|
|
|
#ifndef FIRMWARE_HANDLING_H_
|
|
|
|
#define FIRMWARE_HANDLING_H_
|
|
|
|
|
2022-02-11 00:19:20 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2022-02-16 00:41:47 +01:00
|
|
|
/**** DEFINES ****/
|
2022-02-11 00:19:20 +01:00
|
|
|
/* Max prog_actions per key_prog */
|
|
|
|
#define MAX_ACTION 100
|
|
|
|
/* Defines for key offsets */
|
|
|
|
#define F8_KEY1 0x00005189
|
|
|
|
#define F8_KEY2 0x00005181
|
|
|
|
#define F8_KEY3 0x00005179
|
|
|
|
#define F8_KEY4 0x00005149
|
|
|
|
#define F8_KEY5 0x0000518A
|
|
|
|
#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
|
|
|
|
#define F8_PROG3 0xD9
|
|
|
|
#define F8_PROG4 0xDA
|
|
|
|
#define F8_PROG5 0xDB
|
|
|
|
#define F8_PROG6 0xDC
|
|
|
|
#define F8_PROG7 0xDD
|
|
|
|
#define F8_PROG8 0xDE
|
|
|
|
|
|
|
|
/* Define for prog1-8 offset */
|
|
|
|
#define PROG1_OFFSET 0x0000539C
|
|
|
|
#define PROG2_OFFSET 0x000056BC
|
|
|
|
#define PROG3_OFFSET 0x000059DC
|
|
|
|
#define PROG4_OFFSET 0x00005CFC
|
|
|
|
#define PROG5_OFFSET 0x0000601C
|
|
|
|
#define PROG6_OFFSET 0x0000633C
|
|
|
|
#define PROG7_OFFSET 0x0000665C
|
|
|
|
#define PROG8_OFFSET 0x0000697C
|
|
|
|
|
2022-02-16 00:41:47 +01:00
|
|
|
/**** STRUCTS ****/
|
|
|
|
typedef struct f_bffr_t *f_bffrP;
|
|
|
|
struct f_bffr_t {
|
2022-02-11 00:19:20 +01:00
|
|
|
char *buffer;
|
2022-02-09 05:10:15 +01:00
|
|
|
int size;
|
|
|
|
};
|
|
|
|
|
2022-02-16 00:41:47 +01:00
|
|
|
/*
|
2022-02-11 00:19:20 +01:00
|
|
|
* A single macro action
|
2022-02-16 00:41:47 +01:00
|
|
|
* 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
|
2022-02-11 00:19:20 +01:00
|
|
|
*/
|
2022-02-16 00:41:47 +01:00
|
|
|
typedef struct prog_action *prog_actionP;
|
|
|
|
struct prog_action {
|
2022-02-11 00:19:20 +01:00
|
|
|
uint8_t k_modifier;
|
|
|
|
uint8_t k_delay;
|
|
|
|
uint8_t k_action1;
|
|
|
|
uint8_t k_action2;
|
|
|
|
uint8_t k_action3;
|
|
|
|
uint8_t k_action4;
|
|
|
|
uint8_t k_action5;
|
|
|
|
uint8_t k_action6;
|
|
|
|
};
|
|
|
|
|
2022-02-16 00:41:47 +01:00
|
|
|
/*
|
|
|
|
* A single macro program consisting of the offset and up to MAX_ACTION (100)
|
|
|
|
* actions
|
2022-02-11 00:19:20 +01:00
|
|
|
*/
|
2022-02-16 00:41:47 +01:00
|
|
|
typedef struct key_prog *key_progP;
|
|
|
|
struct key_prog {
|
2022-02-11 00:19:20 +01:00
|
|
|
int prog_offset;
|
|
|
|
prog_actionP prog_actions[MAX_ACTION];
|
|
|
|
};
|
|
|
|
|
2022-02-16 00:41:47 +01:00
|
|
|
/*
|
|
|
|
* 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
|
2022-02-11 00:19:20 +01:00
|
|
|
*/
|
|
|
|
void set_key_value(char *firmware_buffer, int key, int value);
|
|
|
|
|
|
|
|
void set_program(f_bffrP p_fb, key_progP kp);
|
|
|
|
|
2022-02-09 05:10:15 +01:00
|
|
|
/* reads in the firmware file into a buffer */
|
2022-02-16 00:41:47 +01:00
|
|
|
f_bffrP get_firmware_buffer(char *filename);
|
2022-02-11 00:19:20 +01:00
|
|
|
|
|
|
|
void write_firmware_buffer(char *filename, f_bffrP p_fb);
|
2022-02-09 05:10:15 +01:00
|
|
|
|
2022-02-16 00:41:47 +01:00
|
|
|
#endif /* FIRMWARE_HANDLING_H_ */
|