コード例 #1
0
        public float getState(int action, InputMap map = null)
        {
            if (map == null)
            {
                map = InputMapping[action];
            }

            /*InputController IC = this;
             * if (map.controller != null)
             * {
             *  IC = map.controller;
             * }*/
            string TID = id;

            if (map.controllerID != "")
            {
                TID = map.controllerID;
            }

            if (TID == "Keyboard")
            {
                return(getKeyboardMapState(map));
            }
            else if (TID == "Mouse")
            {
                return(getMouseMapState(map));
            }
            else
            {
                return(getGamepadMapState(map));
            }
            return(0);
        }
コード例 #2
0
        protected float getGamepadMapState(InputMap map)
        {
            string TID = id;

            if (map.controllerID != "")
            {
                TID = map.controllerID;
            }
            GamePad P = GamePadManager._this.GetPad(TID);

            if (P == null || !P.connected)
            {
                return(0);
            }
            if (!map.axis)
            {
                if (P.buttons[map.map].pressed)
                {
                    return(1);
                }
                else if (map.antimap >= 0 && P.buttons[map.antimap].pressed)
                {
                    return(-1);
                }
                return(0);
            }
            else
            {
                return((float)P.axes[map.map]);
            }
        }
コード例 #3
0
        protected void initgamepad()
        {
            int i = 0;

            while (i < NumberOfActions)
            {
                InputMap map = new InputMap(-1);
                if (i == 0)
                {
                    map.map  = 0;
                    map.axis = true;
                }
                if (i == 1)
                {
                    map.map  = 1;
                    map.axis = true;
                }

                if (i > 1)
                {
                    map.map = i - 2;
                }
                InputMapping.Add(map);
                i++;
            }
        }
コード例 #4
0
 public string getMapControllerID(InputMap map)
 {
     if (map.controllerID != "")
     {
         return(map.controllerID);
     }
     else
     {
         return(id);
     }
 }
コード例 #5
0
        protected float getMouseMapState(InputMap map)
        {
            List <int> L = KeyboardManager._this.PressedMouseButtons;

            if (L.Contains(map.map))
            {
                return(1f);
            }
            else if (L.Contains(map.antimap))
            {
                return(-1f);
            }
            return(0);
        }
コード例 #6
0
        protected void initkeyboard()
        {
            int i = 0;

            while (i < NumberOfActions)
            {
                InputMap map = new InputMap(-1);
                if (i == 0)
                {
                    map.map     = 39;
                    map.antimap = 37;

                    /*map.map = 68;
                     * map.antimap= 65;*/
                }
                if (i == 1)
                {
                    map.map     = 40;
                    map.antimap = 38;

                    /*map.map = 83;
                     * map.antimap = 87;*/
                }

                if (i == 2)
                {
                    //map.map = 32;
                    map.map = 90;
                }
                if (i == 3)
                {
                    map.map = 88;
                }
                if (i == 4)
                {
                    map.map = 65;//a
                }
                if (i == 5)
                {
                    map.map = 13;//enter
                }
                InputMapping.Add(map);
                i++;
            }
        }
コード例 #7
0
        public void CopyFromMap(dynamic[] Map)
        {
            string[] fields = new string[] { "map", "antimap", "name", "axis", "controllerID" };

            int i = 0;

            while (i < Map.Length)
            {
                if (i >= InputMapping.Count)
                {
                    InputMapping.Add(new InputMap());
                }
                InputMap IM = InputMapping[i];
                Helper.CopyFields(Map[i], IM, fields);
                //ret[i] = Helper.MakeShallowCopy(InputMapping[i], fields);
                i++;
            }
        }
コード例 #8
0
        public InputMap FindAnyPressedGamePadInput()
        {
            InputMap       ret = new InputMap();
            List <GamePad> L   = GamePadManager._this.activeGamepads;

            L.ForEach(G =>
            {
                if (ret.map == -1)
                {
                    ret.controllerID   = G.id;
                    GamePadButton[] GB = G.buttons.Where(B => B.pressed).ToArray();
                    if (GB.Length > 0)
                    {
                        ret.axis          = false;
                        GamePadButton tmp = GB[0];
                        ret.map           = new List <GamePadButton>(G.buttons).IndexOf(tmp);
                    }
                    else
                    {
                        int i = 0;
                        while (i < G.axes.Length && ret.map == -1)
                        {
                            if (Math.Abs(G.axes[i]) > 0.7 && Math.Abs(G.axes[i]) < 2.0)
                            {
                                ret.axis = true;
                                ret.map  = i;
                                if (G.axes[i] < 0)
                                {
                                    ret.name    = "anti";
                                    ret.antimap = i;
                                }
                            }
                            i++;
                        }
                    }
                }
            }
                      );
            if (ret.map != -1)
            {
                return(ret);
            }
            return(null);
        }
コード例 #9
0
        public static void Main()
        {
            //USE THE JSON ZIP ARCHIVE FEATURE FROM BNTEST FOR LOADING IMAGES AND FILES.

            Document.Body.Style.CssText = "overflow: hidden;margin: 0;padding: 0;";
            GamePadManager._this        = new GamePadManager();
            GamePadManager._this.Update();
            Global.SetTimeout(() => {
                GamePadManager._this.Update();

                IC          = InputControllerManager._this.Controllers[0];
                InputMap IM = InputControllerManager._this.Controllers[0].InputMapping[2];
            }, 5);

            var ok     = false;
            var uptest = true;

            JSONArchive.Open("Assets/Images.JSON", json =>
            {
                JSON = json;

                JSON.PreloadImages(() =>
                {
                    ok = true;
                    Finish();
                });
            });

            // After building (Ctrl + Shift + B) this project,
            // browse to the /bin/Debug or /bin/Release folder.

            // A new bridge/ folder is created and contains
            // your projects JavaScript files.

            // Open the bridge/index.html file in a brower by
            // Right-Click > Open With..., then choose a
            // web browser from the list

            // This application will then run in a browser.
        }
コード例 #10
0
 public bool getPressed(int action, InputMap map = null)
 {
     return(getState(action, map) >= 0.7f);
 }