}
/* emulator window scale */
-void set_emul_win_scale(int scale)
+void set_emul_win_scale(double scale_factor)
{
- _emul_state.scale = scale;
- INFO("emulator window scale = %d\n", _emul_state.scale);
+ _emul_state.scale_factor = scale_factor;
+ INFO("emulator window scale_factor = %d\n", _emul_state.scale_factor);
}
-int get_emul_win_scale(void)
+double get_emul_win_scale(void)
{
- return _emul_state.scale;
+ return _emul_state.scale_factor;
}
/* emulator rotation */
-void set_emul_rotation(short rotation)
+void set_emul_rotation(short rotation_type)
{
- _emul_state.rotation = rotation;
- INFO("emulator rotation = %d\n", _emul_state.rotation);
+ _emul_state.rotation_type = rotation_type;
+ INFO("emulator rotation type = %d\n", _emul_state.rotation_type);
}
short get_emul_rotation(void)
{
- return _emul_state.rotation;
+ return _emul_state.rotation_type;
}
} emulator_config_info;
typedef struct emulator_config_state {
- int scale;
- short rotation;
+ double scale_factor;
+ short rotation_type;
//TODO:
} emulator_config_state;
/* setter */
void set_emul_lcd_size(int width, int height);
-void set_emul_win_scale(int scale);
-void set_emul_rotation(short scale);
+void set_emul_win_scale(double scale);
+void set_emul_rotation(short rotation_type);
/* getter */
int get_emul_lcd_width(void);
int get_emul_lcd_height(void);
-int get_emul_win_scale(void);
+double get_emul_win_scale(void);
short get_emul_rotation(void);
#include "process.h"
#include "option.h"
#include "emul_state.h"
-#include "sdl_rotate.h"
+
#ifdef _WIN32
#include <winsock2.h>
#endif
INFO("construct main window\n");
//TODO: init
- set_emul_win_scale(50);
+ set_emul_win_scale(0.5);
set_emul_rotation(0);
#include <pthread.h>
#include "maru_sdl.h"
#include "emul_state.h"
+#include "sdl_rotate.h"
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
static int sdl_thread_initialized = 0;
#endif
+#define SDL_FLAGS (SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME)
+
static void qemu_update(void)
{
#ifndef SDL_THREAD
pthread_mutex_lock(&sdl_mutex);
#endif
SDL_Surface *processing_screen;
- double angle = 0.0;
+ double angle = 0.0; //ROTATION_PORTRAIT
//TODO: convert type define to angle value
short rotaton_type = get_emul_rotation();
- if (rotaton_type == 1) {
+ if (rotaton_type == ROTATION_LANDSCAPE) {
angle = 90.0;
- } else if (rotaton_type == 2) {
+ } else if (rotaton_type == ROTATION_REVERSE_PORTRAIT) {
angle = 180.0;
- } else if (rotaton_type == 3) {
+ } else if (rotaton_type == ROTATION_REVERSE_LANDSCAPE) {
angle = 270.0;
}
- processing_screen = rotozoomSurface(surface_qemu, angle, ((double)get_emul_win_scale()) / 100, 1);
+ processing_screen = rotozoomSurface(surface_qemu, angle, get_emul_win_scale(), 1);
SDL_BlitSurface(processing_screen, NULL, surface_screen, NULL);
SDL_UpdateRect(surface_screen, 0, 0, 0, 0);
while (SDL_PollEvent(ev)) {
switch (ev->type) {
- case SDL_KEYDOWN:
- case SDL_KEYUP:
+ case SDL_VIDEORESIZE:
+ {
+ SDL_ResizeEvent *rev = &ev->resize;
+ SDL_Quit();
+
+ surface_screen = SDL_SetVideoMode(rev->w, rev->h, 0, SDL_FLAGS);
+ if (surface_screen == NULL) {
+ //TODO : SDL_GetError
+ }
break;
+ }
+
default:
break;
}
}
INFO( "qemu_sdl_initialize\n");
- surface_screen = SDL_SetVideoMode(lcd_size_width, lcd_size_height,
- 0, SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_NOFRAME);
+ surface_screen = SDL_SetVideoMode(lcd_size_width, lcd_size_height, 0, SDL_FLAGS);
+ if (surface_screen == NULL) {
+ //TODO : SDL_GetError
+ }
set_emul_lcd_size(lcd_size_width, lcd_size_height);
#ifndef _WIN32
SDL_GetWMInfo(&info);
#endif
}
+
+void maruskin_sdl_resize(int w, int h)
+{
+ SDL_Event ev;
+
+ /* this fails if SDL is not initialized */
+ memset(&ev, 0, sizeof(ev));
+ ev.resize.type = SDL_VIDEORESIZE;
+ ev.resize.w = w;
+ ev.resize.h = h;
+ SDL_PushEvent(&ev);
+}
void maruskin_display_init(DisplayState *ds);
void maruskin_sdl_init(int swt_handle, int lcd_size_width, int lcd_size_height);
+void maruskin_sdl_resize(int w, int h);
#endif /* MARU_SDL_H_ */
#include "nbd.h"
#include "../mloop_event.h"
#include "emul_state.h"
-#include "sdl_rotate.h"
#ifndef _WIN32
#include "maruskin_keymap.h"
KEY_RELEASED = 2,
};
-void start_display( int handle_id, int lcd_size_width, int lcd_size_height, int scale, short rotation ) {
- INFO( "start_display handle_id:%d, lcd size:%dx%d, scale:%d, rotation:%d\n",
- handle_id, lcd_size_width, lcd_size_height, scale, rotation );
+void start_display( int handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short rotation ) {
+ INFO( "start_display handle_id:%d, lcd size:%dx%d, scale_factor:%lf, rotation:%d\n",
+ handle_id, lcd_size_width, lcd_size_height, scale_factor, rotation );
maruskin_sdl_init(handle_id, lcd_size_width, lcd_size_height);
}
}
-void do_scale_event( int event_type) {
- INFO( "do_scale_event event_type:%d", event_type);
+void do_scale_event( double scale_factor ) {
+ INFO( "do_scale_event scale_factor:%lf", scale_factor);
+
+ /*int rotation_type = get_emul_rotation();
+ if (rotation_type == ROTATION_PORTRAIT || rotation_type == ROTATION_REVERSE_PORTRAIT) {
+ maruskin_sdl_resize(get_emul_lcd_width() * scale_factor, get_emul_lcd_height() * scale_factor);
+ } else if (rotation_type == ROTATION_LANDSCAPE || rotation_type == ROTATION_REVERSE_LANDSCAPE) {
+ maruskin_sdl_resize(get_emul_lcd_height() * scale_factor, get_emul_lcd_width() * scale_factor);
+ }*/
//qemu refresh
vga_hw_invalidate();
vga_hw_update();
- set_emul_win_scale(event_type);
+ set_emul_win_scale(scale_factor);
}
-void do_rotation_event( int event_type) {
+void do_rotation_event( int rotation_type) {
- INFO( "do_rotation_event event_type:%d", event_type);
+ INFO( "do_rotation_event rotation_type:%d", rotation_type);
int buf_size = 32;
char send_buf[32] = { 0 };
- switch ( event_type ) {
- case ROTATION_PORTRAIT:
- sprintf( send_buf, "1\n3\n0\n-9.80665\n0\n" );
- break;
- case ROTATION_LANDSCAPE:
- sprintf( send_buf, "1\n3\n0\n9.80665\n0\n" );
- break;
- case ROTATION_REVERSE_PORTRAIT:
- sprintf( send_buf, "1\n3\n-9.80665\n0\n0\n" );
- break;
- case ROTATION_REVERSE_LANDSCAPE:
- sprintf(send_buf, "1\n3\n9.80665\n0\n0\n");
- break;
+ switch ( rotation_type ) {
+ case ROTATION_PORTRAIT:
+ sprintf( send_buf, "1\n3\n0\n-9.80665\n0\n" );
+ break;
+ case ROTATION_LANDSCAPE:
+ sprintf( send_buf, "1\n3\n0\n9.80665\n0\n" );
+ break;
+ case ROTATION_REVERSE_PORTRAIT:
+ sprintf( send_buf, "1\n3\n-9.80665\n0\n0\n" );
+ break;
+ case ROTATION_REVERSE_LANDSCAPE:
+ sprintf(send_buf, "1\n3\n9.80665\n0\n0\n");
+ break;
+
+ default:
+ break;
}
// send_to_sensor_daemon
INFO( "send to sendord(size: %d) 127.0.0.1:%d/tcp \n", buf_size, tizen_base_port + SDB_TCP_EMULD_INDEX);
- set_emul_rotation(event_type);
+ /*if (rotation_type == ROTATION_PORTRAIT || rotation_type == ROTATION_REVERSE_PORTRAIT) {
+ maruskin_sdl_resize(get_emul_lcd_width(), get_emul_lcd_height());
+ } else if (rotation_type == ROTATION_LANDSCAPE || rotation_type == ROTATION_REVERSE_LANDSCAPE) {
+ maruskin_sdl_resize(get_emul_lcd_height(), get_emul_lcd_width());
+ }*/
+ set_emul_rotation(rotation_type);
#ifdef _WIN32
closesocket( s );
#ifndef MARUSKIN_OPERATION_H_
#define MARUSKIN_OPERATION_H_
-void start_display( int handle_id, int lcd_size_width, int lcd_size_height, int scale, short direction );
+void start_display( int handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short direction );
void do_mouse_event( int event_type, int x, int y, int z );
void do_hardkey_event( int event_type, int keycode );
-void do_scale_event( int event_type);
+void do_scale_event( double scale_factor);
-void do_rotation_event( int event_type );
+void do_rotation_event( int rotation_type );
void open_shell(void);
int lcd_size_width = 0;
int lcd_size_height = 0;
int scale = 0;
+ double scale_ratio = 0.0;
short rotation = 0;
char* p = readbuf;
lcd_size_width = ntohl( lcd_size_width );
lcd_size_height = ntohl( lcd_size_height );
scale = ntohl( scale );
+ scale_ratio = ((double)scale) / 100;
rotation = ntohs( rotation );
- set_emul_win_scale(scale);
+ set_emul_win_scale(scale_ratio);
if ( start_heart_beat( client_sock ) ) {
- start_display( handle_id, lcd_size_width, lcd_size_height, scale, rotation );
+ start_display( handle_id, lcd_size_width, lcd_size_height, scale_ratio, rotation );
} else {
stop_server = 1;
}
}
int scale = 0;
- short rotation = 0;
+ double scale_ratio = 0.0;
+ short rotation_type = 0;
char* p = readbuf;
memcpy( &scale, p, sizeof( scale ) );
p += sizeof( scale );
- memcpy( &rotation, p, sizeof( rotation ) );
+ memcpy( &rotation_type, p, sizeof( rotation_type ) );
scale = ntohl( scale );
- rotation = ntohs( rotation );
+ scale_ratio = ((double)scale) / 100;
+ rotation_type = ntohs( rotation_type );
- if ( get_emul_win_scale() != scale ) {
- do_scale_event( scale );
+ if ( get_emul_win_scale() != scale_ratio ) {
+ do_scale_event( scale_ratio );
}
- if ( is_sensord_initialized == 1 && get_emul_rotation() != rotation ) {
- do_rotation_event( rotation );
+ if ( is_sensord_initialized == 1 && get_emul_rotation() != rotation_type ) {
+ do_rotation_event( rotation_type );
}
break;
}