<commit_before>﻿/**
 * Copyright (c) 2017 The Campfire Union Inc - All Rights Reserved.
 *
 * Licensed under the MIT license. See LICENSE file in the project root for
 * full license information.
 *
 * Email:   <EMAIL>
 * Website: https://www.campfireunion.com
 */

using UnityEngine;
using UnityEngine.XR;
using UnityEngine.Events;
using System;
using System.Collections;
using TMPro;

namespace VRKeys {

	/// <summary>
	/// Keyboard input system for use with NewtonVR. To use, drop the VRKeys prefab
	/// into your scene and activate as needed. Listen for OnUpdate and OnSubmit events,
	/// and set the text via SetText(string).
	///
	/// Input validation can be done during OnUpdate and OnSubmit events by calling
	/// ShowValidationMessage(msg) and HideValidationMessage(). The keyboard does not
	/// automatically hide OnSubmit, but rather you should call SetActive(false) when
	/// you have finished validating the submitted text.
	/// </summary>
	public class Keyboard : MonoBehaviour {
		public GameObject playerSpace;

		public Vector3 positionRelativeToUser = new Vector3 (0f, 1.35f, 2f);

		public KeyboardLayout keyboardLayout = KeyboardLayout.Qwerty;

		[Space (15)]
		public TextMeshProUGUI placeholder;

		public string placeholderMessage = "Tap the keys to begin typing";

		public TextMeshProUGUI displayText;

		public GameObject validationNotice;

		public TextMeshProUGUI validationMessage;

		public GameObject infoNotice;

		public TextMeshProUGUI infoMessage;

		public GameObject successNotice;

		public TextMeshProUGUI successMessage;

		[Space (15)]
		public Color displayTextColor = Color.black;

		public Color caretColor = Color.gray;

		[Space (15)]
		public GameObject keyPrefab;

		public Transform keysParent;

		public float keyWidth = 0.16f;

		public float keyHeight = 0.16f;

		[Space (15)]
		public string text = "";

		[Space (15)]
		public GameObject canvas;

		public GameObject leftMallet;

		public GameObject rightMallet;

		public GameObject keyboardWrapper;

		public ShiftKey shiftKey;

		public Key[] extraKeys;

		[Space (15)]
		public bool leftPressing = false;

		public bool rightPressing = false;

		public bool initialized = false;

		public bool disabled = true;

		[Serializable]
		public class KeyboardUpdateEvent : UnityEvent<string> { }

		[Serializable]
		public class KeyboardSubmitEvent : UnityEvent<string> { }

		[Space (15)]

		/// <summary>
		/// Listen for events whenever the text changes.
		/// </summary>
		public KeyboardUpdateEvent OnUpdate = new KeyboardUpdateEvent ();

		/// <summary>
		/// Listen for events when Submit() is called.
		/// </summary>
		public KeyboardSubmitEvent OnSubmit = new KeyboardSubmitEvent ();

		/// <summary>
		/// Listen for events when Cancel() is called.
		/// </summary>
		public UnityEvent OnCancel = new UnityEvent ();

		private GameObject leftHand;

		private GameObject rightHand;

		private LetterKey[] keys;

		private bool shifted = false;

		private Layout layout;

		/// <summary>
		/// Initialization.
		/// </summary>
		private IEnumerator Start () {
			if (XRDevice.GetTrackingSpaceType () != TrackingSpaceType.RoomScale) {
				XRDevice.SetTrackingSpaceType (TrackingSpaceType.RoomScale);
			}

			if (playerSpace == null) playerSpace = new GameObject ("Play Space");
			//playerSpace.transform.localPosition = InputTracking.GetLocalPosition (XRNode.TrackingReference);
			//playerSpace.transform.localRotation = InputTracking.GetLocalRotation (XRNode.TrackingReference);

			leftHand = new GameObject ("Left Hand");
			rightHand = new GameObject ("Right Hand");

			yield return StartCoroutine (DoSetLanguage (keyboardLayout));

			validationNotice.SetActive (false);
			infoNotice.SetActive (false);
			successNotice.SetActive (false);

			UpdateDisplayText ();
			PlaceholderVisibility ();

			initialized = true;
		}

