<commit_before>﻿using SharpDX;
using System;
using Valve.VR;

public class ControllerStateTracker {
	private readonly uint deviceIdx;

	private bool active;
	private bool menuOpen;
	private VRControllerState_t secondPreviousState;
	private VRControllerState_t previousState;
	private VRControllerState_t currentState;
	private int staleness;
	private int previousStaleness;

	public ControllerStateTracker(uint deviceIdx) {
		this.deviceIdx = deviceIdx;
	}

	public void Update() {
		if (OpenVR.System.GetTrackedDeviceClass(deviceIdx) != ETrackedDeviceClass.Controller) {
			active = false;
			return;
		}

		if (!OpenVR.System.GetControllerState(deviceIdx, out var controllerState)) {
			active = false;
			return;
		}

		if (active) {
			staleness += 1;
			if (controllerState.unPacketNum == currentState.unPacketNum) {
				return;
			}
		}

		if (!active) {
			//activate
			Console.WriteLine("activate");
			active = true;
			secondPreviousState = default(VRControllerState_t);
			previousState = default(VRControllerState_t);
		} else {
			secondPreviousState = previousState;
			previousState = currentState;
			previousStaleness = staleness;
		}

		currentState = controllerState;
		staleness = 0;

		if (WasClicked(EVRButtonId.k_EButton_ApplicationMenu)) {
			menuOpen = !menuOpen;
		}
	}<commit_msg>Remove ControllerStateTracker debug logging I accidently left in<commit_after>﻿using SharpDX;
using System;
using Valve.VR;

public class ControllerStateTracker {
	private readonly uint deviceIdx;

	private bool active;
	private bool menuOpen;
	private VRControllerState_t secondPreviousState;
	private VRControllerState_t previousState;
	private VRControllerState_t currentState;
	private int staleness;
	private int previousStaleness;

	public ControllerStateTracker(uint deviceIdx) {
		this.deviceIdx = deviceIdx;
	}

	public void Update() {
		if (OpenVR.System.GetTrackedDeviceClass(deviceIdx) != ETrackedDeviceClass.Controller) {
			active = false;
			return;
		}

		if (!OpenVR.System.GetControllerState(deviceIdx, out var controllerState)) {
			active = false;
			return;
		}

		if (active) {
			staleness += 1;
			if (controllerState.unPacketNum == currentState.unPacketNum) {
				return;
			}
		}

		if (!active) {
			//activate
			active = true;
			secondPreviousState = default(VRControllerState_t);
			previousState = default(VRControllerState_t);
		} else {
			secondPreviousState = previousState;
			previousState = currentState;
			previousStaleness = staleness;
		}

		currentState = controllerState;
		staleness = 0;

		if (WasClicked(EVRButtonId.k_EButton_ApplicationMenu)) {
			menuOpen = !menuOpen;
		}
	}
{'fraction_non_alphanumeric': 0.08583364982909229, 'fraction_numerical': 0.0015191796429927839, 'mean_word_length': 4.545263157894737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2877818', 'n_tokens_mistral': 919, 'n_tokens_neox': 791, 'n_words': 184}