Ejemplo n.º 1
0
        /// <summary>
        /// Load the hardware data and maps existing functions with the hardware
        /// </summary>
        public static void InitHardware()
        {
            HardwareData   hardware = HardwareDataManager.LoadData();
            HardwareAction actions  = new HardwareAction(hardware);

            InputDispatcher.RegisterHardware(actions.HardwareCreator());
        }
        public void HardwareCreatorCostructor()
        {
            HardwareData creator = HardwareDataManager.LoadData("{\"PushButton\": {\"type\":\"list\", \"buttons\":[{\"id\": 1},{\"id\": 2}]},\"RotaryEncoder\": [{\"id\": 0,\"hasButton\": true}]}");

            Assert.AreEqual(creator.PushButtons.Count, 2);
            Assert.AreEqual(creator.RotaryEncoders.Count, 1);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Store the hardware configuration into it's file
        /// </summary>
        /// <param name="description">the hardware description instance</param>
        public static void StoreConfiguration(HardwareDescription description)
        {
            if (!Directory.Exists(AppContext.BaseDirectory + "Data/Hardware/"))
            {
                Directory.CreateDirectory(AppContext.BaseDirectory + "Data/Hardware/");
            }

            JsonSerializer serializer = new JsonSerializer()
            {
                Formatting = Formatting.Indented
            };

            using (StreamWriter writer = new StreamWriter(string.Format("{0}/{1}", AppContext.BaseDirectory, HardwareDescriptionFile)))
                using (JsonWriter jsonWriter = new JsonTextWriter(writer))
                {
                    serializer.Serialize(jsonWriter, HardwareDataManager.Serialize(description));
                }
        }
Ejemplo n.º 4
0
 public static void UpdateActionMappingFile()
 {
     HardwareDataManager.StoreMapping(InputDataMapping);
 }