Exemple #1
0
        public GameBoy(string romPath)
        {
            _logger = new Logger();

            _mainMemory    = new MainMemory();
            _dmaController = new DmaController(_mainMemory);

            _timer  = new Timer(_mainMemory);
            _joypad = new Joypad();

            _serialController = new SerialController(_mainMemory);

            _pixelProcessingUnit = new PixelProcessingUnit(_mainMemory, _logger);
            _audioProcessingUnit = new AudioProcessingUnit();

            IRandomAccessMemory mainMemoryProxy = new MainMemoryDmaProxy(_mainMemory, _dmaController);

            _cpuCore = new CpuCore(mainMemoryProxy, new CpuState(), _logger);

            IRomLoader romLoader = new FileRomLoader(romPath);

            _ramManager = new FileRamManager(Path.ChangeExtension(romPath, ".sav"));

            _memoryBankController = MBCFactory.CreateMBC(romLoader);
            _memoryBankController.LoadRam(_ramManager);

            _mainMemory.RegisterMemoryAccessDelegate(_memoryBankController as IMemoryAccessDelegate);
            _mainMemory.RegisterMemoryAccessDelegate(_pixelProcessingUnit);
            _mainMemory.RegisterMemoryAccessDelegate(_timer);
            _mainMemory.RegisterMemoryAccessDelegate(_joypad);
            _mainMemory.RegisterMemoryAccessDelegate(_audioProcessingUnit);
            _mainMemory.RegisterMemoryAccessDelegate(_serialController);
        }
Exemple #2
0
    public void ListScroll(int target, Joypad clickInput, bool clickWithScroll)
    {
        // TODO: Not sure if this code is all correct
        var scroll = CalcScroll(target, CpuRead("wCurrentMenuItem") + CpuRead("wListScrollOffset"), CpuRead("wListCount"), false);

        for (int i = 0; i < scroll.Amount - 1; i++)
        {
            MenuPress(scroll.Input | (Joypad)(((i & 1) + 1) << 4), true);
        }

        byte menuItem           = CpuRead("wCurrentMenuItem");
        bool canClickWithScroll = clickWithScroll && (menuItem == 1 || (menuItem == 0 && scroll.Input == Joypad.Down) || (menuItem == 2 && scroll.Input == Joypad.Down));

        if (scroll.Amount == 0)
        {
            MenuPress(clickInput | Joypad.Left, true);
        }
        else
        {
            if (canClickWithScroll)
            {
                MenuPress(scroll.Input | Joypad.Start, true);
                MenuPress(clickInput, true);
            }
            else
            {
                MenuPress(scroll.Input | clickInput, true);
            }
        }
    }
Exemple #3
0
        private static Emulator Boot()
        {
            var ppuRegs   = new PPURegisters();
            var memoryBus = new MemoryBus(ppuRegs)
            {
                IsBootRomMapped = useBootRom
            };
            //memoryBus.Attach(new GameLinkConsole());
            var ppu = new PPU(ppuRegs, memoryBus);

            ppu.Boot();

            var cpu = new CPU(new Registers(), memoryBus);

            if (!useBootRom)
            {
                cpu.BootWithoutBootRom();
            }

            var rom = Cartridge.LoadFrom(romPath);

            memoryBus.Load(rom);

            var joypad = new Joypad(memoryBus.JoypadRegister);

            return(new Emulator(cpu, ppu, joypad));
        }
Exemple #4
0
    public (Joypad Input, int Amount) CalcScroll(int target, int current, int max, bool wrapping)
    {
        if ((CpuRead(0xfff6 + (this is Yellow ? 4 : 0)) & 0x02) > 0)
        {
            // The move selection is its own thing for some reason, so the input values are wrong have to be adjusted.
            current--;
            max      = CpuRead("wNumMovesMinusOne");
            wrapping = true;
        }

        // The input is either Up or Down depending on whether the 'target' slot is above or below the 'current' slot.
        Joypad scrollInput = target < current ? Joypad.Up : Joypad.Down;
        // The number of inputs needed is the distance between the 'current' slot and the 'target' slot.
        int amount = Math.Abs(current - target);

        // If the menu wraps around, the number of inputs should never exceed half of the menus size.
        if (wrapping && amount > max / 2)
        {
            // If it does exceed, going the other way is fewer inputs.
            amount       = max - amount + 1;
            scrollInput ^= (Joypad)0xc0;  // Switch to the other button. This is achieved by XORing the value by 0xc0.
                                          // (Joypad.Down) 01000000 xor 11000000 = 10000000 (Joypad.Up)
                                          // (Joypad.Up)   10000000 xor 11000000 = 01000000 (Joypad.Down)
        }

        if (amount == 0)
        {
            scrollInput = Joypad.None;
        }

        return(scrollInput, amount);
    }
Exemple #5
0
    public override void ChooseMenuItem(int target, Joypad direction = Joypad.None)
    {
        RunUntil("_Joypad", "HandleMenuInput_.getJoypadState");
        int caller = CpuReadLE <ushort>(SP + 6);

        MenuScroll(target, Joypad.A | direction, !IsYellow && caller != SYM["RedisplayStartMenu.loop"] + 0x3 && caller != (SYM["SelectMenuItem.select"] & 0xffff) + 0x8);
    }
Exemple #6
0
	// Use this for initialization
	void Start () {
		
		// Assignation des joueurs et manettes
		for (int j = 0; j < 4; j++) {
			joypads[j] = new Joypad(j);
		}
	}
Exemple #7
0
 public void AdvanceFrames(int amount, Joypad joypad = Joypad.None)
 {
     for (int i = 0; i < amount; i++)
     {
         AdvanceFrame(joypad);
     }
 }
Exemple #8
0
 // Emulates until the next video frame has to be drawn. Returns the hit address.
 public int AdvanceFrame(Joypad joypad = Joypad.None)
 {
     CurrentJoypad = joypad;
     RunFor(SamplesPerFrame - BufferSamples);
     CurrentJoypad = Joypad.None;
     return(Libgambatte.gambatte_gethitinterruptaddress(Handle));
 }
Exemple #9
0
    public void PlayGambatteMovie(string filename)
    {
        byte[]     file  = File.ReadAllBytes(filename);
        ReadStream movie = new ReadStream(file);

        Debug.Assert(movie.u8() == 0xfe, "The specified file was not a gambatte movie.");
        Debug.Assert(movie.u8() == 0x01, "The specified gambatte movie was of an incorrect version.");

        int stateSize = movie.u24be();

        byte[] state = movie.Read(stateSize);

        LoadState(state);

        while (movie.Position < file.Length)
        {
            long samples = movie.u32be();
            byte input   = movie.u8();

            if (input == 0xff)
            {
                HardReset();
            }
            else
            {
                CurrentJoypad = (Joypad)input;
                while (samples > 0)
                {
                    samples -= RunFor((int)Math.Min(samples, SamplesPerFrame));
                }
            }
        }
    }
