예제 #1
0
파일: Map.cs 프로젝트: mtwomey/FreedomJoy
        private void _initAxisMappings()
        {
            foreach (JToken mapping in _config.MappingsAxis)
            {
                var requestedPhysicalDevice = (uint)mapping["physicalDevice"]["id"];
                var physicalDevice          = ControllerFactory.GetPhysicalController(_config.GetPhysicalDeviceGuidFromId(requestedPhysicalDevice));
                var requestedVjoyDevice     = (uint)mapping["vJoyDevice"]["id"];
                var vJoyDevice = ControllerFactory.GetvJoyController(_config.GetVjoyDeviceSystemIdFromId(requestedVjoyDevice));

                AxisMapping newAxisMapping = new AxisMapping(
                    physicalAxis: (string)mapping["physicalDevice"]["axis"],
                    vjoyAxis: (string)mapping["vJoyDevice"]["axis"],
                    controller: physicalDevice,
                    vcontroller: vJoyDevice
                    );
                _controllerMaps.Add(newAxisMapping);
            }
        }
예제 #2
0
파일: Map.cs 프로젝트: mtwomey/FreedomJoy
        private void _initSimpleButtonMappings() // Todo: abstract these _init mapping methods so we're not repeating so much stuff...
        {
            foreach (JToken mapping in _config.MappingsSimpleButton)
            {
                var requestedPhysicalDevice = (uint)mapping["physicalDevice"]["id"];
                var physicalDeviceGuid      = _config.GetPhysicalDeviceGuidFromId(requestedPhysicalDevice);
                var requestedVjoyDevice     = (uint)mapping["vJoyDevice"]["id"];
                var vJoyDeviceSystemId      = _config.GetVjoyDeviceSystemIdFromId(requestedVjoyDevice);

                SimpleButtonMapping newSimpleButtonMapping = new SimpleButtonMapping(
                    controllerPressedButtons: mapping["physicalDevice"]["buttons"].ToObject <string[]>(),
                    controllerNotPressedButtons: mapping["physicalDevice"]["notButtons"] != null ? mapping["physicalDevice"]["notButtons"].ToObject <string[]>() : new string [] {},
                    vJoyPressedButtons: mapping["vJoyDevice"]["buttons"].ToObject <string[]>(),
                    controller: ControllerFactory.GetPhysicalController(physicalDeviceGuid),
                    vcontroller: ControllerFactory.GetvJoyController(vJoyDeviceSystemId)
                    );
                _controllerMaps.Add(newSimpleButtonMapping);
            }
        }
예제 #3
0
 private void _checkControllersCallback(Object state)
 {
     try
     {
         var newPhysicalControllerCount = _di.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly).Count; // I think this call is expensive, if I do it too often, CPU util goes up
         if (newPhysicalControllerCount != _physicalControllerCount)
         {
             Logger.Log("Controller count changed from " + _physicalControllerCount + " to " + newPhysicalControllerCount);
             _physicalControllerCount = newPhysicalControllerCount; // This is first so that it's updated ahead of time in case of exception
             _map.Stop();
             ControllerFactory.ReleasePhysicalControllers();
             _map.Reset();
             _map.Run();
         }
     }
     catch (Exception e)
     {
         Logger.Log(e.Message);
     }
 }
예제 #4
0
파일: Map.cs 프로젝트: mtwomey/FreedomJoy
        private void _initVirtualAxisMappings()
        {
            foreach (JToken mapping in _config.MappingsVirtualAxis)
            {
                var requestedPhysicalDevice = (uint)mapping["physicalDevice"]["id"];
                var physicalDevice          = ControllerFactory.GetPhysicalController(_config.GetPhysicalDeviceGuidFromId(requestedPhysicalDevice));
                var requestedVjoyDevice     = (uint)mapping["vJoyDevice"]["id"];
                var vJoyDevice = ControllerFactory.GetvJoyController(_config.GetVjoyDeviceSystemIdFromId(requestedVjoyDevice));

                VirtualAxisMapping newVirtualAxisMapping = new VirtualAxisMapping(
                    increaseButtons: mapping["physicalDevice"]["increaseButtons"].ToObject <string[]>(),
                    increaseNotButtons: mapping["physicalDevice"]["increaseNotButtons"] != null ? mapping["physicalDevice"]["increaseNotButtons"].ToObject <string[]>() : new string[] {},
                    decreaseButtons: mapping["physicalDevice"]["decreaseButtons"].ToObject <string[]>(),
                    decreaseNotButtons: mapping["physicalDevice"]["decreaseNotButtons"] != null ? mapping["physicalDevice"]["decreaseNotButtons"].ToObject <string[]>() : new string[] {},
                    controller: physicalDevice,
                    vcontroller: vJoyDevice,
                    ratePerSecond: (int)mapping["settings"]["ratePerSecond"],
                    virtualAxis: vJoyDevice.AxesByName[(string)mapping["vJoyDevice"]["axis"]]
                    );
                _controllerMaps.Add(newVirtualAxisMapping);
            }
        }
예제 #5
0
파일: Map.cs 프로젝트: mtwomey/FreedomJoy
        private void _initPhysicalDevices()
        {
            for (int deviceNumber = 0; deviceNumber < _config.PhysicalDevices.Count(); deviceNumber++)
            {
                JToken     physicalDevice = _config.PhysicalDevices[deviceNumber];
                Controller controller     = ControllerFactory.GetPhysicalController((string)physicalDevice["guid"]);
                _activeControllers.Add(controller);

                for (int povNumber = 0; povNumber < physicalDevice["povs"].Count(); povNumber++)
                {
                    JToken pov = physicalDevice["povs"][povNumber];
                    if ((string)pov["type"] == "button4")
                    {
                        controller.PovsByName[(string)pov["name"]].SetType(Pov.PovType.Button4);
                    }
                    if ((string)pov["type"] == "button8")
                    {
                        controller.PovsByName[(string)pov["name"]].SetType(Pov.PovType.Button8);
                    }
                }
            }
        }