blubuild Posted August 30, 2015 Share Posted August 30, 2015 While trying to write a mod, I couldn't find any method allowing Lua/a mod to detect focus changes of the game application, or its current focus state. I guess I'll ask, by the way... is there good documentation for this (modding and DS Lua functions), or an index of good resources? Did see that pinned topic in the modding section (possibly not updated since 2013?). Currently, there are already OnFocusGained() and OnFocusLost() hooks within the game, but they seem to have been made exclusively for the Android version of it; this is seen from what their overrides are actually programmed to do as well as its comment (within saveindex.lua). Apparently, these hooks were added hastily to address a specific issue, while missing their modding potential/potential flexibility, and so they aren't called by non-Android game versions. I request that these hooks will be called on all platforms, and that their default declaration will be changed to verify the game's Android version is running before doing its stuff, to accommodate. While an event approach is of course comparably superior, there is also an existing TheSystemService:HasFocus() function, which either has to do with something else than the game program's focus, or according to my test always returns true on Windows (7 64-bit). According to the usage of this one (in gamelogic.lua), it may be a PS4-centric function: there would also be no harm in making it work across all platforms, either. Similarly, while I'm requesting this for DS, DST should also have this modding capability, if it hasn't already. Some possible uses reacting to focus change are: pausing while unfocused*, AFK detection and handling, etc. Personally, I'm also looking to see if I can make a mod fix a bug where keys (or specifically the alt key) enter a stuck state after Alt-Tabbing. Currently, to do any of these I have to do it the primitive, manual way by monitoring for Alt-Tab and WinKey keypresses, which isn't foolproof (or cross-platform) at all. *: Slightly odd that it's done in vanilla for *some* platforms, may want to reconsider that and add a togglable vanilla setting to allow this behavior on Windows and the other platforms as well. Link to comment https://forums.kleientertainment.com/forums/topic/57513-onfocusgained-and-onfocuslost-lua-functions-usable-on-all-platforms/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.