filename | src/gui_jni.c |
changeset | 1241:74f8e11ab4b8 |
prev | 1239:be3121267597 |
author | nkeynes |
date | Tue Feb 28 17:27:39 2012 +1000 (8 years ago) |
permissions | -rw-r--r-- |
last change | Pass the application home dir through to the native code, so we can use it as the default data directory |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * JNI wrappers for operating the emulator from Java.
5 *
6 * Copyright (c) 2012 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #include <jni.h>
20 #include <android/log.h>
21 #include <libisofs.h>
22 #include "dreamcast.h"
23 #include "gui.h"
24 #include "config.h"
25 #include "lxpaths.h"
26 #include "display.h"
27 #include "gdlist.h"
28 #include "hotkeys.h"
29 #include "serial.h"
30 #include "aica/audio.h"
31 #include "drivers/video_gl.h"
32 #include "maple/maple.h"
33 #include "vmu/vmulist.h"
35 static char *getStringChars( JNIEnv *env, jstring str )
36 {
37 jboolean iscopy;
38 const char *p = (*env)->GetStringUTFChars(env, str, &iscopy);
39 char *result = strdup(p);
40 (*env)->ReleaseStringUTFChars(env,str,p);
41 return result;
42 }
44 static const char *appHome = NULL;
46 JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_init(JNIEnv * env, jclass obj, jstring homeDir )
47 {
48 appHome = getStringChars(env, homeDir);
49 const char *confFile = g_strdup_printf("%s/lxdreamrc", appHome);
50 set_user_data_path(appHome);
51 lxdream_set_config_filename( confFile );
52 lxdream_make_config_dir( );
53 lxdream_load_config( );
54 iso_init();
55 gdrom_list_init();
56 vmulist_init();
57 dreamcast_init(1);
59 audio_init_driver(NULL);
60 display_driver_t display_driver = get_display_driver_by_name(NULL);
61 display_set_driver(display_driver);
63 hotkeys_init();
64 serial_init();
65 maple_reattach_all();
66 INFO( "%s! ready...", APP_NAME );
67 }
69 JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_setViewSize(JNIEnv * env, jclass obj, jint width, jint height)
70 {
71 gl_set_video_size(width, height);
72 }
74 JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_run(JNIEnv * env, jclass obj)
75 {
76 dreamcast_run();
77 }
79 JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_stop(JNIEnv * env, jclass obj)
80 {
81 dreamcast_stop();
82 }
84 gboolean gui_parse_cmdline( int *argc, char **argv[] )
85 {
86 return TRUE;
87 }
89 gboolean gui_init( gboolean debug, gboolean fullscreen )
90 {
91 return TRUE;
92 }
94 void gui_main_loop( gboolean run ) {
95 if( run ) {
96 dreamcast_run();
97 }
98 }
100 gboolean gui_error_dialog( const char *fmt, ... )
101 {
102 return TRUE;
103 }
105 void gui_update_state()
106 {
107 }
109 void gui_set_use_grab( gboolean grab )
110 {
111 }
113 void gui_update_io_activity( io_activity_type activity, gboolean active )
114 {
115 }
117 void gui_do_later( do_later_callback_t func )
118 {
119 func();
120 }
.