diff --git a/trunk/desmume/src/gtk/Makefile.am b/trunk/desmume/src/gtk/Makefile.am index e2fc3780b..c8f27d621 100644 --- a/trunk/desmume/src/gtk/Makefile.am +++ b/trunk/desmume/src/gtk/Makefile.am @@ -1,4 +1,5 @@ bin_PROGRAMS = desmume -desmume_SOURCES = gtk-compat.c gtk-compat.h main.c desmume.c dToolsList.c tools/ioregsView.c ../sndsdl.c +desmume_SOURCES = gtk-compat.c gtk-compat.h desmume.h desmume.c dToolsList.c tools/ioregsView.c globals.h ../sndsdl.c joysdl.h joysdl.c main.c desmume_LDADD = ../libdesmume.a $(SDL_LIBS) $(GTK_LIBS) desmume_CFLAGS = $(SDL_CFLAGS) $(GTK_CFLAGS) +#desmume_LDFLAGS = -rdynamic diff --git a/trunk/desmume/src/gtk/desmume.c b/trunk/desmume/src/gtk/desmume.c index 207a48622..1a8019620 100644 --- a/trunk/desmume/src/gtk/desmume.c +++ b/trunk/desmume/src/gtk/desmume.c @@ -1,13 +1,22 @@ -#include -#include -#include -#include - -#include "../MMU.h" -#include "../armcpu.h" -#include "../NDSSystem.h" -#include "../cflash.h" -#include "../sndsdl.h" +/* desmume.c - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ #include "desmume.h" @@ -53,12 +62,14 @@ BOOL desmume_running() void desmume_cycle() { + process_joy_events(); desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE); SPU_Emulate(); } void desmume_keypad(u16 k) { + printf("Update keypad...%x\n", k); unsigned short k_ext = (k >> 10) & 0x3; unsigned short k_pad = k & 0x3FF; ((unsigned short *)ARM9Mem.ARM9_REG)[0x130>>1] = k_pad; diff --git a/trunk/desmume/src/gtk/desmume.h b/trunk/desmume/src/gtk/desmume.h index 892eff2a4..45036a78c 100644 --- a/trunk/desmume/src/gtk/desmume.h +++ b/trunk/desmume/src/gtk/desmume.h @@ -1,8 +1,6 @@ #ifndef __DESMUME_H__ #define __DESMUME_H__ -#include "../types.h" - #define DESMUME_NB_KEYS 13 #define DESMUME_KEYMASK_(k) (1 << k) @@ -22,6 +20,8 @@ #define DESMUME_KEY_Y 12 #define DESMUME_KEY_DEBUG 13 +#include "joysdl.h" + extern void desmume_init(); extern void desmume_free(); diff --git a/trunk/desmume/src/gtk/main.c b/trunk/desmume/src/gtk/main.c index 694c18b4f..e1180c70a 100644 --- a/trunk/desmume/src/gtk/main.c +++ b/trunk/desmume/src/gtk/main.c @@ -1,21 +1,5 @@ -#include -#include -#include -#include - -#include -#include - -#include "../MMU.h" -#include "../armcpu.h" -#include "../NDSSystem.h" +#include "globals.h" #include "../debug.h" -#include "../sndsdl.h" - -#include "desmume.h" - -#include -#include #include "DeSmuME.xpm" @@ -142,6 +126,22 @@ const gint Default_Keypad_Config[DESMUME_NB_KEYS] = 112 }; +const u16 Default_Joypad_Config[DESMUME_NB_KEYS] = + { 1, // A + 0, // B + 5, // select + 8, // start + 20, // Right -- Start cheating abit... + 21, // Left + 22, // Up + 23, // Down -- End of cheating. + 7, // R + 6, // L + 3, // Y + 4, // X + -1 // DEBUG + }; + void Load_DefaultConfig() { memcpy(Keypad_Config, Default_Keypad_Config, sizeof(Keypad_Config)); @@ -993,6 +993,7 @@ static void dui_set_accel_group(gpointer action, gpointer group) { int main (int argc, char *argv[]) { + int nbJoysticks; int i; const char *commandLine_File = NULL; @@ -1008,13 +1009,34 @@ int main (int argc, char *argv[]) LogStart(); #endif + memcpy(Joypad_Config, Default_Joypad_Config, sizeof(Joypad_Config)); + gtk_init(&argc, &argv); - SDL_Init(SDL_INIT_VIDEO); + if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) == -1) + { + fprintf(stderr, "Error trying to initialize SDL: %s\n", + SDL_GetError()); + return 1; + } desmume_init(); dTools_running = (BOOL*)malloc(sizeof(BOOL) * dTools_list_size); for(i=0; i