Exemple #10
0
        static void Search()
        {
            var controller = Joypad.TryConnect();

            while (controller?.IsConnected() == true)
            {
                if (!IsEmbarkAlive() && IsOpenComboPressed(ref controller))
                {
                    Thread.Sleep(2000);

                    if (IsOpenComboPressed(ref controller))
                    {
                        WiggleMouse();

                        StartEmbark();
                    }
                }
                else if (IsMouseComboPressed(ref controller))
                {
                    Thread.Sleep(2000);

                    if (IsMouseComboPressed(ref controller))
                    {
                        WiggleMouse();

                        while (IsMouseComboPressed(ref controller)) /*wait*/ } {
                        StartMouseMode(ref controller);
                }
            }

            Thread.Sleep(200);     // loop until disconnect
        }

        controller = null;
    }
        public bool LoadState(string FilePath, NES nes)
        {
            try
            {
                if (File.Exists(FilePath))
                {
                    nes.PAUSE = true;
                    while (!nes.paused)
                    {
                    }

                    //Backups
                    byte[][]       prg   = nes.Memory.Cartridge.PRG;
                    byte[][]       chr   = nes.Memory.Cartridge.CHR;
                    IGraphicDevice video = nes.PPU.VIDEO;

                    /*Control _Control = nes.APU._Control;
                     * DirectSound _SoundDevice = nes.APU._SoundDevice;
                     * SecondarySoundBuffer buffer = nes.APU.buffer;*/
                    byte[]       DATA         = nes.APU.DATA;
                    InputManager InputManager = nes.Memory.InputManager;
                    Joypad       Joypad1      = nes.Memory.Joypad1;
                    Joypad       Joypad2      = nes.Memory.Joypad2;
                    string       RomPath      = nes.Memory.Cartridge.RomPath;
                    //Do it

                    /*FileStream fs = new FileStream(FilePath, FileMode.Open);
                     * BinaryFormatter formatter = new BinaryFormatter();
                     * NES _Nes = (NES)formatter.Deserialize(fs);
                     * fs.Close();*/

                    /*nes.APU = _Nes.APU;
                     * nes.APU._Control = _Control;
                     * nes.APU._SoundDevice = _SoundDevice;
                     * nes.APU.DATA = DATA;
                     * nes.APU.buffer = buffer;
                     * nes.CPU = _Nes.CPU;
                     * nes.Memory = _Nes.Memory;
                     * nes.Memory.Cartridge.PRG = prg;*/
                    //If not vram, simply load back CHRs
                    if (!nes.Memory.Cartridge.IsVRAM)
                    {
                        nes.Memory.Cartridge.CHR = chr;
                    }
                    nes.Memory.Cartridge.RomPath = RomPath;
                    nes.Memory.InputManager      = InputManager;
                    nes.Memory.Joypad1           = Joypad1;
                    nes.Memory.Joypad2           = Joypad2;
                    //nes.PPU = _Nes.PPU;
                    nes.PPU.Timer = new TIMER();
                    nes.PPU.VIDEO = video;
                    nes.PAUSE     = false;
                    return(true);
                }
                nes.PAUSE = false;
                return(false);
            }
            catch { nes.PAUSE = false; return(false); };
        }
Exemple #12
0
    public void Update()
    {
        //Update nécessaire pour le fonctionnement des Joypad
        Joypad.UpdateAll();

        // Mise à jour de la position des nuages
        UpdateClouds(Time.deltaTime);
    }
Exemple #13
0
 // Use this for initialization
 void Start()
 {
     // Assignation des joueurs et manettes
     for (int j = 0; j < 4; j++)
     {
         joypads[j] = new Joypad(j);
     }
 }
Exemple #14
0
    // Emulates until the next video frame has to be drawn. Returns the hit address.
    public int AdvanceFrame(Joypad joypad = Joypad.None)
    {
        CurrentJoypad = joypad;
        int hitaddress = RunFor(SamplesPerFrame - BufferSamples);

        CurrentJoypad = Joypad.None;
        return(hitaddress);
    }
Exemple #15
0
 public CpuBus(byte[] programRom, Ppu ppu, Joypad joypad, DMA dma, Func <int> cpuMasterClockCyclesAction)
 {
     _programRom           = programRom;
     _ppu                  = ppu;
     _joypad               = joypad;
     _dma                  = dma;
     _cpuMasterClockCycles = cpuMasterClockCyclesAction;
 }
Exemple #16
0
    void OnPlayerJoinDone(string data)
    {
        string[] dataSplit = data.Split('|');

        // player_join_done:0|大中天|10|1.2,1.2,1.2|0,0,0|1,1,1
        int     playerId    = int.Parse(dataSplit[0]);
        string  playerName  = dataSplit[1];
        float   playerHp    = float.Parse(dataSplit[2]);
        Vector3 playerPos   = connectionAgent.ParseStringToVector(dataSplit[3]);
        Vector3 playerEuler = connectionAgent.ParseStringToVector(dataSplit[4]);
        Vector3 playerScale = connectionAgent.ParseStringToVector(dataSplit[5]);

        Player newPlayer = GameObject.Instantiate(playerPrefab);

        newPlayer.playerId             = playerId;
        newPlayer.playerName           = playerName;
        newPlayer.playerHp             = playerHp;
        newPlayer.transform.position   = playerPos;
        newPlayer.transform.rotation   = Quaternion.Euler(playerEuler);
        newPlayer.transform.localScale = playerScale;

        if (newPlayer.playerId == mySocketId)
        {
            if (me != null)
            {
                GameObject.Destroy(me.gameObject);
            }
            me = newPlayer;

            me.gameObject.AddComponent <PlayerGravity>();
            me.name = "ME";

            SyncTransformToEveryone nst = me.gameObject.AddComponent <SyncTransformToEveryone>();
            nst.Init(newPlayer.playerId, connectionAgent);

            PlayerMove pm     = me.gameObject.GetComponent <PlayerMove>();
            Joypad     joypad = GameObject.FindObjectOfType <Joypad>();
            joypad.onPointerEventW.onPress.AddListener(pm.GoForward);
            joypad.onPointerEventS.onPress.AddListener(pm.GoBackward);
            joypad.onPointerEventA.onPress.AddListener(pm.GoLeft);
            joypad.onPointerEventD.onPress.AddListener(pm.GoRight);
            joypad.onPointerEventQ.onPress.AddListener(pm.TurnLeft);
            joypad.onPointerEventE.onPress.AddListener(pm.TurnRight);
            joypad.testAutoPlay = autoPlay;
        }
        else
        {
            GameObject.Destroy(newPlayer.GetComponentInChildren <AudioListener>());
            GameObject.Destroy(newPlayer.GetComponentInChildren <FlareLayer>());
            GameObject.Destroy(newPlayer.GetComponentInChildren <Camera>());
            newPlayer.gameObject.GetComponent <PlayerMove>().enabled          = false;
            newPlayer.gameObject.GetComponent <CharacterController>().enabled = false;

            newPlayer.gameObject.AddComponent <LerpPosition>();
        }

        playersInScene.Add(newPlayer);
    }
Exemple #17
0
 public void FastOptions(Joypad joypad)
 {
     if (CurrentMenuType == MenuType.Options)
     {
         return;
     }
     OpenStartMenu();
     ChooseMenuItem(4 + StartMenuOffset(), joypad);
     CurrentMenuType = MenuType.Options;
 }
Exemple #18
0
    // Executes the specified button presses while respecting consecutive input lag.
    public void MenuPress(Joypad joypad, bool doubleInput = false)
    {
        Joypad lastInput = (Joypad)CpuRead("hJoyLast");

        if ((doubleInput && lastInput == joypad) || (!doubleInput && (lastInput & joypad) > 0))
        {
            Press(Joypad.None);
        }
        Press(joypad);
    }
Exemple #19
0
    /**
     * Démarrage d'une partie
     */
    public void Start()
    {
        for (int i = 0; i < 4; i++)
        {
            joypads[i] = new Joypad(i);
        }

        // Lancement d'une partie
        game = ExecGame.MakeExecGame();
    }
Exemple #20
0
	/**
	 * Démarrage d'une partie
	 */
	public void Start() {
		
		for (int i = 0; i < 4; i++) {
			joypads[i] = new Joypad(i);
		}
		
		// Lancement d'une partie
		game = ExecGame.MakeExecGame();
		
	}
        private new void Update()
        {
            if (_currentlyUpdating)
            {
                return;
            }

            _currentlyUpdating = true;

            //Save State Path
            _currentFrame++;
            string path = @"C:\Users\ericm\source\repos\MachineGaming\BizHawk\SNES\State\YoshisIsland1.State";

            if ((_currentFrame % 5) == 0)
            {
                //Refesh Inputs
                _inputCollector.RefreshInputs(_inputs);
                _engine.populateInputs(_inputs);

                _engine.activateCurrent();

                //Collect Output
                _engine.retrieveOutputs(_outputs);
            }

            //Update Controller
            ClearController();
            Joypad.Set("P1 Right", true);

            //Update Game Run Tracking
            if (_inputCollector.CharX > _maxX)
            {
                _maxX    = _inputCollector.CharX;
                _timeout = TIMEOUT;
            }
            _timeout--;

            if (_timeout <= 0 || _inputCollector.LevelStatus == 9)
            {
                if (_engine.nextGenome()) //Load game and run next genome
                {
                    Debug.Print(_engine.getGenomeDetail());
                    SaveStateApi.Load(path);
                    _inputCollector.RefreshInputs(_inputs);
                    _timeout      = TIMEOUT;
                    _currentFrame = 0;
                    _maxX         = 0;
                }
                else //Population has been fully explored.
                {
                }
            }

            _currentlyUpdating = false;
        }
        private void ClearController()
        {
            var controls = Emulator.ControllerDefinition.ControlsOrdered.GetEnumerator();

            controls.MoveNext(); //Skip Console Controls
            controls.MoveNext(); //Move to player 1 buttons.

            foreach (string button in controls.Current)
            {
                Joypad.Set(button, false);
            }
        }
Exemple #23
0
    public void Update()
    {
        currentTime += Time.deltaTime;
        // Update nécessaire pour le fonctionnement des Joypad
        Joypad.UpdateAll();

        // On est dans le menu principal
        if (menuMask.activeSelf)
        {
            foreach (Joypad joypad in joypads)
            {
                if (joypad.IsDown("Right"))
                {
                    if (currentButton == buttonCommencer)
                    {
                        SetActiveButton(buttonTutoriel);
                    }
                    else
                    {
                        SetActiveButton(buttonQuitter);
                    }
                }
                else if (joypad.IsDown("Left"))
                {
                    if (currentButton == buttonQuitter)
                    {
                        SetActiveButton(buttonTutoriel);
                    }
                    else
                    {
                        SetActiveButton(buttonCommencer);
                    }
                }
                else if (joypad.IsDown("A"))
                {
                    if (currentButton == buttonCommencer)
                    {
                        StartLevel();
                    }
                    else if (currentButton == buttonTutoriel)
                    {
                        StartTuto();
                    }
                    else
                    {
                        CloseGame();
                    }
                }
            }
        }

        UpdateClouds(Time.deltaTime);
    }
Exemple #24
0
    void Start()
    {
        tutorialMask = GameObject.Find("Tutorial");
        tutorialMask.SetActive(false);

        menuMask = GameObject.Find("MenuMask");
        menuMask.SetActive(true);

        buttonsGroup = GameObject.Find("Boutons");
        buttonsGroup.SetActive(false);

        subtitle = GameObject.Find("Subtitle");
        subtitle.SetActive(false);

        introText1 = GameObject.Find("Texte1");
        introText2 = GameObject.Find("Texte2");
        title      = GameObject.Find("MainTitle");

        titleStartPosition = title.transform.position;
        titleEndPosition   = new Vector3(0, 45, 0);

        introText1.SetActive(false);
        introText2.SetActive(false);

        if (introText1.activeSelf == false)
        {
            StartCoroutine(introCine());
        }

        for (int i = 0; i < 4; i++)
        {
            joypads[i] = new Joypad(i);
        }



        // Tableau des prefabs
        prefabs = new Dictionary <string, GameObject>();

        // Chargement des prefabs des nuages
        clouds = GameObject.Find("Clouds");
        for (int i = 0; i < 3; i++)
        {
            prefabs.Add("Cloud" + i, Resources.Load("Clouds/Cloud" + i, typeof(GameObject)) as GameObject);
        }

        // Boutons du menu
        var buttonsTransf = GameObject.Find("MenuMask").transform.Find("Boutons").gameObject.transform;

        buttonCommencer = buttonsTransf.Find("ButtonCommencer/Hover").gameObject;
        buttonTutoriel  = buttonsTransf.Find("ButtonTutoriel/Hover").gameObject;
        buttonQuitter   = buttonsTransf.Find("ButtonQuitter/Hover").gameObject;
    }
Exemple #25
0
        public GameBoy(string rom)
        {
            this.cart = new Cartridge(rom);
            //build the hardware and load the cartridge/

            this.clock       = new Clock();
            this.ppu         = new PPU(clock);
            this.JoyPad      = new Joypad();
            this.sound       = new Sound(clock);
            this.memory      = new MMU(this.cart, this.ppu, this.clock, sound, JoyPad);
            this.cpu         = new CPU(this.memory, clock);
            this.PowerSwitch = true;
        }
Exemple #26
0
	void Start() {

		tutorialMask = GameObject.Find("Tutorial");
		tutorialMask.SetActive(false);
		
		menuMask = GameObject.Find("MenuMask");
		menuMask.SetActive(true);

		buttonsGroup = GameObject.Find ("Boutons");
		buttonsGroup.SetActive (false);

		subtitle = GameObject.Find ("Subtitle");
		subtitle.SetActive (false);

		introText1 = GameObject.Find ("Texte1");
		introText2 = GameObject.Find ("Texte2");
		title = GameObject.Find ("MainTitle");

		titleStartPosition = title.transform.position;
		titleEndPosition = new Vector3 (0, 45, 0);

		introText1.SetActive (false);
		introText2.SetActive (false);

		if (introText1.activeSelf == false) {
			StartCoroutine(introCine ());
		}
		
		for (int i = 0; i < 4; i++) {
			joypads[i] = new Joypad(i);
		}
		
		

		
		
		// Tableau des prefabs
		prefabs = new Dictionary<string, GameObject>();
		
		// Chargement des prefabs des nuages
		clouds = GameObject.Find("Clouds");
		for (int i = 0; i < 3; i++) {
			prefabs.Add("Cloud" + i, Resources.Load("Clouds/Cloud" + i, typeof(GameObject)) as GameObject);
		}
		
		// Boutons du menu
		var buttonsTransf = GameObject.Find("MenuMask").transform.Find("Boutons").gameObject.transform;
		buttonCommencer = buttonsTransf.Find("ButtonCommencer/Hover").gameObject;
		buttonTutoriel = buttonsTransf.Find("ButtonTutoriel/Hover").gameObject;
		buttonQuitter = buttonsTransf.Find("ButtonQuitter/Hover").gameObject;
	}
