Apply clang format for samples files (#833)
Apply clang format for c source files under samples folder
This commit is contained in:
@ -14,12 +14,15 @@
|
||||
#define MONITOR_HOR_RES 320
|
||||
#define MONITOR_VER_RES 240
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#define MONITOR_ZOOM 1
|
||||
#endif
|
||||
#define SDL_REFR_PERIOD 50
|
||||
void monitor_sdl_init(void);
|
||||
void monitor_sdl_refr_core(void);
|
||||
void monitor_sdl_clean_up(void);
|
||||
#define SDL_REFR_PERIOD 50
|
||||
void
|
||||
monitor_sdl_init(void);
|
||||
void
|
||||
monitor_sdl_refr_core(void);
|
||||
void
|
||||
monitor_sdl_clean_up(void);
|
||||
|
||||
static uint32_t tft_fb[MONITOR_HOR_RES * MONITOR_VER_RES];
|
||||
|
||||
@ -30,22 +33,23 @@ time_get_ms(wasm_exec_env_t exec_env)
|
||||
gettimeofday(&tv, NULL);
|
||||
long long time_in_mill = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000;
|
||||
|
||||
return (int) time_in_mill;
|
||||
return (int)time_in_mill;
|
||||
}
|
||||
|
||||
SDL_Window * window;
|
||||
SDL_Renderer * renderer;
|
||||
SDL_Texture * texture;
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Texture *texture;
|
||||
static volatile bool sdl_inited = false;
|
||||
static volatile bool sdl_refr_qry = false;
|
||||
static volatile bool sdl_quit_qry = false;
|
||||
|
||||
void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color)
|
||||
void
|
||||
monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0 || y2 < 0 || x1 > MONITOR_HOR_RES - 1
|
||||
|| y1 > MONITOR_VER_RES - 1) {
|
||||
|| y1 > MONITOR_VER_RES - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -71,8 +75,8 @@ void monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
* @param y2 bottom coordinate
|
||||
* @param color fill color
|
||||
*/
|
||||
void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t *color)
|
||||
void
|
||||
monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0)
|
||||
@ -92,7 +96,7 @@ void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
uint32_t color32 = color->full; //lv_color_to32(color);
|
||||
uint32_t color32 = color->full; // lv_color_to32(color);
|
||||
|
||||
for (x = act_x1; x <= act_x2; x++) {
|
||||
for (y = act_y1; y <= act_y2; y++) {
|
||||
@ -111,8 +115,9 @@ void monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
* @param y2 bottom coordinate
|
||||
* @param color an array of colors
|
||||
*/
|
||||
void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color)
|
||||
void
|
||||
monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color)
|
||||
{
|
||||
/*Return if the area is out the screen*/
|
||||
if (x2 < 0)
|
||||
@ -135,7 +140,8 @@ void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
|
||||
for (y = act_y1; y <= act_y2; y++) {
|
||||
for (x = act_x1; x <= act_x2; x++) {
|
||||
tft_fb[y * MONITOR_HOR_RES + x] = color->full; //lv_color_to32(*color);
|
||||
tft_fb[y * MONITOR_HOR_RES + x] =
|
||||
color->full; // lv_color_to32(*color);
|
||||
color++;
|
||||
}
|
||||
|
||||
@ -145,38 +151,33 @@ void monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
sdl_refr_qry = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
display_init(void)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
display_flush(wasm_exec_env_t exec_env,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t *color)
|
||||
display_flush(wasm_exec_env_t exec_env, int32_t x1, int32_t y1, int32_t x2,
|
||||
int32_t y2, lv_color_t *color)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(module_inst,
|
||||
color, sizeof(lv_color_t)))
|
||||
if (!wasm_runtime_validate_native_addr(module_inst, color,
|
||||
sizeof(lv_color_t)))
|
||||
return;
|
||||
|
||||
monitor_flush(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
void
|
||||
display_fill(wasm_exec_env_t exec_env,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t *color)
|
||||
display_fill(wasm_exec_env_t exec_env, int32_t x1, int32_t y1, int32_t x2,
|
||||
int32_t y2, lv_color_t *color)
|
||||
{
|
||||
monitor_fill(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
void
|
||||
display_map(wasm_exec_env_t exec_env,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color)
|
||||
display_map(wasm_exec_env_t exec_env, int32_t x1, int32_t y1, int32_t x2,
|
||||
int32_t y2, const lv_color_t *color)
|
||||
{
|
||||
monitor_map(x1, y1, x2, y2, color);
|
||||
}
|
||||
@ -188,20 +189,17 @@ typedef struct display_input_data {
|
||||
} display_input_data;
|
||||
|
||||
bool
|
||||
display_input_read(wasm_exec_env_t exec_env,
|
||||
void *input_data_app)
|
||||
display_input_read(wasm_exec_env_t exec_env, void *input_data_app)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
display_input_data *data_app = (display_input_data*)input_data_app;
|
||||
display_input_data *data_app = (display_input_data *)input_data_app;
|
||||
bool ret;
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(module_inst,
|
||||
data_app,
|
||||
if (!wasm_runtime_validate_native_addr(module_inst, data_app,
|
||||
sizeof(display_input_data)))
|
||||
return false;
|
||||
|
||||
|
||||
lv_indev_data_t data = {0};
|
||||
lv_indev_data_t data = { 0 };
|
||||
|
||||
ret = mouse_read(&data);
|
||||
|
||||
@ -215,27 +213,26 @@ display_input_read(wasm_exec_env_t exec_env,
|
||||
|
||||
void
|
||||
display_deinit(wasm_exec_env_t exec_env)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
display_vdb_write(wasm_exec_env_t exec_env,
|
||||
void *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t *color, lv_opa_t opa)
|
||||
display_vdb_write(wasm_exec_env_t exec_env, void *buf, lv_coord_t buf_w,
|
||||
lv_coord_t x, lv_coord_t y, lv_color_t *color, lv_opa_t opa)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
unsigned char *buf_xy = (unsigned char*)buf + 4 * x + 4 * y * buf_w;
|
||||
unsigned char *buf_xy = (unsigned char *)buf + 4 * x + 4 * y * buf_w;
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(module_inst,
|
||||
color, sizeof(lv_color_t)))
|
||||
if (!wasm_runtime_validate_native_addr(module_inst, color,
|
||||
sizeof(lv_color_t)))
|
||||
return;
|
||||
|
||||
*(lv_color_t *)buf_xy = *color;
|
||||
}
|
||||
|
||||
int monitor_sdl_refr_thread(void * param)
|
||||
int
|
||||
monitor_sdl_refr_thread(void *param)
|
||||
{
|
||||
(void) param;
|
||||
(void)param;
|
||||
|
||||
/*If not OSX initialize SDL in the Thread*/
|
||||
monitor_sdl_init();
|
||||
@ -250,14 +247,16 @@ int monitor_sdl_refr_thread(void * param)
|
||||
|
||||
return 0;
|
||||
}
|
||||
extern void mouse_handler(SDL_Event *event);
|
||||
void monitor_sdl_refr_core(void)
|
||||
extern void
|
||||
mouse_handler(SDL_Event *event);
|
||||
void
|
||||
monitor_sdl_refr_core(void)
|
||||
{
|
||||
if (sdl_refr_qry != false) {
|
||||
sdl_refr_qry = false;
|
||||
|
||||
SDL_UpdateTexture(texture, NULL, tft_fb,
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
SDL_RenderClear(renderer);
|
||||
/*Update the renderer with the texture containing the rendered image*/
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
@ -272,29 +271,29 @@ void monitor_sdl_refr_core(void)
|
||||
if ((&event)->type == SDL_WINDOWEVENT) {
|
||||
switch ((&event)->window.event) {
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||
case SDL_WINDOWEVENT_TAKE_FOCUS:
|
||||
#endif
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
|
||||
SDL_UpdateTexture(texture, NULL, tft_fb,
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
SDL_UpdateTexture(texture, NULL, tft_fb,
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Sleep some time*/
|
||||
SDL_Delay(SDL_REFR_PERIOD);
|
||||
|
||||
}
|
||||
int quit_filter(void * userdata, SDL_Event * event)
|
||||
int
|
||||
quit_filter(void *userdata, SDL_Event *event)
|
||||
{
|
||||
(void) userdata;
|
||||
(void)userdata;
|
||||
|
||||
if (event->type == SDL_QUIT) {
|
||||
sdl_quit_qry = true;
|
||||
@ -303,7 +302,8 @@ int quit_filter(void * userdata, SDL_Event * event)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void monitor_sdl_clean_up(void)
|
||||
void
|
||||
monitor_sdl_clean_up(void)
|
||||
{
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
@ -311,34 +311,37 @@ void monitor_sdl_clean_up(void)
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void monitor_sdl_init(void)
|
||||
void
|
||||
monitor_sdl_init(void)
|
||||
{
|
||||
/*Initialize the SDL*/
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
SDL_SetEventFilter(quit_filter, NULL);
|
||||
|
||||
window = SDL_CreateWindow("TFT Simulator", SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
MONITOR_HOR_RES * MONITOR_ZOOM, MONITOR_VER_RES * MONITOR_ZOOM, 0); /*last param. SDL_WINDOW_BORDERLESS to hide borders*/
|
||||
window = SDL_CreateWindow(
|
||||
"TFT Simulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
MONITOR_HOR_RES * MONITOR_ZOOM, MONITOR_VER_RES * MONITOR_ZOOM,
|
||||
0); /*last param. SDL_WINDOW_BORDERLESS to hide borders*/
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STATIC, MONITOR_HOR_RES, MONITOR_VER_RES);
|
||||
SDL_TEXTUREACCESS_STATIC, MONITOR_HOR_RES,
|
||||
MONITOR_VER_RES);
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
|
||||
/*Initialize the frame buffer to gray (77 is an empirical value) */
|
||||
memset(tft_fb, 0x44, MONITOR_HOR_RES * MONITOR_VER_RES * sizeof(uint32_t));
|
||||
SDL_UpdateTexture(texture, NULL, tft_fb,
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
MONITOR_HOR_RES * sizeof(uint32_t));
|
||||
sdl_refr_qry = true;
|
||||
sdl_inited = true;
|
||||
}
|
||||
|
||||
void display_SDL_init()
|
||||
void
|
||||
display_SDL_init()
|
||||
{
|
||||
SDL_CreateThread(monitor_sdl_refr_thread, "sdl_refr", NULL);
|
||||
while (sdl_inited == false)
|
||||
; /*Wait until 'sdl_refr' initializes the SDL*/
|
||||
}
|
||||
|
||||
|
||||
@ -43,11 +43,16 @@ static char *uart_device = "/dev/ttyS2";
|
||||
static int baudrate = B115200;
|
||||
#endif
|
||||
|
||||
extern void init_sensor_framework();
|
||||
extern void exit_sensor_framework();
|
||||
extern void exit_connection_framework();
|
||||
extern int aee_host_msg_callback(void *msg, uint32_t msg_len);
|
||||
extern bool init_connection_framework();
|
||||
extern void
|
||||
init_sensor_framework();
|
||||
extern void
|
||||
exit_sensor_framework();
|
||||
extern void
|
||||
exit_connection_framework();
|
||||
extern int
|
||||
aee_host_msg_callback(void *msg, uint32_t msg_len);
|
||||
extern bool
|
||||
init_connection_framework();
|
||||
|
||||
#ifndef CONNECTION_UART
|
||||
int listenfd = -1;
|
||||
@ -61,7 +66,8 @@ int uartfd = -1;
|
||||
static bool server_mode = false;
|
||||
|
||||
// Function designed for chat between client and server.
|
||||
void* func(void* arg)
|
||||
void *
|
||||
func(void *arg)
|
||||
{
|
||||
char buff[MAX];
|
||||
int n;
|
||||
@ -75,7 +81,8 @@ void* func(void* arg)
|
||||
if (sockfd == -1) {
|
||||
printf("socket creation failed...\n");
|
||||
return NULL;
|
||||
} else
|
||||
}
|
||||
else
|
||||
printf("Socket successfully created..\n");
|
||||
bzero(&servaddr, sizeof(servaddr));
|
||||
// assign IP, PORT
|
||||
@ -84,11 +91,12 @@ void* func(void* arg)
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
// connect the client socket to server socket
|
||||
if (connect(sockfd, (SA*) &servaddr, sizeof(servaddr)) != 0) {
|
||||
if (connect(sockfd, (SA *)&servaddr, sizeof(servaddr)) != 0) {
|
||||
printf("connection with the server failed...\n");
|
||||
sleep(10);
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf("connected to the server..\n");
|
||||
}
|
||||
|
||||
@ -99,7 +107,7 @@ void* func(void* arg)
|
||||
// read the message from client and copy it in buffer
|
||||
n = read(sockfd, buff, sizeof(buff));
|
||||
// print buffer which contains the client contents
|
||||
//fprintf(stderr, "recieved %d bytes from host: %s", n, buff);
|
||||
// fprintf(stderr, "recieved %d bytes from host: %s", n, buff);
|
||||
|
||||
// socket disconnected
|
||||
if (n <= 0)
|
||||
@ -113,12 +121,14 @@ void* func(void* arg)
|
||||
close(sockfd);
|
||||
}
|
||||
|
||||
static bool host_init()
|
||||
static bool
|
||||
host_init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int host_send(void * ctx, const char *buf, int size)
|
||||
int
|
||||
host_send(void *ctx, const char *buf, int size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -137,7 +147,8 @@ int host_send(void * ctx, const char *buf, int size)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void host_destroy()
|
||||
void
|
||||
host_destroy()
|
||||
{
|
||||
if (server_mode)
|
||||
close(listenfd);
|
||||
@ -147,13 +158,12 @@ void host_destroy()
|
||||
pthread_mutex_unlock(&sock_lock);
|
||||
}
|
||||
|
||||
host_interface interface = {
|
||||
.init = host_init,
|
||||
host_interface interface = { .init = host_init,
|
||||
.send = host_send,
|
||||
.destroy = host_destroy
|
||||
};
|
||||
.destroy = host_destroy };
|
||||
|
||||
void* func_server_mode(void* arg)
|
||||
void *
|
||||
func_server_mode(void *arg)
|
||||
{
|
||||
int clilent;
|
||||
struct sockaddr_in serv_addr, cli_addr;
|
||||
@ -173,14 +183,14 @@ void* func_server_mode(void* arg)
|
||||
}
|
||||
|
||||
/* Initialize socket structure */
|
||||
bzero((char *) &serv_addr, sizeof(serv_addr));
|
||||
bzero((char *)&serv_addr, sizeof(serv_addr));
|
||||
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
serv_addr.sin_port = htons(port);
|
||||
|
||||
/* Now bind the host address using bind() call.*/
|
||||
if (bind(listenfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
|
||||
if (bind(listenfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
|
||||
perror("ERROR on binding");
|
||||
exit(1);
|
||||
}
|
||||
@ -191,7 +201,7 @@ void* func_server_mode(void* arg)
|
||||
while (1) {
|
||||
pthread_mutex_lock(&sock_lock);
|
||||
|
||||
sockfd = accept(listenfd, (struct sockaddr *) &cli_addr, &clilent);
|
||||
sockfd = accept(listenfd, (struct sockaddr *)&cli_addr, &clilent);
|
||||
|
||||
pthread_mutex_unlock(&sock_lock);
|
||||
|
||||
@ -225,7 +235,8 @@ void* func_server_mode(void* arg)
|
||||
}
|
||||
|
||||
#else
|
||||
static int parse_baudrate(int baud)
|
||||
static int
|
||||
parse_baudrate(int baud)
|
||||
{
|
||||
switch (baud) {
|
||||
case 9600:
|
||||
@ -268,7 +279,8 @@ static int parse_baudrate(int baud)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
static bool uart_init(const char *device, int baudrate, int *fd)
|
||||
static bool
|
||||
uart_init(const char *device, int baudrate, int *fd)
|
||||
{
|
||||
int uart_fd;
|
||||
struct termios uart_term;
|
||||
@ -299,7 +311,8 @@ static bool uart_init(const char *device, int baudrate, int *fd)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void *func_uart_mode(void *arg)
|
||||
static void *
|
||||
func_uart_mode(void *arg)
|
||||
{
|
||||
int n;
|
||||
char buff[MAX];
|
||||
@ -326,7 +339,8 @@ static void *func_uart_mode(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int uart_send(void * ctx, const char *buf, int size)
|
||||
static int
|
||||
uart_send(void *ctx, const char *buf, int size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -335,12 +349,14 @@ static int uart_send(void * ctx, const char *buf, int size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void uart_destroy()
|
||||
static void
|
||||
uart_destroy()
|
||||
{
|
||||
close(uartfd);
|
||||
}
|
||||
|
||||
static host_interface interface = { .send = uart_send, .destroy = uart_destroy };
|
||||
static host_interface interface = { .send = uart_send,
|
||||
.destroy = uart_destroy };
|
||||
|
||||
#endif
|
||||
|
||||
@ -350,6 +366,7 @@ static char global_heap_buf[400 * 1024] = { 0 };
|
||||
static char global_heap_buf[270 * 1024] = { 0 };
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
static void showUsage()
|
||||
{
|
||||
#ifndef CONNECTION_UART
|
||||
@ -373,8 +390,10 @@ static void showUsage()
|
||||
printf("\nNote:\n");
|
||||
printf("\tUse -w|--wasi_root to specify the root dir (default to '.') of WASI wasm modules. \n");
|
||||
}
|
||||
/* clang-format on */
|
||||
|
||||
static bool parse_args(int argc, char *argv[])
|
||||
static bool
|
||||
parse_args(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -382,17 +401,17 @@ static bool parse_args(int argc, char *argv[])
|
||||
int optIndex = 0;
|
||||
static struct option longOpts[] = {
|
||||
#ifndef CONNECTION_UART
|
||||
{ "server_mode", no_argument, NULL, 's' },
|
||||
{ "host_address", required_argument, NULL, 'a' },
|
||||
{ "port", required_argument, NULL, 'p' },
|
||||
{ "server_mode", no_argument, NULL, 's' },
|
||||
{ "host_address", required_argument, NULL, 'a' },
|
||||
{ "port", required_argument, NULL, 'p' },
|
||||
#else
|
||||
{ "uart", required_argument, NULL, 'u' },
|
||||
{ "baudrate", required_argument, NULL, 'b' },
|
||||
{ "uart", required_argument, NULL, 'u' },
|
||||
{ "baudrate", required_argument, NULL, 'b' },
|
||||
#endif
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
{ "wasi_root", required_argument, NULL, 'w' },
|
||||
{ "wasi_root", required_argument, NULL, 'w' },
|
||||
#endif
|
||||
{ "help", required_argument, NULL, 'h' },
|
||||
{ "help", required_argument, NULL, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@ -453,7 +472,8 @@ static NativeSymbol native_symbols[] = {
|
||||
};
|
||||
|
||||
// Driver function
|
||||
int iwasm_main(int argc, char *argv[])
|
||||
int
|
||||
iwasm_main(int argc, char *argv[])
|
||||
{
|
||||
RuntimeInitArgs init_args;
|
||||
korp_tid tid;
|
||||
@ -493,11 +513,12 @@ int iwasm_main(int argc, char *argv[])
|
||||
#ifndef CONNECTION_UART
|
||||
if (server_mode)
|
||||
os_thread_create(&tid, func_server_mode, NULL,
|
||||
BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
else
|
||||
os_thread_create(&tid, func, NULL, BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
#else
|
||||
os_thread_create(&tid, func_uart_mode, NULL, BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
os_thread_create(&tid, func_uart_mode, NULL,
|
||||
BH_APPLET_PRESERVED_STACK_SIZE);
|
||||
#endif
|
||||
|
||||
app_manager_startup(&interface);
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
extern int iwasm_main(int argc, char *argv[]);
|
||||
int main(int argc, char *argv[])
|
||||
extern int
|
||||
iwasm_main(int argc, char *argv[]);
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
return iwasm_main(argc,argv);
|
||||
return iwasm_main(argc, argv);
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#define MONITOR_ZOOM 1
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@ -43,17 +43,18 @@ static int16_t last_y = 0;
|
||||
/**
|
||||
* Initialize the mouse
|
||||
*/
|
||||
void mouse_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
void
|
||||
mouse_init(void)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Get the current position and state of the mouse
|
||||
* @param data store the mouse data here
|
||||
* @return false: because the points are not buffered, so no more data to be read
|
||||
* @return false: because the points are not buffered, so no more data to be
|
||||
* read
|
||||
*/
|
||||
bool mouse_read(lv_indev_data_t * data)
|
||||
bool
|
||||
mouse_read(lv_indev_data_t *data)
|
||||
{
|
||||
/*Store the collected data*/
|
||||
data->point.x = last_x;
|
||||
@ -66,27 +67,27 @@ bool mouse_read(lv_indev_data_t * data)
|
||||
/**
|
||||
* It will be called from the main SDL thread
|
||||
*/
|
||||
void mouse_handler(SDL_Event * event)
|
||||
void
|
||||
mouse_handler(SDL_Event *event)
|
||||
{
|
||||
switch (event->type) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (event->button.button == SDL_BUTTON_LEFT)
|
||||
left_button_down = false;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (event->button.button == SDL_BUTTON_LEFT) {
|
||||
left_button_down = true;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
if (event->button.button == SDL_BUTTON_LEFT)
|
||||
left_button_down = false;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
if (event->button.button == SDL_BUTTON_LEFT) {
|
||||
left_button_down = true;
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
last_x = event->motion.x / MONITOR_ZOOM;
|
||||
last_y = event->motion.y / MONITOR_ZOOM;
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
Reference in New Issue
Block a user