View Single Post
Old 08-10-2022, 12:16 PM   #451
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 3,060
Karma: 18821071
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
Here is what I have learned about the gsensor within the PocketBook InkView library:

I believe that QueryGSensor() just returns 0 if there is no gsensor, otherwise it returns some non-zero value. So, you can use the function to test whether you need to handle gsensor events, and how to handle the orientation at the start and end of the application.

GetOrientation/SetOrientation deal with the orientation in the InkView library. The orientation values are: 0 portrait, 1 landscape, 2 landscape 270, 3 portrait 180, -1 auto (gsensor). You probably don't need these functions for koreader unless you are querying libinkview functions for display settings (e.g. ScreenHeight() and ScreenWidth()).

gsensor events are of type EVT_ORIENTATION, and the first parameter provided with them is the new orientation (0-3 as described above). The idea is that you rotate what you are displaying to the given orientation each time such an event is signaled in your inkview main handler function. You would also call SetOrientation() then if necessary.

Older devices let you configure a global orientation in the system settings. Nice apps would honour that setting (retrieved via GetGlobalOrientation()). If the global orientation is set to -1, then you would track the gsensor, otherwise you ignore it. I don't see this system configuration option on my newish Colour ereader, so this probably isn't needed anymore. It looks like the more recent InkView API has new gsensor specific functions (SetGSensorEnabled(), IsGSensorEnabled(), GetGSensorOrientation()), but these are not available in older versions of the library. If you are not tracking InkView events, then maybe you can use GetGSensorOrientation() on newer devices to poll what the new orientation should be rather than mess with the mysterious ReadGSensor(). Or maybe do some testing to see if you can figure out how the ReadGSensor() readings correlate to the orientation values, and then just use that function on old and new devices.
rkomar is offline   Reply With Quote