Exemple #27
0
    public override int Execute(params Action[] actions)
    {
        int ret = 0;

        foreach (Action action in actions)
        {
            switch (action & ~Action.A)
            {
            case Action.Right:
            case Action.Left:
            case Action.Up:
            case Action.Down:
                Joypad input = (Joypad)action;
                RunUntil("OWPlayerInput");
                InjectOverworld(input);
                ret = Hold(input, "CountStep", "RandomEncounter.ok", "PrintLetterDelay.checkjoypad", "DoPlayerMovement.BumpSound");
                if (ret == SYM["CountStep"])
                {
                    ret = Hold(input, "OWPlayerInput", "RandomEncounter.ok");
                }

                if (ret != SYM["OWPlayerInput"])
                {
                    return(ret);
                }

                InjectOverworld(Joypad.None);
                break;

            case Action.StartB:
                InjectOverworld(Joypad.Start);
                AdvanceFrame(Joypad.Start);
                Hold(Joypad.B, "GetJoypad");
                Inject(Joypad.B);
                ret = Hold(Joypad.B, "OWPlayerInput");
                break;

            case Action.Select:
                InjectOverworld(Joypad.Select);
                AdvanceFrame(Joypad.Select);
                ret = Hold(Joypad.Select, "OWPlayerInput");
                break;

            default:
                break;
            }
        }

        return(ret);
    }
Exemple #28
0
        public Joypad ConfigureJoypad(KeyboardState keyboardState, GameControllerManager gameControllerManager)
        {
            Joypad joypad = new Joypad();

            joypad.Start  = DecodeMapping(Start, keyboardState, gameControllerManager);
            joypad.Select = DecodeMapping(Select, keyboardState, gameControllerManager);
            joypad.A      = DecodeMapping(A, keyboardState, gameControllerManager);
            joypad.B      = DecodeMapping(B, keyboardState, gameControllerManager);
            joypad.Up     = DecodeMapping(Up, keyboardState, gameControllerManager);
            joypad.Down   = DecodeMapping(Down, keyboardState, gameControllerManager);
            joypad.Left   = DecodeMapping(Left, keyboardState, gameControllerManager);
            joypad.Right  = DecodeMapping(Right, keyboardState, gameControllerManager);
            return(joypad);
        }
Exemple #29
0
    // Emulates while holding the specified input until the program counter hits one of the specified breakpoints.
    public unsafe virtual int Hold(Joypad joypad, params int[] addrs)
    {
        fixed(int *addrPtr = addrs)   // Note: Not fixing the pointer causes an AccessValidationException.
        {
            Libgambatte.gambatte_setinterruptaddresses(Handle, addrPtr, addrs.Length);
            int hitaddress;

            do
            {
                hitaddress = AdvanceFrame(joypad);
            } while(Array.IndexOf(addrs, hitaddress) == -1);
            Libgambatte.gambatte_setinterruptaddresses(Handle, null, 0);
            return(hitaddress);
        }
    }
Exemple #30
0
    static void StartMouseMode(ref Joypad controller)
    {
        var isClicked = false;

        while (!IsMouseComboPressed(ref controller))
        {
            Thread.Sleep(20);

            var buttons = controller.GetInput();

            if (!isClicked && buttons.A)
            {
                mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                isClicked = true;
            }
            else if (isClicked && !buttons.A)
            {
                mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                isClicked = false;
            }

            if (!IsEmbarkAlive() && buttons.Start && buttons.Select)
            {
                Thread.Sleep(2000);

                if (buttons.Start && buttons.Select)
                {
                    WiggleMouse();

                    StartEmbark();
                }
            }

            if (Math.Abs(buttons.XAxis) < 3000 &&
                Math.Abs(buttons.YAxis) < 3000)
            {
                continue;
            }


            var x = (int)((double)buttons.XAxis * 0.0005);
            var y = (int)((double)-buttons.YAxis * 0.0005);

            Cursor.Position = new Point(Cursor.Position.X + x, Cursor.Position.Y + y);
        }
    }
Exemple #31
0
    public void MenuScroll(int target, Joypad clickInput, bool clickWithScroll)
    {
        var scroll = CalcScroll(target, CpuRead("wCurrentMenuItem"), CpuRead("wMaxMenuItem"), CpuRead("wMenuWrappingEnabled") > 0);

        if (clickWithScroll)
        {
            scroll.Amount--;
            clickInput |= scroll.Input;
        }

        for (int i = 0; i < scroll.Amount; i++)
        {
            MenuPress(scroll.Input);
        }

        MenuPress(clickInput);
    }
Exemple #32
0
 public override void Press(params Joypad[] joypads)
 {
     for (int i = 0; i < joypads.Length; i++)
     {
         Joypad joypad = joypads[i];
         if (Registers.PC == (SYM["OWPlayerInput"] & 0xffff))
         {
             InjectOverworld(joypad);
             Hold(joypad, "GetJoypad");
         }
         else
         {
             Hold(joypad, SYM["GetJoypad"] + 0x7);
             Inject(joypad);
             AdvanceFrame(joypad);
         }
     }
 }
