Port to *BSD. It runs but isn't terribly useful without Cg.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5934 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-07-22 03:29:35 +00:00
parent cdce0ec322
commit 83883cee45
29 changed files with 5353 additions and 148 deletions

View File

@ -10,7 +10,14 @@ files = [
'src/joystick/SDL_joystick.c', 'src/joystick/SDL_joystick.c',
] ]
if sys.platform == 'darwin': if sys.platform.count('bsd'):
env['LIBS'] += ['usbhid']
files += [
'src/joystick/bsd/SDL_sysjoystick.c',
'src/stdlib/SDL_malloc.c',
'src/stdlib/SDL_string.c',
]
elif sys.platform == 'darwin':
files += [ files += [
'src/joystick/darwin/SDL_sysjoystick.c', 'src/joystick/darwin/SDL_sysjoystick.c',
] ]
@ -19,6 +26,10 @@ elif sys.platform == 'linux2':
'src/joystick/linux/SDL_sysjoystick.c', 'src/joystick/linux/SDL_sysjoystick.c',
'src/stdlib/SDL_string.c', 'src/stdlib/SDL_string.c',
] ]
elif sys.platform == 'win32':
files += [
'src/joystick/win32/SDL_mmjoystick.c',
]
else: else:
files += [ files += [
'src/joystick/dummy/SDL_sysjoystick.c', 'src/joystick/dummy/SDL_sysjoystick.c',

67
Externals/SDL/SDL/SDL_config_bsd.h vendored Normal file
View File

@ -0,0 +1,67 @@
#ifndef _SDL_config_h
#define _SDL_config_h
#include <sys/ioctl.h> /* XXX */
#define SDL_JOYSTICK_USBHID 1
#ifdef __FreeBSD__
#define HAVE_USBHID_H
#endif
#define USBHID_NEW
#define USBHID_UCR_DATA
#define HAVE_ABS 1
#define HAVE_ALLOCA 1
#define HAVE_ATOF 1
#define HAVE_ATOI 1
#define HAVE_BCOPY 1
#define HAVE_CALLOC 1
#define HAVE_CTYPE_H 1
#define HAVE_FREE 1
#define HAVE_GETENV 1
#define HAVE_INTTYPES_H 1
#define HAVE_MALLOC 1
#define HAVE_MATH_H 1
#define HAVE_MEMCMP 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMORY_H 1
#define HAVE_MEMSET 1
#define HAVE_MPROTECT 1
#define HAVE_NANOSLEEP 1
#define HAVE_PUTENV 1
#define HAVE_QSORT 1
#define HAVE_REALLOC 1
#define HAVE_SETJMP 1
#define HAVE_SIGACTION 1
#define HAVE_SIGNAL_H 1
#define HAVE_SNPRINTF 1
#define HAVE_SSCANF 1
#define HAVE_STDARG_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRCASECMP 1
#define HAVE_STRCHR 1
#define HAVE_STRCMP 1
#define HAVE_STRDUP 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRLCAT 1
#define HAVE_STRLCPY 1
#define HAVE_STRLEN 1
#define HAVE_STRNCASECMP 1
#define HAVE_STRNCMP 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOD 1
#define HAVE_STRTOL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOULL 1
#define HAVE_SYS_TYPES_H
#define HAVE_UNSETENV 1
#define HAVE_VSNPRINTF 1
#endif

View File

@ -1,5 +1,9 @@
#include <sys/param.h>
#if defined __APPLE__ #if defined __APPLE__
#include "include/SDL_config_macosx.h" #include "include/SDL_config_macosx.h"
#elif defined BSD4_4
#include "SDL/SDL_config_bsd.h"
#elif defined __linux__ #elif defined __linux__
#include "SDL/SDL_config_linux.h" #include "SDL/SDL_config_linux.h"
#endif #endif

View File

@ -197,12 +197,12 @@ SDL_SYS_JoystickInit(void)
} }
const char * const char *
SDL_SYS_JoystickName(int index) SDL_SYS_JoystickName(int jindex)
{ {
if (joydevnames[index] != NULL) { if (joydevnames[jindex] != NULL) {
return (joydevnames[index]); return (joydevnames[jindex]);
} }
return (joynames[index]); return (joynames[jindex]);
} }
static int static int

