mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #200 from houqp/new_ui_code
add getOrientation method
This commit is contained in:
37
einkfb.c
37
einkfb.c
@@ -225,7 +225,23 @@ static int einkSetOrientation(lua_State *L) {
|
||||
return luaL_error(L, "Wrong rotation mode %d given!", mode);
|
||||
}
|
||||
|
||||
/* ioctl has a different definition for rotation mode. */
|
||||
/* ioctl has a different definition for rotation mode.
|
||||
* 1
|
||||
* +--------------+
|
||||
* | +----------+ |
|
||||
* | | | |
|
||||
* | | Freedom! | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* 3 | | | | 2
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | +----------+ |
|
||||
* | |
|
||||
* | |
|
||||
* +--------------+
|
||||
* 0
|
||||
* */
|
||||
if (mode == 1)
|
||||
mode = 2;
|
||||
else if (mode == 2)
|
||||
@@ -236,6 +252,24 @@ static int einkSetOrientation(lua_State *L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int einkGetOrientation(lua_State *L) {
|
||||
int mode = 0;
|
||||
#ifndef EMULATE_READER
|
||||
FBInfo *fb = (FBInfo*) luaL_checkudata(L, 1, "einkfb");
|
||||
|
||||
ioctl(fb->fd, FBIO_EINK_GET_DISPLAY_ORIENTATION, &mode);
|
||||
|
||||
/* adjust ioctl's rotate mode definition to KPV's
|
||||
* refer to screen.lua */
|
||||
if (mode == 2)
|
||||
mode = 1;
|
||||
else if (mode == 1)
|
||||
mode = 2;
|
||||
#endif
|
||||
lua_pushinteger(L, mode);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static const struct luaL_Reg einkfb_func[] = {
|
||||
{"open", openFrameBuffer},
|
||||
@@ -246,6 +280,7 @@ static const struct luaL_Reg einkfb_meth[] = {
|
||||
{"close", closeFrameBuffer},
|
||||
{"__gc", closeFrameBuffer},
|
||||
{"refresh", einkUpdate},
|
||||
{"getOrientation", einkGetOrientation},
|
||||
{"setOrientation", einkSetOrientation},
|
||||
{"getSize", getSize},
|
||||
{NULL, NULL}
|
||||
|
||||
@@ -84,13 +84,8 @@ function Screen:getHeight()
|
||||
end
|
||||
|
||||
function Screen:updateRotationMode()
|
||||
if util.isEmulated() then -- in EMU mode always set to 0
|
||||
self.cur_rotation_mode = 0
|
||||
else
|
||||
orie_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_orientation", "r"))
|
||||
updown_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_upside_down", "r"))
|
||||
self.cur_rotation_mode = orie_fd:read() + (updown_fd:read() * 2)
|
||||
end
|
||||
-- in EMU mode, you will always get 0 from getOrientation()
|
||||
self.cur_rotation_mode = self.fb:getOrientation()
|
||||
end
|
||||
|
||||
function Screen:saveCurrentBB()
|
||||
|
||||
Reference in New Issue
Block a user