<commit_before># -*- coding: utf-8 -*-
import cwiid
import threading
import time

class WiiRemote:

    def __init__(self, n):
        self.btn1 = False
        self.btn2 = False
        self.btnA = False
        self.btnB = False
        self.btnC = False
        self.btnZ = False
        self.btnUp = False
        self.btnDown = False
        self.btnLeft = False
        self.btnRight = False
        self.id = id
        self.active = True
        self.wm = None
        self.stickH = 0
        self.stickV = 0

        # Connection à la manette Wii
        print "Appuyez simultamément les boutons 1 et 2 de la manette Wii maintenant"
        i = 1
        while not self.wm:
            try:
                self.wm = cwiid.Wiimote()
            except RuntimeError:
                if i > 10:
                    quit()
                    break
                print "Impossible de connecter le manette Wii"
                print "Tentative " + str(i)
                i += 1
        print "Manette Wii connectée avec succès"
        self.wm.led = n
        self.wm.rumble = True
        time.sleep(.2)
        self.wm.rumble = False
         
    def _robotRemote(self, freq):

        self.wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC | cwiid.RPT_NUNCHUK

        nunHRange = 222. - 22.
        nunHCenter = 122.
        nunVRange = 231. - 38.
        nunVCenter = 134.
        
        while self.active:
            buttons = self.wm.state['buttons']
            nunAcc = self.wm.state['nunchuk']['acc']
            nunButtons = self.wm.state['nunchuk']['buttons']
            nunStick = self.wm.state['nunchuk']['stick']
           
            nunStickH, nunStickV = nunStick

            self.stickH = (float(nunStickH) - nunHCenter) / nunHRange
            self.stickV = (float(nunStickV) - nunVCenter) / nunVRange
            
            if buttons & cwiid.BTN_A:
                self.btnA = True
            else:
                self.btnA = False
            time.sleep(1 / freq)

    def _release(self):
        self.active = False
        print "Déconnection de la manette Wii\n"
        self.wm.rumble = True
        time.sleep(.2)
        self.wm.rumble = False
        self.wm.led = 0

    def robotRemote(self, freq):
        thread1 = threading.Thread(target = self._robotRemote, args = [freq])
        thread1.start()

    def release(self):
        if self.active:
            thread2 = threading.Thread(target = self._release, args = [])
            thread2.start()<commit_msg>Added button Z support<commit_after># -*- coding: utf-8 -*-
import cwiid
import threading
import time

class WiiRemote:

    def __init__(self, n):
        self.btn1 = False
        self.btn2 = False
        self.btnA = False
        self.btnB = False
        self.btnC = False
        self.btnZ = False
        self.btnUp = False
        self.btnDown = False
        self.btnLeft = False
        self.btnRight = False
        self.id = id
        self.active = True
        self.wm = None
        self.stickH = 0
        self.stickV = 0

        # Connection à la manette Wii
        print "Appuyez simultamément les boutons 1 et 2 de la manette Wii maintenant"
        i = 1
        while not self.wm:
            try:
                self.wm = cwiid.Wiimote()
            except RuntimeError:
                if i > 10:
                    quit()
                    break
                print "Impossible de connecter le manette Wii"
                print "Tentative " + str(i)
                i += 1
        print "Manette Wii connectée avec succès"
        self.wm.led = n
        self.wm.rumble = True
        time.sleep(.2)
        self.wm.rumble = False
         
    def _robotRemote(self, freq):

        self.wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC | cwiid.RPT_NUNCHUK

        nunHRange = 222. - 22.
        nunHCenter = 122.
        nunVRange = 231. - 38.
        nunVCenter = 134.
        
        while self.active:
            buttons = self.wm.state['buttons']
            nunAcc = self.wm.state['nunchuk']['acc']
            nunButtons = self.wm.state['nunchuk']['buttons']
            nunStick = self.wm.state['nunchuk']['stick']
           
            nunStickH, nunStickV = nunStick

            self.stickH = (float(nunStickH) - nunHCenter) / nunHRange
            self.stickV = (float(nunStickV) - nunVCenter) / nunVRange
            
            if buttons & cwiid.BTN_A:
                self.btnA = True
            else:
                self.btnA = False
	    if nunButtons & cwiid.NUNCHUK_BTN_Z:
                self.btnZ = True
	    else:
                self.btnZ = False
            time.sleep(1 / freq)

    def _release(self):
        self.active = False
        print "Déconnection de la manette Wii\n"
        self.wm.rumble = True
        time.sleep(.2)
        self.wm.rumble = False
        self.wm.led = 0

    def robotRemote(self, freq):
        thread1 = threading.Thread(target = self._robotRemote, args = [freq])
        thread1.start()

    def release(self):
        if self.active:
            thread2 = threading.Thread(target = self._release, args = [])
            thread2.start()
{'fraction_non_alphanumeric': 0.09488625315963445, 'fraction_numerical': 0.013610733035193466, 'mean_word_length': 1.4218455743879472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1295233', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1580, 'n_words': 380}