dev #4
175
.clang-format
Normal file
175
.clang-format
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignArrayOfStructures: Left
|
||||||
|
AlignConsecutiveMacros: None
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
AlignConsecutiveBitFields: None
|
||||||
|
AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Always
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: TopLevelDefinitions
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BitFieldColonSpacing: Before
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeConceptDeclarations: true
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentRequires: false
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PointerAlignment: Right
|
||||||
|
PPIndentWidth: -1
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
Standard: Latest
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseCRLF: false
|
||||||
|
UseTab: Never
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- STRINGIZE
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
...
|
||||||
|
|
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
## Compiler settings
|
## Compiler settings
|
||||||
CC = cc
|
CC = cc
|
||||||
CFLAGS = -Wall -Werror -g -std=c99
|
CFLAGS = -Wall -Werror -g -std=c99 -lcjson
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
|
|
||||||
## Project settings
|
## Project settings
|
||||||
|
21
config.json
Normal file
21
config.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"macros": [
|
||||||
|
{
|
||||||
|
"macro_no": 1,
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"mod_keys": "",
|
||||||
|
"delay": 0.0,
|
||||||
|
"keys": [
|
||||||
|
"KEY_a_A",
|
||||||
|
"KEY_b_B",
|
||||||
|
"KEY_c_C",
|
||||||
|
"KEY_d_D",
|
||||||
|
"KEY_e_E",
|
||||||
|
"KEY_f_F"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
44
config2.json
Normal file
44
config2.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"macros": [
|
||||||
|
{
|
||||||
|
"macro_no": 1,
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"mod_keys": "",
|
||||||
|
"delay": 0.0,
|
||||||
|
"keys": ["a", "b", "c", "d", "e", "f"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mod_keys": "",
|
||||||
|
"delay": 0.0,
|
||||||
|
"keys": ["1", "2", "3", "4", "5", "6"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mod_keys": "",
|
||||||
|
"delay": 0.0,
|
||||||
|
"keys": ["!", "\"", "§", "$", "%", "&"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mod_keys": "",
|
||||||
|
"delay": 0.0,
|
||||||
|
"keys": ["Z", "Y", "X", "W", "V", "U"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"macro_no": 2,
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"mod_keys": "",
|
||||||
|
"delay": 0.0,
|
||||||
|
"keys": ["a"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mod_keys": "",
|
||||||
|
"delay": 0.0,
|
||||||
|
"keys": ["1"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
10
include/config_handling.h
Normal file
10
include/config_handling.h
Normal file
@ -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_ */
|
@ -1,8 +1,11 @@
|
|||||||
|
#ifndef FIRMWARE_HANDLING_H_
|
||||||
|
#define FIRMWARE_HANDLING_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/**** DEFINES ****/
|
||||||
/* Max prog_actions per key_prog */
|
/* Max prog_actions per key_prog */
|
||||||
#define MAX_ACTION 100
|
#define MAX_ACTION 100
|
||||||
|
|
||||||
/* Defines for key offsets */
|
/* Defines for key offsets */
|
||||||
#define F8_KEY1 0x00005189
|
#define F8_KEY1 0x00005189
|
||||||
#define F8_KEY2 0x00005181
|
#define F8_KEY2 0x00005181
|
||||||
@ -12,7 +15,6 @@
|
|||||||
#define F8_KEY6 0x00005182
|
#define F8_KEY6 0x00005182
|
||||||
#define F8_KEY7 0x0000517A
|
#define F8_KEY7 0x0000517A
|
||||||
#define F8_KEY8 0x0000514A
|
#define F8_KEY8 0x0000514A
|
||||||
|
|
||||||
/* Defines for key program code */
|
/* Defines for key program code */
|
||||||
#define F8_PROG1 0xD7
|
#define F8_PROG1 0xD7
|
||||||
#define F8_PROG2 0xD8
|
#define F8_PROG2 0xD8
|
||||||
@ -33,22 +35,22 @@
|
|||||||
#define PROG7_OFFSET 0x0000665C
|
#define PROG7_OFFSET 0x0000665C
|
||||||
#define PROG8_OFFSET 0x0000697C
|
#define PROG8_OFFSET 0x0000697C
|
||||||
|
|
||||||
typedef struct f_bffr_t* f_bffrP;
|
/**** STRUCTS ****/
|
||||||
struct f_bffr_t
|
typedef struct f_bffr_t *f_bffrP;
|
||||||
{
|
struct f_bffr_t {
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A single macro action
|
* A single macro action
|
||||||
* First value is the modifiers to be hold while executing the other actions (see keycodes.h)
|
* First value is the modifiers to be hold while executing the other actions
|
||||||
* Second value is the delay between the keypresse ranging from 0.0 seconds to 3.0 seconds
|
* (see keycodes.h) Second value is the delay between the keypresse ranging from
|
||||||
* The remaining values are the keycodes to be pressed
|
* 0.0 seconds to 3.0 seconds The remaining values are the keycodes to be
|
||||||
|
* pressed
|
||||||
*/
|
*/
|
||||||
typedef struct prog_action* prog_actionP;
|
typedef struct prog_action *prog_actionP;
|
||||||
struct prog_action
|
struct prog_action {
|
||||||
{
|
|
||||||
uint8_t k_modifier;
|
uint8_t k_modifier;
|
||||||
uint8_t k_delay;
|
uint8_t k_delay;
|
||||||
uint8_t k_action1;
|
uint8_t k_action1;
|
||||||
@ -59,27 +61,28 @@ struct prog_action
|
|||||||
uint8_t k_action6;
|
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;
|
typedef struct key_prog *key_progP;
|
||||||
struct key_prog
|
struct key_prog {
|
||||||
{
|
|
||||||
int prog_offset;
|
int prog_offset;
|
||||||
prog_actionP prog_actions[MAX_ACTION];
|
prog_actionP prog_actions[MAX_ACTION];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set the value "value" to the specified key "key" inside the buffer "firmware_buffer"
|
* set the value "value" to the specified key "key" inside the buffer
|
||||||
* Key has to be the offset of the key to be altered.
|
* "firmware_buffer" Key has to be the offset of the key to be altered. Value
|
||||||
* Value has to be a keycode
|
* has to be a keycode
|
||||||
*/
|
*/
|
||||||
void set_key_value(char *firmware_buffer, int key, int value);
|
void set_key_value(char *firmware_buffer, int key, int value);
|
||||||
|
|
||||||
void set_program(f_bffrP p_fb, key_progP kp);
|
void set_program(f_bffrP p_fb, key_progP kp);
|
||||||
|
|
||||||
/* reads in the firmware file into a buffer */
|
/* 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);
|
void write_firmware_buffer(char *filename, f_bffrP p_fb);
|
||||||
|
|
||||||
|
#endif /* FIRMWARE_HANDLING_H_ */
|
||||||
|
@ -1,7 +1,30 @@
|
|||||||
/* keycodes taken from https://usb.org/sites/default/files/hut1_22.pdf
|
/* 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
|
* 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_ErrorRollOver 0x01
|
||||||
#define KEY_POSTFail 0x02
|
#define KEY_POSTFail 0x02
|
||||||
#define KEY_ErrorUndefined 0x03
|
#define KEY_ErrorUndefined 0x03
|
||||||
@ -84,7 +107,6 @@
|
|||||||
#define KEY_LeftArrow 0x50
|
#define KEY_LeftArrow 0x50
|
||||||
#define KEY_DownArrow 0x51
|
#define KEY_DownArrow 0x51
|
||||||
#define KEY_UpArrow 0x52
|
#define KEY_UpArrow 0x52
|
||||||
|
|
||||||
#define KEYPAD_NumLock_Clear 0x53
|
#define KEYPAD_NumLock_Clear 0x53
|
||||||
#define KEYPAD_Slash 0x54
|
#define KEYPAD_Slash 0x54
|
||||||
#define KEYPAD_Asterisk 0x55
|
#define KEYPAD_Asterisk 0x55
|
||||||
@ -102,13 +124,10 @@
|
|||||||
#define KEYPAD_9_PageUp 0x61
|
#define KEYPAD_9_PageUp 0x61
|
||||||
#define KEYPAD_0_Insert 0x62
|
#define KEYPAD_0_Insert 0x62
|
||||||
#define KEYPAD_Period_Delete 0x63
|
#define KEYPAD_Period_Delete 0x63
|
||||||
|
|
||||||
#define KEY_NonUS_Backslash_Pipe 0x64
|
#define KEY_NonUS_Backslash_Pipe 0x64
|
||||||
#define KEY_Application 0x65
|
#define KEY_Application 0x65
|
||||||
#define KEY_Power 0x66
|
#define KEY_Power 0x66
|
||||||
|
|
||||||
#define KEYPAD_Equal 0x67
|
#define KEYPAD_Equal 0x67
|
||||||
|
|
||||||
#define KEY_F13 0x68
|
#define KEY_F13 0x68
|
||||||
#define KEY_F14 0x69
|
#define KEY_F14 0x69
|
||||||
#define KEY_F15 0x6A
|
#define KEY_F15 0x6A
|
||||||
@ -138,10 +157,8 @@
|
|||||||
#define KEY_LockingCapsLock 0x82
|
#define KEY_LockingCapsLock 0x82
|
||||||
#define KEY_LockingNumLock 0x83
|
#define KEY_LockingNumLock 0x83
|
||||||
#define KEY_LockingScrollLock 0x84
|
#define KEY_LockingScrollLock 0x84
|
||||||
|
|
||||||
#define KEYPAD_Comma 0x85
|
#define KEYPAD_Comma 0x85
|
||||||
#define KEYPAD_EqualSign 0x86
|
#define KEYPAD_EqualSign 0x86
|
||||||
|
|
||||||
#define KEY_International1 0x87
|
#define KEY_International1 0x87
|
||||||
#define KEY_International2 0x88
|
#define KEY_International2 0x88
|
||||||
#define KEY_International3 0x89
|
#define KEY_International3 0x89
|
||||||
@ -175,17 +192,14 @@
|
|||||||
// (Reserved) 0xA5..0xAF
|
// (Reserved) 0xA5..0xAF
|
||||||
#define KEYPAD_00 0xB0
|
#define KEYPAD_00 0xB0
|
||||||
#define KEYPAD_000 0xB1
|
#define KEYPAD_000 0xB1
|
||||||
|
|
||||||
#define KEY_ThousandsSeparator 0xB2
|
#define KEY_ThousandsSeparator 0xB2
|
||||||
#define KEY_DecimalSeparator 0xB3
|
#define KEY_DecimalSeparator 0xB3
|
||||||
#define KEY_CurrencyUnit 0xB4
|
#define KEY_CurrencyUnit 0xB4
|
||||||
#define KEY_CurrencySubunit 0xB5
|
#define KEY_CurrencySubunit 0xB5
|
||||||
|
|
||||||
#define KEYPAD_LeftParenthesis 0xB6
|
#define KEYPAD_LeftParenthesis 0xB6
|
||||||
#define KEYPAD_RightParenthesis 0xB7
|
#define KEYPAD_RightParenthesis 0xB7
|
||||||
#define KEYPAD_LeftBrace 0xB8
|
#define KEYPAD_LeftBrace 0xB8
|
||||||
#define KEYPAD_RightBrace 0xB9
|
#define KEYPAD_RightBrace 0xB9
|
||||||
|
|
||||||
#define KEYPAD_Tab 0xBA
|
#define KEYPAD_Tab 0xBA
|
||||||
#define KEYPAD_Backspace 0xBB
|
#define KEYPAD_Backspace 0xBB
|
||||||
#define KEYPAD_A 0xBC
|
#define KEYPAD_A 0xBC
|
||||||
@ -231,3 +245,5 @@
|
|||||||
#define KEY_RightShift 0xE5
|
#define KEY_RightShift 0xE5
|
||||||
#define KEY_RightAlt 0xE6
|
#define KEY_RightAlt 0xE6
|
||||||
#define KEY_RightGUI 0xE7
|
#define KEY_RightGUI 0xE7
|
||||||
|
|
||||||
|
#endif /* KEYCODES_H_ */
|
||||||
|
20
include/keycodes_conv.h
Normal file
20
include/keycodes_conv.h
Normal file
@ -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_ */
|
96
src/config_handling.c
Normal file
96
src/config_handling.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#include "../include/config_handling.h"
|
||||||
|
|
||||||
|
#include "../include/keycodes_conv.h"
|
||||||
|
|
||||||
|
#include <cjson/cJSON.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
/* define declarations */
|
||||||
|
#define JO_MACROS "macros"
|
||||||
|
#define JO_MACRO_NO "macro_no"
|
||||||
|
#define JO_ACTIONS "actions"
|
||||||
|
#define JO_MOD_KEYS "mod_keys"
|
||||||
|
#define JO_DELAY "delay"
|
||||||
|
#define JO_KEYS "keys"
|
||||||
|
|
||||||
|
/* method declarations */
|
||||||
|
char *read_in_config(char *conf_name);
|
||||||
|
|
||||||
|
prog_actionP *
|
||||||
|
get_config(char *conf_name) {
|
||||||
|
|
||||||
|
const cJSON *macros = NULL;
|
||||||
|
const cJSON *macro = NULL;
|
||||||
|
|
||||||
|
/* parse the read in config file */
|
||||||
|
cJSON *config_json = cJSON_Parse(read_in_config(conf_name));
|
||||||
|
if (config_json == NULL) {
|
||||||
|
const char *error_ptr = cJSON_GetErrorPtr();
|
||||||
|
if (error_ptr != NULL) {
|
||||||
|
fprintf(stderr, "Error before: %s\n", error_ptr);
|
||||||
|
}
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// READ IN VALUES //
|
||||||
|
macros = cJSON_GetObjectItemCaseSensitive(config_json, JO_MACROS);
|
||||||
|
cJSON_ArrayForEach(macro, macros) {
|
||||||
|
// cJSON *macro_no = cJSON_GetObjectItemCaseSensitive(macro,
|
||||||
|
// JO_MACRO_NO);
|
||||||
|
cJSON *action = NULL;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
cJSON *actions = cJSON_GetObjectItemCaseSensitive(macro, JO_ACTIONS);
|
||||||
|
cJSON_ArrayForEach(action, actions) {
|
||||||
|
cJSON *mod_keys =
|
||||||
|
cJSON_GetObjectItemCaseSensitive(action, JO_MOD_KEYS);
|
||||||
|
// cJSON *delay = cJSON_GetObjectItemCaseSensitive(action,
|
||||||
|
// JO_DELAY);
|
||||||
|
cJSON *keys = cJSON_GetObjectItemCaseSensitive(action, JO_KEYS);
|
||||||
|
|
||||||
|
prog_actionP pa = calloc(1, sizeof(*pa));
|
||||||
|
pa->k_modifier =
|
||||||
|
get_modkeycode_by_name(cJSON_GetStringValue(mod_keys));
|
||||||
|
pa->k_delay = 0x00;
|
||||||
|
pa->k_action1 = get_keycode_by_name(
|
||||||
|
cJSON_GetStringValue(cJSON_GetArrayItem(keys, 0)));
|
||||||
|
pa->k_action2 = get_keycode_by_name(
|
||||||
|
cJSON_GetStringValue(cJSON_GetArrayItem(keys, 1)));
|
||||||
|
pa->k_action3 = get_keycode_by_name(
|
||||||
|
cJSON_GetStringValue(cJSON_GetArrayItem(keys, 2)));
|
||||||
|
pa->k_action4 = get_keycode_by_name(
|
||||||
|
cJSON_GetStringValue(cJSON_GetArrayItem(keys, 3)));
|
||||||
|
pa->k_action5 = get_keycode_by_name(
|
||||||
|
cJSON_GetStringValue(cJSON_GetArrayItem(keys, 4)));
|
||||||
|
pa->k_action6 = get_keycode_by_name(
|
||||||
|
cJSON_GetStringValue(cJSON_GetArrayItem(keys, 5)));
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
read_in_config(char *conf_name) {
|
||||||
|
|
||||||
|
FILE *fp = fopen(conf_name, "r");
|
||||||
|
if (!fp) {
|
||||||
|
perror("Error while reading conf file");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct stat sb;
|
||||||
|
if (stat(conf_name, &sb) == -1) {
|
||||||
|
perror("Error while reading config file metadata.\r\nExiting.");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *config = malloc(sb.st_size);
|
||||||
|
fread(config, sb.st_size, 1, fp);
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
@ -4,28 +4,29 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
/* Just for debugging */
|
/* Just for debugging */
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "../include/firmware_handling.h"
|
#include "../include/firmware_handling.h"
|
||||||
|
|
||||||
f_bffrP get_firmware_buffer(char *filename) {
|
#include <ctype.h>
|
||||||
|
|
||||||
|
f_bffrP
|
||||||
|
get_firmware_buffer(char *filename) {
|
||||||
|
|
||||||
f_bffrP p_fb = malloc(sizeof(*p_fb));
|
f_bffrP p_fb = malloc(sizeof(*p_fb));
|
||||||
|
|
||||||
FILE *firmware = fopen(filename, "rb");
|
FILE *firmware = fopen(filename, "rb");
|
||||||
if(!firmware) {
|
if (!firmware) {
|
||||||
perror("Error while reading in Firmware File.\r\nExiting.");
|
perror("Error while reading in Firmware File.\r\nExiting.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
if(stat(filename, &sb) == -1) {
|
if (stat(filename, &sb) == -1) {
|
||||||
perror("Error while reading Firmware metadata.\r\nExiting.");
|
perror("Error while reading Firmware metadata.\r\nExiting.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set buffer size and read in firmware file into buffer*/
|
/* set buffer size and read in firmware file into buffer*/
|
||||||
p_fb->size = sb.st_size;
|
p_fb->size = sb.st_size;
|
||||||
p_fb->buffer = malloc(p_fb->size);
|
p_fb->buffer = malloc(p_fb->size);
|
||||||
fread(p_fb->buffer, p_fb->size, 1, firmware);
|
fread(p_fb->buffer, p_fb->size, 1, firmware);
|
||||||
|
|
||||||
@ -37,10 +38,11 @@ f_bffrP get_firmware_buffer(char *filename) {
|
|||||||
return p_fb;
|
return p_fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_firmware_buffer(char *filename, f_bffrP p_fb) {
|
void
|
||||||
|
write_firmware_buffer(char *filename, f_bffrP p_fb) {
|
||||||
|
|
||||||
FILE *firmware_file = fopen(filename, "wb+");
|
FILE *firmware_file = fopen(filename, "wb+");
|
||||||
if(!firmware_file) {
|
if (!firmware_file) {
|
||||||
perror("Error while opening in Firmware File.\r\nExiting.");
|
perror("Error while opening in Firmware File.\r\nExiting.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -50,32 +52,43 @@ void write_firmware_buffer(char *filename, f_bffrP p_fb) {
|
|||||||
fclose(firmware_file);
|
fclose(firmware_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
void set_key_value(char *firmware_buffer, int key, int value) {
|
set_key_value(char *firmware_buffer, int key, int value) {
|
||||||
memset(firmware_buffer + key, value, 1);
|
memset(firmware_buffer + key, value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_program(f_bffrP p_fb, key_progP kp) {
|
void
|
||||||
for(int i=0; i<MAX_ACTION; i++){
|
set_program(f_bffrP p_fb, key_progP kp) {
|
||||||
|
for (int i = 0; i < MAX_ACTION; i++) {
|
||||||
|
|
||||||
// Check if an action for that position exists
|
// Check if an action for that position exists
|
||||||
if(kp->prog_actions[i]){
|
if (kp->prog_actions[i]) {
|
||||||
/* calculate the offset for the action
|
/* calculate the offset for the action
|
||||||
* -> general prog_offset + current prog_action i times bytes per action
|
* -> general prog_offset + current prog_action i times bytes per
|
||||||
*/
|
* action
|
||||||
int actionpointer = kp->prog_offset + (i * sizeof(*kp->prog_actions[0]));
|
*/
|
||||||
|
int actionpointer =
|
||||||
|
kp->prog_offset + (i * sizeof(*kp->prog_actions[0]));
|
||||||
|
|
||||||
/* set the modifiers */
|
/* set the modifiers */
|
||||||
memset(p_fb->buffer + actionpointer + 0, kp->prog_actions[i]->k_modifier, 1);
|
memset(p_fb->buffer + actionpointer + 0,
|
||||||
/* set timing delay */
|
kp->prog_actions[i]->k_modifier, 1);
|
||||||
memset(p_fb->buffer + actionpointer + 1, kp->prog_actions[i]->k_delay, 1);
|
/* set timing delay */
|
||||||
|
memset(p_fb->buffer + actionpointer + 1,
|
||||||
|
kp->prog_actions[i]->k_delay, 1);
|
||||||
/* set action 1-6 */
|
/* set action 1-6 */
|
||||||
memset(p_fb->buffer + actionpointer + 2, kp->prog_actions[i]->k_action1, 1);
|
memset(p_fb->buffer + actionpointer + 2,
|
||||||
memset(p_fb->buffer + actionpointer + 3, kp->prog_actions[i]->k_action2, 1);
|
kp->prog_actions[i]->k_action1, 1);
|
||||||
memset(p_fb->buffer + actionpointer + 4, kp->prog_actions[i]->k_action3, 1);
|
memset(p_fb->buffer + actionpointer + 3,
|
||||||
memset(p_fb->buffer + actionpointer + 5, kp->prog_actions[i]->k_action4, 1);
|
kp->prog_actions[i]->k_action2, 1);
|
||||||
memset(p_fb->buffer + actionpointer + 6, kp->prog_actions[i]->k_action5, 1);
|
memset(p_fb->buffer + actionpointer + 4,
|
||||||
memset(p_fb->buffer + actionpointer + 7, kp->prog_actions[i]->k_action6, 1);
|
kp->prog_actions[i]->k_action3, 1);
|
||||||
|
memset(p_fb->buffer + actionpointer + 5,
|
||||||
|
kp->prog_actions[i]->k_action4, 1);
|
||||||
|
memset(p_fb->buffer + actionpointer + 6,
|
||||||
|
kp->prog_actions[i]->k_action5, 1);
|
||||||
|
memset(p_fb->buffer + actionpointer + 7,
|
||||||
|
kp->prog_actions[i]->k_action6, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
262
src/keycodes_conv.c
Normal file
262
src/keycodes_conv.c
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
#include "../include/keycodes_conv.h"
|
||||||
|
|
||||||
|
const keyCode keycodes[] = {
|
||||||
|
|
||||||
|
KEYCODE(KEY_ErrorRollOver),
|
||||||
|
KEYCODE(KEY_POSTFail),
|
||||||
|
KEYCODE(KEY_ErrorUndefined),
|
||||||
|
KEYCODE(KEY_a_A),
|
||||||
|
KEYCODE(KEY_b_B),
|
||||||
|
KEYCODE(KEY_c_C),
|
||||||
|
KEYCODE(KEY_d_D),
|
||||||
|
KEYCODE(KEY_e_E),
|
||||||
|
KEYCODE(KEY_f_F),
|
||||||
|
KEYCODE(KEY_g_G),
|
||||||
|
KEYCODE(KEY_h_H),
|
||||||
|
KEYCODE(KEY_i_I),
|
||||||
|
KEYCODE(KEY_j_J),
|
||||||
|
KEYCODE(KEY_k_K),
|
||||||
|
KEYCODE(KEY_l_L),
|
||||||
|
KEYCODE(KEY_m_M),
|
||||||
|
KEYCODE(KEY_n_N),
|
||||||
|
KEYCODE(KEY_o_O),
|
||||||
|
KEYCODE(KEY_p_P),
|
||||||
|
KEYCODE(KEY_q_Q),
|
||||||
|
KEYCODE(KEY_r_R),
|
||||||
|
KEYCODE(KEY_s_S),
|
||||||
|
KEYCODE(KEY_t_T),
|
||||||
|
KEYCODE(KEY_u_U),
|
||||||
|
KEYCODE(KEY_v_V),
|
||||||
|
KEYCODE(KEY_w_W),
|
||||||
|
KEYCODE(KEY_x_X),
|
||||||
|
KEYCODE(KEY_y_Y),
|
||||||
|
KEYCODE(KEY_z_Z),
|
||||||
|
KEYCODE(KEY_1_Exclamation),
|
||||||
|
KEYCODE(KEY_2_At),
|
||||||
|
KEYCODE(KEY_3_Pound),
|
||||||
|
KEYCODE(KEY_4_Dollar),
|
||||||
|
KEYCODE(KEY_5_Percent),
|
||||||
|
KEYCODE(KEY_6_Caret),
|
||||||
|
KEYCODE(KEY_7_Ampersand),
|
||||||
|
KEYCODE(KEY_8_Asterisk),
|
||||||
|
KEYCODE(KEY_9_LeftParenthesis),
|
||||||
|
KEYCODE(KEY_0_RightParenthesis),
|
||||||
|
KEYCODE(KEY_ReturnEnter),
|
||||||
|
KEYCODE(KEY_Escape),
|
||||||
|
KEYCODE(KEY_DeleteBackspace),
|
||||||
|
KEYCODE(KEY_Tab),
|
||||||
|
KEYCODE(KEY_Spacebar),
|
||||||
|
KEYCODE(KEY_Dash_Underscore),
|
||||||
|
KEYCODE(KEY_Equal_Plus),
|
||||||
|
KEYCODE(KEY_LeftBracket_LeftBrace),
|
||||||
|
KEYCODE(KEY_RightBracket_RightBrace),
|
||||||
|
KEYCODE(KEY_Backslash_Pipe),
|
||||||
|
KEYCODE(KEY_NonUS_Pound_Tilde),
|
||||||
|
KEYCODE(KEY_Semicolon_Colon),
|
||||||
|
KEYCODE(KEY_SingleQuote_DoubleQuote),
|
||||||
|
KEYCODE(KEY_GraveAccent_Tilde),
|
||||||
|
KEYCODE(KEY_Comma_LessThan),
|
||||||
|
KEYCODE(KEY_Period_GreaterThan),
|
||||||
|
KEYCODE(KEY_Slash_Question),
|
||||||
|
KEYCODE(KEY_CapsLock),
|
||||||
|
KEYCODE(KEY_F1),
|
||||||
|
KEYCODE(KEY_F2),
|
||||||
|
KEYCODE(KEY_F3),
|
||||||
|
KEYCODE(KEY_F4),
|
||||||
|
KEYCODE(KEY_F5),
|
||||||
|
KEYCODE(KEY_F6),
|
||||||
|
KEYCODE(KEY_F7),
|
||||||
|
KEYCODE(KEY_F8),
|
||||||
|
KEYCODE(KEY_F9),
|
||||||
|
KEYCODE(KEY_F10),
|
||||||
|
KEYCODE(KEY_F11),
|
||||||
|
KEYCODE(KEY_F12),
|
||||||
|
KEYCODE(KEY_PrintScreen),
|
||||||
|
KEYCODE(KEY_ScrollLock),
|
||||||
|
KEYCODE(KEY_Pause),
|
||||||
|
KEYCODE(KEY_Insert),
|
||||||
|
KEYCODE(KEY_Home),
|
||||||
|
KEYCODE(KEY_PageUp),
|
||||||
|
KEYCODE(KEY_DeleteForward),
|
||||||
|
KEYCODE(KEY_End),
|
||||||
|
KEYCODE(KEY_PageDown),
|
||||||
|
KEYCODE(KEY_RightArrow),
|
||||||
|
KEYCODE(KEY_LeftArrow),
|
||||||
|
KEYCODE(KEY_DownArrow),
|
||||||
|
KEYCODE(KEY_UpArrow),
|
||||||
|
KEYCODE(KEYPAD_NumLock_Clear),
|
||||||
|
KEYCODE(KEYPAD_Slash),
|
||||||
|
KEYCODE(KEYPAD_Asterisk),
|
||||||
|
KEYCODE(KEYPAD_Minus),
|
||||||
|
KEYCODE(KEYPAD_Plus),
|
||||||
|
KEYCODE(KEYPAD_ENTER),
|
||||||
|
KEYCODE(KEYPAD_1_End),
|
||||||
|
KEYCODE(KEYPAD_2_DownArrow),
|
||||||
|
KEYCODE(KEYPAD_3_PageDown),
|
||||||
|
KEYCODE(KEYPAD_4_LeftArrow),
|
||||||
|
KEYCODE(KEYPAD_5),
|
||||||
|
KEYCODE(KEYPAD_6_RightArrow),
|
||||||
|
KEYCODE(KEYPAD_7_Home),
|
||||||
|
KEYCODE(KEYPAD_8_UpArrow),
|
||||||
|
KEYCODE(KEYPAD_9_PageUp),
|
||||||
|
KEYCODE(KEYPAD_0_Insert),
|
||||||
|
KEYCODE(KEYPAD_Period_Delete),
|
||||||
|
KEYCODE(KEY_NonUS_Backslash_Pipe),
|
||||||
|
KEYCODE(KEY_Application),
|
||||||
|
KEYCODE(KEY_Power),
|
||||||
|
KEYCODE(KEYPAD_Equal),
|
||||||
|
KEYCODE(KEY_F13),
|
||||||
|
KEYCODE(KEY_F14),
|
||||||
|
KEYCODE(KEY_F15),
|
||||||
|
KEYCODE(KEY_F16),
|
||||||
|
KEYCODE(KEY_F17),
|
||||||
|
KEYCODE(KEY_F18),
|
||||||
|
KEYCODE(KEY_F19),
|
||||||
|
KEYCODE(KEY_F20),
|
||||||
|
KEYCODE(KEY_F21),
|
||||||
|
KEYCODE(KEY_F22),
|
||||||
|
KEYCODE(KEY_F23),
|
||||||
|
KEYCODE(KEY_F24),
|
||||||
|
KEYCODE(KEY_Execute),
|
||||||
|
KEYCODE(KEY_Help),
|
||||||
|
KEYCODE(KEY_Menu),
|
||||||
|
KEYCODE(KEY_Select),
|
||||||
|
KEYCODE(KEY_Stop),
|
||||||
|
KEYCODE(KEY_Again),
|
||||||
|
KEYCODE(KEY_Undo),
|
||||||
|
KEYCODE(KEY_Cut),
|
||||||
|
KEYCODE(KEY_Copy),
|
||||||
|
KEYCODE(KEY_Paste),
|
||||||
|
KEYCODE(KEY_Find),
|
||||||
|
KEYCODE(KEY_Mute),
|
||||||
|
KEYCODE(KEY_VolumeUp),
|
||||||
|
KEYCODE(KEY_VolumeDown),
|
||||||
|
KEYCODE(KEY_LockingCapsLock),
|
||||||
|
KEYCODE(KEY_LockingNumLock),
|
||||||
|
KEYCODE(KEY_LockingScrollLock),
|
||||||
|
KEYCODE(KEYPAD_Comma),
|
||||||
|
KEYCODE(KEYPAD_EqualSign),
|
||||||
|
KEYCODE(KEY_International1),
|
||||||
|
KEYCODE(KEY_International2),
|
||||||
|
KEYCODE(KEY_International3),
|
||||||
|
KEYCODE(KEY_International4),
|
||||||
|
KEYCODE(KEY_International5),
|
||||||
|
KEYCODE(KEY_International6),
|
||||||
|
KEYCODE(KEY_International7),
|
||||||
|
KEYCODE(KEY_International8),
|
||||||
|
KEYCODE(KEY_International9),
|
||||||
|
KEYCODE(KEY_LANG1),
|
||||||
|
KEYCODE(KEY_LANG2),
|
||||||
|
KEYCODE(KEY_LANG3),
|
||||||
|
KEYCODE(KEY_LANG4),
|
||||||
|
KEYCODE(KEY_LANG5),
|
||||||
|
KEYCODE(KEY_LANG6),
|
||||||
|
KEYCODE(KEY_LANG7),
|
||||||
|
KEYCODE(KEY_LANG8),
|
||||||
|
KEYCODE(KEY_LANG9),
|
||||||
|
KEYCODE(KEY_AlternateErase),
|
||||||
|
KEYCODE(KEY_SysReq_Attention),
|
||||||
|
KEYCODE(KEY_Cancel),
|
||||||
|
KEYCODE(KEY_Clear),
|
||||||
|
KEYCODE(KEY_Prior),
|
||||||
|
KEYCODE(KEY_Return),
|
||||||
|
KEYCODE(KEY_Separator),
|
||||||
|
KEYCODE(KEY_Out),
|
||||||
|
KEYCODE(KEY_Oper),
|
||||||
|
KEYCODE(KEY_Clear_Again),
|
||||||
|
KEYCODE(KEY_CrSel_Props),
|
||||||
|
KEYCODE(KEY_ExSel),
|
||||||
|
KEYCODE(KEYPAD_00),
|
||||||
|
KEYCODE(KEYPAD_000),
|
||||||
|
KEYCODE(KEY_ThousandsSeparator),
|
||||||
|
KEYCODE(KEY_DecimalSeparator),
|
||||||
|
KEYCODE(KEY_CurrencyUnit),
|
||||||
|
KEYCODE(KEY_CurrencySubunit),
|
||||||
|
KEYCODE(KEYPAD_LeftParenthesis),
|
||||||
|
KEYCODE(KEYPAD_RightParenthesis),
|
||||||
|
KEYCODE(KEYPAD_LeftBrace),
|
||||||
|
KEYCODE(KEYPAD_RightBrace),
|
||||||
|
KEYCODE(KEYPAD_Tab),
|
||||||
|
KEYCODE(KEYPAD_Backspace),
|
||||||
|
KEYCODE(KEYPAD_A),
|
||||||
|
KEYCODE(KEYPAD_B),
|
||||||
|
KEYCODE(KEYPAD_C),
|
||||||
|
KEYCODE(KEYPAD_D),
|
||||||
|
KEYCODE(KEYPAD_E),
|
||||||
|
KEYCODE(KEYPAD_F),
|
||||||
|
KEYCODE(KEYPAD_XOR),
|
||||||
|
KEYCODE(KEYPAD_Caret),
|
||||||
|
KEYCODE(KEYPAD_Percent),
|
||||||
|
KEYCODE(KEYPAD_LessThan),
|
||||||
|
KEYCODE(KEYPAD_GreaterThan),
|
||||||
|
KEYCODE(KEYPAD_Ampersand),
|
||||||
|
KEYCODE(KEYPAD_AmpersandAmpersand),
|
||||||
|
KEYCODE(KEYPAD_Pipe),
|
||||||
|
KEYCODE(KEYPAD_PipePipe),
|
||||||
|
KEYCODE(KEYPAD_Colon),
|
||||||
|
KEYCODE(KEYPAD_Pound),
|
||||||
|
KEYCODE(KEYPAD_Space),
|
||||||
|
KEYCODE(KEYPAD_At),
|
||||||
|
KEYCODE(KEYPAD_Exclamation),
|
||||||
|
KEYCODE(KEYPAD_MemoryStore),
|
||||||
|
KEYCODE(KEYPAD_MemoryRecall),
|
||||||
|
KEYCODE(KEYPAD_MemoryClear),
|
||||||
|
KEYCODE(KEYPAD_MemoryAdd),
|
||||||
|
KEYCODE(KEYPAD_MemorySubtract),
|
||||||
|
KEYCODE(KEYPAD_MemoryMultiply),
|
||||||
|
KEYCODE(KEYPAD_MemoryDivide),
|
||||||
|
KEYCODE(KEYPAD_PlusMinus),
|
||||||
|
KEYCODE(KEYPAD_Clear),
|
||||||
|
KEYCODE(KEYPAD_ClearEntry),
|
||||||
|
KEYCODE(KEYPAD_Binary),
|
||||||
|
KEYCODE(KEYPAD_Octal),
|
||||||
|
KEYCODE(KEYPAD_Decimal),
|
||||||
|
KEYCODE(KEYPAD_Hexadecimal),
|
||||||
|
KEYCODE(KEY_LeftControl),
|
||||||
|
KEYCODE(KEY_LeftShift),
|
||||||
|
KEYCODE(KEY_LeftAlt),
|
||||||
|
KEYCODE(KEY_LeftGUI),
|
||||||
|
KEYCODE(KEY_RightControl),
|
||||||
|
KEYCODE(KEY_RightShift),
|
||||||
|
KEYCODE(KEY_RightAlt),
|
||||||
|
KEYCODE(KEY_RightGUI),
|
||||||
|
};
|
||||||
|
|
||||||
|
const keyCode modkeycodes[] = {
|
||||||
|
KEYCODE(MODKEY_LCTR), KEYCODE(MODKEY_LSHI),
|
||||||
|
KEYCODE(MODKEY_LALT), KEYCODE(MODKEY_LWIN),
|
||||||
|
KEYCODE(MODKEY_RCTR), KEYCODE(MODKEY_RSHI),
|
||||||
|
KEYCODE(MODKEY_RALT), KEYCODE(MODKEY_RWIN),
|
||||||
|
KEYCODE(MODKEY_RWIN_RSHI), KEYCODE(MODKEY_RWIN_RCTR),
|
||||||
|
KEYCODE(MODKEY_RWIN_RALT), KEYCODE(MODKEY_RWIN_RCTR_RSHI),
|
||||||
|
KEYCODE(MODKEY_RCTR_RALT), KEYCODE(MODKEY_RCTR_RSHI),
|
||||||
|
KEYCODE(MODKEY_RALT_RSHI), KEYCODE(MODKEY_RALT_RCTR_RSHI),
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t
|
||||||
|
get_keycode_by_name(char *key_name) {
|
||||||
|
uint8_t keycode = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < (sizeof(keycodes) / sizeof(keycodes[0])); i++) {
|
||||||
|
if (strcmp(keycodes[i].key_name, key_name) == 0) {
|
||||||
|
keycode = keycodes[i].key_code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keycode;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t
|
||||||
|
get_modkeycode_by_name(char *modkey_name) {
|
||||||
|
uint8_t keycode = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < (sizeof(modkeycodes) / sizeof(modkeycodes[0])); i++) {
|
||||||
|
if (strcmp(modkeycodes[i].key_name, modkey_name) == 0) {
|
||||||
|
keycode = modkeycodes[i].key_code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keycode;
|
||||||
|
}
|
59
src/main.c
59
src/main.c
@ -1,16 +1,15 @@
|
|||||||
|
#include "../include/firmware_handling.h"
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "../include/firmware_handling.h"
|
void testing(f_bffrP p_fb);
|
||||||
#include "../include/keycodes.h"
|
|
||||||
|
|
||||||
void testing (f_bffrP p_fb);
|
|
||||||
char *updated_file_name(char *orig);
|
char *updated_file_name(char *orig);
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int
|
||||||
{
|
main(int argc, char *argv[]) {
|
||||||
/* Read in the firmware file into a f_bffr_t struct */
|
/* Read in the firmware file into a f_bffr_t struct */
|
||||||
f_bffrP p_fb = get_firmware_buffer(argv[1]);
|
f_bffrP p_fb = get_firmware_buffer(argv[1]);
|
||||||
|
|
||||||
@ -25,21 +24,25 @@ int main (int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *updated_file_name (char *orig){
|
char *
|
||||||
char *ne = "_new.bin";
|
updated_file_name(char *orig) {
|
||||||
int len = strlen(orig);
|
char *ne = "_new.bin";
|
||||||
|
int len = strlen(orig);
|
||||||
|
|
||||||
char *new_name = malloc(len + 4);
|
char *new_name = malloc(len + 4);
|
||||||
|
|
||||||
strncpy(new_name, orig, len - 4);
|
strncpy(new_name, orig, len - 4);
|
||||||
strcat(new_name, ne);
|
strcat(new_name, ne);
|
||||||
|
|
||||||
printf("New File Name: %s", new_name);
|
printf("New File Name: %s", new_name);
|
||||||
|
|
||||||
return new_name;
|
return new_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testing (f_bffrP p_fb) {
|
void
|
||||||
|
testing(f_bffrP p_fb) {
|
||||||
|
|
||||||
|
/*
|
||||||
set_key_value(p_fb->buffer, F8_KEY1, KEY_9_LeftParenthesis);
|
set_key_value(p_fb->buffer, F8_KEY1, KEY_9_LeftParenthesis);
|
||||||
set_key_value(p_fb->buffer, F8_KEY2, KEY_8_Asterisk);
|
set_key_value(p_fb->buffer, F8_KEY2, KEY_8_Asterisk);
|
||||||
set_key_value(p_fb->buffer, F8_KEY3, KEY_7_Ampersand);
|
set_key_value(p_fb->buffer, F8_KEY3, KEY_7_Ampersand);
|
||||||
@ -48,6 +51,7 @@ void testing (f_bffrP p_fb) {
|
|||||||
set_key_value(p_fb->buffer, F8_KEY6, KEY_4_Dollar);
|
set_key_value(p_fb->buffer, F8_KEY6, KEY_4_Dollar);
|
||||||
set_key_value(p_fb->buffer, F8_KEY7, KEY_3_Pound);
|
set_key_value(p_fb->buffer, F8_KEY7, KEY_3_Pound);
|
||||||
set_key_value(p_fb->buffer, F8_KEY8, KEY_2_At);
|
set_key_value(p_fb->buffer, F8_KEY8, KEY_2_At);
|
||||||
|
*/
|
||||||
|
|
||||||
/* for debugging -> print content of buffer to terminal */
|
/* for debugging -> print content of buffer to terminal */
|
||||||
/*
|
/*
|
||||||
@ -57,25 +61,24 @@ void testing (f_bffrP p_fb) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
prog_actionP pa = calloc(1, sizeof(*pa));
|
prog_actionP pa = calloc(1, sizeof(*pa));
|
||||||
pa->k_modifier = 0x00;
|
pa->k_modifier = 0x00;
|
||||||
pa->k_delay = 0x00;
|
pa->k_delay = 0x00;
|
||||||
pa->k_action1 = 0x0B;
|
pa->k_action1 = 0x0B;
|
||||||
pa->k_action2 = 0x04;
|
pa->k_action2 = 0x04;
|
||||||
pa->k_action3 = 0x0F;
|
pa->k_action3 = 0x0F;
|
||||||
pa->k_action4 = 0x0F;
|
pa->k_action4 = 0x0F;
|
||||||
pa->k_action5 = 0x12;
|
pa->k_action5 = 0x12;
|
||||||
pa->k_action6 = 0x00;
|
pa->k_action6 = 0x00;
|
||||||
|
|
||||||
|
key_progP kp = calloc(1, sizeof(*kp));
|
||||||
key_progP kp = calloc(1, sizeof(*kp));
|
kp->prog_offset = PROG1_OFFSET;
|
||||||
kp->prog_offset = PROG1_OFFSET;
|
kp->prog_actions[0] = pa;
|
||||||
kp->prog_actions[0] = pa;
|
kp->prog_actions[1] = pa;
|
||||||
kp->prog_actions[1] = pa;
|
kp->prog_actions[2] = pa;
|
||||||
kp->prog_actions[2] = pa;
|
kp->prog_actions[3] = pa;
|
||||||
kp->prog_actions[3] = pa;
|
|
||||||
kp->prog_actions[99] = pa;
|
kp->prog_actions[99] = pa;
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
set_program(p_fb, kp);
|
set_program(p_fb, kp);
|
||||||
|
|
||||||
free(kp);
|
free(kp);
|
||||||
|
Loading…
Reference in New Issue
Block a user