Exemple #33
0
                public EmuGB(ConfigsGB aConfigs)
                {
                    m_configs = aConfigs;

                    m_cpu = new CPU();
                    m_ppu = new PPU();
                    m_apu = new APU();

                    m_mem             = new MEM();
                    m_dmaController   = new DMAController();
                    m_timerController = new TimerController();

                    m_joypad = new Joypad();

                    m_serialIO = new SerialIO();

                    // Start paused
                    m_paused = true;

                    // Temp binding
                    DrawDisplay     = (aPPU) => { };
                    DrawDisplayLine = (aPPU, aScanline) => { };


                    m_mem.AttachCPU(m_cpu);
                    m_mem.AttachPPU(m_ppu);
                    m_mem.AttachAPU(m_apu);
                    m_mem.AttachDMAController(m_dmaController);
                    m_mem.AttachTimerController(m_timerController);
                    m_mem.AttachJoypad(m_joypad);
                    m_mem.AttachSerialIO(m_serialIO);
                    m_cpu.ProcessorState.BindCyclesStep(m_ppu.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_apu.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_dmaController.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_timerController.CyclesStep);
                    m_cpu.ProcessorState.BindCyclesStep(m_serialIO.CyclesStep);

                    m_ppu.BindRequestIRQ(m_cpu.RequestIRQ);
                    m_timerController.BindRequestIRQ(m_cpu.RequestIRQ);
                    m_joypad.BindRequestIRQ(m_cpu.RequestIRQ);
                    m_serialIO.BindRequestIRQ(m_cpu.RequestIRQ);
                    //m_ppu.BindDrawDisplayLine(DrawDisplayLine);
                }
 public void LoadButtons( Joypad joypad )
 {
     buttonNotFoundedCOUNT=0;
      if(joypad==Joypad.Joypad1){
          Joy1ButtonA=LoadButton("Joy1ButtonA",joypad);
          Joy1ButtonB=LoadButton("Joy1ButtonB",joypad);
          Joy1ButtonX=LoadButton("Joy1ButtonX",joypad);
          Joy1ButtonY=LoadButton("Joy1ButtonY",joypad);
          Joy1ButtonL1=LoadButton("Joy1ButtonL1",joypad);
          Joy1ButtonL2=LoadButton("Joy1ButtonL2",joypad);
          Joy1ButtonR1=LoadButton("Joy1ButtonR1",joypad);
          Joy1ButtonR2=LoadButton("Joy1ButtonR2",joypad);
          Joy1ButtonStart=LoadButton("Joy1ButtonStart",joypad);
          Joy1ButtonSelect=LoadButton("Joy1ButtonSelect",joypad);
          }
      else if(joypad==Joypad.Joypad2){
          Joy2ButtonA=LoadButton("Joy2ButtonA",joypad);
          Joy2ButtonB=LoadButton("Joy2ButtonB",joypad);
          Joy2ButtonX=LoadButton("Joy2ButtonX",joypad);
          Joy2ButtonY=LoadButton("Joy2ButtonY",joypad);
          Joy2ButtonL1=LoadButton("Joy2ButtonL1",joypad);
          Joy2ButtonL2=LoadButton("Joy2ButtonL2",joypad);
          Joy2ButtonR1=LoadButton("Joy2ButtonR1",joypad);
          Joy2ButtonR2=LoadButton("Joy2ButtonR2",joypad);
          Joy2ButtonStart=LoadButton("Joy2ButtonStart",joypad);
          Joy2ButtonSelect=LoadButton("Joy2ButtonSelect",joypad);
          }
      else if(joypad==Joypad.Joypad3){
          Joy3ButtonA=LoadButton("Joy3ButtonA",joypad);
          Joy3ButtonB=LoadButton("Joy3ButtonB",joypad);
          Joy3ButtonX=LoadButton("Joy3ButtonX",joypad);
          Joy3ButtonY=LoadButton("Joy3ButtonY",joypad);
          Joy3ButtonL1=LoadButton("Joy3ButtonL1",joypad);
          Joy3ButtonL2=LoadButton("Joy3ButtonL2",joypad);
          Joy3ButtonR1=LoadButton("Joy3ButtonR1",joypad);
          Joy3ButtonR2=LoadButton("Joy3ButtonR2",joypad);
          Joy3ButtonStart=LoadButton("Joy3ButtonStart",joypad);
          Joy3ButtonSelect=LoadButton("Joy3ButtonSelect",joypad);
          }
      else if(joypad==Joypad.Joypad4){
          Joy4ButtonA=LoadButton("Joy4ButtonA",joypad);
          Joy4ButtonB=LoadButton("Joy4ButtonB",joypad);
          Joy4ButtonX=LoadButton("Joy4ButtonX",joypad);
          Joy4ButtonY=LoadButton("Joy4ButtonY",joypad);
          Joy4ButtonL1=LoadButton("Joy4ButtonL1",joypad);
          Joy4ButtonL2=LoadButton("Joy4ButtonL2",joypad);
          Joy4ButtonR1=LoadButton("Joy4ButtonR1",joypad);
          Joy4ButtonR2=LoadButton("Joy4ButtonR2",joypad);
          Joy4ButtonStart=LoadButton("Joy4ButtonStart",joypad);
          Joy4ButtonSelect=LoadButton("Joy4ButtonSelect",joypad);
          }
 }
 public void ResetDefaultButton( Joypad JoyX )
 {
     if(JoyX==Joypad.Joypad1){
          Joy1ButtonA=KeyCode.Joystick1Button0;
          Joy1ButtonB=KeyCode.Joystick1Button1;
          Joy1ButtonX=KeyCode.Joystick1Button2;
          Joy1ButtonY=KeyCode.Joystick1Button3;
          Joy1ButtonL1=KeyCode.Joystick1Button4;
          Joy1ButtonL2=KeyCode.Joystick1Button6;
          Joy1ButtonR1=KeyCode.Joystick1Button5;
          Joy1ButtonR2=KeyCode.Joystick1Button7;
          Joy1ButtonStart=KeyCode.Joystick1Button9;
          Joy1ButtonSelect=KeyCode.Joystick1Button8;
          }
      else if(JoyX==Joypad.Joypad2){
          Joy2ButtonA=KeyCode.Joystick2Button0;
          Joy2ButtonB=KeyCode.Joystick2Button1;
          Joy2ButtonX=KeyCode.Joystick2Button2;
          Joy2ButtonY=KeyCode.Joystick2Button3;
          Joy2ButtonL1=KeyCode.Joystick2Button4;
          Joy2ButtonL2=KeyCode.Joystick2Button6;
          Joy2ButtonR1=KeyCode.Joystick2Button5;
          Joy2ButtonR2=KeyCode.Joystick2Button7;
          Joy2ButtonStart=KeyCode.Joystick2Button9;
          Joy2ButtonSelect=KeyCode.Joystick2Button8;
          }
      else if(JoyX==Joypad.Joypad3){
          Joy3ButtonA=KeyCode.Joystick3Button0;
          Joy3ButtonB=KeyCode.Joystick3Button1;
          Joy3ButtonX=KeyCode.Joystick3Button2;
          Joy3ButtonY=KeyCode.Joystick3Button3;
          Joy3ButtonL1=KeyCode.Joystick3Button4;
          Joy3ButtonL2=KeyCode.Joystick3Button6;
          Joy3ButtonR1=KeyCode.Joystick3Button5;
          Joy3ButtonR2=KeyCode.Joystick3Button7;
          Joy3ButtonStart=KeyCode.Joystick3Button9;
          Joy3ButtonSelect=KeyCode.Joystick3Button8;
          }
      else if(JoyX==Joypad.Joypad4){
          Joy4ButtonA=KeyCode.Joystick4Button0;
          Joy4ButtonB=KeyCode.Joystick4Button1;
          Joy4ButtonX=KeyCode.Joystick4Button2;
          Joy4ButtonY=KeyCode.Joystick4Button3;
          Joy4ButtonL1=KeyCode.Joystick4Button4;
          Joy4ButtonL2=KeyCode.Joystick4Button6;
          Joy4ButtonR1=KeyCode.Joystick4Button5;
          Joy4ButtonR2=KeyCode.Joystick4Button7;
          Joy4ButtonStart=KeyCode.Joystick4Button9;
          Joy4ButtonSelect=KeyCode.Joystick4Button8;
          }
 }
 public void saveButtons( Joypad joypad )
 {
     if(joypad==Joypad.Joypad1){
          saveButton("Joy1ButtonA",Joy1ButtonA);
          saveButton("Joy1ButtonB",Joy1ButtonB);
          saveButton("Joy1ButtonX",Joy1ButtonX);
          saveButton("Joy1ButtonY",Joy1ButtonY);
          saveButton("Joy1ButtonL1",Joy1ButtonL1);
          saveButton("Joy1ButtonL2",Joy1ButtonL2);
          saveButton("Joy1ButtonR1",Joy1ButtonR1);
          saveButton("Joy1ButtonR2",Joy1ButtonR2);
          saveButton("Joy1ButtonStart",Joy1ButtonStart);
          saveButton("Joy1ButtonSelect",Joy1ButtonSelect);
          PlayerPrefs.Save();
          }
      else if(joypad==Joypad.Joypad2){
          saveButton("Joy2ButtonA",Joy2ButtonA);
          saveButton("Joy2ButtonB",Joy2ButtonB);
          saveButton("Joy2ButtonX",Joy2ButtonX);
          saveButton("Joy2ButtonY",Joy2ButtonY);
          saveButton("Joy2ButtonL1",Joy2ButtonL1);
          saveButton("Joy2ButtonL2",Joy2ButtonL2);
          saveButton("Joy2ButtonR1",Joy2ButtonR1);
          saveButton("Joy2ButtonR2",Joy2ButtonR2);
          saveButton("Joy2ButtonStart",Joy2ButtonStart);
          saveButton("Joy2ButtonSelect",Joy2ButtonSelect);
          PlayerPrefs.Save();
          }
      else if(joypad==Joypad.Joypad3){
          saveButton("Joy3ButtonA",Joy3ButtonA);
          saveButton("Joy3ButtonB",Joy3ButtonB);
          saveButton("Joy3ButtonX",Joy3ButtonX);
          saveButton("Joy3ButtonY",Joy3ButtonY);
          saveButton("Joy3ButtonL1",Joy3ButtonL1);
          saveButton("Joy3ButtonL2",Joy3ButtonL2);
          saveButton("Joy3ButtonR1",Joy3ButtonR1);
          saveButton("Joy3ButtonR2",Joy3ButtonR2);
          saveButton("Joy3ButtonStart",Joy3ButtonStart);
          saveButton("Joy3ButtonSelect",Joy3ButtonSelect);
          PlayerPrefs.Save();
          }
      else if(joypad==Joypad.Joypad4){
          saveButton("Joy4ButtonA",Joy4ButtonA);
          saveButton("Joy4ButtonB",Joy4ButtonB);
          saveButton("Joy4ButtonX",Joy4ButtonX);
          saveButton("Joy4ButtonY",Joy4ButtonY);
          saveButton("Joy4ButtonL1",Joy4ButtonL1);
          saveButton("Joy4ButtonL2",Joy4ButtonL2);
          saveButton("Joy4ButtonR1",Joy4ButtonR1);
          saveButton("Joy4ButtonR2",Joy4ButtonR2);
          saveButton("Joy4ButtonStart",Joy4ButtonStart);
          saveButton("Joy4ButtonSelect",Joy4ButtonSelect);
          PlayerPrefs.Save();
          }
 }
