blob: ffd547b597abaf87aac2aa99cbcfc344b4d5d370 [file] [log] [blame]
Vladimir Chtchetkine01193622010-05-11 13:07:22 -07001/* Copyright (C) 2006-2010 The Android Open Source Project
2**
3** This software is licensed under the terms of the GNU General Public
4** License version 2, as published by the Free Software Foundation, and
5** may be copied, distributed, and modified under those terms.
6**
7** This program is distributed in the hope that it will be useful,
8** but WITHOUT ANY WARRANTY; without even the implied warranty of
9** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10** GNU General Public License for more details.
11*/
12
Vladimir Chtchetkine01193622010-05-11 13:07:22 -070013#include "android/utils/debug.h"
14#include "android/utils/bufprint.h"
15#include "android/globals.h"
16#include "android/qemulator.h"
Vladimir Chtchetkine777eb682011-01-26 11:19:19 -080017#include "android/protocol/core-commands-api.h"
18#include "android/protocol/ui-commands-api.h"
David 'Digit' Turnerd4e803c2013-12-14 23:45:50 +010019#include "android/user-events.h"
Vladimir Chtchetkine01193622010-05-11 13:07:22 -070020
21#define D(...) do { if (VERBOSE_CHECK(init)) dprint(__VA_ARGS__); } while (0)
22static double get_default_scale( AndroidOptions* opts );
23
24/* QEmulator structure instance. */
25static QEmulator qemulator[1];
26
David 'Digit' Turner055ae422010-07-27 11:34:16 -070027static void handle_key_command( void* opaque, SkinKeyCommand command, int param );
28static void qemulator_refresh(QEmulator* emulator);
Vladimir Chtchetkine6b985d72011-01-20 18:02:35 -080029extern void qemu_system_shutdown_request(void);
David 'Digit' Turner055ae422010-07-27 11:34:16 -070030
Vladimir Chtchetkine01193622010-05-11 13:07:22 -070031static void
32qemulator_light_brightness( void* opaque, const char* light, int value )
33{
34 QEmulator* emulator = opaque;
35
36 VERBOSE_PRINT(hw_control,"%s: light='%s' value=%d window=%p", __FUNCTION__, light, value, emulator->window);
37 if ( !strcmp(light, "lcd_backlight") ) {
38 emulator->lcd_brightness = value;
39 if (emulator->window)
40 skin_window_set_lcd_brightness( emulator->window, value );
41 return;
42 }
43}
44
45static void
46qemulator_setup( QEmulator* emulator )
47{
48 AndroidOptions* opts = emulator->opts;
49
50 if ( !emulator->window && !opts->no_window ) {
51 SkinLayout* layout = emulator->layout;
52 double scale = get_default_scale(emulator->opts);
53
54 emulator->window = skin_window_create( layout, emulator->win_x, emulator->win_y, scale, 0);
55 if (emulator->window == NULL)
56 return;
57
58 {
59 SkinTrackBall* ball;
60 SkinTrackBallParameters params;
61
62 params.diameter = 30;
63 params.ring = 2;
64 params.ball_color = 0xffe0e0e0;
65 params.dot_color = 0xff202020;
66 params.ring_color = 0xff000000;
67
68 ball = skin_trackball_create( &params );
69 emulator->trackball = ball;
70 skin_window_set_trackball( emulator->window, ball );
71
72 emulator->lcd_brightness = 128; /* 50% */
73 skin_window_set_lcd_brightness( emulator->window, emulator->lcd_brightness );
74 }
75
76 if ( emulator->onion != NULL )
77 skin_window_set_onion( emulator->window,
78 emulator->onion,
79 emulator->onion_rotation,
80 emulator->onion_alpha );
81
82 qemulator_set_title(emulator);
83
Vladimir Chtchetkine863d1012012-03-16 12:25:23 -070084 skin_window_enable_touch ( emulator->window,
85 !androidHwConfig_isScreenNoTouch(android_hw));
Vladimir Chtchetkine01193622010-05-11 13:07:22 -070086 skin_window_enable_dpad ( emulator->window, android_hw->hw_dPad != 0 );
87 skin_window_enable_qwerty( emulator->window, android_hw->hw_keyboard != 0 );
88 skin_window_enable_trackball( emulator->window, android_hw->hw_trackBall != 0 );
89 }
90
91 /* initialize hardware control support */
Vladimir Chtchetkine777eb682011-01-26 11:19:19 -080092 uicmd_set_brightness_change_callback(qemulator_light_brightness,
93 emulator);
Vladimir Chtchetkine01193622010-05-11 13:07:22 -070094}
95
96static void
97qemulator_fb_update( void* _emulator, int x, int y, int w, int h )
98{
99 QEmulator* emulator = _emulator;
100
David 'Digit' Turner07db3492011-02-02 17:36:34 +0100101 if (!emulator->window) {
David 'Digit' Turnera1dcb6c2011-02-09 17:32:56 +0100102 if (emulator->opts->no_window)
103 return;
David 'Digit' Turner07db3492011-02-02 17:36:34 +0100104 qemulator_setup( emulator );
105 }
106 skin_window_update_display( emulator->window, x, y, w, h );
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700107}
108
109static void
110qemulator_fb_rotate( void* _emulator, int rotation )
111{
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700112 QEmulator* emulator = _emulator;
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700113
114 qemulator_setup( emulator );
115}
116
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700117static void
118qemulator_fb_poll( void* _emulator )
119{
120 QEmulator* emulator = _emulator;
121 qemulator_refresh(emulator);
122}
123
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700124QEmulator*
125qemulator_get(void)
126{
127 return qemulator;
128}
129
130int
131qemulator_init( QEmulator* emulator,
132 AConfig* aconfig,
133 const char* basepath,
134 int x,
135 int y,
136 AndroidOptions* opts )
137{
138 emulator->aconfig = aconfig;
139 emulator->layout_file = skin_file_create_from_aconfig(aconfig, basepath);
140 emulator->layout = emulator->layout_file->layouts;
Xavier Ducrohet72d56112011-08-11 18:47:27 -0700141 emulator->keyboard = skin_keyboard_create(opts->charmap, opts->raw_keys);
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700142 emulator->window = NULL;
143 emulator->win_x = x;
144 emulator->win_y = y;
145 emulator->opts[0] = opts[0];
146
147 /* register as a framebuffer clients for all displays defined in the skin file */
148 SKIN_FILE_LOOP_PARTS( emulator->layout_file, part )
149 SkinDisplay* disp = part->display;
150 if (disp->valid) {
151 qframebuffer_add_client( disp->qfbuff,
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700152 emulator,
153 qemulator_fb_update,
154 qemulator_fb_rotate,
155 qemulator_fb_poll,
156 NULL );
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700157 }
158 SKIN_FILE_LOOP_END_PARTS
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700159
160 skin_keyboard_enable( emulator->keyboard, 1 );
161 skin_keyboard_on_command( emulator->keyboard, handle_key_command, emulator );
162
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700163 return 0;
164}
165
166void
167qemulator_done(QEmulator* emulator)
168{
169 if (emulator->window) {
170 skin_window_free(emulator->window);
171 emulator->window = NULL;
172 }
173 if (emulator->trackball) {
174 skin_trackball_destroy(emulator->trackball);
175 emulator->trackball = NULL;
176 }
177 if (emulator->keyboard) {
178 skin_keyboard_free(emulator->keyboard);
179 emulator->keyboard = NULL;
180 }
181 emulator->layout = NULL;
182 if (emulator->layout_file) {
183 skin_file_free(emulator->layout_file);
184 emulator->layout_file = NULL;
185 }
186}
187
188SkinLayout*
189qemulator_get_layout(QEmulator* emulator)
190{
191 return emulator->layout;
192}
193
Vladimir Chtchetkinecf755ea2011-01-12 14:38:19 -0800194QFrameBuffer*
195qemulator_get_first_framebuffer(QEmulator* emulator)
196{
197 /* register as a framebuffer clients for all displays defined in the skin file */
198 SKIN_FILE_LOOP_PARTS( emulator->layout_file, part )
199 SkinDisplay* disp = part->display;
200 if (disp->valid) {
201 return disp->qfbuff;
202 }
203 SKIN_FILE_LOOP_END_PARTS
204 return NULL;
205}
206
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700207void
208qemulator_set_title(QEmulator* emulator)
209{
210 char temp[128], *p=temp, *end=p+sizeof temp;;
211
212 if (emulator->window == NULL)
213 return;
214
215 if (emulator->show_trackball) {
216 SkinKeyBinding bindings[ SKIN_KEY_COMMAND_MAX_BINDINGS ];
217 int count;
218
219 count = skin_keyset_get_bindings( android_keyset,
220 SKIN_KEY_COMMAND_TOGGLE_TRACKBALL,
221 bindings );
222
223 if (count > 0) {
224 int nn;
225 p = bufprint( p, end, "Press " );
226 for (nn = 0; nn < count; nn++) {
227 if (nn > 0) {
228 if (nn < count-1)
229 p = bufprint(p, end, ", ");
230 else
231 p = bufprint(p, end, " or ");
232 }
233 p = bufprint(p, end, "%s",
234 skin_key_symmod_to_str( bindings[nn].sym,
235 bindings[nn].mod ) );
236 }
237 p = bufprint(p, end, " to leave trackball mode. ");
238 }
239 }
240
241 p = bufprint(p, end, "%d:%s",
Vladimir Chtchetkine57584042011-01-20 16:15:30 -0800242 android_base_port,
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700243 avdInfo_getName( android_avdInfo ));
244
245 skin_window_set_title( emulator->window, temp );
246}
247
248/*
249 * Helper routines
250 */
251
David 'Digit' Turner5377c5b2011-02-10 16:52:19 +0100252static int
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700253get_device_dpi( AndroidOptions* opts )
254{
Vladimir Chtchetkine777eb682011-01-26 11:19:19 -0800255 int dpi_device = corecmd_get_hw_lcd_density();
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700256
257 if (opts->dpi_device != NULL) {
258 char* end;
259 dpi_device = strtol( opts->dpi_device, &end, 0 );
260 if (end == NULL || *end != 0 || dpi_device <= 0) {
261 fprintf(stderr, "argument for -dpi-device must be a positive integer. Aborting\n" );
262 exit(1);
263 }
264 }
265 return dpi_device;
266}
267
268static double
269get_default_scale( AndroidOptions* opts )
270{
271 int dpi_device = get_device_dpi( opts );
272 int dpi_monitor = -1;
273 double scale = 0.0;
274
275 /* possible values for the 'scale' option are
276 * 'auto' : try to determine the scale automatically
277 * '<number>dpi' : indicates the host monitor dpi, compute scale accordingly
278 * '<fraction>' : use direct scale coefficient
279 */
280
281 if (opts->scale) {
282 if (!strcmp(opts->scale, "auto"))
283 {
284 /* we need to get the host dpi resolution ? */
285 int xdpi, ydpi;
286
287 if ( SDL_WM_GetMonitorDPI( &xdpi, &ydpi ) < 0 ) {
288 fprintf(stderr, "could not get monitor DPI resolution from system. please use -dpi-monitor to specify one\n" );
289 exit(1);
290 }
291 D( "system reported monitor resolutions: xdpi=%d ydpi=%d\n", xdpi, ydpi);
292 dpi_monitor = (xdpi + ydpi+1)/2;
293 }
294 else
295 {
296 char* end;
297 scale = strtod( opts->scale, &end );
298
299 if (end && end[0] == 'd' && end[1] == 'p' && end[2] == 'i' && end[3] == 0) {
300 if ( scale < 20 || scale > 1000 ) {
301 fprintf(stderr, "emulator: ignoring bad -scale argument '%s': %s\n", opts->scale,
302 "host dpi number must be between 20 and 1000" );
303 exit(1);
304 }
305 dpi_monitor = scale;
306 scale = 0.0;
307 }
308 else if (end == NULL || *end != 0) {
309 fprintf(stderr, "emulator: ignoring bad -scale argument '%s': %s\n", opts->scale,
310 "not a number or the 'auto' keyword" );
311 exit(1);
312 }
313 else if ( scale < 0.1 || scale > 3. ) {
314 fprintf(stderr, "emulator: ignoring bad -window-scale argument '%s': %s\n", opts->scale,
315 "must be between 0.1 and 3.0" );
316 exit(1);
317 }
318 }
319 }
320
321 if (scale == 0.0 && dpi_monitor > 0)
322 scale = dpi_monitor*1.0/dpi_device;
323
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700324 return scale;
325}
326
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700327/* used to respond to a given keyboard command shortcut
328 */
329static void
330handle_key_command( void* opaque, SkinKeyCommand command, int down )
331{
332 static const struct { SkinKeyCommand cmd; AndroidKeyCode kcode; } keycodes[] =
333 {
Maciek Molerus97d15562011-07-06 12:27:56 +0200334 { SKIN_KEY_COMMAND_BUTTON_CALL, kKeyCodeCall },
335 { SKIN_KEY_COMMAND_BUTTON_HOME, kKeyCodeHome },
336 { SKIN_KEY_COMMAND_BUTTON_BACK, kKeyCodeBack },
337 { SKIN_KEY_COMMAND_BUTTON_HANGUP, kKeyCodeEndCall },
338 { SKIN_KEY_COMMAND_BUTTON_POWER, kKeyCodePower },
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700339 { SKIN_KEY_COMMAND_BUTTON_SEARCH, kKeyCodeSearch },
340 { SKIN_KEY_COMMAND_BUTTON_MENU, kKeyCodeMenu },
341 { SKIN_KEY_COMMAND_BUTTON_DPAD_UP, kKeyCodeDpadUp },
342 { SKIN_KEY_COMMAND_BUTTON_DPAD_LEFT, kKeyCodeDpadLeft },
343 { SKIN_KEY_COMMAND_BUTTON_DPAD_RIGHT, kKeyCodeDpadRight },
344 { SKIN_KEY_COMMAND_BUTTON_DPAD_DOWN, kKeyCodeDpadDown },
345 { SKIN_KEY_COMMAND_BUTTON_DPAD_CENTER, kKeyCodeDpadCenter },
346 { SKIN_KEY_COMMAND_BUTTON_VOLUME_UP, kKeyCodeVolumeUp },
347 { SKIN_KEY_COMMAND_BUTTON_VOLUME_DOWN, kKeyCodeVolumeDown },
348 { SKIN_KEY_COMMAND_BUTTON_CAMERA, kKeyCodeCamera },
Maciek Molerus97d15562011-07-06 12:27:56 +0200349 { SKIN_KEY_COMMAND_BUTTON_TV, kKeyCodeTV },
350 { SKIN_KEY_COMMAND_BUTTON_EPG, kKeyCodeEPG },
351 { SKIN_KEY_COMMAND_BUTTON_DVR, kKeyCodeDVR },
352 { SKIN_KEY_COMMAND_BUTTON_PREV, kKeyCodePrevious },
353 { SKIN_KEY_COMMAND_BUTTON_NEXT, kKeyCodeNext },
354 { SKIN_KEY_COMMAND_BUTTON_PLAY, kKeyCodePlay },
355 { SKIN_KEY_COMMAND_BUTTON_PAUSE, kKeyCodePause },
356 { SKIN_KEY_COMMAND_BUTTON_STOP, kKeyCodeStop },
357 { SKIN_KEY_COMMAND_BUTTON_REWIND, kKeyCodeRewind },
358 { SKIN_KEY_COMMAND_BUTTON_FFWD, kKeyCodeFastForward },
359 { SKIN_KEY_COMMAND_BUTTON_BOOKMARKS, kKeyCodeBookmarks },
360 { SKIN_KEY_COMMAND_BUTTON_WINDOW, kKeyCodeCycleWindows },
361 { SKIN_KEY_COMMAND_BUTTON_CHANNELUP, kKeyCodeChannelUp },
362 { SKIN_KEY_COMMAND_BUTTON_CHANNELDOWN, kKeyCodeChannelDown },
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700363 { SKIN_KEY_COMMAND_NONE, 0 }
364 };
365 int nn;
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700366 QEmulator* emulator = opaque;
367
368
369 for (nn = 0; keycodes[nn].kcode != 0; nn++) {
370 if (command == keycodes[nn].cmd) {
371 unsigned code = keycodes[nn].kcode;
372 if (down)
373 code |= 0x200;
374 user_event_keycode( code );
375 return;
376 }
377 }
378
379 // for the show-trackball command, handle down events to enable, and
380 // up events to disable
381 if (command == SKIN_KEY_COMMAND_SHOW_TRACKBALL) {
382 emulator->show_trackball = (down != 0);
383 skin_window_show_trackball( emulator->window, emulator->show_trackball );
384 //qemulator_set_title( emulator );
385 return;
386 }
387
388 // only handle down events for the rest
389 if (down == 0)
390 return;
391
392 switch (command)
393 {
394 case SKIN_KEY_COMMAND_TOGGLE_NETWORK:
395 {
Vladimir Chtchetkine777eb682011-01-26 11:19:19 -0800396 corecmd_toggle_network();
397 D( "network is now %s", corecmd_is_network_disabled() ?
Vladimir Chtchetkinecefa7442010-09-01 09:17:11 -0700398 "disconnected" : "connected" );
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700399 }
400 break;
401
402 case SKIN_KEY_COMMAND_TOGGLE_FULLSCREEN:
403 if (emulator->window) {
404 skin_window_toggle_fullscreen(emulator->window);
405 }
406 break;
407
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700408 case SKIN_KEY_COMMAND_TOGGLE_TRACKBALL:
409 emulator->show_trackball = !emulator->show_trackball;
410 skin_window_show_trackball( emulator->window, emulator->show_trackball );
411 qemulator_set_title(emulator);
412 break;
413
414 case SKIN_KEY_COMMAND_ONION_ALPHA_UP:
415 case SKIN_KEY_COMMAND_ONION_ALPHA_DOWN:
416 if (emulator->onion)
417 {
418 int alpha = emulator->onion_alpha;
419
420 if (command == SKIN_KEY_COMMAND_ONION_ALPHA_UP)
421 alpha += 16;
422 else
423 alpha -= 16;
424
425 if (alpha > 256)
426 alpha = 256;
427 else if (alpha < 0)
428 alpha = 0;
429
430 emulator->onion_alpha = alpha;
431 skin_window_set_onion( emulator->window, emulator->onion, emulator->onion_rotation, alpha );
432 skin_window_redraw( emulator->window, NULL );
433 //dprint( "onion alpha set to %d (%.f %%)", alpha, alpha/2.56 );
434 }
435 break;
436
437 case SKIN_KEY_COMMAND_CHANGE_LAYOUT_PREV:
438 case SKIN_KEY_COMMAND_CHANGE_LAYOUT_NEXT:
439 {
440 SkinLayout* layout = NULL;
441
442 if (command == SKIN_KEY_COMMAND_CHANGE_LAYOUT_NEXT) {
443 layout = emulator->layout->next;
444 if (layout == NULL)
445 layout = emulator->layout_file->layouts;
446 }
447 else if (command == SKIN_KEY_COMMAND_CHANGE_LAYOUT_PREV) {
448 layout = emulator->layout_file->layouts;
449 while (layout->next && layout->next != emulator->layout)
450 layout = layout->next;
451 }
452 if (layout != NULL) {
453 SkinRotation rotation;
454
455 emulator->layout = layout;
456 skin_window_reset( emulator->window, layout );
457
458 rotation = skin_layout_get_dpad_rotation( layout );
459
460 if (emulator->keyboard)
461 skin_keyboard_set_rotation( emulator->keyboard, rotation );
462
463 if (emulator->trackball) {
464 skin_trackball_set_rotation( emulator->trackball, rotation );
465 skin_window_set_trackball( emulator->window, emulator->trackball );
466 skin_window_show_trackball( emulator->window, emulator->show_trackball );
467 }
468
469 skin_window_set_lcd_brightness( emulator->window, emulator->lcd_brightness );
470
471 qframebuffer_invalidate_all();
472 qframebuffer_check_updates();
473 }
474 }
475 break;
476
477 default:
478 /* XXX: TODO ? */
479 ;
480 }
481}
482
483/* called periodically to poll for user input events */
484static void qemulator_refresh(QEmulator* emulator)
485{
486 SDL_Event ev;
487 SkinWindow* window = emulator->window;
488 SkinKeyboard* keyboard = emulator->keyboard;
489
490 /* this will eventually call sdl_update if the content of the VGA framebuffer
491 * has changed */
492 qframebuffer_check_updates();
493
494 if (window == NULL)
495 return;
496
497 while(SDL_PollEvent(&ev)){
498 switch(ev.type){
499 case SDL_VIDEOEXPOSE:
500 skin_window_redraw( window, NULL );
501 break;
502
503 case SDL_KEYDOWN:
504#ifdef _WIN32
505 /* special code to deal with Alt-F4 properly */
506 if (ev.key.keysym.sym == SDLK_F4 &&
507 ev.key.keysym.mod & KMOD_ALT) {
508 goto CleanExit;
509 }
510#endif
511#ifdef __APPLE__
512 /* special code to deal with Command-Q properly */
513 if (ev.key.keysym.sym == SDLK_q &&
514 ev.key.keysym.mod & KMOD_META) {
515 goto CleanExit;
516 }
517#endif
518 skin_keyboard_process_event( keyboard, &ev, 1 );
519 break;
520
521 case SDL_KEYUP:
522 skin_keyboard_process_event( keyboard, &ev, 0 );
523 break;
524
525 case SDL_MOUSEMOTION:
526 skin_window_process_event( window, &ev );
527 break;
528
529 case SDL_MOUSEBUTTONDOWN:
530 case SDL_MOUSEBUTTONUP:
531 {
532 int down = (ev.type == SDL_MOUSEBUTTONDOWN);
533 if (ev.button.button == 4)
534 {
535 /* scroll-wheel simulates DPad up */
536 AndroidKeyCode kcode;
537
538 kcode = // qemulator_rotate_keycode(kKeyCodeDpadUp);
539 android_keycode_rotate(kKeyCodeDpadUp,
540 skin_layout_get_dpad_rotation(qemulator_get_layout(qemulator_get())));
541 user_event_key( kcode, down );
542 }
543 else if (ev.button.button == 5)
544 {
545 /* scroll-wheel simulates DPad down */
546 AndroidKeyCode kcode;
547
548 kcode = // qemulator_rotate_keycode(kKeyCodeDpadDown);
549 android_keycode_rotate(kKeyCodeDpadDown,
550 skin_layout_get_dpad_rotation(qemulator_get_layout(qemulator_get())));
551 user_event_key( kcode, down );
552 }
553 else if (ev.button.button == SDL_BUTTON_LEFT) {
554 skin_window_process_event( window, &ev );
555 }
556#if 0
557 else {
558 fprintf(stderr, "... mouse button %s: button=%d state=%04x x=%d y=%d\n",
559 down ? "down" : "up ",
560 ev.button.button, ev.button.state, ev.button.x, ev.button.y);
561 }
562#endif
563 }
564 break;
565
566 case SDL_QUIT:
567#if defined _WIN32 || defined __APPLE__
568 CleanExit:
569#endif
570 /* only save emulator config through clean exit */
571 qemulator_done(qemulator_get());
Vladimir Chtchetkine6b985d72011-01-20 18:02:35 -0800572 qemu_system_shutdown_request();
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700573 return;
574 }
575 }
576
577 skin_keyboard_flush( keyboard );
578}
579
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700580/*
581 * android/console.c helper routines.
582 */
583
584SkinKeyboard*
585android_emulator_get_keyboard(void)
586{
587 return qemulator->keyboard;
588}
589
590void
591android_emulator_set_window_scale( double scale, int is_dpi )
592{
593 QEmulator* emulator = qemulator;
594
595 if (is_dpi)
596 scale /= get_device_dpi( emulator->opts );
597
598 if (emulator->window)
599 skin_window_set_scale( emulator->window, scale );
600}
601
David 'Digit' Turner3cf34f22010-07-30 16:53:39 -0700602
603void
604android_emulator_set_base_port( int port )
605{
Vladimir Chtchetkinecefa7442010-09-01 09:17:11 -0700606 /* Base port is already set in the emulator's core. */
David 'Digit' Turner3cf34f22010-07-30 16:53:39 -0700607 qemulator_set_title(qemulator);
608}