示例#1
0
        public override void Assemble(Assembler assembler)
        {
            int keycode = Key.KeyCode;

            if (Duration is ValRegEx)
            {
                if (Duration is ValReg32)
                {
                    throw new AssembleException(ErrorMessage.NotSupported);
                }
                var reg = Duration as ValReg;
                assembler.Add(AsmStoreOp.Create(reg.Index));
                assembler.Add(AsmKey_Standard.Create(keycode, 0));
                ReleasePrevious(assembler);
            }
            else if (Duration is ValInstant)
            {
                int duration = (Duration as ValInstant).Val;
                var ins      = AsmKey_Standard.Create(keycode, duration);
                if (ins.Success)
                {
                    assembler.Add(ins);
                    ReleasePrevious(assembler);
                }
                else if (ins == Instruction.Failed.OutOfRange)
                {
                    assembler.Add(AsmKey_Hold.Create(keycode));
                    ReleasePrevious(assembler);
                    assembler.KeyMapping[keycode] = assembler.Last() as AsmKey_Hold;
                    assembler.Add(AsmWait.Create(duration));
                    assembler.Add(AsmEmpty.Create());
                    ReleasePrevious(assembler);
                }
            }
            else
            {
                throw new AssembleException(ErrorMessage.NotImplemented);
            }
        }
示例#2
0
 public override void Assemble(Assembler assembler)
 {
     assembler.Add(AsmKey_Hold.Create(Key.KeyCode));
     ReleasePrevious(assembler);
     assembler.KeyMapping[Key.KeyCode] = assembler.Last() as AsmKey_Hold;
 }