Repository: kivy/kivy

Issue:
postproc does not invert on_touch_up events and therefore does not properly dispatch on_release
**Software Versions**
* Python: 3.7
* OS: Raspberry Pi OS
* Kivy: v2.0.0rc3, git-Unknown, 20200723
* Kivy installation method: Master

**Describe the bug**
on_touch_up is not inverted by post processing and therefore on_release is not dispatched on a button release unless moving your finger to the inverted position on the screen before releasing.

**Expected behavior**
Having applied post processing to touch input events to invert y axis, on_press works but on_release does not

**To Reproduce**
Invert your input events in config.ini:
```
[input]
mtdev_%(name)s = probesysfs,provider=mtdev

[postproc:calibration]
(mtdev) = xoffset=1,yoffset=1,xratio=-1,yratio=-1
```

Run this code.  Assuming your touch is usually ok and you don't need any postproc, this will be slightly different for you than me: Touch the top of the screen which should press the button at the bottom of the screen due to inversion; and release, no on_release is dispatched. Now, touch the top of the screen, move your finger to the bottom half, release and on_release is dispatched.  You can try in horizontal mode too by toggling comments.

```
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button


class MyPage(BoxLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.orientation = 'vertical'
        #self.orientation = 'horizontal'

        # Message
        self.message = Label(text='Top section, no button')
        self.add_widget(self.message)

        # Button
        self.btn = Button(text='Bottom section, button')
        self.btn.bind(on_press=self.my_press)
        self.btn.bind(on_release=self.my_release)
        #self.btn.bind(on_touch_up=self.my_touch_up)
        self.add_widget(self.btn)

    def my_press(self, touch):
        print('on press', self.btn.collide_point(*touch.pos))

    def my_release(self, touch):
        print('on release', self.btn.collide_point(*touch.pos))

    def my_touch_up(self, instance, touch):
        print('on_touch_up', self.btn.collide_point(*touch.pos))


class TouchApp(App):
    def build(self):
        page = MyPage()
        return page


if __name__ == "__main__":
  app = TouchApp()
  app.run()
```


If you remove the post processing, you will likely see that everything is normal, this shows that it is an error with post processing (or at lease the way it is applied to on_touch_up) as the on_press reverts to the same as on_release.

I hope this is all clear but please let me know any more info required.  I have not posted the trace as this is not an issue that crashes and therefore I don't think it is useful but let me know if that's wrong and I will post.

I also have an issue that is likely related to this when using a horizontal carousel within a vertical carousel: with the same layout as above (i.e. button on the bottom half of the screen) when tapping the top half, the button presses and releases but when holding the bottom half, the button presses and releases when released.  I am still trying to simplify an example for this issue but referencing here in case it effects above.

Thanks!


Discussion:
I tried to adjust the Button class by manually inverting the touch (i.e. * -1) but no dice, it's a bit (quite a lot) over my head.  The workaround I have for now is `always_release=True` on the button but it's not ideal.
I'm having the same issue, I also have my touchscreen inverted. I'm using Ryce358's workaround. Is there a way I can silence the error message?
I found a fix by making changes in the Kivy config.ini file in my $HOME/.kivy.
```
hid_%(name)s = probesysfs,provider=hidinput,invert_x=1,invert_y=1
display = mtdev,/dev/input/event0,invert_x=1,invert_y=1
```
I added the following lines above to the [input] section and removed other inputs as I'm solely using touch.
I previously had;
```
(mtdev) = xoffset=1,yoffset=1,xratio=-1,yratio=-1
```
This has been removed from the [postproc:calibration] section and the on_release on my inverted display work great!
(No need for ```always_release=True```)

It may be nice to add this to the docs as an example config if people run into this problem and are unable to find in the docs how to write the configuration to solve it. So PR welcome.

Resolving patch:
diff --git a/kivy/input/providers/mtdev.py b/kivy/input/providers/mtdev.py
--- a/kivy/input/providers/mtdev.py
+++ b/kivy/input/providers/mtdev.py
@@ -34,6 +34,12 @@
 * min_touch_minor : width shape minimum
 * max_touch_minor : height shape maximum
 * rotation : 0,90,180 or 270 to rotate
+
+An inverted display configuration will look like this::
+
+    [input]
+    # example for inverting touch events
+    display = mtdev,/dev/input/event0,invert_x=1,invert_y=1
 '''
 
 __all__ = ('MTDMotionEventProvider', 'MTDMotionEvent')


Test patch: