예제 #1
0
    private void LoadTextFromJson()
    {
        currentDevice = transform.GetComponentInParent <Pvr_ControllerVisual>().currentDevice;
        transform.Find("apptip/btn/Text").GetComponent <Text>().text   = Pvr_UnitySDKAPI.System.UPvr_GetLangString("apptip");
        transform.Find("touchtip/btn/Text").GetComponent <Text>().text = Pvr_UnitySDKAPI.System.UPvr_GetLangString("touchtip");
        transform.Find("hometip/btn/Text").GetComponent <Text>().text  = Pvr_UnitySDKAPI.System.UPvr_GetLangString("hometip");

        var volup = transform.Find("volup/btn/Text");

        if (volup != null)
        {
            volup.GetComponent <Text>().text = Pvr_UnitySDKAPI.System.UPvr_GetLangString("voluptip");
        }
        var voldown = transform.Find("voldown/btn/Text");

        if (voldown != null)
        {
            voldown.GetComponent <Text>().text = Pvr_UnitySDKAPI.System.UPvr_GetLangString("voldowntip");
        }
        var trigtip = transform.Find("triggertip/btn/Text");

        if (trigtip != null)
        {
            trigtip.GetComponent <Text>().text = Pvr_UnitySDKAPI.System.UPvr_GetLangString("triggertip");
        }
        var griptip = transform.Find("grip/btn/Text");

        if (griptip != null)
        {
            griptip.GetComponent <Text>().text = Pvr_UnitySDKAPI.System.UPvr_GetLangString("griptip");
        }
    }
예제 #2
0
 void Start()
 {
     powerRenderMat = GetComponent <MeshRenderer>();
     powerValue     = -1;
     variety        = transform.GetComponentInParent <Pvr_ControllerModuleInit>().Variety;
     currentDevice  = transform.GetComponentInParent <Pvr_ControllerVisual>().currentDevice;
 }
예제 #3
0
 void Start()
 {
     powerImage    = transform.GetComponent <Image>();
     powerValue    = -1;
     variety       = transform.GetComponentInParent <Pvr_ControllerModuleInit>().Variety;
     currentDevice = transform.GetComponentInParent <Pvr_ControllerVisual>().currentDevice;
 }
예제 #4
0
파일: Server.cs 프로젝트: ZhiqingWei/UC
        /// <summary>
        /// Get metainfo associated with a function via known function name
        /// </summary>
        /// <param name="controllerDevice">Device object corresponding to the function</param>
        /// <param name="funcName">Known function name</param>
        /// <returns></returns>
        public MethodInfo GetMethodInfo(ControllerDevice controllerDevice, string funcName)
        {
            Assembly dll            = controllerDevice.Library;
            dynamic  deviceInstance = controllerDevice.DeviceObject;
            //Type deviceType = dll.GetType(controllerDevice.DeviceInfo.Device);
            Type deviceType = dll.GetType(dll.GetName().Name + "." + controllerDevice.DeviceInfo.Device);

            return(deviceType.GetMethod(funcName));
        }
예제 #5
0
 private void JoyDevicesCBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.JoyDevicesCBox.SelectedIndex >= 0)
     {
         this.selectedJoystick = this.joysticks[this.JoyDevicesCBox.SelectedIndex];
         this.selectedJoystick.Acquire(new Form());
         this.Temp.ControllerConfigurations[this.Temp.EditNumber].DeviceGuid = this.selectedJoystick.Guid;
         this.Temp.ControllerConfigurations[this.Temp.EditNumber].Selected   = true;
         foreach (ComboBox joyButtonCBox in this.JoyButtonCBoxs)
         {
             for (int y = 0; y < this.selectedJoystick.ButtonCount; y++)
             {
                 joyButtonCBox.Items.Add(y.ToString(CultureInfo.InvariantCulture));
             }
         }
         this.updateUiTimer.Start();
         foreach (ComboBox item in this.JoyButtonCBoxs)
         {
             item.IsEnabled = true;
         }
         foreach (ComboBox item2 in this.ButtonFunctionsCBoxs)
         {
             item2.IsEnabled = true;
         }
     }
     else
     {
         this.updateUiTimer.Stop();
         this.selectedJoystick = null;
         this.Temp.ControllerConfigurations[this.Temp.EditNumber].Selected = false;
         foreach (ComboBox item in this.JoyButtonCBoxs)
         {
             item.IsEnabled = false;
         }
         foreach (ComboBox item2 in this.ButtonFunctionsCBoxs)
         {
             item2.IsEnabled = false;
         }
     }
 }
