n4archive / pigame

A pygame wrapper for the libary pitft_touchscreen.
GNU Lesser General Public License v3.0
6 stars 1 forks source link

Add support for swapped and inverted axes. #15

Closed BroMarduk closed 5 years ago

BroMarduk commented 5 years ago

Add parameter to the initialization to support swapped and inverted axes. There are times when other software would require a display to be configured in a non-standard manner and adding these parameters would give a way to allow pigame to run in these configurations.

nift4 commented 5 years ago

I'm working on this...

nift4 commented 5 years ago

Working as excepted?

nift4 commented 5 years ago

In 3d930d6

nift4 commented 5 years ago

And b734b19

nift4 commented 5 years ago

And 3a7795e9

BroMarduk commented 5 years ago

I think the parameters are swapXY (or swapAxes), invertX, invertY.

Swap X axis with Y axis is a single operation and would be done when the event queue is parsed into the event. Invert X axis and Invert Y are independent and would be done when we calculate the position.

The naming goes along with what I have seen in the Adafruit and other screen dtoverlays

https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper

nift4 commented 5 years ago

Oops, my fail :)

nift4 commented 5 years ago

Finished, but must I swap and invert rel? I think so but I'm not sure.

nift4 commented 5 years ago

Hello? @BroMarduk

gmeader commented 5 years ago

If I set invertx=True , then x is always returned as 0

For example in sdl.py in Raspberry-Pi-Testing, changing pitft = pigame.PiTft() to pitft = pigame.PiTft(invertx = True) causes x to always be returned as zero by pygame.mouse.get_pos()

# To invert x, you need to subtract x from the screen_width screen_width, screen_height = pygame.display.get_surface().get_size() x = screen_width - x

gmeader commented 5 years ago

I got sdl.py in Raspberry-Pi-Testing working for my PiTFT 320x240 (EDIT by nift4: 2.8") capacitive by changing pigame.py:

  1. implementing a proper swapxy using a temp_x variable to hold the x value while it is being overwritten by the y value.
  2. implementing rotation=0 (do nothing)
nift4 commented 5 years ago

Oops, I'm banana :/

nift4 commented 5 years ago

I hope it works now, I think swapxy works because it's readed before writing (Python first builds the dictoniary and least but not last it assigns it to the variable)

nift4 commented 5 years ago

@gmeader Please post details about your workaround in #17

nift4 commented 5 years ago

Tested it, works