private unsafe PinMameController(IInputContext input) { _pinMame = PinMame.PinMame.Instance(); _pinMame.OnGameStarted += OnGameStarted; _pinMame.OnDisplayAvailable += OnDisplayAvailable; _pinMame.OnDisplayUpdated += OnDisplayUpdated; _pinMame.OnAudioAvailable += OnAudioAvailable; _pinMame.OnAudioUpdated += OnAudioUpdated; _pinMame.OnConsoleDataUpdated += OnConsoleDataUpdated; _pinMame.OnGameEnded += OnGameEnded; _pinMame.IsKeyPressed += IsKeyPressed; _pinMame.SetHandleKeyboard(true); _dmdController = DmdController.Instance(); _input = input; foreach (var keyboard in _input.Keyboards) { keyboard.KeyDown += (arg1, arg2, arg3) => { if (_keycodeMap.TryGetValue(arg2, out var keycode)) { Logger.Trace($"KeyDown() {keycode} ({(int)keycode})"); _keypress[(int)keycode] = 1; } }; keyboard.KeyUp += (arg1, arg2, arg3) => { if (_keycodeMap.TryGetValue(arg2, out var keycode)) { Logger.Trace($"KeyUp() {keycode} ({(int)keycode})"); _keypress[(int)keycode] = 0; } }; } _al = AL.GetApi(true); ALContext alContext = ALContext.GetApi(true); var device = alContext.OpenDevice(""); if (device != null) { alContext.MakeContextCurrent( alContext.CreateContext(device, null)); _audioSource = _al.GenSource(); _audioBuffers = _al.GenBuffers(_maxAudioBuffers); } else { Logger.Error("PinMameController(): Could not create device"); } }
static void Main(string[] args) { LogManager.Configuration = new LoggingConfiguration(); var target = new ConsoleTarget("PinMameSilk"); LogManager.Configuration.AddTarget(target); LogManager.Configuration.AddRule(LogLevel.Info, LogLevel.Fatal, target); LogManager.ReconfigExistingLoggers(); var options = WindowOptions.Default; options.Size = new Vector2D <int>(128 * 6, 32 * 6); options.Title = "PinMAME Silk"; var window = Window.Create(options); DmdController dmdController = null; UIOverlayController uiOverlayController = null; PinMameController pinMameController = null; GL gl = null; window.Load += () => { gl = GL.GetApi(window); var input = window.CreateInput(); dmdController = DmdController.Instance(window); uiOverlayController = UIOverlayController.Instance(window, input, gl); pinMameController = PinMameController.Instance(); // (ImGui needs resize message first) window.Resize += (size) => { size.Y = size.X * 32 / 128; window.Size = size; }; }; window.FramebufferResize += (size) => { gl.Viewport(size); }; window.Render += (delta) => { gl.Clear((uint)ClearBufferMask.ColorBufferBit); gl.ClearColor(1.0f, 1.0f, 0.0f, 1.0f); dmdController.Render(); uiOverlayController.Render(delta); }; window.Run(); }
private UIOverlayController(IView window, IInputContext input, GL gl) { _window = window; _input = input; _imGuiController = new ImGuiController( gl, window, _input); _imGuiFadeInOut = new ImGuiFadeInOut(); _pinMameController = PinMameController.Instance(_input); _dmdController = DmdController.Instance(); }
public static DmdController Instance(IView window = null) => _instance ?? (_instance = new DmdController(window));