public PollKey(EmuKeys oldKey, string message, string inputMode) { InitializeComponent(); switch (inputMode) { default: case "Win": input = new WinInput(this, this); break; #if !NO_DX case "DX": input = new DXInput(this); break; case "XIn": input = new XInInput(); break; #endif case "Null": input = new NullInput(); break; } lblMessage.Text = message; input.Create(); input.InputEvent += new InputHandler(input_InputEvent); input.InputScalerEvent += new InputScalerHandler(input_InputScalerEvent); this.oldKey = this.newKey = oldKey; tmrPoll.Enabled = true; }
void input_InputEvent(EmuKeys key, bool pressed) { if (key != EmuKeys.None && pressed) { newKey = key; DialogResult = System.Windows.Forms.DialogResult.OK; } }
void input_InputScalerEvent(EmuKeys key, int value) { }
void input_InputEvent(EmuKeys key, bool pressed) { if (key == keyBindings.Player1A) { player1Pressed.a = pressed; } else if (key == keyBindings.Player1TurboA) { player1A.on = pressed; if(!pressed) player1A.count = 1; } else if (key == keyBindings.Player1B) { player1Pressed.b = pressed; } else if (key == keyBindings.Player1TurboB) { player1B.on = pressed; if (!pressed) player1B.count = 1; } else if (key == keyBindings.Player1Select) { player1Pressed.select = pressed; } else if (key == keyBindings.Player1Start) { player1Pressed.start = pressed; } else if (key == keyBindings.Player1Up) { player1Pressed.up = pressed; } else if (key == keyBindings.Player1Down) { player1Pressed.down = pressed; } else if (key == keyBindings.Player1Left) { player1Pressed.left = pressed; if (cpu != null && !pressed) cpu.NSFPreviousSong(); } else if (key == keyBindings.Player1Right) { player1Pressed.right = pressed; if (cpu != null && !pressed) cpu.NSFNextSong(); } else if (key == EmuKeys.Mouse1) { player1.triggerPulled = pressed; player2.triggerPulled = pressed; } else if (key == keyBindings.Player2A) { player2Pressed.a = pressed; } else if (key == keyBindings.Player2TurboA) { player2A.on = pressed; if (!pressed) player2A.count = 1; } else if (key == keyBindings.Player2B) { player2Pressed.b = pressed; } else if (key == keyBindings.Player2TurboB) { player2B.on = pressed; if (!pressed) player2B.count = 1; } else if (key == keyBindings.Player2Select) { player2Pressed.select = pressed; } else if (key == keyBindings.Player2Start) { player2Pressed.start = pressed; } else if (key == keyBindings.Player2Up) { player2Pressed.up = pressed; } else if (key == keyBindings.Player2Down) { player2Pressed.down = pressed; } else if (key == keyBindings.Player2Left) { player2Pressed.left = pressed; } else if (key == keyBindings.Player2Right) { player2Pressed.right = pressed; } else if (key == EmuKeys.Q) { controlStrobe = pressed; } else if (key == keyBindings.SaveState) { if (!pressed) this.storeState = true; } else if (key == keyBindings.LoadState) { if (!pressed) this.loadState = true; } else if (key == keyBindings.Rewind) { rewinding = pressed; } else if (key == keyBindings.FastForward) { frameSkipper = pressed ? maxFrameSkip : 1; } else if (key == EmuKeys.F2) { player1.coin = pressed; } else if (key == EmuKeys.F3) { player2.coin = pressed; } else if (key == keyBindings.Pause) { if (!pressed) { if (state == SystemState.Playing) state = SystemState.Paused; else if (state == SystemState.Paused) state = SystemState.Playing; this.message = "Paused"; this.messageDuration = 1; } } else if (key == keyBindings.Reset) { if (!pressed) { this.SaveGame(); moviePtr = 0; this.cpu.Reset(); this.LoadGame(); this.message = "Reset"; this.messageDuration = 90; } } else if (key == keyBindings.Power) { if (!pressed) { this.SaveGame(); moviePtr = 0; this.cpu.Power(); this.LoadGame(); this.message = "Power"; this.messageDuration = 90; } } else if (key == EmuKeys.LeftBracket) { if (!pressed) { quickSaveSlot--; if (quickSaveSlot < 0) quickSaveSlot = 9; this.message = "Save Slot " + quickSaveSlot.ToString(); this.messageDuration = 90; } } else if (key == EmuKeys.RightBracket) { if (!pressed) { quickSaveSlot++; if (quickSaveSlot > 9) quickSaveSlot = 0; this.message = "Save Slot " + quickSaveSlot.ToString(); this.messageDuration = 90; } } else if (key == EmuKeys.Backslash) { if (!pressed) { if (state == SystemState.Paused) state = SystemState.Playing; frameAdvance = true; this.message = "Paused"; this.messageDuration = 2; } } else if (key == EmuKeys.Grave) { if (!pressed) { if (rewindingEnabled) { if (state == SystemState.Paused) state = SystemState.Playing; frameDevance = true; rewinding = true; this.message = "Paused"; this.messageDuration = 2; } } } }
void input_InputScalerEvent(EmuKeys key, int value) { switch (key) { case EmuKeys.MouseX: Point tmpPointX = surfaceControl.PointToClient(new Point(value, 0)); tmpPointX.X = (int)((256 * tmpPointX.X) / (surfaceControl.Width * 1.0)); if (tmpPointX.X < 0) tmpPointX.X = 0; else if (tmpPointX.X >= 256) tmpPointX.X = 256 - 1; player1.x = (byte)tmpPointX.X; player2.x = player1.x; break; case EmuKeys.MouseY: Point tmpPointY = surfaceControl.PointToClient(new Point(0, value)); tmpPointY.Y = (int)((240 * tmpPointY.Y) / (surfaceControl.Height * 1.0)); if (tmpPointY.Y < 0) tmpPointY.Y = 0; else if (tmpPointY.Y >= 240) tmpPointY.Y = 240 - 1; player1.y = (byte)tmpPointY.Y; player2.y = player1.y; break; } }