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-20 00:52:42 +01:00
|
|
|
/* Max f8_macro_actions per f8_macro */
|
2022-02-11 00:19:20 +01:00
|
|
|
#define MAX_ACTION 100
|
|
|
|
|
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-20 00:52:42 +01:00
|
|
|
int size;
|
2022-02-09 05:10:15 +01:00
|
|
|
};
|
|
|
|
|
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-20 00:52:42 +01:00
|
|
|
typedef struct f8_macro_action *f8_macro_actionP;
|
|
|
|
struct f8_macro_action {
|
|
|
|
uint8_t modifier;
|
|
|
|
uint8_t delay;
|
|
|
|
uint8_t action1;
|
|
|
|
uint8_t action2;
|
|
|
|
uint8_t action3;
|
|
|
|
uint8_t action4;
|
|
|
|
uint8_t action5;
|
|
|
|
uint8_t action6;
|
2022-02-11 00:19:20 +01:00
|
|
|
};
|
|
|
|
|
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-20 00:52:42 +01:00
|
|
|
typedef struct f8_macro *f8_macroP;
|
|
|
|
struct f8_macro {
|
|
|
|
int offset;
|
|
|
|
f8_macro_actionP actions[MAX_ACTION];
|
2022-02-11 00:19:20 +01:00
|
|
|
};
|
|
|
|
|
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
|
|
|
*/
|
2022-02-20 00:52:42 +01:00
|
|
|
void set_key_value(char *firmware_buffer, int key, int value);
|
2022-02-11 00:19:20 +01:00
|
|
|
|
2022-02-20 00:52:42 +01:00
|
|
|
void set_program(f_bffrP p_fb, f8_macroP kp);
|
2022-02-11 00:19:20 +01:00
|
|
|
|
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
|
|
|
|
2022-02-20 00:52:42 +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_ */
|