# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Actions

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

class InputKeyParam(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = InputKeyParam()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsInputKeyParam(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # InputKeyParam
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # InputKeyParam
    def Press(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
        return 0

    # InputKeyParam
    def Codes(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return ""

    # InputKeyParam
    def CodesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # InputKeyParam
    def CodesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

def InputKeyParamStart(builder): builder.StartObject(2)
def Start(builder):
    return InputKeyParamStart(builder)
def InputKeyParamAddPress(builder, press): builder.PrependInt16Slot(0, press, 0)
def AddPress(builder, press):
    return InputKeyParamAddPress(builder, press)
def InputKeyParamAddCodes(builder, codes): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(codes), 0)
def AddCodes(builder, codes):
    return InputKeyParamAddCodes(builder, codes)
def InputKeyParamStartCodesVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartCodesVector(builder, numElems):
    return InputKeyParamStartCodesVector(builder, numElems)
def InputKeyParamEnd(builder): return builder.EndObject()
def End(builder):
    return InputKeyParamEnd(builder)
try:
    from typing import List
except:
    pass

class InputKeyParamT(object):

    # InputKeyParamT
    def __init__(self):
        self.press = 0  # type: int
        self.codes = None  # type: List[str]

    @classmethod
    def InitFromBuf(cls, buf, pos):
        inputKeyParam = InputKeyParam()
        inputKeyParam.Init(buf, pos)
        return cls.InitFromObj(inputKeyParam)

    @classmethod
    def InitFromPackedBuf(cls, buf, pos=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
        return cls.InitFromBuf(buf, pos+n)

    @classmethod
    def InitFromObj(cls, inputKeyParam):
        x = InputKeyParamT()
        x._UnPack(inputKeyParam)
        return x

    # InputKeyParamT
    def _UnPack(self, inputKeyParam):
        if inputKeyParam is None:
            return
        self.press = inputKeyParam.Press()
        if not inputKeyParam.CodesIsNone():
            self.codes = []
            for i in range(inputKeyParam.CodesLength()):
                self.codes.append(inputKeyParam.Codes(i))

    # InputKeyParamT
    def Pack(self, builder):
        if self.codes is not None:
            codeslist = []
            for i in range(len(self.codes)):
                codeslist.append(builder.CreateString(self.codes[i]))
            InputKeyParamStartCodesVector(builder, len(self.codes))
            for i in reversed(range(len(self.codes))):
                builder.PrependUOffsetTRelative(codeslist[i])
            codes = builder.EndVector()
        InputKeyParamStart(builder)
        InputKeyParamAddPress(builder, self.press)
        if self.codes is not None:
            InputKeyParamAddCodes(builder, codes)
        inputKeyParam = InputKeyParamEnd(builder)
        return inputKeyParam
