Beispiel #1
0
    private void Start()
    {
        //print($"{gameObject.GetInstanceID()} is Start()");
        //print($"cur active scene is {SceneManager.GetActiveScene().name}");

        //print($"input device checker sceneName : {SceneManager.GetActiveScene().name}");
        //if (SceneManager.GetActiveScene() != SceneManager.GetSceneByName("LoadingScene") && PlayerPrefs.HasKey("deviceName") )
        //{
        //    SetInputDevice(PlayerPrefs.GetString("deviceName"));
        //    print($"[TEST] MyRoom device is set to {PlayerPrefs.GetString("deviceName")}");
        //}

        //else
        //{
        //    //if (PlayerPrefs.HasKey("deviceName")){
        //    //    PlayerPrefs.SetString("deviceName", "Keyboard");
        //    //}
        //    keyboard_eventSystem.SetActive(true);
        //    joystick_eventSystem.SetActive(false);

        //    inputDevice = INPUT_DEVICE.Keyboard;
        //}

        if (isStart)
        {
            isStart = false;

            keyboard_eventSystem.SetActive(true);
            joystick_eventSystem.SetActive(false);

            inputDevice = INPUT_DEVICE.Keyboard;
        }
        else
        {
            SetInputDevice(PlayerPrefs.GetString("deviceName"));
            print($"[TEST] MyRoom device is set to {PlayerPrefs.GetString("deviceName")}");
        }
    }
Beispiel #2
0
    /// <summary>
    /// 입력 장치 연결을 확인하는 함수
    /// 현재, 키보드 - 컨트롤러(DXe) 지원
    /// </summary>
    public bool ConnectedDeviceRefresher(string deviceName)
    {
        if (deviceName == "Keyboard")
        {
            // setting Input manager
            keyboard_eventSystem.SetActive(true);
            joystick_eventSystem.SetActive(false);

            IngameCanvasManager.instance.eventSystem = keyboard_eventSystem.GetComponent <EventSystem>();

            inputDevice = INPUT_DEVICE.Keyboard;
            PlayerPrefs.SetString("deviceName", deviceName);

            print("Joystick device is not found");

            return(true);
        }


        inputDeviceName = Input.GetJoystickNames();

        bool isError = true;

        foreach (string s in inputDeviceName)
        {
            if (s == deviceName)
            {
                print($"[{deviceName}] 연결 확인");
                isError = false;
                break;
            }
        }

        // 해당 디바이스가 연결되어 있지 않다면 키보드로 설정.
        if (isError)
        {
            // setting Input manager
            keyboard_eventSystem.SetActive(true);
            joystick_eventSystem.SetActive(false);

            IngameCanvasManager.instance.eventSystem = keyboard_eventSystem.GetComponent <EventSystem>();

            inputDevice = INPUT_DEVICE.Keyboard;
            PlayerPrefs.SetString("deviceName", "Keyboard");

            return(false);
        }

        switch (deviceName)
        {
        case "SPEKTRUM RECEIVER":
            keyboard_eventSystem.SetActive(false);
            joystick_eventSystem.SetActive(true);

            IngameCanvasManager.instance.eventSystem = joystick_eventSystem.GetComponent <EventSystem>();

            inputDevice  = INPUT_DEVICE.Joystick;
            isInterLinkX = false;

            print(inputDeviceName[0] + " is connected");

            break;

        case "InterLinkDX":
            keyboard_eventSystem.SetActive(false);
            joystick_eventSystem.SetActive(true);

            IngameCanvasManager.instance.eventSystem = joystick_eventSystem.GetComponent <EventSystem>();

            inputDevice  = INPUT_DEVICE.Joystick;
            isInterLinkX = false;

            print(inputDeviceName[0] + " is connected");
            break;

        case "InterLink-X":
            keyboard_eventSystem.SetActive(false);
            joystick_eventSystem.SetActive(true);

            IngameCanvasManager.instance.eventSystem = joystick_eventSystem.GetComponent <EventSystem>();

            inputDevice  = INPUT_DEVICE.Joystick;
            isInterLinkX = true;

            print(inputDeviceName[0] + " is connected");
            break;
        }

        PlayerPrefs.SetString("deviceName", deviceName);
        return(true);
    }