<commit_before>#<NAME>
#Leap Python mouse controller POC

import Leap
import Geometry
import math

class debouncer(object): #Takes a "signal" and debounces it.
    def __init__(self, debounce_time): #Takes as an argument the number of opposite samples it needs to debounce.
        self.opposite_counter = 0 #Number of contrary samples vs agreeing samples.
        self.state = False #Default state.
        self.debounce_time = debounce_time #Number of samples to change states (debouncing threshold)

    def signal(self, value): #Update the signal.
        if value != self.state: #we are receiving a different signal than what we have been
            self.opposite_counter = self.opposite_counter + 1
        else: #we are recieving the same signal that we have been
            self.opposite_counter = self.opposite_counter - 1

        if self.opposite_counter < 0: self.opposite_counter = 0
        if self.opposite_counter > self.debounce_time: self.opposite_counter = self.debounce_time
        #no sense building up negative or huge numbers of agreeing/contrary samples

        if self.opposite_counter >= self.debounce_time: #we have seen a lot of evidence that our internal state is wrong
            self.state = not self.state #change internal state
            self.opposite_counter = 0 #we reset the number of contrary samples
        return self.state #return the debounced signal (may help keep code cleaner)

class mouse_manager(object):
        def __init__(self):
            self.xcounter = 0.0
            self.ycounter = 0.0

        def add(self, (x, y)):
            self.xcounter = self.xcounter + x
            self.ycounter = self.ycounter + y
            split_x = math.modf(self.xcounter)#saves the float part (remainder) into the counter
            split_y = math.modf(self.ycounter)#and the int part into the movement
            self.xcounter = split_x[0]
            xmovement = int(split_x[1])
            self.ycounter = split_y[0]
            ymovement = int(split_y[1])
            return xmovement, ymovement   


class Listener(Leap.Listener): #The Listener that we attach to the controller
    def __init__(self, cursor):
        super(Listener, self).__init__() #Initialize like a normal listener
        #Initialize a bunch of stuff specific to this implementation
        self.screen = None
        self.screen_resolution = (0,0)
        self.cursor = cursor #The cursor object that lets us control mice cross-platform<commit_msg>Updated Comments<commit_after>#<NAME>
#Leap Python mouse controller POC

import Leap
import Geometry
import math

class debouncer(object): #Takes a "signal" and debounces it.
    def __init__(self, debounce_time): #Takes as an argument the number of opposite samples it needs to debounce.
        self.opposite_counter = 0 #Number of contrary samples vs agreeing samples.
        self.state = False #Default state.
        self.debounce_time = debounce_time #Number of samples to change states (debouncing threshold)

    def signal(self, value): #Update the signal.
        if value != self.state: #we are receiving a different signal than what we have been
            self.opposite_counter = self.opposite_counter + 1
        else: #we are recieving the same signal that we have been
            self.opposite_counter = self.opposite_counter - 1

        if self.opposite_counter < 0: self.opposite_counter = 0
        if self.opposite_counter > self.debounce_time: self.opposite_counter = self.debounce_time
        #no sense building up negative or huge numbers of agreeing/contrary samples

        if self.opposite_counter >= self.debounce_time: #we have seen a lot of evidence that our internal state is wrong
            self.state = not self.state #change internal state
            self.opposite_counter = 0 #we reset the number of contrary samples
        return self.state #return the debounced signal (may help keep code cleaner)

class mouse_manager(object):
        def __init__(self):
            self.xcounter = 0.0
            self.ycounter = 0.0

        #Returns the integer part of the mouse movement, stores the leftover float part for later
        def add(self, (x, y)):
            self.xcounter = self.xcounter + x
            self.ycounter = self.ycounter + y
            split_x = math.modf(self.xcounter) #Saves the float part (remainder) into the counter
            split_y = math.modf(self.ycounter) #And the int part into the movement
            self.xcounter = split_x[0]
            xmovement = int(split_x[1])
            self.ycounter = split_y[0]
            ymovement = int(split_y[1])
            return xmovement, ymovement   


class Listener(Leap.Listener): #The Listener that we attach to the controller
    def __init__(self, cursor):
        super(Listener, self).__init__() #Initialize like a normal listener
        #Initialize a bunch of stuff specific to this implementation
        self.screen = None
        self.screen_resolution = (0,0)
        self.cursor = cursor #The cursor object that lets us control mice cross-platform
{'fraction_non_alphanumeric': 0.06878829808262503, 'fraction_numerical': 0.006325360743229888, 'mean_word_length': 2.7288135593220337, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3659793', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1359, 'n_words': 515}