public string Generate()
        {
            var sb = new StringBuilder();

            foreach (var group in _source.Definition.ControlsOrdered)
            {
                if (group.Any())
                {
                    foreach (var button in group)
                    {
                        if (_source.Definition.Axes.TryGetValue(button, out var range))
                        {
                            var val = _source.AxisValue(button);

                            if (val == range.Mid)
                            {
                                sb.Append("      ");
                            }
                            else
                            {
                                sb.Append(val.ToString().PadLeft(5, ' ')).Append(',');
                            }
                        }
                        else if (_source.Definition.BoolButtons.Contains(button))
                        {
                            sb.Append(_source.IsPressed(button)
                                                                ? Bk2MnemonicLookup.Lookup(button, _systemId)
                                                                : ' ');
                        }
                    }
                }
            }

            return(sb.ToString());
        }
Esempio n. 2
0
        public override void Attach(IEmulator emulator)
        {
            if (!emulator.HasSavestates())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service");
            }

            if (!emulator.CanPollInput())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IInputPollable)} service");
            }

            _inputPollable = emulator.AsInputPollable();

            if (StartsFromSavestate)
            {
                TasStateManager.Engage(BinarySavestate);
            }
            else
            {
                var ms = new MemoryStream();
                emulator.AsStatable().SaveStateBinary(new BinaryWriter(ms));
                TasStateManager.Engage(ms.ToArray());
            }

            base.Attach(emulator);

            foreach (var button in emulator.ControllerDefinition.BoolButtons)
            {
                _mnemonicCache[button] = Bk2MnemonicLookup.Lookup(button, emulator.SystemId);
            }
        }
        private string CreateLogEntry(bool createEmpty = false)
        {
            var sb = new StringBuilder();

            sb.Append('|');

            foreach (var group in _source.Definition.ControlsOrdered)
            {
                if (group.Any())
                {
                    foreach (var button in group)
                    {
                        if (_source.Definition.AxisControls.Contains(button))
                        {
                            int val;
                            int i   = _source.Definition.AxisControls.IndexOf(button);
                            var mid = _source.Definition.AxisRanges[i].Mid;

                            if (createEmpty)
                            {
                                val = mid;
                            }
                            else
                            {
                                val = (int)_source.AxisValue(button);
                            }

                            sb.Append(val.ToString().PadLeft(5, ' ')).Append(',');
                        }
                        else if (_source.Definition.BoolButtons.Contains(button))
                        {
                            if (createEmpty)
                            {
                                sb.Append('.');
                            }
                            else
                            {
                                sb.Append(_source.IsPressed(button)
                                                                        ? Bk2MnemonicLookup.Lookup(button, _systemId)
                                                                        : '.');
                            }
                        }
                    }

                    sb.Append('|');
                }
            }

            return(sb.ToString());
        }
Esempio n. 4
0
        public Dictionary <string, string> Map()
        {
            var dict = new Dictionary <string, string>();

            foreach (var group in _source.Definition.ControlsOrdered.Where(c => c.Any()))
            {
                foreach (var button in group)
                {
                    if (_source.Definition.BoolButtons.Contains(button))
                    {
                        dict.Add(button, Bk2MnemonicLookup.Lookup(button, _systemId).ToString());
                    }
                    else if (_source.Definition.AxisControls.Contains(button))
                    {
                        dict.Add(button, Bk2MnemonicLookup.LookupAxis(button, _systemId));
                    }
                }
            }

            return(dict);
        }
Esempio n. 5
0
        public override void Attach(IEmulator emulator)
        {
            if (!emulator.HasSavestates())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service");
            }

            if (!emulator.CanPollInput())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IInputPollable)} service");
            }

            _inputPollable = emulator.AsInputPollable();
            TasStateManager.Attach(emulator);

            base.Attach(emulator);

            foreach (var button in emulator.ControllerDefinition.BoolButtons)
            {
                _mnemonicCache[button] = Bk2MnemonicLookup.Lookup(button, emulator.SystemId);
            }
        }
Esempio n. 6
0
        private string CreateLogEntry(bool createEmpty = false)
        {
            var sb = new StringBuilder();

            sb.Append('|');

            foreach (var group in _source.Definition.ControlsOrdered)
            {
                if (group.Any())
                {
                    foreach (var button in group)
                    {
                        if (_source.Definition.Axes.TryGetValue(button, out var range))
                        {
                            var val = createEmpty ? range.Mid : _source.AxisValue(button);

                            sb.Append(val.ToString().PadLeft(5, ' ')).Append(',');
                        }
                        else if (_source.Definition.BoolButtons.Contains(button))
                        {
                            if (createEmpty)
                            {
                                sb.Append('.');
                            }
                            else
                            {
                                sb.Append(_source.IsPressed(button)
                                                                        ? Bk2MnemonicLookup.Lookup(button, _systemId)
                                                                        : '.');
                            }
                        }
                    }

                    sb.Append('|');
                }
            }

            return(sb.ToString());
        }