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