def test_get_mouse(self, devices):
        """Get event reads from the first mouse."""
        mouse = mock.MagicMock()
        reader = mock.MagicMock()
        mouse.read = reader
        devices.mice = [mouse]

        inputs.get_mouse()

        reader.assert_called_once()
def follow_scroll():
    position = 0

    while 1:
        sleep(0.001)
        events = get_mouse()
        for state in [
                event.state for event in events if event.code == "REL_X"
        ]:

            try:
                if state // precision <= 0:
                    r.motor.turn(0)
                else:
                    r.motor.turn(state // precision)

            except:
                pass
Esempio n. 3
0
 def recording_function(self):
     try:
         while self.recording_signal.is_set():
             events = inputs.get_mouse()
             for event in events:
                 if event.code == "ABS_X":
                     self.roll = (event.state / mouse_absolute_maximum) * 3
                 elif event.code == "ABS_Y":
                     self.pitch = (event.state / mouse_absolute_maximum) * 3
                 elif event.code == "BTN_LEFT" and event.state == 1:
                     self.yaw += 1
                 elif event.code == "BTN_RIGHT" and event.state == 1:
                     self.yaw -= 1
                 elif event.code == "REL_WHEEL":
                     self.throttle += event.state
                     if self.throttle < 0:
                         self.throttle = 0
         return 0
     except:
         return 1
 def test_get_mouse_index_error(self, devices):
     """Raises unpluggged error if no mouse attached."""
     devices.mice = []
     with self.assertRaises(inputs.UnpluggedError):
         # pylint: disable=pointless-statement
         inputs.get_mouse()
Esempio n. 5
0
def main():
    """Just print out some event infomation when the mouse is used."""
    while 1:
        events = get_mouse()
        for event in events:
            print(event.ev_type, event.code, event.state)
Esempio n. 6
0
#!/usr/bin/env python

import sys
from time import sleep
from inputs import get_mouse, UnpluggedError
from liblo import send

while 1:
    try:
        events = get_mouse()
        for event in events:
            if event.ev_type == 'Key' and event.state == 1:
                send(57120, "/trig")
        sleep(0.1)
    except UnpluggedError, err:
        print err
        sys.exit(1)










Esempio n. 7
0
def main():
    """Just print out some event infomation when the mouse is used."""
    while 1:
        events = get_mouse()
        for event in events:
            print(event.ev_type, event.code, event.state)