Ejemplo n.º 1
0
 public KeyState PollInput()
 {
     KeyState ret = new KeyState();
     ret.IsADown = IsKeyDown(keySettings.Keyboard_Button_A);
     ret.IsBDown = IsKeyDown(keySettings.Keyboard_Button_B);
     ret.IsStartDown = IsKeyDown(keySettings.Keyboard_Button_Start);
     ret.IsSelectDown = IsKeyDown(keySettings.Keyboard_Button_Select);
     ret.IsUpDown = IsKeyDown(keySettings.Keyboard_Button_Up);
     ret.IsDownDown = IsKeyDown(keySettings.Keyboard_Button_Down);
     ret.IsLeftDown = IsKeyDown(keySettings.Keyboard_Button_Left);
     ret.IsRightDown = IsKeyDown(keySettings.Keyboard_Button_Right);
     ret.IsPauseToggled = IsKeyToggled(keySettings.Keyboard_Button_Pause);
     ret.IsFrameLimitToggled = IsKeyToggled(keySettings.Keyboard_Button_FrameLimit);
     if (controller != null)
     {
         var keyState = controller.GetCurrentState();
         ret.IsADown |= keyState.Buttons[keySettings.Controller_Button_A];
         ret.IsBDown |= keyState.Buttons[keySettings.Controller_Button_B];
         ret.IsStartDown |= keyState.Buttons[keySettings.Controller_Button_Start];
         ret.IsSelectDown |= keyState.Buttons[keySettings.Controller_Button_Select];
         ret.IsUpDown |= keyState.Y < defaultControllerState.Y;
         ret.IsDownDown |= keyState.Y > defaultControllerState.Y;
         ret.IsLeftDown |= keyState.X < defaultControllerState.X;
         ret.IsRightDown |= keyState.X > defaultControllerState.X;
     }
     return ret;
 }
Ejemplo n.º 2
0
 public void StartSystem()
 {
     state = GBSystemState.Running;
     var frameInput = new KeyState();
     while (state != GBSystemState.Stopped)
     {
         if (frameInput.IsPauseToggled)
         {
             TogglePause();
         }
         if (frameInput.IsFrameLimitToggled)
         {
             ToggleFrameSpeed();
         }
         if (state == GBSystemState.Paused)
         {
             continue;
         }
         Profiler.GetInstance().Restart("Main CPU");
         frameTimer.Start();
         cpu.RunFor(video.TimeToNextVBlank());
         if (isFocused)
         {
             frameInput = inputHandler.PollInput();
             input.UpdateInput(frameInput);
         }
         cpu.RunFor(video.TimeToTopOfLCD());
         while (frameTimer.ElapsedSeconds() < SpeedLimits[frameLimitIndex])
         {
         }
         GBMonitor.CPUTime = Profiler.GetInstance().StopAndGetTimeAsFrameTimePercent("Main CPU");
     }
 }
Ejemplo n.º 3
0
 public GBInput(InterruptManager iM, IInputHandler handler)
 {
     interruptManager = iM;
     inputHandler = handler;
     keyState = new KeyState();
 }
Ejemplo n.º 4
0
 public void UpdateInput(KeyState ks)
 {
     int diff1 =
         (keyState.buttonState ^ ks.buttonState) & ks.buttonState |
         ((keyState.dpadState ^ ks.dpadState) & ks.dpadState);
     if (diff1 != 0)
     {
         interruptManager.RequestInterrupt(InterruptType.Joypad);
     }
     keyState.buttonState = ks.buttonState;
     keyState.dpadState = ks.dpadState;
 }
Ejemplo n.º 5
0
 public GBInput(InterruptManager iM, IInputHandler handler)
 {
     interruptManager = iM;
     inputHandler     = handler;
     keyState         = new KeyState();
 }