Updating KLL to generate _KLL defines for upcoming firmware update
- Compatible with earlier Kiibohd firmware
This commit is contained in:
parent
034927e13b
commit
2eb41e3a13
@ -1,9 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# KLL Compiler - Kiibohd Backend
|
'''
|
||||||
#
|
KLL Compiler - Kiibohd Backend
|
||||||
# Backend code generator for the Kiibohd Controller firmware.
|
|
||||||
#
|
Backend code generator for the Kiibohd Controller firmware.
|
||||||
# Copyright (C) 2014-2015 by Jacob Alexander
|
'''
|
||||||
|
# Copyright (C) 2014-2016 by Jacob Alexander
|
||||||
#
|
#
|
||||||
# This file is free software: you can redistribute it and/or modify
|
# This file is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -37,6 +38,11 @@ from kll_lib.hid_dict import *
|
|||||||
### Classes ###
|
### Classes ###
|
||||||
|
|
||||||
class Backend( BackendBase ):
|
class Backend( BackendBase ):
|
||||||
|
'''
|
||||||
|
Kiibohd Code-Generation Backend
|
||||||
|
|
||||||
|
Kiibohd specific code generation.
|
||||||
|
'''
|
||||||
# Default templates and output files
|
# Default templates and output files
|
||||||
templatePaths = ["templates/kiibohdKeymap.h", "templates/kiibohdDefs.h"]
|
templatePaths = ["templates/kiibohdKeymap.h", "templates/kiibohdDefs.h"]
|
||||||
outputPaths = ["generatedKeymap.h", "kll_defs.h"]
|
outputPaths = ["generatedKeymap.h", "kll_defs.h"]
|
||||||
@ -147,6 +153,9 @@ class Backend( BackendBase ):
|
|||||||
self.fill_dict['CapabilitiesList'] += "};"
|
self.fill_dict['CapabilitiesList'] += "};"
|
||||||
self.fill_dict['CapabilitiesIndices'] += "} CapabilityIndex;"
|
self.fill_dict['CapabilitiesIndices'] += "} CapabilityIndex;"
|
||||||
|
|
||||||
|
# Define for total number of capabilities
|
||||||
|
self.fill_dict['Defines'] += "\n#define CapabilitiesNum_KLL {0}".format( len( capabilities.keys() ) )
|
||||||
|
|
||||||
|
|
||||||
## Results Macros ##
|
## Results Macros ##
|
||||||
self.fill_dict['ResultMacros'] = ""
|
self.fill_dict['ResultMacros'] = ""
|
||||||
@ -218,12 +227,15 @@ class Backend( BackendBase ):
|
|||||||
self.fill_dict['ResultMacroList'] += "\tDefine_RM( {0} ),\n".format( result )
|
self.fill_dict['ResultMacroList'] += "\tDefine_RM( {0} ),\n".format( result )
|
||||||
self.fill_dict['ResultMacroList'] += "};"
|
self.fill_dict['ResultMacroList'] += "};"
|
||||||
|
|
||||||
results_count = len( macros.resultsIndexSorted );
|
results_count = len( macros.resultsIndexSorted )
|
||||||
|
|
||||||
|
|
||||||
## Result Macro Record ##
|
## Result Macro Record ##
|
||||||
self.fill_dict['ResultMacroRecord'] = "ResultMacroRecord ResultMacroRecordList[ ResultMacroNum ];"
|
self.fill_dict['ResultMacroRecord'] = "ResultMacroRecord ResultMacroRecordList[ ResultMacroNum ];"
|
||||||
|
|
||||||
|
# Define for total number of Result Macros
|
||||||
|
self.fill_dict['Defines'] += "\n#define ResultMacroNum_KLL {0}".format( len( macros.resultsIndexSorted ) )
|
||||||
|
|
||||||
|
|
||||||
## Trigger Macros ##
|
## Trigger Macros ##
|
||||||
self.fill_dict['TriggerMacros'] = ""
|
self.fill_dict['TriggerMacros'] = ""
|
||||||
@ -259,10 +271,9 @@ class Backend( BackendBase ):
|
|||||||
if stateWordSize == "8" and (triggers_count > 255 or results_count > 255):
|
if stateWordSize == "8" and (triggers_count > 255 or results_count > 255):
|
||||||
print ("{0} Over 255 trigger or result macros, changing stateWordSize from {1} to 16.".format( WARNING, stateWordSize ) )
|
print ("{0} Over 255 trigger or result macros, changing stateWordSize from {1} to 16.".format( WARNING, stateWordSize ) )
|
||||||
print( "Results count: ", results_count )
|
print( "Results count: ", results_count )
|
||||||
print( "Triggers count:", triggers_count )
|
print( "Triggers count: ", triggers_count )
|
||||||
stateWordSize == "16"
|
stateWordSize == "16"
|
||||||
self.fill_dict['Defines'] = self.fill_dict['Defines'].replace("StateWordSize_define 8", "StateWordSize_define 16")
|
self.fill_dict['Defines'] = self.fill_dict['Defines'].replace("StateWordSize_define 8", "StateWordSize_define 16")
|
||||||
#print (self.fill_dict['Defines'])
|
|
||||||
|
|
||||||
## Trigger Macro List ##
|
## Trigger Macro List ##
|
||||||
self.fill_dict['TriggerMacroList'] = "const TriggerMacro TriggerMacroList[] = {\n"
|
self.fill_dict['TriggerMacroList'] = "const TriggerMacro TriggerMacroList[] = {\n"
|
||||||
@ -277,6 +288,9 @@ class Backend( BackendBase ):
|
|||||||
## Trigger Macro Record ##
|
## Trigger Macro Record ##
|
||||||
self.fill_dict['TriggerMacroRecord'] = "TriggerMacroRecord TriggerMacroRecordList[ TriggerMacroNum ];"
|
self.fill_dict['TriggerMacroRecord'] = "TriggerMacroRecord TriggerMacroRecordList[ TriggerMacroNum ];"
|
||||||
|
|
||||||
|
# Define for total number of Trigger Macros
|
||||||
|
self.fill_dict['Defines'] += "\n#define TriggerMacroNum_KLL {0}".format( len( macros.triggersIndexSorted ) )
|
||||||
|
|
||||||
|
|
||||||
## Max Scan Code ##
|
## Max Scan Code ##
|
||||||
self.fill_dict['MaxScanCode'] = "#define MaxScanCode 0x{0:X}".format( macros.overallMaxScanCode )
|
self.fill_dict['MaxScanCode'] = "#define MaxScanCode 0x{0:X}".format( macros.overallMaxScanCode )
|
||||||
@ -368,6 +382,9 @@ class Backend( BackendBase ):
|
|||||||
self.fill_dict['LayerIndexList'] += '\tLayer_IN( layer{0}_scanMap, "{0}: {2}", 0x{1:02X} ),\n'.format( layer, firstScanCode, stackName )
|
self.fill_dict['LayerIndexList'] += '\tLayer_IN( layer{0}_scanMap, "{0}: {2}", 0x{1:02X} ),\n'.format( layer, firstScanCode, stackName )
|
||||||
self.fill_dict['LayerIndexList'] += "};"
|
self.fill_dict['LayerIndexList'] += "};"
|
||||||
|
|
||||||
|
# Define for total number of Trigger Macros
|
||||||
|
self.fill_dict['Defines'] += "\n#define LayerNum_KLL {0}".format( len( macros.triggerList ) )
|
||||||
|
|
||||||
|
|
||||||
## Layer State ##
|
## Layer State ##
|
||||||
self.fill_dict['LayerState'] = "uint8_t LayerState[ LayerNum ];"
|
self.fill_dict['LayerState'] = "uint8_t LayerState[ LayerNum ];"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014-2015 by Jacob Alexander
|
/* Copyright (C) 2014-2016 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* This file is free software: you can redistribute it and/or modify
|
* This file is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2014-2015 by Jacob Alexander
|
/* Copyright (C) 2014-2016 by Jacob Alexander
|
||||||
*
|
*
|
||||||
* This file is free software: you can redistribute it and/or modify
|
* This file is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
Reference in New Issue
Block a user