From 0b221cdb516c1537d90a27010e72a7766b1d0a16 Mon Sep 17 00:00:00 2001 From: tulthix Date: Sun, 1 Mar 2015 22:17:43 -0600 Subject: [PATCH] Clean up my git merge mess. --- defaults.json | 136 -------------------------------------------------- g600prog.py | 136 -------------------------------------------------- 2 files changed, 272 deletions(-) diff --git a/defaults.json b/defaults.json index e6adc24..4ac7da4 100644 --- a/defaults.json +++ b/defaults.json @@ -1,19 +1,11 @@ { "Mode1 (default)": { -<<<<<<< HEAD - "LedColors": { -======= "LedColorsNormal": { ->>>>>>> release-0.1 "Red": 0, "Green": 0, "Blue": 0 }, -<<<<<<< HEAD - "MaybeLighting": [ -======= "lighting?": [ ->>>>>>> release-0.1 2, 6, 0, @@ -148,21 +140,12 @@ "kbScanCode": "KC_EQUAL" } }, -<<<<<<< HEAD - "padding?": [ - 8, - 4, - 0 - ], - "buttonMapShift": { -======= "LedColorsShifted": { "Red": 255, "Green": 255, "Blue": 255 }, "buttonMapShifted": { ->>>>>>> release-0.1 "g1 (left button)": { "mouseScanCode": "LEFT_CLICK", "kbModifier": "NO_MOD", @@ -266,20 +249,12 @@ } }, "Mode2": { -<<<<<<< HEAD - "LedColors": { -======= "LedColorsNormal": { ->>>>>>> release-0.1 "Red": 255, "Green": 255, "Blue": 255 }, -<<<<<<< HEAD - "MaybeLighting": [ -======= "lighting?": [ ->>>>>>> release-0.1 0, 0, 0, @@ -414,21 +389,12 @@ "kbScanCode": "KC_KP_PLUS" } }, -<<<<<<< HEAD - "padding?": [ - 255, - 255, - 255 - ], - "buttonMapShift": { -======= "LedColorsShifted": { "Red": 255, "Green": 255, "Blue": 255 }, "buttonMapShifted": { ->>>>>>> release-0.1 "g1 (left button)": { "mouseScanCode": "LEFT_CLICK", "kbModifier": "NO_MOD", @@ -532,20 +498,12 @@ } }, "Mode3": { -<<<<<<< HEAD - "LedColors": { -======= "LedColorsNormal": { ->>>>>>> release-0.1 "Red": 0, "Green": 255, "Blue": 0 }, -<<<<<<< HEAD - "MaybeLighting": [ -======= "lighting?": [ ->>>>>>> release-0.1 1, 4, 0, @@ -680,47 +638,6 @@ "kbScanCode": "KC_NOKEY" } }, -<<<<<<< HEAD - "padding?": [ - 8, - 4, - 0 - ], - "buttonMapShift": { - "g1 (left button)": { - "mouseScanCode": "NO_MOUSEBUT", - "kbModifier": "KC_LGUI", - "kbScanCode": "KC_A" - }, - "g2 (right button)": { - "mouseScanCode": "NO_MOUSEBUT", - "kbModifier": "KC_LCTRL", - "kbScanCode": "KC_NOKEY" - }, - "g3 (middle button)": { - "mouseScanCode": "NO_MOUSEBUT", - "kbModifier": "KC_LSHIFT", - "kbScanCode": "KC_NOKEY" - }, - "g4 (mousewheel left)": { - "mouseScanCode": "NO_MOUSEBUT", - "kbModifier": "KC_LCTRL+KC_LSHIFT", - "kbScanCode": "KC_NOKEY" - }, - "g5 (mousewheel right)": { - "mouseScanCode": "NO_MOUSEBUT", - "kbModifier": "KC_LALT", - "kbScanCode": "KC_NOKEY" - }, - "g6 (side/gshift)": { - "mouseScanCode": "NO_MOUSEBUT", - "kbModifier": "KC_LCTRL+KC_LALT", - "kbScanCode": "KC_NOKEY" - }, - "g7 (button back)": { - "mouseScanCode": "NO_MOUSEBUT", - "kbModifier": "KC_LCTRL+KC_LSHIFT+KC_LALT+KC_RCTRL", -======= "LedColorsShifted": { "Red": 255, "Green": 255, @@ -760,7 +677,6 @@ "g7 (button back)": { "mouseScanCode": "DPI_CYCLING", "kbModifier": "NO_MOD", ->>>>>>> release-0.1 "kbScanCode": "KC_NOKEY" }, "g8 (button forward)": { @@ -770,116 +686,64 @@ }, "g9 (side buttonpad)": { "mouseScanCode": "NO_MOUSEBUT", -<<<<<<< HEAD - "kbModifier": "KC_LALT+KC_RCTRL", - "kbScanCode": "KC_NOKEY" -======= "kbModifier": "NO_MOD", "kbScanCode": "KC_1" ->>>>>>> release-0.1 }, "g10 (side buttonpad)": { "mouseScanCode": "NO_MOUSEBUT", "kbModifier": "NO_MOD", -<<<<<<< HEAD - "kbScanCode": "KC_NOKEY" - }, - "g11 (side buttonpad)": { - "mouseScanCode": "UNDEFINED030", - "kbModifier": "NO_MOD", - "kbScanCode": "KC_Q" -======= "kbScanCode": "KC_2" }, "g11 (side buttonpad)": { "mouseScanCode": "NO_MOUSEBUT", "kbModifier": "NO_MOD", "kbScanCode": "KC_3" ->>>>>>> release-0.1 }, "g12 (side buttonpad)": { "mouseScanCode": "NO_MOUSEBUT", "kbModifier": "NO_MOD", -<<<<<<< HEAD - "kbScanCode": "KC_NOKEY" -======= "kbScanCode": "KC_4" ->>>>>>> release-0.1 }, "g13 (side buttonpad)": { "mouseScanCode": "NO_MOUSEBUT", "kbModifier": "NO_MOD", -<<<<<<< HEAD - "kbScanCode": "KC_NOKEY" -======= "kbScanCode": "KC_5" ->>>>>>> release-0.1 }, "g14 (side buttonpad)": { "mouseScanCode": "NO_MOUSEBUT", "kbModifier": "NO_MOD", -<<<<<<< HEAD - "kbScanCode": "KC_NOKEY" - }, - "g15 (side buttonpad)": { - "mouseScanCode": "NO_MOUSEBUT", -======= "kbScanCode": "KC_6" }, "g15 (side buttonpad)": { "mouseScanCode": "DPI_UP", ->>>>>>> release-0.1 "kbModifier": "NO_MOD", "kbScanCode": "KC_NOKEY" }, "g16 (side buttonpad)": { -<<<<<<< HEAD - "mouseScanCode": "NO_MOUSEBUT", -======= "mouseScanCode": "DPI_DEFAULT", ->>>>>>> release-0.1 "kbModifier": "NO_MOD", "kbScanCode": "KC_NOKEY" }, "g17 (side buttonpad)": { -<<<<<<< HEAD - "mouseScanCode": "NO_MOUSEBUT", -======= "mouseScanCode": "FORWARD", ->>>>>>> release-0.1 "kbModifier": "NO_MOD", "kbScanCode": "KC_NOKEY" }, "g18 (side buttonpad)": { -<<<<<<< HEAD - "mouseScanCode": "NO_MOUSEBUT", -======= "mouseScanCode": "DPI_DOWN", ->>>>>>> release-0.1 "kbModifier": "NO_MOD", "kbScanCode": "KC_NOKEY" }, "g19 (side buttonpad)": { "mouseScanCode": "NO_MOUSEBUT", "kbModifier": "NO_MOD", -<<<<<<< HEAD - "kbScanCode": "KC_NOKEY" - }, - "g20 (side buttonpad)": { - "mouseScanCode": "NO_MOUSEBUT", -======= "kbScanCode": "KC_E" }, "g20 (side buttonpad)": { "mouseScanCode": "BACK", ->>>>>>> release-0.1 "kbModifier": "NO_MOD", "kbScanCode": "KC_NOKEY" } } } -<<<<<<< HEAD -} -======= } ->>>>>>> release-0.1 diff --git a/g600prog.py b/g600prog.py index b4e9598..e9ec296 100755 --- a/g600prog.py +++ b/g600prog.py @@ -375,22 +375,15 @@ def invMap(mapDict): ## json string ## simple representable types (array, ordered dict, integer, string) # types here: -<<<<<<< HEAD -# * base scalar (that defaults to a single byte) -======= # * singleByte ->>>>>>> release-0.1 # * homogeneous array # * heterogeneous ordered dict constant0ByteIter = itertools.repeat(0) -<<<<<<< HEAD -======= class MappingBuildError(Exception): pass class FromJsonError(Exception): pass ->>>>>>> release-0.1 class BaseFieldType(object): """Base type the other classes, do not use this class directly""" ID = "BaseField" @@ -405,39 +398,6 @@ def toJson(self): return json.dumps(self.simpleRepr, indent=4) def fromJson(self, jsonStr): -<<<<<<< HEAD - self.simpleRepr = json.loads(jsonStr, object_pairs_hook=collections.OrderedDict) - - json = property(toJson, fromJson) - -class ScalarFieldType(BaseFieldType): - ID = "ScalarField" - BYTE_LEN = 1 - def __init__(self, byteArray=constant0ByteIter, id=None, byteLen=None): - super(ScalarFieldType, self).__init__(byteArray, id) # python2 compatibility - self.byteLen = self.BYTE_LEN if byteLen is None else byteLen - self.bytes = byteArray - - def toByteArray(self): - return self._byteArray - - def fromByteArray(self, byteArray): - self._byteArray = bytearray() - for i, byte in zip(range(self.byteLen), iter(byteArray)): - self._byteArray.append(byte) - - def toSimpleRepr(self): - if self.byteLen == 1: - return self.bytes[0] - else: - return list(self.bytes) - - def fromSimpleRepr(self, arg): - if self.byteLen == 1: - self.bytes = bytearray([arg]) - else: - self.bytes = bytearray(arg) -======= try: self.simpleRepr = json.loads(jsonStr) except MappingBuildError as err: @@ -473,7 +433,6 @@ def fromSimpleRepr(self, arg): errStr = "{id}: ".format(id=self.id) raise MappingBuildError(errStr + str(err)) from err self.fromByteArray(bArr) ->>>>>>> release-0.1 bytes = property(toByteArray, fromByteArray) simpleRepr = property(toSimpleRepr, fromSimpleRepr) @@ -482,13 +441,9 @@ def fromSimpleRepr(self, arg): class ArrayFieldType(BaseFieldType): ID = "ArrayField" NUM_ELEM = 2 -<<<<<<< HEAD - ELEM_TYPE = ScalarFieldType -======= ELEM_TYPE = SingleByteFieldType ERR_FMT_PREFIX = "{id}[{index}]=>" ->>>>>>> release-0.1 def __init__(self, byteArray=constant0ByteIter, id=None, numElem=None, elemType=None, ): super(ArrayFieldType, self).__init__() # python2 compatibility self.id = self.ID if id is None else id @@ -513,11 +468,6 @@ def fromByteArray(self, byteArray): def toSimpleRepr(self): return [field.simpleRepr for field in self.elemList] -<<<<<<< HEAD - def fromSimpleRepr(self, arg): - for elem, argElem in zip(self.elemList, arg): - elem.simpleRepr = argElem -======= def _assertArraySane(self, arg): if len(self.elemList) != len(arg): errStr = self.ERR_FMT_PREFIX.format(id=self.id, index="") @@ -534,7 +484,6 @@ def fromSimpleRepr(self, arg): prependStr = self.ERR_FMT_PREFIX.format(id=self.id, index=index) err.args = (prependStr + err.args[0],) + err.args[1:] raise err ->>>>>>> release-0.1 bytes = property(toByteArray, fromByteArray) simpleRepr = property(toSimpleRepr, fromSimpleRepr) @@ -542,13 +491,9 @@ def fromSimpleRepr(self, arg): class CompositeFieldType(BaseFieldType): ID = "CompositeField" -<<<<<<< HEAD - KTM = [("f1", ScalarFieldType), ("f2", ScalarFieldType)] -======= KTM = [("f1", SingleByteFieldType), ("f2", SingleByteFieldType)] ERR_FMT_PREFIX = "{id}[{field}]=>" ->>>>>>> release-0.1 def __init__(self, byteArray=constant0ByteIter, id=None, keyToTypeMap=None, ): super(CompositeFieldType, self).__init__() self.id = self.ID if id is None else id @@ -575,11 +520,6 @@ def toSimpleRepr(self): simpleDict[fieldId] = self.elemDict[fieldId].toSimpleRepr() return simpleDict -<<<<<<< HEAD - def fromSimpleRepr(self, arg): - for fieldId, argId in zip(self.elemDict.keys(), arg.keys()): - self.elemDict[fieldId].fromSimpleRepr(arg[argId]) -======= def _assertFieldsSane(self, arg): missingFields = set(self.elemDict.keys()) - set(arg.keys()) extraFields = set(arg.keys()) - set(self.elemDict.keys()) @@ -598,7 +538,6 @@ def fromSimpleRepr(self, arg): prependStr = self.ERR_FMT_PREFIX.format(id=self.id, field=fieldId) err.args = (prependStr + err.args[0],) + err.args[1:] raise err ->>>>>>> release-0.1 bytes = property(toByteArray, fromByteArray) simpleRepr = property(toSimpleRepr, fromSimpleRepr) @@ -612,11 +551,7 @@ def cleanStr(arg): return arg.strip().upper() def convertErr(arg, id): -<<<<<<< HEAD - raise Exception("{} unable to convert representation of {}".format(id, arg)) -======= raise MappingBuildError("{} unable to convert representation of {}".format(id, arg)) ->>>>>>> release-0.1 def undefinedConvert(arg, id): u = "UNDEFINED" @@ -628,11 +563,7 @@ def undefinedConvert(arg, id): raise convertErr(arg, id) return int(argClean[len(u):]) -<<<<<<< HEAD -class G600MouseScanCodeType(ScalarFieldType): -======= class G600MouseScanCodeType(SingleByteFieldType): ->>>>>>> release-0.1 ID = "mouseScanCode" def toSimpleRepr(self): @@ -648,17 +579,10 @@ def fromSimpleRepr(self, arg): b = MOUSE_SCAN_CODES_INVDICT[argClean] else: b = undefinedConvert(argClean, self.id) -<<<<<<< HEAD - self.bytes[0] = b - - -class KbModifierBitWiseType(ScalarFieldType): -======= self.bytes = [b] class KbModifierBitWiseType(SingleByteFieldType): ->>>>>>> release-0.1 ID = "kbModifier" def toSimpleRepr(self): b = self.bytes[0] @@ -683,17 +607,10 @@ def fromSimpleRepr(self, arg): convertErr(modifierCode, self.id) else: b += 2 ** (KB_MODIFIER_BIT_CODES_INVDICT[modifierCode]) -<<<<<<< HEAD - self.bytes[0] = b - - -class KbScanCodeType(ScalarFieldType): -======= self.bytes = [b] class KbScanCodeType(SingleByteFieldType): ->>>>>>> release-0.1 ID = "kbScanCode" def toSimpleRepr(self): b = self.bytes[0] @@ -708,15 +625,9 @@ def fromSimpleRepr(self, arg): b = KB_SCAN_CODES_INVDICT[argClean] else: b = undefinedConvert(argClean, self.id) -<<<<<<< HEAD - self.bytes[0] = b - -class G600PollRateType(ScalarFieldType): -======= self.bytes = [b] class G600PollRateType(SingleByteFieldType): ->>>>>>> release-0.1 ID = "pollRate" def calcDerivedPollRate(self, b): @@ -736,15 +647,9 @@ def fromSimpleRepr(self, arg): argActual = self.calcDerivedPollRate(b) if argActual != arg: print("Warning! Requested pollrate of {} resulted in a actual pollrate of {}".format(arg, argActual)) -<<<<<<< HEAD - self.bytes[0] = b - -class G600DPIType(ScalarFieldType): -======= self.bytes = [b] class G600DPIType(SingleByteFieldType): ->>>>>>> release-0.1 ID = "dpi" def calcDerivedDpi(self, b): @@ -766,16 +671,8 @@ def fromSimpleRepr(self, arg): argActual = self.calcDerivedDpi(b) if argActual != arg: print("Warning! Requested dpi of {} resulted in a actual dpi of {}".format(arg, argActual)) -<<<<<<< HEAD - self.bytes[0] = b - -class G600ModeScalarType(ScalarFieldType): - ID = "mode (1, 2, or 3)" - -======= self.bytes = [b] ->>>>>>> release-0.1 class G600MouseButtonActionType(CompositeFieldType): KTM = [(G600MouseScanCodeType.ID, G600MouseScanCodeType), (KbModifierBitWiseType.ID, KbModifierBitWiseType), @@ -784,11 +681,7 @@ class G600MouseButtonActionType(CompositeFieldType): class G600DPIGroupType(CompositeFieldType): KTM = [('ShiftDPI', G600DPIType), -<<<<<<< HEAD - ('DefaultDPIIndex', ScalarFieldType), -======= ('DefaultDPIIndex', SingleByteFieldType), ->>>>>>> release-0.1 ('DPI1', G600DPIType), ('DPI2', G600DPIType), ('DPI3', G600DPIType), @@ -796,15 +689,9 @@ class G600DPIGroupType(CompositeFieldType): ] class G600LedColorsType(CompositeFieldType): -<<<<<<< HEAD - KTM = [('Red', ScalarFieldType), - ('Green', ScalarFieldType), - ('Blue', ScalarFieldType), -======= KTM = [('Red', SingleByteFieldType), ('Green', SingleByteFieldType), ('Blue', SingleByteFieldType), ->>>>>>> release-0.1 ] class G600ButtonMapType(CompositeFieldType): @@ -835,46 +722,23 @@ class G600ButtonMapType(CompositeFieldType): class UnknownBytesArray0(ArrayFieldType): ID = "Unknown" NUM_ELEM = 0x4b-0x44 -<<<<<<< HEAD - ELEM_TYPE = ScalarFieldType -======= ELEM_TYPE = SingleByteFieldType ->>>>>>> release-0.1 class UnknownBytesArray1(ArrayFieldType): ID = "Unknown" NUM_ELEM = 0x5f-0x52 -<<<<<<< HEAD - ELEM_TYPE = ScalarFieldType - -class UnknownBytesArray2(ArrayFieldType): - ID = "Unknown" - NUM_ELEM = 0x9e-0x9b - ELEM_TYPE = ScalarFieldType - -class G600ModeMouseMappingType(CompositeFieldType): - ID = "ConfigMode" - KTM = [("LedColors", G600LedColorsType), - ("MaybeLighting", UnknownBytesArray0), -======= ELEM_TYPE = SingleByteFieldType class G600ModeMouseMappingType(CompositeFieldType): ID = "ConfigMode" KTM = [("LedColorsNormal", G600LedColorsType), ("lighting?", UnknownBytesArray0), ->>>>>>> release-0.1 ("PollRate", G600PollRateType), ("DPI", G600DPIGroupType), ("Unknown1", UnknownBytesArray1), ("buttonMapNormal", G600ButtonMapType), -<<<<<<< HEAD - ("padding?", UnknownBytesArray2), - ("buttonMapShift", G600ButtonMapType), -======= ("LedColorsShifted", G600LedColorsType), ("buttonMapShifted", G600ButtonMapType), ->>>>>>> release-0.1 ] class G600MouseMapping(CompositeFieldType):