Initial joypad support for gtk UI.
This commit is contained in:
parent
af1bde05d9
commit
e7c4734cff
|
@ -1,4 +1,5 @@
|
||||||
bin_PROGRAMS = desmume
|
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_LDADD = ../libdesmume.a $(SDL_LIBS) $(GTK_LIBS)
|
||||||
desmume_CFLAGS = $(SDL_CFLAGS) $(GTK_CFLAGS)
|
desmume_CFLAGS = $(SDL_CFLAGS) $(GTK_CFLAGS)
|
||||||
|
#desmume_LDFLAGS = -rdynamic
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
#include <stdio.h>
|
/* desmume.c - this file is part of DeSmuME
|
||||||
#include <stdlib.h>
|
*
|
||||||
#include <string.h>
|
* Copyright (C) 2006,2007 DeSmuME Team
|
||||||
#include <libgen.h>
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
#include "../MMU.h"
|
* it under the terms of the GNU General Public License as published by
|
||||||
#include "../armcpu.h"
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
#include "../NDSSystem.h"
|
* any later version.
|
||||||
#include "../cflash.h"
|
*
|
||||||
#include "../sndsdl.h"
|
* 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"
|
#include "desmume.h"
|
||||||
|
|
||||||
|
@ -53,12 +62,14 @@ BOOL desmume_running()
|
||||||
|
|
||||||
void desmume_cycle()
|
void desmume_cycle()
|
||||||
{
|
{
|
||||||
|
process_joy_events();
|
||||||
desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE);
|
desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE);
|
||||||
SPU_Emulate();
|
SPU_Emulate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void desmume_keypad(u16 k)
|
void desmume_keypad(u16 k)
|
||||||
{
|
{
|
||||||
|
printf("Update keypad...%x\n", k);
|
||||||
unsigned short k_ext = (k >> 10) & 0x3;
|
unsigned short k_ext = (k >> 10) & 0x3;
|
||||||
unsigned short k_pad = k & 0x3FF;
|
unsigned short k_pad = k & 0x3FF;
|
||||||
((unsigned short *)ARM9Mem.ARM9_REG)[0x130>>1] = k_pad;
|
((unsigned short *)ARM9Mem.ARM9_REG)[0x130>>1] = k_pad;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef __DESMUME_H__
|
#ifndef __DESMUME_H__
|
||||||
#define __DESMUME_H__
|
#define __DESMUME_H__
|
||||||
|
|
||||||
#include "../types.h"
|
|
||||||
|
|
||||||
#define DESMUME_NB_KEYS 13
|
#define DESMUME_NB_KEYS 13
|
||||||
|
|
||||||
#define DESMUME_KEYMASK_(k) (1 << k)
|
#define DESMUME_KEYMASK_(k) (1 << k)
|
||||||
|
@ -22,6 +20,8 @@
|
||||||
#define DESMUME_KEY_Y 12
|
#define DESMUME_KEY_Y 12
|
||||||
#define DESMUME_KEY_DEBUG 13
|
#define DESMUME_KEY_DEBUG 13
|
||||||
|
|
||||||
|
#include "joysdl.h"
|
||||||
|
|
||||||
extern void desmume_init();
|
extern void desmume_init();
|
||||||
extern void desmume_free();
|
extern void desmume_free();
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,5 @@
|
||||||
#include <stdlib.h>
|
#include "globals.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include "../MMU.h"
|
|
||||||
#include "../armcpu.h"
|
|
||||||
#include "../NDSSystem.h"
|
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
#include "../sndsdl.h"
|
|
||||||
|
|
||||||
#include "desmume.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
|
|
||||||
#include "DeSmuME.xpm"
|
#include "DeSmuME.xpm"
|
||||||
|
|
||||||
|
@ -142,6 +126,22 @@ const gint Default_Keypad_Config[DESMUME_NB_KEYS] =
|
||||||
112
|
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()
|
void Load_DefaultConfig()
|
||||||
{
|
{
|
||||||
memcpy(Keypad_Config, Default_Keypad_Config, sizeof(Keypad_Config));
|
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 main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int nbJoysticks;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
const char *commandLine_File = NULL;
|
const char *commandLine_File = NULL;
|
||||||
|
@ -1008,13 +1009,34 @@ int main (int argc, char *argv[])
|
||||||
LogStart();
|
LogStart();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
memcpy(Joypad_Config, Default_Joypad_Config, sizeof(Joypad_Config));
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
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();
|
desmume_init();
|
||||||
|
|
||||||
dTools_running = (BOOL*)malloc(sizeof(BOOL) * dTools_list_size);
|
dTools_running = (BOOL*)malloc(sizeof(BOOL) * dTools_list_size);
|
||||||
for(i=0; i<dTools_list_size; i++) dTools_running[i]=FALSE;
|
for(i=0; i<dTools_list_size; i++) dTools_running[i]=FALSE;
|
||||||
|
|
||||||
|
/* Initialize joysticks */
|
||||||
|
nbJoysticks = SDL_NumJoysticks();
|
||||||
|
printf("Nbr of joysticks: %d\n\n", nbJoysticks);
|
||||||
|
|
||||||
|
for (i = 0; i < nbJoysticks; i++)
|
||||||
|
{
|
||||||
|
SDL_Joystick * joy = SDL_JoystickOpen(i);
|
||||||
|
printf("Joystick %s\n", i, SDL_JoystickName(i));
|
||||||
|
printf("Axes: %d\n", SDL_JoystickNumAxes(joy));
|
||||||
|
printf("Buttons: %d\n", SDL_JoystickNumButtons(joy));
|
||||||
|
printf("Trackballs: %d\n", SDL_JoystickNumBalls(joy));
|
||||||
|
printf("Hats: %d\n\n", SDL_JoystickNumHats(joy));
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG_FILE = g_build_filename(g_get_home_dir(), ".desmume.ini", NULL);
|
CONFIG_FILE = g_build_filename(g_get_home_dir(), ".desmume.ini", NULL);
|
||||||
Read_ConfigFile();
|
Read_ConfigFile();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue