As the title says it i’m looking for the APi in haiku that can get me this info from the OS, i looked at Screensaver.h but couldn’t find anything.
I found the following for other platforms in this file.
Get the number of seconds the user has been idle. In Unix-world
* this is based on the X Windows usage. In MS Windows this is
* based on keyboard/mouse usage information obtained from the OS.
* In MacOS X, this is based on keyboard/mouse usage information
* obtained from the OS, if configure detected IOKit. Otherwise,
* MacOS X is handled as a case of X Windows.
So, how is it for haiku?
You can read up the section titled SetEventMask(), SetMouseEventMask(), EventMask() at https://www.haiku-os.org/legacy-docs/bebook/BView.html#BView_Input
You can probably store the time of the last event, and update it in the mouse and keyboard event handlers. The idle time would then be the difference of current time to the last event time.
As for starting the screensaver, that is implemented using an input filter, see src/add-ons/input_server/filters/screen_saver/ScreenSaverFilter.cpp — however, this will run inside the input_server process. You can see that with Process Controller, inspecting the threads of input_server.