예제 #6
0
    // Use this for initialization
    void Start()
    {
        SystemLanguage localanguage = Application.systemLanguage;

        currentDevice = transform.GetComponentInParent <Pvr_ControllerVisual>().currentDevice;
        if (localanguage == SystemLanguage.Chinese || localanguage == SystemLanguage.ChineseSimplified || localanguage == SystemLanguage.ChineseTraditional)
        {
            transform.Find("apptip/btn/Text").GetComponent <Text>().text     = "返回键";
            transform.Find("touchtip/btn/Text").GetComponent <Text>().text   = "确认键";
            transform.Find("hometip/btn/Text").GetComponent <Text>().text    = "Home键";
            transform.Find("volup/btn/Text").GetComponent <Text>().text      = "音量+";
            transform.Find("voldown/btn/Text").GetComponent <Text>().text    = "音量-";
            transform.Find("triggertip/btn/Text").GetComponent <Text>().text = "扳机键";
        }
        else
        {
            transform.Find("apptip/btn/Text").GetComponent <Text>().text     = "Back";
            transform.Find("touchtip/btn/Text").GetComponent <Text>().text   = "Confirm";
            transform.Find("hometip/btn/Text").GetComponent <Text>().text    = "Home";
            transform.Find("volup/btn/Text").GetComponent <Text>().text      = "Volume+";
            transform.Find("voldown/btn/Text").GetComponent <Text>().text    = "Volume-";
            transform.Find("triggertip/btn/Text").GetComponent <Text>().text = "Trigger";
        }

        if (currentDevice == ControllerDevice.Goblin1)
        {
            trigger.SetActive(false);
            app.transform.localPosition  = new Vector3(185, 460, 0);
            home.transform.localPosition = new Vector3(185, -80, 0);
        }
        if (currentDevice == ControllerDevice.Goblin2)
        {
            trigger.SetActive(true);
            app.transform.localPosition  = new Vector3(185, -79, 0);
            home.transform.localPosition = new Vector3(185, -238, 0);
        }
    }
 /// <summary>
 /// Set the ControllerDevice to connect with.
 /// </summary>
 /// <param name="pControllerDevice">A ControllerDevice discovered during <see cref="Scan(bool)"/>.</param>
 public void SetSelectedControllerDevice(ControllerDevice pControllerDevice)
 {
     _controllerPlugin.SetSelectedControllerDevice(pControllerDevice);
 }