5111
Externals/SDL/src/stdlib/SDL_malloc.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,6 @@ cppDefines = [
] ]
include_paths = [ include_paths = [
'#',
'#Source/Core/Common/Src', '#Source/Core/Common/Src',
'#Source/Core/DiscIO/Src', '#Source/Core/DiscIO/Src',
'#Source/PluginSpecs', '#Source/PluginSpecs',
@ -68,7 +67,6 @@ dirs = [
'Source/Core/DSPCore/Src', 'Source/Core/DSPCore/Src',
'Source/DSPTool/Src', 'Source/DSPTool/Src',
'Source/Core/InputUICommon/Src', 'Source/Core/InputUICommon/Src',
'Source/Plugins/Plugin_VideoOGL/Src',
'Source/Plugins/Plugin_VideoSoftware/Src', 'Source/Plugins/Plugin_VideoSoftware/Src',
'Source/Plugins/Plugin_DSP_HLE/Src', 'Source/Plugins/Plugin_DSP_HLE/Src',
'Source/Plugins/Plugin_DSP_LLE/Src', 'Source/Plugins/Plugin_DSP_LLE/Src',
@ -79,6 +77,9 @@ dirs = [
'Source/UnitTests', 'Source/UnitTests',
] ]
if sys.platform == 'darwin' or sys.platform == 'linux2':
dirs += ['Source/Plugins/Plugin_VideoOGL/Src']
builders = {} builders = {}
if sys.platform == 'darwin': if sys.platform == 'darwin':
from plistlib import writePlist from plistlib import writePlist
@ -288,13 +289,13 @@ elif sys.platform == 'win32':
env['tools'] = ['mingw'] env['tools'] = ['mingw']
else: else:
env['CPPPATH'].insert(0, '#')
env['LINKFLAGS'] += ['-pthread']
conf = env.Configure(custom_tests = tests, config_h="#config.h") conf = env.Configure(custom_tests = tests, config_h="#config.h")
if not conf.CheckPKGConfig('0.15.0'): if not conf.CheckPKGConfig('0.15.0'):
print "Can't find pkg-config, some tests will fail" print "Can't find pkg-config, some tests will fail"
env['LINKFLAGS'] += ['-pthread']
if env['shared_glew']: if env['shared_glew']:
shared['glew'] = conf.CheckPKG('GLEW') shared['glew'] = conf.CheckPKG('GLEW')
if env['shared_sdl']: if env['shared_sdl']:
@ -324,6 +325,8 @@ else:
print "WX libraries not found - see config.log" print "WX libraries not found - see config.log"
Exit(1) Exit(1)
conf.CheckPKG('usbhid')
env['HAVE_BLUEZ'] = conf.CheckPKG('bluez') env['HAVE_BLUEZ'] = conf.CheckPKG('bluez')
conf.Define('HAVE_BLUEZ', env['HAVE_BLUEZ']) conf.Define('HAVE_BLUEZ', env['HAVE_BLUEZ'])
@ -359,12 +362,14 @@ else:
if not conf.CheckPKG('GLU'): if not conf.CheckPKG('GLU'):
print "Must have GLU to build" print "Must have GLU to build"
Exit(1) Exit(1)
if not conf.CheckPKG('Cg'):
print "Must have Cg toolkit from NVidia to build" if sys.platform == 'linux2':
Exit(1) if not conf.CheckPKG('Cg'):
if not conf.CheckPKG('CgGL'): print "Must have Cg toolkit from NVidia to build"
print "Must have CgGl to build" Exit(1)
Exit(1) if not conf.CheckPKG('CgGL'):
print "Must have CgGl to build"
Exit(1)
if env['opencl']: if env['opencl']:
env['HAVE_OPENCL'] = conf.CheckPKG('OpenCL') env['HAVE_OPENCL'] = conf.CheckPKG('OpenCL')

View File

@ -26,12 +26,14 @@ void AudioCommonConfig::Load(IniFile &file) {
file.Get("Config", "Volume", &m_Volume, 75); file.Get("Config", "Volume", &m_Volume, 75);
#ifdef _WIN32 #ifdef _WIN32
file.Get("Config", "Backend", &sBackend, BACKEND_DIRECTSOUND); file.Get("Config", "Backend", &sBackend, BACKEND_DIRECTSOUND);
#elif defined(__APPLE__) #elif defined __APPLE__
std::string temp; std::string temp;
file.Get("Config", "Backend", &temp, BACKEND_COREAUDIO); file.Get("Config", "Backend", &temp, BACKEND_COREAUDIO);
strncpy(sBackend, temp.c_str(), 128); strncpy(sBackend, temp.c_str(), 128);
#else // linux #elif defined __linux__
file.Get("Config", "Backend", &sBackend, BACKEND_ALSA); file.Get("Config", "Backend", &sBackend, BACKEND_ALSA);
#else
file.Get("Config", "Backend", &sBackend, BACKEND_OPENAL);
#endif #endif
} }

View File

@ -26,7 +26,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include "../../../../Externals/OpenAL/include/al.h" #include "../../../../Externals/OpenAL/include/al.h"
#include "../../../../Externals/OpenAL/include/alc.h" #include "../../../../Externals/OpenAL/include/alc.h"
#elif defined __linux__ #else
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h> #include <AL/alc.h>
#endif #endif

View File

@ -27,7 +27,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include "../../../../Externals/OpenAL/include/al.h" #include "../../../../Externals/OpenAL/include/al.h"
#include "../../../../Externals/OpenAL/include/alc.h" #include "../../../../Externals/OpenAL/include/alc.h"
#else // linux #else
#include <AL/al.h> #include <AL/al.h>
#include <AL/alc.h> #include <AL/alc.h>
#endif #endif

View File

@ -1,51 +1,55 @@
// Most of the code in this file was shamelessly ripped from libcdio With minor adjustments // Most of the code in this file was shamelessly ripped from libcdio With minor adjustments
#include "CDUtils.h" #include "CDUtils.h"
#include "Common.h" #include "Common.h"
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#elif __APPLE__ #elif __APPLE__
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOBSD.h>
#include <IOKit/IOKitLib.h> #include <IOKit/IOKitLib.h>
#include <IOKit/storage/IOCDMedia.h> #include <IOKit/storage/IOCDMedia.h>
#include <IOKit/storage/IOMedia.h> #include <IOKit/storage/IOMedia.h>
#include <IOKit/IOBSD.h>
#include <paths.h> #include <paths.h>
#elif __linux__ #else
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/cdrom.h>
#endif // WIN32 #endif // WIN32
#ifdef __linux__
#include <linux/cdrom.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
// Returns a string that can be used in a CreateFile call if // Returns a string that can be used in a CreateFile call if
// c_drive letter is a character. If not NULL is returned. // c_drive letter is a character. If not NULL is returned.
const char *is_cdrom(const char c_drive_letter) const char *is_cdrom(const char c_drive_letter)
{ {
UINT uDriveType; UINT uDriveType;
char sz_win32_drive[4]; char sz_win32_drive[4];
sz_win32_drive[0]= c_drive_letter; sz_win32_drive[0]= c_drive_letter;
sz_win32_drive[1]=':'; sz_win32_drive[1]=':';
sz_win32_drive[2]='\\'; sz_win32_drive[2]='\\';
sz_win32_drive[3]='\0'; sz_win32_drive[3]='\0';
uDriveType = GetDriveType(sz_win32_drive); uDriveType = GetDriveType(sz_win32_drive);
switch(uDriveType) switch(uDriveType)
{ {
case DRIVE_CDROM: case DRIVE_CDROM:
{ {
char sz_win32_drive_full[] = "\\\\.\\X:"; char sz_win32_drive_full[] = "\\\\.\\X:";
sz_win32_drive_full[4] = c_drive_letter; sz_win32_drive_full[4] = c_drive_letter;
return __strdup(&sz_win32_drive_full[4]); return __strdup(&sz_win32_drive_full[4]);
} }
default: default:
//cdio_debug("Drive %c is not a CD-ROM", c_drive_letter); {
return NULL; //cdio_debug("Drive %c is not a CD-ROM", c_drive_letter);
return NULL;
}
} }
} }
@ -53,7 +57,7 @@ const char *is_cdrom(const char c_drive_letter)
std::vector<std::string> cdio_get_devices() { std::vector<std::string> cdio_get_devices() {
std::vector<std::string> drives; std::vector<std::string> drives;
char drive_letter; char drive_letter;
// Scan the system for CD-ROM drives. // Scan the system for CD-ROM drives.
for (drive_letter='A'; drive_letter <= 'Z'; drive_letter++) { for (drive_letter='A'; drive_letter <= 'Z'; drive_letter++) {
const char *drive_str=is_cdrom(drive_letter); const char *drive_str=is_cdrom(drive_letter);
@ -74,55 +78,53 @@ std::vector<std::string> cdio_get_devices()
io_iterator_t media_iterator; io_iterator_t media_iterator;
CFMutableDictionaryRef classes_to_match; CFMutableDictionaryRef classes_to_match;
std::vector<std::string> drives; std::vector<std::string> drives;
kern_result = IOMasterPort( MACH_PORT_NULL, &master_port ); kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
if( kern_result != KERN_SUCCESS ) if( kern_result != KERN_SUCCESS )
return( drives ); return( drives );
classes_to_match = IOServiceMatching( kIOCDMediaClass ); classes_to_match = IOServiceMatching( kIOCDMediaClass );
if( classes_to_match == NULL ) if( classes_to_match == NULL )
return( drives ); return( drives );
CFDictionarySetValue( classes_to_match, CFSTR(kIOMediaEjectableKey), CFDictionarySetValue( classes_to_match,
kCFBooleanTrue ); CFSTR(kIOMediaEjectableKey), kCFBooleanTrue );
kern_result = IOServiceGetMatchingServices( master_port, kern_result = IOServiceGetMatchingServices( master_port,
classes_to_match, classes_to_match, &media_iterator );
&media_iterator );
if( kern_result != KERN_SUCCESS) if( kern_result != KERN_SUCCESS)
return( drives ); return( drives );
next_media = IOIteratorNext( media_iterator ); next_media = IOIteratorNext( media_iterator );
if( next_media != 0 ) if( next_media != 0 )
{ {
char psz_buf[0x32]; char psz_buf[0x32];
size_t dev_path_length; size_t dev_path_length;
CFTypeRef str_bsd_path; CFTypeRef str_bsd_path;
do do
{ {
str_bsd_path = str_bsd_path =
IORegistryEntryCreateCFProperty( next_media, IORegistryEntryCreateCFProperty( next_media,
CFSTR( kIOBSDNameKey ), CFSTR( kIOBSDNameKey ), kCFAllocatorDefault,
kCFAllocatorDefault, 0 );
0 );
if( str_bsd_path == NULL ) if( str_bsd_path == NULL )
{ {
IOObjectRelease( next_media ); IOObjectRelease( next_media );
continue; continue;
} }
// Below, by appending 'r' to the BSD node name, we indicate // Below, by appending 'r' to the BSD node name, we indicate
// a raw disk. Raw disks receive I/O requests directly and // a raw disk. Raw disks receive I/O requests directly and
// don't go through a buffer cache. // don't go through a buffer cache.
snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' ); snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
dev_path_length = strlen( psz_buf ); dev_path_length = strlen( psz_buf );
if( CFStringGetCString( (CFStringRef)str_bsd_path, if( CFStringGetCString( (CFStringRef)str_bsd_path,
(char*)&psz_buf + dev_path_length, (char*)&psz_buf + dev_path_length,
sizeof(psz_buf) - dev_path_length, sizeof(psz_buf) - dev_path_length,
kCFStringEncodingASCII)) kCFStringEncodingASCII))
{ {
if(psz_buf != NULL) if(psz_buf != NULL)
{ {
std::string str = psz_buf; std::string str = psz_buf;
@ -131,26 +133,31 @@ std::vector<std::string> cdio_get_devices()
} }
CFRelease( str_bsd_path ); CFRelease( str_bsd_path );
IOObjectRelease( next_media ); IOObjectRelease( next_media );
} while( ( next_media = IOIteratorNext( media_iterator ) ) != 0 ); } while( ( next_media = IOIteratorNext( media_iterator ) ) != 0 );
} }
IOObjectRelease( media_iterator ); IOObjectRelease( media_iterator );
return drives; return drives;
} }
#elif defined __linux__ #else
// checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr? // checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr?
static struct static struct
{ {
const char * format; const char * format;
unsigned int num_min; unsigned int num_min;
unsigned int num_max; unsigned int num_max;
} checklist[] = } checklist[] =
{ {
#ifdef __linux__
{ "/dev/cdrom", 0, 0}, { "/dev/cdrom", 0, 0},
{ "/dev/dvd", 0, 0}, { "/dev/dvd", 0, 0},
{ "/dev/hd%c", 'a', 'z' }, { "/dev/hd%c", 'a', 'z' },
{ "/dev/scd%d", 0, 27 }, { "/dev/scd%d", 0, 27 },
{ "/dev/sr%d", 0, 27 }, { "/dev/sr%d", 0, 27 },
#else
{ "/dev/acd%d", 0, 27 },
{ "/dev/cd%d", 0, 27 },
#endif
{ NULL } { NULL }
}; };
@ -161,7 +168,8 @@ bool is_device(const char *source_name)
if (0 != lstat(source_name, &buf)) if (0 != lstat(source_name, &buf))
return false; return false;
return ((S_ISBLK(buf.st_mode) || S_ISCHR(buf.st_mode)) && !S_ISLNK(buf.st_mode)); return ((S_ISBLK(buf.st_mode) || S_ISCHR(buf.st_mode)) &&
!S_ISLNK(buf.st_mode));
} }
// Check a device to see if it is a DVD/CD-ROM drive // Check a device to see if it is a DVD/CD-ROM drive
@ -169,39 +177,40 @@ static bool is_cdrom(const char *drive, char *mnttype)
{ {
bool is_cd=false; bool is_cd=false;
int cdfd; int cdfd;
// Check if the device exists // Check if the device exists
if (!is_device(drive)) if (!is_device(drive))
return(false); return(false);
// If it does exist, verify that it is a cdrom/dvd drive // If it does exist, verify that it is a cdrom/dvd drive
cdfd = open(drive, (O_RDONLY|O_NONBLOCK), 0); cdfd = open(drive, (O_RDONLY|O_NONBLOCK), 0);
if ( cdfd >= 0 ) if ( cdfd >= 0 )
{ {
#ifdef __linux__
if (ioctl(cdfd, CDROM_GET_CAPABILITY, 0) != -1) if (ioctl(cdfd, CDROM_GET_CAPABILITY, 0) != -1)
#endif
is_cd = true; is_cd = true;
close(cdfd); close(cdfd);
} }
return(is_cd); return(is_cd);
} }
// Returns a pointer to an array of strings with the device names // Returns a pointer to an array of strings with the device names
std::vector<std::string> cdio_get_devices () std::vector<std::string> cdio_get_devices ()
{ {
unsigned int i; unsigned int i;
char drive[40]; char drive[40];
std::vector<std::string> drives; std::vector<std::string> drives;
// Scan the system for DVD/CD-ROM drives. // Scan the system for DVD/CD-ROM drives.
for ( i=0; checklist[i].format; ++i ) for ( i=0; checklist[i].format; ++i )
{ {
unsigned int j; unsigned int j;
for ( j=checklist[i].num_min; j<=checklist[i].num_max; ++j ) for ( j=checklist[i].num_min; j<=checklist[i].num_max; ++j )
{ {
sprintf(drive, checklist[i].format, j); sprintf(drive, checklist[i].format, j);
if ( (is_cdrom(drive, NULL)) > 0 ) if ( (is_cdrom(drive, NULL)) > 0 )
{ {
std::string str = drive; std::string str = drive;
drives.push_back(str); drives.push_back(str);
} }
@ -215,8 +224,8 @@ std::vector<std::string> cdio_get_devices ()
bool cdio_is_cdrom(std::string device) bool cdio_is_cdrom(std::string device)
{ {
#ifdef __linux__ #ifdef __linux__
// Resolve symbolic links. This allows symbolic links to valid cdrom/dvd drives to // Resolve symbolic links. This allows symbolic links to valid
// be passed from the command line with the -e flag. // drives to be passed from the command line with the -e flag.
char *devname = realpath(device.c_str(), NULL); char *devname = realpath(device.c_str(), NULL);
if (!devname) if (!devname)
return false; return false;
@ -225,23 +234,23 @@ bool cdio_is_cdrom(std::string device)
std::vector<std::string> devices = cdio_get_devices(); std::vector<std::string> devices = cdio_get_devices();
bool res = false; bool res = false;
for (unsigned int i = 0; i < devices.size(); i++) for (unsigned int i = 0; i < devices.size(); i++)
{ {
#ifdef __linux__ #ifdef __linux__
if (strncmp(devices[i].c_str(), devname, MAX_PATH) == 0) if (strncmp(devices[i].c_str(), devname, MAX_PATH) == 0)
#else #else
if (strncmp(devices[i].c_str(), device.c_str(), MAX_PATH) == 0) if (strncmp(devices[i].c_str(), device.c_str(), MAX_PATH) == 0)
#endif #endif
{ {
res = true; res = true;
break; break;
} }
} }
#ifdef __linux__ #ifdef __linux__
if (devname) if (devname)
free(devname); free(devname);
#endif #endif
devices.clear(); devices.clear();
return res; return res;
} }

View File

@ -29,15 +29,14 @@ template<> struct CompileTimeAssert<true> {};
#ifndef _WIN32 #ifndef _WIN32
#if defined __APPLE__ #include <errno.h>
char* strndup (char const *s, size_t n);
size_t strnlen(const char *s, size_t n);
#else
#ifdef __linux__ #ifdef __linux__
#include <byteswap.h> #include <byteswap.h>
#else
char * strndup(char const *s, size_t n);
size_t strnlen(const char *s, size_t n);
#endif #endif
#endif // APPLE
#include <errno.h>
// go to debugger mode // go to debugger mode
#ifdef GEKKO #ifdef GEKKO
#define Crash() #define Crash()

View File

@ -48,6 +48,10 @@
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
#endif #endif
#if defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__
#define stat64 stat // XXX
#endif
// This namespace has various generic functions related to files and paths. // This namespace has various generic functions related to files and paths.
// The code still needs a ton of cleanup. // The code still needs a ton of cleanup.
// REMEMBER: strdup considered harmful! // REMEMBER: strdup considered harmful!

View File

@ -120,7 +120,7 @@ u8* MemArena::Find4GBBase()
return base; return base;
#else #else
void* base = mmap(0, 0x31000000, PROT_READ | PROT_WRITE, void* base = mmap(0, 0x31000000, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED, 0, 0); MAP_ANON | MAP_SHARED, -1, 0);
if (base == MAP_FAILED) { if (base == MAP_FAILED) {
PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno)); PanicAlert("Failed to map 1 GB of memory space: %s", strerror(errno));
return 0; return 0;

View File

@ -37,7 +37,7 @@ const char *GetLastErrorMsg()
return errStr; return errStr;
} }
#ifdef __APPLE__ #if !defined(__linux__) && !defined(_WIN32)
// strlen with cropping after size n // strlen with cropping after size n
size_t strnlen(const char *s, size_t n) size_t strnlen(const char *s, size_t n)
{ {

View File

@ -16,7 +16,7 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <time.h> #include <time.h>
#include <sys/timeb.h> #include <sys/time.h>
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
@ -37,9 +37,9 @@ u32 Timer::GetTimeMs() {
#else #else
u32 Timer::GetTimeMs() u32 Timer::GetTimeMs()
{ {
struct timeb t; struct timeval t;
ftime(&t); (void)gettimeofday(&t, NULL);
return ((u32)(t.time * 1000 + t.millitm)); return((u32)(t.tv_sec * 1000 + t.tv_usec / 1000));
} }
#endif #endif
@ -202,9 +202,9 @@ std::string Timer::GetTimeFormatted()
strftime(tmp, 6, "%M:%S", gmTime); strftime(tmp, 6, "%M:%S", gmTime);
// Now tack on the milliseconds // Now tack on the milliseconds
struct timeb tp; struct timeval t;
(void)::ftime(&tp); (void)gettimeofday(&t, NULL);
sprintf(formattedTime, "%s:%03i", tmp, tp.millitm); sprintf(formattedTime, "%s:%03ld", tmp, t.tv_usec / 1000);
return std::string(formattedTime); return std::string(formattedTime);
} }
@ -214,8 +214,8 @@ std::string Timer::GetTimeFormatted()
// ---------------- // ----------------
double Timer::GetDoubleTime() double Timer::GetDoubleTime()
{ {
struct timeb tp; struct timeval t;
(void)::ftime(&tp); (void)gettimeofday(&t, NULL);
u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970(); // Get continous timestamp u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970(); // Get continous timestamp
/* Remove a few years. We only really want enough seconds to make sure that we are /* Remove a few years. We only really want enough seconds to make sure that we are
@ -226,7 +226,7 @@ double Timer::GetDoubleTime()
//if (TmpSeconds < 0) return 0; // Check the the user's clock is working somewhat //if (TmpSeconds < 0) return 0; // Check the the user's clock is working somewhat
u32 Seconds = (u32)TmpSeconds; // Make a smaller integer that fits in the double u32 Seconds = (u32)TmpSeconds; // Make a smaller integer that fits in the double
double ms = tp.millitm / 1000.0; double ms = t.tv_usec / 1000.0 / 1000.0;
double TmpTime = Seconds + ms; double TmpTime = Seconds + ms;
return TmpTime; return TmpTime;
} }

View File

@ -211,9 +211,8 @@ bool RamWriteAndFill()
case 0x4 : case 0x4 :
{ {
// TODO: complete // TODO: complete
u32 new_data = data; // u32 new_data = data;
return false; return false;
} }
break; break;
@ -372,7 +371,6 @@ bool FlowControl()
// not all of these are used in all subtypes // not all of these are used in all subtypes
const u8 block_num = (u8)(code.data & 0xF); const u8 block_num = (u8)(code.data & 0xF);
const s16 code_offset = (s16)code.address;
switch (code.subtype) switch (code.subtype)
{ {
@ -680,8 +678,6 @@ bool SpecialIf()
// CT5 Part2 : 16bits Counter check // CT5 Part2 : 16bits Counter check
// TODO: // TODO:
const u16 z = (u16)(data >> 16);
switch (code.subtype) switch (code.subtype)
{ {
// CST4 : 16bits (endif, then) If counter value equal // CST4 : 16bits (endif, then) If counter value equal
@ -849,4 +845,4 @@ bool EndCodes()
return true; return true;
} }
} // namespace Gecko } // namespace Gecko

View File

@ -136,6 +136,4 @@ void SaveCodes(IniFile& inifile, const std::vector<GeckoCode>& gcodes)
inifile.SetLines(GECKO_CODE_INI_SECTION, lines); inifile.SetLines(GECKO_CODE_INI_SECTION, lines);
} }
};
};

View File

@ -12,9 +12,6 @@ namespace Gecko
void LoadCodes(const IniFile& inifile, std::vector<GeckoCode>& gcodes); void LoadCodes(const IniFile& inifile, std::vector<GeckoCode>& gcodes);
void SaveCodes(IniFile& inifile, const std::vector<GeckoCode>& gcodes); void SaveCodes(IniFile& inifile, const std::vector<GeckoCode>& gcodes);
}; };
#endif #endif

View File

@ -23,8 +23,12 @@
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <net/if.h> #include <net/if.h>
#ifdef __linux__
#include <linux/if_tun.h> #include <linux/if_tun.h>
#else
#include <net/if_tun.h>
#endif
#include <assert.h> #include <assert.h>
int fd = -1; int fd = -1;
bool CEXIETHERNET::deactivate() bool CEXIETHERNET::deactivate()
@ -39,6 +43,7 @@ bool CEXIETHERNET::isActivated()
} }
bool CEXIETHERNET::activate() { bool CEXIETHERNET::activate() {
#ifdef __linux__
if(isActivated()) if(isActivated())
return true; return true;
if( (fd = open("/dev/net/tun", O_RDWR)) < 0) if( (fd = open("/dev/net/tun", O_RDWR)) < 0)
@ -77,8 +82,8 @@ bool CEXIETHERNET::activate() {
system("brctl addif pan0 Dolphin"); system("brctl addif pan0 Dolphin");
system("ifconfig Dolphin 0.0.0.0 promisc up"); system("ifconfig Dolphin 0.0.0.0 promisc up");
resume(); resume();
#endif
return true; return true;
} }
bool CEXIETHERNET::CheckRecieved() bool CEXIETHERNET::CheckRecieved()
{ {

View File

@ -25,4 +25,4 @@ void GCPad_Deinit();
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus); void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus);
void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength); void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
InputPlugin *PAD_GetPlugin(); InputPlugin *PAD_GetPlugin();

View File

@ -193,4 +193,4 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
// Triggers // Triggers
set_control(m_triggers, 0, "Q"); // L set_control(m_triggers, 0, "Q"); // L
set_control(m_triggers, 1, "W"); // R set_control(m_triggers, 1, "W"); // R
} }

View File

@ -353,17 +353,7 @@ u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = {
0x00, // Nothing interesting past this point. 0x00, // Nothing interesting past this point.
}; };
#elif defined __linux__ #else
// TODO Add support for Linux keycodes
u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = {
0
};
u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = {
0
};
#elif defined __APPLE__
// TODO Add support for Apple keycodes
u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = { u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = {
0 0
}; };

View File

@ -17,7 +17,6 @@
#ifndef _WIN32 #ifndef _WIN32
#include <execinfo.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <sys/ucontext.h> // Look in here for the context definition. #include <sys/ucontext.h> // Look in here for the context definition.
@ -26,11 +25,16 @@
#define CREG_RIP(ctx) (ctx)->gregs[REG_RIP] #define CREG_RIP(ctx) (ctx)->gregs[REG_RIP]
#define CREG_EAX(ctx) (ctx)->gregs[REG_EAX] #define CREG_EAX(ctx) (ctx)->gregs[REG_EAX]
#define CREG_EIP(ctx) (ctx)->gregs[REG_EIP] #define CREG_EIP(ctx) (ctx)->gregs[REG_EIP]
#elif defined(__APPLE__) #elif defined __APPLE__
#define CREG_RAX(ctx) (*(ctx))->__ss.__rax #define CREG_RAX(ctx) (*(ctx))->__ss.__rax
#define CREG_RIP(ctx) (*(ctx))->__ss.__rip #define CREG_RIP(ctx) (*(ctx))->__ss.__rip
#define CREG_EAX(ctx) (*(ctx))->__ss.__eax #define CREG_EAX(ctx) (*(ctx))->__ss.__eax
#define CREG_EIP(ctx) (*(ctx))->__ss.__eip #define CREG_EIP(ctx) (*(ctx))->__ss.__eip
#else
#define CREG_RAX(ctx) (ctx)->mc_rax
#define CREG_RIP(ctx) (ctx)->mc_rip
#define CREG_EAX(ctx) (ctx)->mc_eax
#define CREG_EIP(ctx) (ctx)->mc_eip
#endif #endif
#else #else
@ -152,10 +156,10 @@ void InstallExceptionHandler()
#else // _WIN32 #else // _WIN32
// #if defined __APPLE__ || defined __linux__ || defined _WIN32
// backtrace useful function #ifndef _WIN32
// #include <execinfo.h>
#endif
void print_trace(const char * msg) void print_trace(const char * msg)
{ {
void *array[100]; void *array[100];
@ -170,6 +174,7 @@ void print_trace(const char * msg)
printf("--> %s\n", strings[i]); printf("--> %s\n", strings[i]);
free(strings); free(strings);
} }
#endif
void sigsegv_handler(int signal, siginfo_t *info, void *raw_context) void sigsegv_handler(int signal, siginfo_t *info, void *raw_context)
{ {

View File

@ -256,6 +256,8 @@ int DSPCore_RunCycles(int cycles)
DSPHost_UpdateDebugger(); DSPHost_UpdateDebugger();
break; break;
case DSPCORE_STOP:
break;
} }
} }
return cycles; return cycles;

View File

@ -82,6 +82,7 @@ elif sys.platform == 'darwin' and env['HAVE_WX']:
) )
else: else:
files += [ 'X11Utils.cpp' ] files += [ 'X11Utils.cpp' ]
libs += [ 'SDL' ]
exeGUI = env['binary_dir'] + 'dolphin-emu' exeGUI = env['binary_dir'] + 'dolphin-emu'
exeNoGUI = env['binary_dir'] + 'dolphin-emu-nogui' exeNoGUI = env['binary_dir'] + 'dolphin-emu-nogui'

View File

@ -8,7 +8,8 @@ files = [
'InputConfig.cpp', 'InputConfig.cpp',
'ControllerInterface/ControllerInterface.cpp', 'ControllerInterface/ControllerInterface.cpp',
'UDPWiimote.cpp', 'UDPWiimote.cpp',
'UDPWrapper.cpp' 'UDPWrapper.cpp',
'SDL_Util.cpp', # XXX needed by old Wiimote plugin
] ]
if sys.platform == 'win32': if sys.platform == 'win32':
@ -16,6 +17,7 @@ if sys.platform == 'win32':
'ControllerInterface/DInput/DInput.cpp', 'ControllerInterface/DInput/DInput.cpp',
'ControllerInterface/DInput/DInputJoystick.cpp', 'ControllerInterface/DInput/DInputJoystick.cpp',
'ControllerInterface/DInput/DInputKeyboardMouse.cpp' 'ControllerInterface/DInput/DInputKeyboardMouse.cpp'
'ControllerInterface/SDL/SDL.cpp',
'ControllerInterface/XInput/XInput.cpp', 'ControllerInterface/XInput/XInput.cpp',
] ]
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
@ -23,18 +25,12 @@ elif sys.platform == 'darwin':
'ControllerInterface/OSX/OSX.mm', 'ControllerInterface/OSX/OSX.mm',
'ControllerInterface/OSX/OSXKeyboard.mm', 'ControllerInterface/OSX/OSXKeyboard.mm',
'ControllerInterface/OSX/OSXMouse.mm', 'ControllerInterface/OSX/OSXMouse.mm',
'SDL_Util.cpp', # XXX needed by old Wiimote plugin
] ]
else: elif env['HAVE_X11']:
files += [ files += [
'ControllerInterface/SDL/SDL.cpp',
'ControllerInterface/Xlib/Xlib.cpp', 'ControllerInterface/Xlib/Xlib.cpp',
'X11InputBase.cpp' 'X11InputBase.cpp'
] ]
if sys.platform == 'win32' or sys.platform == 'linux2':
files += [
'ControllerInterface/SDL/SDL.cpp',
'SDL_Util.cpp',
]
env.StaticLibrary(env['local_libs'] + "inputcommon", files) env.StaticLibrary(env['local_libs'] + "inputcommon", files)

View File

@ -76,8 +76,10 @@ WiimoteBasicConfigDialog::WiimoteBasicConfigDialog(wxWindow *parent, wxWindowID
ControlsCreated = false; ControlsCreated = false;
m_Page = 0; m_Page = 0;
#if defined HAVE_WIIUSE && HAVE_WIIUSE
// Initialize the Real WiiMotes here, so we get a count of how many were found and set everything properly // Initialize the Real WiiMotes here, so we get a count of how many were found and set everything properly
WiiMoteReal::Initialize(); WiiMoteReal::Initialize();
#endif
CreateGUIControls(); CreateGUIControls();
UpdateGUI(); UpdateGUI();
@ -93,7 +95,9 @@ void WiimoteBasicConfigDialog::ButtonClick(wxCommandEvent& event)
switch(event.GetId()) switch(event.GetId())
{ {
case wxID_OK: case wxID_OK:
#if defined HAVE_WIIUSE && HAVE_WIIUSE
WiiMoteReal::Allocate(); WiiMoteReal::Allocate();
#endif
g_Config.Save(); g_Config.Save();
Close(); Close();
break; break;

View File

@ -36,4 +36,4 @@ private:
} }
#endif #endif

View File

@ -1,4 +1,3 @@
#include "WiimoteEmu.h" #include "WiimoteEmu.h"
#ifdef USE_WIIMOTE_EMU_SPEAKER #ifdef USE_WIIMOTE_EMU_SPEAKER
@ -36,4 +35,4 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
} }
#endif #endif