Beispiel #1
0
        public int MapGBKey(GameBoyKeys gbKey)
        {
            switch (gbKey)
            {
            default:
            case GameBoyKeys.None: return(0);

            case GameBoyKeys.Right: return(1);

            case GameBoyKeys.Left: return(2);

            case GameBoyKeys.Up: return(3);

            case GameBoyKeys.Down: return(4);

            case GameBoyKeys.A: return(5);

            case GameBoyKeys.B: return(6);

            case GameBoyKeys.Start: return(7);

            case GameBoyKeys.Select: return(8);

            case GameBoyKeys.All: return(9);
            }
        }
			public void NotifyReleasedKeys(int joypadIndex, GameBoyKeys releasedKeys)
			{
				if (joypadIndex < 0 || joypadIndex >= 4) throw new ArgumentOutOfRangeException("joypadIndex");

				if (joypadIndex == 0) @this.baseKeys &= ~releasedKeys;
				else @this.additionalKeys[joypadIndex - 1] &= releasedKeys;
				if (joypadIndex == @this.joypadIndex) @this.UpdateJoypadRegister();
			}
Beispiel #3
0
            public KeyBind(KeyBind keyBind)
            {
                gtkKey = keyBind.gtkKey;

                sdlKey = keyBind.sdlKey;

                gameBoyKey = keyBind.gameBoyKey;
            }
Beispiel #4
0
            public KeyBind(Gdk.Key gtk, SDL2.SDL.SDL_Keycode sdl, GameBoyKeys gbk)
            {
                gtkKey = gtk;

                sdlKey = sdl;

                gameBoyKey = gbk;
            }
Beispiel #5
0
        private static void HandleKeyDown(ref GameBoyKeys keys, KeyEventArgs e, Keys key, GameBoyKeys matchingGameBoyKey)
        {
            if ((e.KeyData & ~Keys.Modifiers) == key)
            {
                keys |= matchingGameBoyKey;

                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
        }
Beispiel #6
0
        public Gdk.Key GetKey(GameBoyKeys gbk)
        {
            for (int i = 0; i < KeyBinds.Length; i++)
            {
                if(KeyBinds[i].gameBoyKey != gbk)
                    continue;

                return KeyBinds[i].gtkKey;
            }

            return Key.F24;
        }
Beispiel #7
0
        public void SetKey(GameBoyKeys gbk, Gdk.Key gtk)
        {
            for (int i = 0; i < KeyBinds.Length; i++)
            {
                if(KeyBinds[i].gameBoyKey != gbk)
                    continue;

                KeyBinds[i].gtkKey = gtk;

                KeyBinds[i].sdlKey = MapGtkToSDL(gtk) ?? SDL2.SDL.SDL_Keycode.SDLK_F24;
            }
        }
Beispiel #8
0
        void SetupInputButton(ref Label label, ref InputKeyButton button, GameBoyKeys key)
        {
            label  = new Label(key.ToString());
            button = new InputKeyButton {
                Label = Program.settings.GetKey(key).ToString(), GameBoyKey = key
            };
            button.Pressed       += ActivateButton;
            button.KeyPressEvent += OnKeyPress;

            masterContainer.Attach(label, 0, buttonCount, 1, 1);
            masterContainer.Attach(button, 1, buttonCount, 1, 1);

            buttonCount++;
        }
Beispiel #9
0
        public bool GetState(GameBoyKeys gbKey)
        {
            for (int i = 0; i < keys.Length; i++)
            {
                if (keys[i].gbKey != gbKey)
                {
                    continue;
                }

                return(keys[i].state);
            }

            return(false);
        }
Beispiel #10
0
        private void OnKeyUp(object sender, KeyEventArgs e)
        {
            var keys = _keys;

            HandleKeyUp(ref keys, e, Keys.Right, GameBoyKeys.Right);
            HandleKeyUp(ref keys, e, Keys.Left, GameBoyKeys.Left);
            HandleKeyUp(ref keys, e, Keys.Up, GameBoyKeys.Up);
            HandleKeyUp(ref keys, e, Keys.Down, GameBoyKeys.Down);
            HandleKeyUp(ref keys, e, Keys.X, GameBoyKeys.A);
            HandleKeyUp(ref keys, e, Keys.Z, GameBoyKeys.B);
            HandleKeyUp(ref keys, e, Keys.RShiftKey, GameBoyKeys.Select);
            HandleKeyUp(ref keys, e, Keys.Return, GameBoyKeys.Start);

            _keys = keys;
        }
Beispiel #11
0
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(sender);
            var keys = _keys;

            HandleKeyDown(ref keys, e, Keys.Right, GameBoyKeys.Right);
            HandleKeyDown(ref keys, e, Keys.Left, GameBoyKeys.Left);
            HandleKeyDown(ref keys, e, Keys.Up, GameBoyKeys.Up);
            HandleKeyDown(ref keys, e, Keys.Down, GameBoyKeys.Down);
            HandleKeyDown(ref keys, e, Keys.X, GameBoyKeys.A);
            HandleKeyDown(ref keys, e, Keys.Z, GameBoyKeys.B);
            HandleKeyDown(ref keys, e, Keys.RShiftKey, GameBoyKeys.Select);
            HandleKeyDown(ref keys, e, Keys.Return, GameBoyKeys.Start);

            _keys = keys;
        }
Beispiel #12
0
        private unsafe byte ReadJoypadRegister()
        {
            GameBoyKeys keys = GameBoyKeys.None;

            switch (joypadIndex)
            {
            case 0: keys = Volatile.Read(ref joypad0).DownKeys; break;

            case 1: keys = Volatile.Read(ref joypad1).DownKeys; break;

            case 2: keys = Volatile.Read(ref joypad2).DownKeys; break;

            case 3: keys = Volatile.Read(ref joypad3).DownKeys; break;
            }

            baseKeys = keys;

            if (joypadIndex == 0)
            {
                UpdateJoypadRegister();
            }

            return(portMemory[0x00]);
        }
			public void NotifyReleasedKeys(GameBoyKeys releasedKeys)
			{
				@this.baseKeys &= ~releasedKeys;
				if (@this.joypadIndex == 0) @this.UpdateJoypadRegister();
			}
			public void NotifyPressedKeys(GameBoyKeys pressedKeys)
			{
				@this.baseKeys |= pressedKeys;
				if (@this.joypadIndex == 0) @this.UpdateJoypadRegister();
			}
		partial void ResetJoypad()
		{
			baseKeys = GameBoyKeys.None;
			joypadRow0 = false;
			joypadRow1 = false;
		}
Beispiel #16
0
 partial void ResetJoypad()
 {
     baseKeys   = GameBoyKeys.None;
     joypadRow0 = false;
     joypadRow1 = false;
 }