Quick search

Table Of Contents

Input management

Our input system is wide and simple at the same time. We are currently able to support natively :

  • Windows multitouch event (pencil and finger)
  • MacOSX touchpad
  • Linux multitouch event (kernel and mtdev)
  • Linux wacom driver (pencil and finger)
  • TUIO

All the input management is configurable in the Kivy configuration. You can easily use many multitouch device into one Kivy application.

When the event have been read from devices, they are dispatched through post processing module, before sending them to your application. We got also several module by default for :

  • Double tap detection
  • Decrease jittering
  • Decrease the loose of touch on “bad” DIY hardware
  • Ignore regions
class kivy.input.MotionEvent(device, id, args)

Bases: object

Abstract class to represent a touch and no-touch object.

Parameters :
id : str

uniq ID of the Motion Event

args : list

list of parameters, passed to depack() function

apply_transform_2d(transform)

Apply a transformation on x, y, z, px, py, pz, ox, oy, oz, dx, dy, dz

copy_to(to)

Copy some attribute to another touch object.

depack(args)

Depack args into attributes in class

distance(other_touch)

Return the distance between the current touch and another touch.

dpos

Return delta between last position and current position, in the screen coordinate system (self.dx, self.dy)

grab(class_instance, exclusive=False)

Grab this motion event. You can grab a touch if you absolutly want to receive on_touch_move() and on_touch_up(), even if the touch is not dispatched by your parent:

def on_touch_down(self, touch):
    touch.grab(self)

def on_touch_move(self, touch):
    if touch.grab_current is self:
        # i receive my grabbed touch
    else:
        # it's a normal touch

def on_touch_up(self, touch):
    if touch.grab_current is self:
        # i receive my grabbed touch, i must ungrab it !
        touch.ungrab(self)
    else:
        # it's a normal touch
        pass
is_mouse_scrolling

Returns True if the touch is a mousewheel scrolling

New in version 1.6.0.

move(args)

Move the touch to another position

opos

Return the initial position of the touch in the screen coordinate system (self.ox, self.oy)

pop()

Pop attributes values from the stack

ppos

Return the previous position of the touch in the screen coordinate system (self.px, self.py)

push(attrs=None)

Push attributes values in attrs in the stack

scale_for_screen(w, h, p=None, rotation=0)

Scale position for the screen

spos

Return the position in the 0-1 coordinate system (self.sx, self.sy)

ungrab(class_instance)

Ungrab a previous grabbed touch

class kivy.input.MotionEventProvider(device, args)

Bases: object

Base class for a provider.

start()

Start the provider. This method is automatically called when the application is started, and if the configuration use the current provider.

stop()

Stop the provider

update(dispatch_fn)

Update the provider, and dispatch all the new touch event though the dispatch_fn argument.

class kivy.input.MotionEventFactory

MotionEvent factory is a class who register all availables input factories. If you create a new input factory, don’t forget to register it:

MotionEventFactory.register('myproviderid', MyInputProvider)
static get(name)

Get a provider class from provider id

static list()

Get a list of all providers availables

static register(name, classname)

Register a input provider in the database