		private void Update () {
			//playerSpace.transform.localPosition = InputTracking.GetLocalPosition (XRNode.TrackingReference);
			//playerSpace.transform.localRotation = InputTracking.GetLocalRotation (XRNode.TrackingReference);

			leftHand.transform.localPosition = InputTracking.GetLocalPosition (XRNode.LeftHand);
			leftHand.transform.localRotation = InputTracking.GetLocalRotation (XRNode.LeftHand);<commit_msg>Parent the hands to the play space so they come with the user after teleporting<commit_after>﻿/**
 * Copyright (c) 2017 The Campfire Union Inc - All Rights Reserved.
 *
 * Licensed under the MIT license. See LICENSE file in the project root for
 * full license information.
 *
 * Email:   <EMAIL>
 * Website: https://www.campfireunion.com
 */

using UnityEngine;
using UnityEngine.XR;
using UnityEngine.Events;
using System;
using System.Collections;
using TMPro;

namespace VRKeys {

	/// <summary>
	/// Keyboard input system for use with NewtonVR. To use, drop the VRKeys prefab
	/// into your scene and activate as needed. Listen for OnUpdate and OnSubmit events,
	/// and set the text via SetText(string).
	///
	/// Input validation can be done during OnUpdate and OnSubmit events by calling
	/// ShowValidationMessage(msg) and HideValidationMessage(). The keyboard does not
	/// automatically hide OnSubmit, but rather you should call SetActive(false) when
	/// you have finished validating the submitted text.
	/// </summary>
	public class Keyboard : MonoBehaviour {
		public GameObject playerSpace;

		public Vector3 positionRelativeToUser = new Vector3 (0f, 1.35f, 2f);

		public KeyboardLayout keyboardLayout = KeyboardLayout.Qwerty;

		[Space (15)]
		public TextMeshProUGUI placeholder;

		public string placeholderMessage = "Tap the keys to begin typing";

		public TextMeshProUGUI displayText;

		public GameObject validationNotice;

		public TextMeshProUGUI validationMessage;

		public GameObject infoNotice;

		public TextMeshProUGUI infoMessage;

		public GameObject successNotice;

		public TextMeshProUGUI successMessage;

		[Space (15)]
		public Color displayTextColor = Color.black;

		public Color caretColor = Color.gray;

		[Space (15)]
		public GameObject keyPrefab;

		public Transform keysParent;

		public float keyWidth = 0.16f;

		public float keyHeight = 0.16f;

		[Space (15)]
		public string text = "";

		[Space (15)]
		public GameObject canvas;

		public GameObject leftMallet;

		public GameObject rightMallet;

		public GameObject keyboardWrapper;

		public ShiftKey shiftKey;

		public Key[] extraKeys;

		[Space (15)]
		public bool leftPressing = false;

		public bool rightPressing = false;

		public bool initialized = false;

		public bool disabled = true;

		[Serializable]
		public class KeyboardUpdateEvent : UnityEvent<string> { }

		[Serializable]
		public class KeyboardSubmitEvent : UnityEvent<string> { }

		[Space (15)]

		/// <summary>
		/// Listen for events whenever the text changes.
		/// </summary>
		public KeyboardUpdateEvent OnUpdate = new KeyboardUpdateEvent ();

		/// <summary>
		/// Listen for events when Submit() is called.
		/// </summary>
		public KeyboardSubmitEvent OnSubmit = new KeyboardSubmitEvent ();

		/// <summary>
		/// Listen for events when Cancel() is called.
		/// </summary>
		public UnityEvent OnCancel = new UnityEvent ();

		private GameObject leftHand;

		private GameObject rightHand;

		private LetterKey[] keys;

		private bool shifted = false;

		private Layout layout;

		/// <summary>
		/// Initialization.
		/// </summary>
		private IEnumerator Start () {
			if (XRDevice.GetTrackingSpaceType () != TrackingSpaceType.RoomScale) {
				XRDevice.SetTrackingSpaceType (TrackingSpaceType.RoomScale);
			}

			if (playerSpace == null) playerSpace = new GameObject ("Play Space");
			//playerSpace.transform.localPosition = InputTracking.GetLocalPosition (XRNode.TrackingReference);
			//playerSpace.transform.localRotation = InputTracking.GetLocalRotation (XRNode.TrackingReference);

			leftHand = new GameObject ("Left Hand");
			rightHand = new GameObject ("Right Hand");

			leftHand.transform.SetParent (playerSpace.transform);
			rightHand.transform.SetParent (playerSpace.transform);

			yield return StartCoroutine (DoSetLanguage (keyboardLayout));

			validationNotice.SetActive (false);
			infoNotice.SetActive (false);
			successNotice.SetActive (false);

			UpdateDisplayText ();
			PlaceholderVisibility ();

			initialized = true;
		}

		private void Update () {
			//playerSpace.transform.localPosition = InputTracking.GetLocalPosition (XRNode.TrackingReference);
			//playerSpace.transform.localRotation = InputTracking.GetLocalRotation (XRNode.TrackingReference);

			leftHand.transform.localPosition = InputTracking.GetLocalPosition (XRNode.LeftHand);
			leftHand.transform.localRotation = InputTracking.GetLocalRotation (XRNode.LeftHand);
{'fraction_non_alphanumeric': 0.09372846312887664, 'fraction_numerical': 0.007121525384792098, 'mean_word_length': 4.038773148148148, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2209987', 'n_tokens_mistral': 2728, 'n_tokens_neox': 2356, 'n_words': 763}