예제 #8
0
        private void PageLoaded1(object sender, RoutedEventArgs e)
        {
            this.updateUiTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 200)
            };
            this.updateUiTimer.Tick += this.UpdateUiTimerTick;
            this.joysticks           = ControllerDevice.Available();
            foreach (ControllerDevice joystickDevice in this.joysticks)
            {
                this.JoyDevicesCBox.Items.Add(joystickDevice.Name);
            }
            this.Temp           = (ConfigurationOptions)this.DataContext;
            this.JoyButtonCBoxs = new List <ComboBox>
            {
                this.JoyButtonCBox1,
                this.JoyButtonCBox2,
                this.JoyButtonCBox3,
                this.JoyButtonCBox4
            };
            this.ButtonFunctionsCBoxs = new List <ComboBox>
            {
                this.ButtonFunctionCBox1,
                this.ButtonFunctionCBox2,
                this.ButtonFunctionCBox3,
                this.ButtonFunctionCBox4
            };
            this.ButtonOptionsCBoxs = new List <ComboBox>
            {
                this.ButtonOptionCBox1,
                this.ButtonOptionCBox2,
                this.ButtonOptionCBox3,
                this.ButtonOptionCBox4
            };
            this.ButtonScreensCBoxs = new List <ComboBox>
            {
                this.ButtonScreenCBox1,
                this.ButtonScreenCBox2,
                this.ButtonScreenCBox3,
                this.ButtonScreenCBox4
            };
            //populate combo boxs
            foreach (var butFunc in this.Temp.Dictionarys.ButtonFunctions)
            {
                foreach (ComboBox cbox in this.ButtonFunctionsCBoxs)
                {
                    cbox.Items.Add(butFunc.Value.Name);
                }
            }
            foreach (ComboBox cBox in this.ButtonScreensCBoxs)
            {
                cBox.IsEnabled = true;
                cBox.Items.Add("All");
                for (int i = 1; i <= this.Temp.NumberDisplays + 1; i++)
                {
                    cBox.Items.Add(i.ToString(CultureInfo.InvariantCulture));
                }
            }
            //data binding here!!!
            for (int x = 0; x < NumberButtonsPerPage; x++)
            {
                var buttonFuncBinding =
                    new Binding(String.Format("ControllerConfigurations[{0}].ButtonFunctions[{1}]", this.Temp.EditNumber, x))
                {
                    Mode = BindingMode.TwoWay
                };
                BindingOperations.SetBinding(this.ButtonFunctionsCBoxs[x], Selector.SelectedValueProperty, buttonFuncBinding);
                var buttonOptBinding =
                    new Binding(String.Format("ControllerConfigurations[{0}].ButtonOptions[{1}]", this.Temp.EditNumber, x))
                {
                    Mode = BindingMode.TwoWay
                };
                BindingOperations.SetBinding(this.ButtonOptionsCBoxs[x], Selector.SelectedValueProperty, buttonOptBinding);
                var buttonScreenBinding =
                    new Binding(String.Format("ControllerConfigurations[{0}].ButtonOptionsScreens[{1}]", this.Temp.EditNumber,
                                              x))
                {
                    Mode = BindingMode.TwoWay
                };
                BindingOperations.SetBinding(this.ButtonScreensCBoxs[x], Selector.SelectedIndexProperty, buttonScreenBinding);
                var buttonNumberBinding =
                    new Binding(String.Format("ControllerConfigurations[{0}].ButtonNumbers[{1}]", this.Temp.EditNumber, x))
                {
                    Mode = BindingMode.TwoWay
                };
                BindingOperations.SetBinding(this.JoyButtonCBoxs[x], Selector.SelectedIndexProperty, buttonNumberBinding);
            }


            if (this.Temp.ControllerConfigurations[this.Temp.EditNumber].Selected)
            {
                //try select correct device in dropdown menu
                for (int p = 0; p < this.joysticks.Count; p++)
                {
                    if (this.joysticks[p].Guid == this.Temp.ControllerConfigurations[this.Temp.EditNumber].DeviceGuid)
                    {
                        //found
                        this.JoyDevicesCBox.SelectedIndex = p;
                    }
                }
            }
        }
예제 #9
0
 void Start()
 {
     variety       = transform.GetComponentInParent <Pvr_ControllerModuleInit>().Variety;
     currentDevice = GetComponentInParent <Pvr_ControllerVisual>().currentDevice;
     touchRenderer = GetComponent <MeshRenderer>();
 }
