Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Issue with event.touch returning values 2x greater than screen resolution #43

Open
michaelroust opened this issue Nov 20, 2017 · 5 comments

Comments

@michaelroust
Copy link

Hello, OCEmu dev's thanks for this program. I explain the issue below.

event = require "event"
component = require "component"
gpu = component.gpu
screen = component.screen

screen.setPrecise(false)
print(gpu.getResolution())
print(screen.isPrecise())

while true do
  _, _, x, y = event.pull("touch")
  print("click at " .. x ..","..y)
end

The above code gives the gpu resolution to be 80, 25 yet when I click in the bottom right corner of the screen the following is printed "click at 160, 50" even after using screen.setPrecise(false). Changing it to screen.setPrecise(true) has no effect on the x, y values returned by event.pull("touch"). I've clicked on the bottom and top of the same 'pixel' and got +1 the value of the top of the pixel, which must mean that OCEmu constantly works as if screen's precise mode is on.

P.S. How can I change the max resolution of the emulator screen. I'd wish to be able to increase it to 160, 50 like a tier 3 screen. Especially since the emulator screen seems to have 'precise' touch event built in which is only a feature of the tier 3 screen.

Hope you can help!

@LoganDark
Copy link

You don't happen to be running macOS on a Retina screen, do you?

I have the same issue. I think the emulator ignores pixel density.

@gamax92
Copy link
Collaborator

gamax92 commented Dec 19, 2017

I don't own any mac computers, so it's hard for me to test this issue. I do pass SDL_WINDOW_ALLOW_HIGHDPI when creating the window.

If possible, can you go into OCEmu/src/component/screen_sdl2.lua and replace bit.bor(SDL.WINDOW_SHOWN, SDL.WINDOW_ALLOW_HIGHDPI) with SDL.WINDOW_SHOWN

@LoganDark
Copy link

LoganDark commented Dec 20, 2017

I believe SDL.WINDOW_ALLOW_HIGHDPI allows you to work in terms of real pixels instead of emulated pixels.

I just tested it, and that seems to be the case. Your solution works (at least on my machine), thanks.

@Taukurade
Copy link

I have a similar problem. I'm bad at programming on lua. does not work this way on my machine please give me the full corrected document code screen_sdl2

@gamax92
Copy link
Collaborator

gamax92 commented Dec 23, 2017

Patched version of screen_sdl2.lua (GitHub only let me upload it as a .txt extension, make sure to change the extension to .lua)

screen_sdl2.txt

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants