From a008e03b224de06866935ffc6dfe1447e641e886 Mon Sep 17 00:00:00 2001 From: Jacob Alexander Date: Sun, 11 Sep 2016 12:38:31 -0700 Subject: [PATCH] Adding support for pixelmap output and backporting features to 0.3d - Enables support for running both kll 0.3d and 0.5c at the same time - Adds output support for generatedPixelmap.c - Adds a --version to 0.3d --- common/organization.py | 5 +++-- emitters/kiibohd/kiibohd.py | 29 +++++++++++++++++++++++------ kll.py | 20 ++++++++++++++++---- templates/kiibohdPixelmap.c | 26 ++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 templates/kiibohdPixelmap.c diff --git a/common/organization.py b/common/organization.py index 2d189a3..8d44441 100644 --- a/common/organization.py +++ b/common/organization.py @@ -20,6 +20,7 @@ KLL Data Organization ### Imports ### +import copy import re @@ -429,8 +430,8 @@ class MappingData( Data ): # 2) #TODO - print("YAY") - print( scan_code_lookup ) + #print("YAY") + #print( scan_code_lookup ) class AnimationData( Data ): diff --git a/emitters/kiibohd/kiibohd.py b/emitters/kiibohd/kiibohd.py index 906630a..33bf109 100644 --- a/emitters/kiibohd/kiibohd.py +++ b/emitters/kiibohd/kiibohd.py @@ -63,10 +63,12 @@ class Kiibohd( Emitter, TextEmitter ): TextEmitter.__init__( self ) # Defaults - self.map_template = "templates/kiibohdKeymap.h" - self.def_template = "templates/kiibohdDefs.h" - self.map_output = "generatedKeymap.h" - self.def_output = "kll_defs.h" + self.map_template = "templates/kiibohdKeymap.h" + self.pixel_template = "templates/kiibohdPixelmap.c" + self.def_template = "templates/kiibohdDefs.h" + self.map_output = "generatedKeymap.h" + self.pixel_output = "generatedPixelmap.c" + self.def_output = "kll_defs.h" self.fill_dict = {} @@ -78,8 +80,10 @@ class Kiibohd( Emitter, TextEmitter ): ''' self.def_template = args.def_template self.map_template = args.map_template + self.pixel_template = args.pixel_template self.def_output = args.def_output self.map_output = args.map_output + self.pixel_output = args.pixel_output def command_line_flags( self, parser ): ''' @@ -98,6 +102,10 @@ class Kiibohd( Emitter, TextEmitter ): help="Specify KLL map .h file template.\n" "\033[1mDefault\033[0m: {0}\n".format( self.map_template ) ) + group.add_argument( '--pixel-template', type=str, default=self.pixel_template, + help="Specify KLL pixel map .c file template.\n" + "\033[1mDefault\033[0m: {0}\n".format( self.pixel_template ) + ) group.add_argument( '--def-output', type=str, default=self.def_output, help="Specify KLL define .h file output.\n" "\033[1mDefault\033[0m: {0}\n".format( self.def_output ) @@ -106,6 +114,10 @@ class Kiibohd( Emitter, TextEmitter ): help="Specify KLL map .h file output.\n" "\033[1mDefault\033[0m: {0}\n".format( self.map_output ) ) + group.add_argument( '--pixel-output', type=str, default=self.pixel_output, + help="Specify KLL map .h file output.\n" + "\033[1mDefault\033[0m: {0}\n".format( self.pixel_output ) + ) def output( self ): ''' @@ -118,8 +130,13 @@ class Kiibohd( Emitter, TextEmitter ): self.generate( self.def_output ) # Load keymap template and generate - self.load_template( self.map_template ) - self.generate( self.map_output ) + # TODO + #self.load_template( self.map_template ) + #self.generate( self.map_output ) + + # Load pixelmap template and generate + self.load_template( self.pixel_template ) + self.generate( self.pixel_output ) def process( self ): ''' diff --git a/kll.py b/kll.py index 1ad0244..097bf15 100755 --- a/kll.py +++ b/kll.py @@ -96,6 +96,12 @@ def processCommandLineArgs(): "Default: " ) pArgs.add_argument( '-h', '--help', action="help", help="This message." ) + pArgs.add_argument( + '-v', '--version', + action="version", + version="%(prog)s {0}".format( version ), + help="Show program's version number and exit" + ) # Process Arguments args = pArgs.parse_args() @@ -722,23 +728,29 @@ def gitRevision( kllPath ): # Get list of files that have changed since the commit changed = subprocess.check_output( ['git', 'diff-index', '--name-only', 'HEAD', '--'] ).decode().splitlines() + + # Get commit date + date = subprocess.check_output( ['git', 'show', '-s', '--format=%ci'] ).decode()[:-1] except: revision = "" changed = [] + date = "" # Change back to the old working directory os.chdir( origPath ) - return revision, changed + return revision, changed, date ### Main Entry Point ### if __name__ == '__main__': - (baseFiles, defaultFiles, partialFileSets, backend_name, templates, outputs) = processCommandLineArgs() - # Look up git information on the compiler - gitRev, gitChanges = gitRevision( os.path.dirname( os.path.realpath( __file__ ) ) ) + gitRev, gitChanges, gitDate = gitRevision( os.path.dirname( os.path.realpath( __file__ ) ) ) + global version + version = "BACKPORT 0.3d.{0} - {1}".format( gitRev, gitDate ) + + (baseFiles, defaultFiles, partialFileSets, backend_name, templates, outputs) = processCommandLineArgs() # Load backend module global backend diff --git a/templates/kiibohdPixelmap.c b/templates/kiibohdPixelmap.c new file mode 100644 index 0000000..b10d722 --- /dev/null +++ b/templates/kiibohdPixelmap.c @@ -0,0 +1,26 @@ +/* Copyright (C) 2016 by Jacob Alexander + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this file. If not, see . + */ + +<|Information|> + + +#pragma once + +// ----- Includes ----- + +// KLL Include +// TODO +