예제 #10
0
파일: Server.cs 프로젝트: ZhiqingWei/UC
        /// <summary>
        /// Send response to the client according to request information
        /// </summary>
        /// <param name="request">Http request from client</param>
        /// <returns>A string corresponding to the status of the operation</returns>
        public string SendResponse(HttpListenerRequest request)
        {
            Console.WriteLine(request.Url);
            string rawUrl = request.RawUrl.Replace("%20", " ");

            string[] parsedRequest = rawUrl.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            int fieldSize = parsedRequest.Length;

            if (parsedRequest.Length == 0)
            {
                return("");
            }
            else if (request.HttpMethod == "POST")
            {
                string           deviceRequested = parsedRequest[0];
                ControllerDevice device          = IsDeviceConnected(deviceRequested);
                if (device == null)
                {
                    return("Device Not Found");

                    throw new InvalidDeviceException("Device Not Found!");
                }
                else
                {
                    if (device.DeviceInfo.ApiType == "LocalLib")
                    {
                        int indexRequested = Int32.Parse(parsedRequest[1]);
                        IEnumerable <USBDeviceMethod> resultList =
                            from result in device.DeviceInfo.FunctionArray
                            where result.ButtonIndex == indexRequested
                            select result;

                        string     functionRequested = resultList.First().Name;
                        MethodInfo method            = GetMethodInfo(device, functionRequested);
                        if (method == null)
                        {
                            return("Method Not Found");

                            throw new InvalidMethodException("Method Not Found!");
                        }
                        else
                        {
                            Task.Run(() =>
                            {
                                bool lockTaken = false;
                                try
                                {
                                    Monitor.TryEnter(device._lock, ref lockTaken);
                                    if (lockTaken)
                                    {
                                        string[] parameters = new string[fieldSize - 2];
                                        Array.Copy(parsedRequest, 2, parameters, 0, fieldSize - 2);

                                        if (deviceRequested == "Jaco")
                                        {
                                            Console.WriteLine(method.Invoke(device.DeviceObject, parameters));
                                        }
                                        else
                                        {
                                            Array.Copy(parsedRequest, 2, parameters, 0, fieldSize - 2);
                                            method.Invoke(device.DeviceObject, parameters);
                                        }
                                    }
                                }
                                finally
                                {
                                    if (lockTaken)
                                    {
                                        Monitor.Exit(device._lock);
                                    }
                                }
                            });
                            return("OK");
                        }
                    }
                    else if (device.DeviceInfo.ApiType == "Http")
                    {
                        int indexRequested = Int32.Parse(parsedRequest[1]);
                        IEnumerable <RemoteDeviceMethod> resultList =
                            from result in device.DeviceInfo.Methods
                            where result.ButtonIndex == indexRequested
                            select result;

                        string     functionRequested = resultList.First().Method;
                        DeviceInfo deviceInfo        = device.DeviceInfo;
                        foreach (RemoteDeviceMethod method in deviceInfo.Methods)
                        {
                            if (method.Method == functionRequested)
                            {
                                HttpRequestMessage message;
                                if (device.DeviceInfo.Device == "Alexa")
                                {
                                    byte[] buffer = new byte[5000];
                                    request.InputStream.Read(buffer, 0, 5000);
                                    string content = System.Text.Encoding.UTF8.GetString(TrimNull(buffer));
                                    content = JsonConvert.DeserializeObject <Dictionary <string, string> >(method.Data)["input"] + content;
                                    content = JsonConvert.SerializeObject(new Dictionary <string, string> {
                                        ["input"] = content
                                    });
                                    message = FormRequestMessage(
                                        method.HttpMethod,
                                        method.Link,
                                        content
                                        );
                                    var response = SendToRemoteServerAsync(message).Result;
                                    if (!response.IsSuccessStatusCode)
                                    {
                                        string errorPhrase = response.ReasonPhrase;
                                        //return errorPhrase;
                                    }

                                    string result = response.Content.ReadAsStringAsync().Result;

                                    result = method.Link.Substring(0, method.Link.Length - 4) + result;
                                    Task.Run(() =>
                                    {
                                        bool lockTaken = false;
                                        try
                                        {
                                            Monitor.TryEnter(device._lock, ref lockTaken);
                                            if (lockTaken)
                                            {
                                                AudioPlayer.Play(result);
                                            }
                                        }
                                        finally
                                        {
                                            if (lockTaken)
                                            {
                                                Monitor.Exit(device._lock);
                                            }
                                        }
                                    });
                                }
                                else
                                {
                                    Task.Run(() =>
                                    {
                                        bool lockTaken = false;
                                        try
                                        {
                                            Monitor.TryEnter(device._lock, ref lockTaken);
                                            if (lockTaken)
                                            {
                                                message = FormRequestMessage(
                                                    method.HttpMethod,
                                                    method.Link,
                                                    method.Data,
                                                    "application/json"
                                                    );
                                                var result = SendToRemoteServerAsync(message);
                                            }
                                        }
                                        finally
                                        {
                                            if (lockTaken)
                                            {
                                                Monitor.Exit(device._lock);
                                            }
                                        }
                                    });
                                }
                            }
                            //else throw new InvalidMethodException("Method not found!");
                        }

                        return("OK");
                    }
                    else
                    {
                        return("Invalid Device API Type");

                        throw new InvalidDeviceException("Invalid device API type");
                    }
                }
            }


            else
            {
                return("Error");
            }
        }
예제 #11
0
파일: Server.cs 프로젝트: ZhiqingWei/UC
 /// <summary>
 /// Add ControllerDevice object to collection
 /// </summary>
 /// <param name="name">Device name</param>
 /// <param name="device">ControllerDevice object</param>
 public void AddDevice(string name, ControllerDevice device)
 {
     ConnectedDeviceList[name] = device;
 }
예제 #12
0
    void Start()
    {
        SystemLanguage localanguage = Application.systemLanguage;

        currentDevice = transform.GetComponentInParent <Pvr_ControllerVisual>().currentDevice;
        if (localanguage == SystemLanguage.Chinese || localanguage == SystemLanguage.ChineseSimplified || localanguage == SystemLanguage.ChineseTraditional)
        {
            transform.Find("apptip/btn/Text").GetComponent <Text>().text   = "返回键";
            transform.Find("touchtip/btn/Text").GetComponent <Text>().text = "确认键";
            transform.Find("hometip/btn/Text").GetComponent <Text>().text  = "Home键";

            var volup = transform.Find("volup/btn/Text");
            if (volup != null)
            {
                volup.GetComponent <Text>().text = "音量+";
            }
            var voldown = transform.Find("voldown/btn/Text");
            if (voldown != null)
            {
                voldown.GetComponent <Text>().text = "音量-";
            }
            var trigtip = transform.Find("triggertip/btn/Text");
            if (trigtip != null)
            {
                trigtip.GetComponent <Text>().text = "扳机键";
            }
        }
        if (localanguage == SystemLanguage.English)
        {
            transform.Find("apptip/btn/Text").GetComponent <Text>().text   = "Back";
            transform.Find("touchtip/btn/Text").GetComponent <Text>().text = "Confirm";
            transform.Find("hometip/btn/Text").GetComponent <Text>().text  = "Home";
            var volup = transform.Find("volup/btn/Text");
            if (volup != null)
            {
                volup.GetComponent <Text>().text = "Volume+";
            }
            var voldown = transform.Find("voldown/btn/Text");
            if (voldown != null)
            {
                voldown.GetComponent <Text>().text = "Volume-";
            }
            var trigtip = transform.Find("triggertip/btn/Text");
            if (trigtip != null)
            {
                trigtip.GetComponent <Text>().text = "Trigger";
            }
        }
        if (localanguage == SystemLanguage.Korean)
        {
            transform.Find("apptip/btn/Text").GetComponent <Text>().text   = "리턴 키";
            transform.Find("touchtip/btn/Text").GetComponent <Text>().text = "확인 키";
            transform.Find("hometip/btn/Text").GetComponent <Text>().text  = "Home 키";
            var volup = transform.Find("volup/btn/Text");
            if (volup != null)
            {
                volup.GetComponent <Text>().text = "볼륨+";
            }
            var voldown = transform.Find("voldown/btn/Text");
            if (voldown != null)
            {
                voldown.GetComponent <Text>().text = "볼륨-";
            }
            var trigtip = transform.Find("triggertip/btn/Text");
            if (trigtip != null)
            {
                trigtip.GetComponent <Text>().text = "트리거 키";
            }
        }
        if (localanguage == SystemLanguage.Japanese)
        {
            transform.Find("apptip/btn/Text").GetComponent <Text>().text   = "バック";
            transform.Find("touchtip/btn/Text").GetComponent <Text>().text = "確認";
            transform.Find("hometip/btn/Text").GetComponent <Text>().text  = "Home";
            var volup = transform.Find("volup/btn/Text");
            if (volup != null)
            {
                volup.GetComponent <Text>().text = "音量+";
            }
            var voldown = transform.Find("voldown/btn/Text");
            if (voldown != null)
            {
                voldown.GetComponent <Text>().text = "音量-";
            }
            var trigtip = transform.Find("triggertip/btn/Text");
            if (trigtip != null)
            {
                trigtip.GetComponent <Text>().text = "トリガー";
            }
        }
    }