PageRenderTime 342ms CodeModel.GetById 201ms app.highlight 5ms RepoModel.GetById 116ms app.codeStats 0ms

/src/backend/native/ftk_backend_gles.c

http://ftk.googlecode.com/
C | 69 lines | 59 code | 9 blank | 1 comment | 13 complexity | f2623030768b74c97b1266aefb83e357 MD5 | raw file
 1#include "ftk_log.h"
 2#include "ftk_globals.h"
 3#include "ftk_display_gles.h"
 4#include "ftk_source_input.h"
 5#include "ftk_wnd_manager.h"
 6#include "ftk_source_tslib.h"
 7
 8static Ret ftk_init_input(void)
 9{
10	char filename[260] = {0};
11	const char* tsdev = NULL;
12	FtkSource* source = NULL;
13	struct dirent* iter = NULL;
14	DIR* dir = opendir("/dev/input");
15	
16	return_val_if_fail(dir != NULL, RET_FAIL);
17
18	tsdev = getenv("FTK_TSLIB_FILE") ? getenv("FTK_TSLIB_FILE") : FTK_TSLIB_FILE;
19	while((iter = readdir(dir)) != NULL)
20	{
21		if(iter->d_name[0] == '.') continue;
22		if(!(iter->d_type & DT_CHR)) continue;
23
24		ftk_snprintf(filename, sizeof(filename), "/dev/input/%s", iter->d_name);
25#ifdef USE_TSLIB
26		if(strcmp(filename, tsdev) == 0)
27		{
28			/*skip tsdev now, open it later.*/
29			continue;
30		}
31		else
32#endif
33		{
34			source = ftk_source_input_create(filename, 
35				(FtkOnEvent)ftk_wnd_manager_queue_event_auto_rotate, ftk_default_wnd_manager());
36		}
37		if(source != NULL)
38		{
39			ftk_sources_manager_add(ftk_default_sources_manager(), source);
40		}
41	}
42	closedir(dir);
43
44#ifdef USE_TSLIB
45	source = ftk_source_tslib_create(tsdev, 
46				(FtkOnEvent)ftk_wnd_manager_queue_event_auto_rotate, ftk_default_wnd_manager());
47	if(source != NULL)
48	{
49		ftk_sources_manager_add(ftk_default_sources_manager(), source);
50	}
51	ftk_logd("%s: tsdev %s source=%p\n", __func__, tsdev, source);
52#endif
53
54	return RET_OK;
55}
56
57Ret ftk_backend_init(int argc, char* argv[])
58{
59	ftk_init_input();
60	ftk_set_display(ftk_display_gles_create());
61	if(ftk_default_display() == NULL)
62	{
63		ftk_loge("open display failed.\n");
64		exit(0);
65	}
66
67	return RET_OK;
68}
69