Exemple #37
0
 public void KeyUp(Joypad input)
 {
 }
Exemple #38
0
 // http://problemkaputt.de/pandocs.htm#joypadinput
 public void KeyDown(Joypad input)
 {
 }
 public void initPlayerButtons( Joypad joypad )
 {
     LoadButtons(joypad);
     if(buttonNotFoundedCOUNT > 2){
         ResetDefaultButton(joypad);
     }
      if(joypad==Joypad.Joypad1){
          Vertical="Joy1X";
          Horizontal="Joy1Y";
          ButtonA=Joy1ButtonA;
          ButtonB=Joy1ButtonB;
          ButtonX=Joy1ButtonX;
          ButtonY=Joy1ButtonY;
          ButtonL1=Joy1ButtonL1;
          ButtonL2=Joy1ButtonL2;
          ButtonR1=Joy1ButtonR1;
          ButtonR2=Joy1ButtonR2;
          ButtonStart=Joy1ButtonStart;
          ButtonSelect=Joy1ButtonSelect;
          }
      else if(joypad==Joypad.Joypad2){
          Vertical="Joy2X";
          Horizontal="Joy2Y";
          ButtonA=Joy2ButtonA;
          ButtonB=Joy2ButtonB;
          ButtonX=Joy2ButtonX;
          ButtonY=Joy2ButtonY;
          ButtonL1=Joy2ButtonL1;
          ButtonL2=Joy2ButtonL2;
          ButtonR1=Joy2ButtonR1;
          ButtonR2=Joy2ButtonR2;
          ButtonStart=Joy2ButtonStart;
          ButtonSelect=Joy2ButtonSelect;
          }
      else if(joypad==Joypad.Joypad3){
          Vertical="Joy3X";
          Horizontal="Joy3Y";
          ButtonA=Joy3ButtonA;
          ButtonB=Joy3ButtonB;
          ButtonX=Joy3ButtonX;
          ButtonY=Joy3ButtonY;
          ButtonL1=Joy3ButtonL1;
          ButtonL2=Joy3ButtonL2;
          ButtonR1=Joy3ButtonR1;
          ButtonR2=Joy3ButtonR2;
          ButtonStart=Joy3ButtonStart;
          ButtonSelect=Joy3ButtonSelect;
          }
      else if(joypad==Joypad.Joypad4){
          Vertical="Joy4X";
          Horizontal="Joy4Y";
          ButtonA=Joy4ButtonA;
          ButtonB=Joy4ButtonB;
          ButtonX=Joy4ButtonX;
          ButtonY=Joy4ButtonY;
          ButtonL1=Joy4ButtonL1;
          ButtonL2=Joy4ButtonL2;
          ButtonR1=Joy4ButtonR1;
          ButtonR2=Joy4ButtonR2;
          ButtonStart=Joy4ButtonStart;
          ButtonSelect=Joy4ButtonSelect;
          }
 }
 public bool getJoystickButton( Joypad joypad , JoyButton joyButton )
 {
     bool waitButton=false;
      waitButtonDelay=0.6f;
      if(joypad==Joypad.Joypad1){
          switch(joyButton){
              case JoyButton.ButtonA: Joy1ButtonA=getJoystick1Button();
              if(Joy1ButtonA != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonB: Joy1ButtonB=getJoystick1Button();
              if(Joy1ButtonB != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonX: Joy1ButtonX=getJoystick1Button();
              if(Joy1ButtonX != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonY: Joy1ButtonY=getJoystick1Button();
              if(Joy1ButtonY != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL1: Joy1ButtonL1=getJoystick1Button();
              if(Joy1ButtonL1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL2: Joy1ButtonL2=getJoystick1Button();
              if(Joy1ButtonL2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR1: Joy1ButtonR1=getJoystick1Button();
              if(Joy1ButtonR1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR2: Joy1ButtonR2=getJoystick1Button();
              if(Joy1ButtonR2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonStart: Joy1ButtonStart=getJoystick1Button();
              if(Joy1ButtonStart != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonSelect: Joy1ButtonSelect=getJoystick1Button();
              if(Joy1ButtonSelect != KeyCode.None)waitButton=true;
              break;
              }
          }
      else if(joypad==Joypad.Joypad2){
          switch(joyButton){
              case JoyButton.ButtonA: Joy2ButtonA=getJoystick2Button();
              if(Joy2ButtonA != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonB: Joy2ButtonB=getJoystick2Button();
              if(Joy2ButtonB != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonX: Joy2ButtonX=getJoystick2Button();
              if(Joy2ButtonX != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonY: Joy2ButtonY=getJoystick2Button();
              if(Joy2ButtonY != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL1: Joy2ButtonL1=getJoystick2Button();
              if(Joy2ButtonL1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL2: Joy2ButtonL2=getJoystick2Button();
              if(Joy2ButtonL2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR1: Joy2ButtonR1=getJoystick2Button();
              if(Joy2ButtonR1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR2: Joy2ButtonR2=getJoystick2Button();
              if(Joy2ButtonR2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonStart: Joy2ButtonStart=getJoystick2Button();
              if(Joy2ButtonStart != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonSelect: Joy2ButtonSelect=getJoystick2Button();
              if(Joy2ButtonSelect != KeyCode.None)waitButton=true;
              break;
              }
          }
      else if(joypad==Joypad.Joypad3){
          switch(joyButton){
              case JoyButton.ButtonA: Joy3ButtonA=getJoystick3Button();
              if(Joy3ButtonA != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonB: Joy3ButtonB=getJoystick3Button();
              if(Joy3ButtonB != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonX: Joy3ButtonX=getJoystick3Button();
              if(Joy3ButtonX != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonY: Joy3ButtonY=getJoystick3Button();
              if(Joy3ButtonY != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL1: Joy3ButtonL1=getJoystick3Button();
              if(Joy3ButtonL1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL2: Joy3ButtonL2=getJoystick3Button();
              if(Joy3ButtonL2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR1: Joy3ButtonR1=getJoystick3Button();
              if(Joy3ButtonR1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR2: Joy3ButtonR2=getJoystick3Button();
              if(Joy3ButtonR2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonStart: Joy3ButtonStart=getJoystick3Button();
              if(Joy3ButtonStart != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonSelect: Joy3ButtonSelect=getJoystick3Button();
              if(Joy3ButtonSelect != KeyCode.None)waitButton=true;
              break;
              }
          }
      else if(joypad==Joypad.Joypad4){
          switch(joyButton){
              case JoyButton.ButtonA: Joy4ButtonA=getJoystick4Button();
              if(Joy4ButtonA != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonB: Joy4ButtonB=getJoystick4Button();
              if(Joy4ButtonB != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonX: Joy4ButtonX=getJoystick4Button();
              if(Joy4ButtonX != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonY: Joy4ButtonY=getJoystick4Button();
              if(Joy4ButtonY != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL1: Joy4ButtonL1=getJoystick4Button();
              if(Joy4ButtonL1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonL2: Joy4ButtonL2=getJoystick4Button();
              if(Joy4ButtonL2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR1: Joy4ButtonR1=getJoystick4Button();
              if(Joy4ButtonR1 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonR2: Joy4ButtonR2=getJoystick4Button();
              if(Joy4ButtonR2 != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonStart: Joy4ButtonStart=getJoystick4Button();
              if(Joy4ButtonStart != KeyCode.None)waitButton=true;
              break;
              case JoyButton.ButtonSelect: Joy4ButtonSelect=getJoystick4Button();
              if(Joy4ButtonSelect != KeyCode.None)waitButton=true;
              break;
              }
          }
      return waitButton;
 }
Exemple #41
0
        public void InitializeEngine()
        {
            myCartridge = new NesCartridge();
            my6502 = new ProcessorNes6502(this);
            myMapper = new Mapper(this, myCartridge);
            myPpu = new Ppu(this);
            myJoypad = new Joypad();

            scratchRam = new byte[4][];
            scratchRam[0] = new byte[0x800];
            scratchRam[1] = new byte[0x800];
            scratchRam[2] = new byte[0x800];
            scratchRam[3] = new byte[0x800];
            saveRam = new byte[0x2000];

            isSaveRamReadOnly = false;
            isDebugging = false;
            isQuitting = false;
            isPaused = false;
            hasQuit = false;
            fixBackgroundChange = false;
            fixSpriteHit = false;
            fixScrollOffset1 = false;
            fixScrollOffset2 = false;
            fixScrollOffset3 = false;
        }
 public Joypad[] getAllJoystickSelected()
 {
     Joypad[] joypadNum1=new Joypad[4];
      for (int i = 1;
              i <= 4;
              i++) {
          if (Mathf.Abs(Input.GetAxis("Joy"+i+"X")) > 0.001f || Mathf.Abs(Input.GetAxis("Joy"+i+"Y")) > 0.001f){
              if(i==1){
                  joypadNum1[0]= Joypad.Joypad1;
                  joypadName[0]=Input.GetJoystickNames()[0];
                  }
              else if(i==2){
                  joypadNum1[1]= Joypad.Joypad2;
                  joypadName[1]=Input.GetJoystickNames()[1];
                  }
              else if(i==3){
                  joypadNum1[2]= Joypad.Joypad3;
                  joypadName[2]=Input.GetJoystickNames()[2];
                  }
              else if(i==4){
                  joypadNum1[3]= Joypad.Joypad4;
                  joypadName[3]=Input.GetJoystickNames()[3];
                  }
              }
          }
      return joypadNum1;
 }
 public KeyCode LoadButton( string NameButton , Joypad joypad )
 {
     KeyCode KeyButton;
      string KeyButtonStr=PlayerPrefs.GetString(NameButton);
      if(KeyButtonStr!=null&&KeyButtonStr!="") {
          FindButton(KeyButtonStr,joypad);
          KeyButton=buttonFounded;
          }
      else KeyButton=KeyCode.None;
      return KeyButton;
 }
 void verifJoypadSelected( Joypad JoypadPlayer11 )
 {
     for (int i = 0;
              i < 4;
              i++) {
          if(JoypadPlayer11==JoypadPlayer[i] && i!=PlayerNumber){
              JoypadPlayer[i]=Joypad.none;
              joypadName[i]="";
              }
          }
 }
 public void FindButton( string NameButton , Joypad joypad )
 {
     if(joypad==Joypad.Joypad1){
          switch (NameButton){
              case "Joystick1Button0": buttonFounded= KeyCode.Joystick1Button0;
              break;
              case "Joystick1Button1": buttonFounded= KeyCode.Joystick1Button1;
              break;
              case "Joystick1Button2": buttonFounded= KeyCode.Joystick1Button2;
              break;
              case "Joystick1Button3": buttonFounded= KeyCode.Joystick1Button3;
              break;
              case "Joystick1Button4": buttonFounded= KeyCode.Joystick1Button4;
              break;
              case "Joystick1Button5": buttonFounded= KeyCode.Joystick1Button5;
              break;
              case "Joystick1Button6": buttonFounded= KeyCode.Joystick1Button6;
              break;
              case "Joystick1Button7": buttonFounded= KeyCode.Joystick1Button7;
              break;
              case "Joystick1Button8": buttonFounded= KeyCode.Joystick1Button8;
              break;
              case "Joystick1Button9": buttonFounded= KeyCode.Joystick1Button9;
              break;
              case "Joystick1Button10": buttonFounded= KeyCode.Joystick1Button10;
              break;
              case "Joystick1Button11": buttonFounded= KeyCode.Joystick1Button11;
              break;
              case "Joystick1Button12": buttonFounded= KeyCode.Joystick1Button12;
              break;
              case "Joystick1Button13": buttonFounded= KeyCode.Joystick1Button13;
              break;
              case "Joystick1Button14": buttonFounded= KeyCode.Joystick1Button14;
              break;
              case "Joystick1Button15": buttonFounded= KeyCode.Joystick1Button15;
              break;
              case "Joystick1Button16": buttonFounded= KeyCode.Joystick1Button16;
              break;
              case "Joystick1Button17": buttonFounded= KeyCode.Joystick1Button17;
              break;
              case "Joystick1Button18": buttonFounded= KeyCode.Joystick1Button18;
              break;
              case "Joystick1Button19": buttonFounded= KeyCode.Joystick1Button19;
              break;
              default:buttonFounded= KeyCode.None;
          		 	 buttonNotFoundedCOUNT++;
              break;
              }
          }
      else if(joypad==Joypad.Joypad2){
          switch (NameButton){
              case "Joystick2Button0": buttonFounded= KeyCode.Joystick2Button0;
              break;
              case "Joystick2Button1": buttonFounded= KeyCode.Joystick2Button1;
              break;
              case "Joystick2Button2": buttonFounded= KeyCode.Joystick2Button2;
              break;
              case "Joystick2Button3": buttonFounded= KeyCode.Joystick2Button3;
              break;
              case "Joystick2Button4": buttonFounded= KeyCode.Joystick2Button4;
              break;
              case "Joystick2Button5": buttonFounded= KeyCode.Joystick2Button5;
              break;
              case "Joystick2Button6": buttonFounded= KeyCode.Joystick2Button6;
              break;
              case "Joystick2Button7": buttonFounded= KeyCode.Joystick2Button7;
              break;
              case "Joystick2Button8": buttonFounded= KeyCode.Joystick2Button8;
              break;
              case "Joystick2Button9": buttonFounded= KeyCode.Joystick2Button9;
              break;
              case "Joystick2Button10": buttonFounded= KeyCode.Joystick2Button10;
              break;
              case "Joystick2Button11": buttonFounded= KeyCode.Joystick2Button11;
              break;
              case "Joystick2Button12": buttonFounded= KeyCode.Joystick2Button12;
              break;
              case "Joystick2Button13": buttonFounded= KeyCode.Joystick2Button13;
              break;
              case "Joystick2Button14": buttonFounded= KeyCode.Joystick2Button14;
              break;
              case "Joystick2Button15": buttonFounded= KeyCode.Joystick2Button15;
              break;
              case "Joystick2Button16": buttonFounded= KeyCode.Joystick2Button16;
              break;
              case "Joystick2Button17": buttonFounded= KeyCode.Joystick2Button17;
              break;
              case "Joystick2Button18": buttonFounded= KeyCode.Joystick2Button18;
              break;
              case "Joystick2Button19": buttonFounded= KeyCode.Joystick2Button19;
              break;
              default:buttonFounded= KeyCode.None;
          		 	 buttonNotFoundedCOUNT++;
              break;
              }
          }
      else if(joypad==Joypad.Joypad3){
          switch (NameButton){
              case "Joystick3Button0": buttonFounded= KeyCode.Joystick3Button0;
              break;
              case "Joystick3Button1": buttonFounded= KeyCode.Joystick3Button1;
              break;
              case "Joystick3Button2": buttonFounded= KeyCode.Joystick3Button2;
              break;
              case "Joystick3Button3": buttonFounded= KeyCode.Joystick3Button3;
              break;
              case "Joystick3Button4": buttonFounded= KeyCode.Joystick3Button4;
              break;
              case "Joystick3Button5": buttonFounded= KeyCode.Joystick3Button5;
              break;
              case "Joystick3Button6": buttonFounded= KeyCode.Joystick3Button6;
              break;
              case "Joystick3Button7": buttonFounded= KeyCode.Joystick3Button7;
              break;
              case "Joystick3Button8": buttonFounded= KeyCode.Joystick3Button8;
              break;
              case "Joystick3Button9": buttonFounded= KeyCode.Joystick3Button9;
              break;
              case "Joystick3Button10": buttonFounded= KeyCode.Joystick3Button10;
              break;
              case "Joystick3Button11": buttonFounded= KeyCode.Joystick3Button11;
              break;
              case "Joystick3Button12": buttonFounded= KeyCode.Joystick3Button12;
              break;
              case "Joystick3Button13": buttonFounded= KeyCode.Joystick3Button13;
              break;
              case "Joystick3Button14": buttonFounded= KeyCode.Joystick3Button14;
              break;
              case "Joystick3Button15": buttonFounded= KeyCode.Joystick3Button15;
              break;
              case "Joystick3Button16": buttonFounded= KeyCode.Joystick3Button16;
              break;
              case "Joystick3Button17": buttonFounded= KeyCode.Joystick3Button17;
              break;
              case "Joystick3Button18": buttonFounded= KeyCode.Joystick3Button18;
              break;
              case "Joystick3Button19": buttonFounded= KeyCode.Joystick3Button19;
              break;
              default:buttonFounded= KeyCode.None;
          		 	 buttonNotFoundedCOUNT++;
              break;
              }
          }
      else if(joypad==Joypad.Joypad4){
          switch (NameButton){
              case "Joystick4Button0": buttonFounded= KeyCode.Joystick4Button0;
              break;
              case "Joystick4Button1": buttonFounded= KeyCode.Joystick4Button1;
              break;
              case "Joystick4Button2": buttonFounded= KeyCode.Joystick4Button2;
              break;
              case "Joystick4Button3": buttonFounded= KeyCode.Joystick4Button3;
              break;
              case "Joystick4Button4": buttonFounded= KeyCode.Joystick4Button4;
              break;
              case "Joystick4Button5": buttonFounded= KeyCode.Joystick4Button5;
              break;
              case "Joystick4Button6": buttonFounded= KeyCode.Joystick4Button6;
              break;
              case "Joystick4Button7": buttonFounded= KeyCode.Joystick4Button7;
              break;
              case "Joystick4Button8": buttonFounded= KeyCode.Joystick4Button8;
              break;
              case "Joystick4Button9": buttonFounded= KeyCode.Joystick4Button9;
              break;
              case "Joystick4Button10": buttonFounded= KeyCode.Joystick4Button10;
              break;
              case "Joystick4Button11": buttonFounded= KeyCode.Joystick4Button11;
              break;
              case "Joystick4Button12": buttonFounded= KeyCode.Joystick4Button12;
              break;
              case "Joystick4Button13": buttonFounded= KeyCode.Joystick4Button13;
              break;
              case "Joystick4Button14": buttonFounded= KeyCode.Joystick4Button14;
              break;
              case "Joystick4Button15": buttonFounded= KeyCode.Joystick4Button15;
              break;
              case "Joystick4Button16": buttonFounded= KeyCode.Joystick4Button16;
              break;
              case "Joystick4Button17": buttonFounded= KeyCode.Joystick4Button17;
              break;
              case "Joystick4Button18": buttonFounded= KeyCode.Joystick4Button18;
              break;
              case "Joystick4Button19": buttonFounded= KeyCode.Joystick4Button19;
              break;
              default:buttonFounded= KeyCode.None;
          		 	 buttonNotFoundedCOUNT++;
              break;
              }
          }
 }
        public bool IsHolding(Joypad Target)
        {
            bool ret = false;

            try
            {
                if (Key[Target] >= 20)
                    ret = true;
            }
            catch
            { }

            return ret;
        }
        public bool IsPressing(Joypad Target)
        {
            bool ret = false;

            try
            {
                ret = Key[Target] > 2;
            }
            catch { }

            return ret;
        }
        public bool IsPressed(Joypad Target)
        {
            bool ret = false;

            try
            {
                ret = LastKey[Target] > 0 && Key[Target] == 0;
            }
            catch { }

            return ret;
        }
Exemple #49
0
	/**
	 * Constructeur
	 * @param <int> id
	 * @param <Joypad> joypad
	 */
	public Player(int id, Joypad joypad) {
		this.id = id;
		this.joypad = joypad;
	}
 public void RemapKey(Joypad RemapTarget, Keys MappingTarget)
 {
     Mapping.Remove(ReMapping[RemapTarget]);
     Mapping.Add(MappingTarget, RemapTarget);
     ReMapping[RemapTarget] = MappingTarget;
 }