Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PS Vita touchpad ID after it has changed in SDL2 v2.30.7 #9307

Merged
merged 2 commits into from
Dec 1, 2024

Conversation

Districh-ru
Copy link
Collaborator

@Districh-ru Districh-ru commented Nov 30, 2024

fix #9305

In SDL2 v.2.30.7 the touchpads IDs for PS Vita have been changed: libsdl-org/SDL#10537
Unfortunately, the change was done not in all the code and the front touch do not work in the current release version of SDL2 yet. :(
But a fix has already been made for the future version of SDL2: libsdl-org/SDL#11442

It's good that the VitaSDK developers forced the specified fix: vitasdk/packages#324
and everything should work fine after we update the ID for touchpad.

@Districh-ru Districh-ru added the bug Something doesn't work label Nov 30, 2024
@Districh-ru Districh-ru added this to the 1.1.5 milestone Nov 30, 2024
@Districh-ru Districh-ru self-assigned this Nov 30, 2024
@Districh-ru
Copy link
Collaborator Author

I've compiled a PS Vita build on my WSL using latest VitaSDK and tested on Vita3K emulator and touch (emulation) works good.

@Districh-ru Districh-ru linked an issue Nov 30, 2024 that may be closed by this pull request
2 tasks
@Districh-ru
Copy link
Collaborator Author

Hi, @kazenoyouni!
Could you please test the fix on your hardware (check that front touch works and back touch activity does not affect fheroes2).
fheroes2_psv.zip

@Districh-ru
Copy link
Collaborator Author

Districh-ru commented Nov 30, 2024

Pønytail from Discord has successfully tested this build on his PS Vita hardware.

@Districh-ru
Copy link
Collaborator Author

Districh-ru commented Nov 30, 2024

Also Pønytail has reported that he has about 40 seconds hang when he wants to start a new game for the first time after fheroes2 has launched - in Russian:

"Пока что из замеченного, при нажатии на "новую игру" приложение всё так же зависает примерно на 40 секунд, после чего нажатие на эту кнопку становится адекватным до следующего перезапуска приложения. Такое поведение тоже началось с версии 1,1,3"

But I could not reproduce such hand on Vita3K emulator.

Copy link
Collaborator

@oleg-derevenetz oleg-derevenetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The only change I made was to use a different device id value depending on the SDL version, so that everything works correctly with older SDL versions, if someone decides to use them.

@kazenoyouni
Copy link

Hi, @Districh-ru !
I have confirmed that the mentioned problem has been fixed on my hardware (back touch activity also does not affect fheroes2).
Thank you very much for your quick action!

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Nov 30, 2024

Also Pønytail has reported that he has about 40 seconds hang when he wants to start a new game for the first time after fheroes2 has launched - in Russian:

"Пока что из замеченного, при нажатии на "новую игру" приложение всё так же зависает примерно на 40 секунд, после чего нажатие на эту кнопку становится адекватным до следующего перезапуска приложения. Такое поведение тоже началось с версии 1,1,3"

But I could not reproduce such hand on Vita3K emulator.

Well, it's hard to say what this is specifically related to. Apparently, I/O on a real device is much slower than on an emulator running on modern hardware, but it's hard to tell without a real device what exactly is so slow - whether getting a list of files via std::filesystem on PS Vita or some kind of map file parsing due to some changes... Those who want to, and have a real device, can try to find out exactly which change slowed down the work using git bisect. Apparently, the result of the corresponding I/O operations is cached after the first time, and then everything works faster.

And how long did it take to get a list of maps before 1.1.3?

@Districh-ru
Copy link
Collaborator Author

Well, it's hard to say what this is specifically related to. Apparently, I/O on a real device is much slower than on an emulator running on modern hardware, but it's hard to tell without a real device what exactly is so slow - whether getting a list of files via std::filesystem on PS Vita or some kind of map file parsing due to some changes... Those who want to, and have a real device, can try to find out exactly which change slowed down the work using git bisect. Apparently, the result of the corresponding I/O operations is cached after the first time, and then everything works faster.

And how long did it take to get a list of maps before 1.1.3?

I've asked Pønytail this question and he'll answer a little later.

On my emulator I've disabled all CPU optimizations (adventure map scrolling with many objects on map gives maximum 15 FPS) and did not notice any lags in opening STANDARD GAME dialog.
So probably it is a filesystem IO issue (my emulator is located on SSD).

@ihhub ihhub merged commit 2b4f5e3 into ihhub:master Dec 1, 2024
20 checks passed
@ihhub
Copy link
Owner

ihhub commented Dec 1, 2024

@Districh-ru , thank you very much for the fix!

@Districh-ru Districh-ru deleted the fix-vita-touchpad branch December 1, 2024 12:02
@Northfear
Copy link
Contributor

Also Pønytail has reported that he has about 40 seconds hang when he wants to start a new game for the first time after fheroes2 has launched - in Russian:

"Пока что из замеченного, при нажатии на "новую игру" приложение всё так же зависает примерно на 40 секунд, после чего нажатие на эту кнопку становится адекватным до следующего перезапуска приложения. Такое поведение тоже началось с версии 1,1,3"

But I could not reproduce such hand on Vita3K emulator.

I/O becomes INCREDIBLY slow on Vita if there are 100+ files in one folder (and maps folder can have hundreds of them). The main bottleneck was in the getFilesFromDirectory function. Previously Vita had a different code path there, but it looks like everything was moved to std::filesystem recently.
Native SCE_S_ISREG macro usage was a key optimization there, since it was preventing us from accessing the file once more in order to determine whether it's a file or a folder.

I can make a PR that restores the optimization (if maintainers don't mind some platform specific code there), but I'll have to dust off my Vita first..

@oleg-derevenetz
Copy link
Collaborator

Hi @Northfear

Native SCE_S_ISREG macro usage was a key optimization there, since it was preventing us from accessing the file once more in order to determine whether it's a file or a folder.

I don't know how exactly std::filesystem is implemented on Vita, but std::filesystem::directory_iterator returns not just the path, but the std::filesystem::directory_entry, which should also contain the file attributes, so checking these attributes should be a no-op and there should no need to access the file once more just to get its attributes. But, of course, anything can happen, and this thing may not be optimally implemented on Vita.

I can make a PR that restores the optimization (if maintainers don't mind some platform specific code there), but I'll have to dust off my Vita first.

I just did this in #9310, so, if it builds, we can try :)

@isage
Copy link

isage commented Jan 5, 2025

I don't know how exactly std::filesystem is implemented on Vita

Should be same as on other platforms (std::filesystem is implemented by gcc's libstdc++ and we don't touch that (yet). This, sadly, yields some issues with absolute/relative paths. This shouldn't be an issue for fheroes2, though)

@oleg-derevenetz
Copy link
Collaborator

Should be same as on other platforms (std::filesystem is implemented by gcc's libstdc++ and we don't touch that (yet). This, sadly, yields some issues with absolute/relative paths. This shouldn't be an issue for fheroes2, though)

It appears, however, that enumerating directory entries using sceIoDread() works faster (on a real device) than using the std::filesystem::directory_iterator given that the additional checks are performed (like calling the directory_entry::is_regular_file()). Apparently, the latter option reads the file attributes twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something doesn't work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Touch screen operation is no longer possible from 1.1.3
6 participants