Compare commits

...
60 Commits
Author SHA1 Message Date
neville f44e0db97c (Load Core) OSX - Filter by dylibs 2016-01-17 19:27:33 +01:00
Twinaphex a4eae00ac2 Make this runtime too 2016-01-17 19:03:57 +01:00
Twinaphex c9c46b8060 Get rid of another compile-time define 2016-01-17 18:58:50 +01:00
Twinaphex 9324f257fc (OSX 10.5) Change label to 'Load Content' 2016-01-17 18:46:26 +01:00
Twinaphex 681396b151 (OSX) Cleanups 2016-01-17 18:45:01 +01:00
Twinaphex bd153870c2 Move callback function up 2016-01-17 18:43:24 +01:00
Twinaphex 43b949a9a0 Create open_document_handler 2016-01-17 18:42:52 +01:00
Twinaphex 4f0233fbf9 Use BOXSTRING 2016-01-17 18:39:42 +01:00
Twinaphex 777af02e82 Create open_core_handler - cut down on code duplication 2016-01-17 18:38:08 +01:00
neville f6c6f64a20 Implement openCore for OSX 10.5 2016-01-17 18:34:18 +01:00
Twinaphex 7f505afda7 (OSX) Prevent crash with previous hack 2016-01-17 16:26:04 +01:00
Twinaphex 55105303ac Add hack that works around this issue 2016-01-17 15:55:30 +01:00
twinaphex dd239fc85d Add HAVE_AVFOUNDATION ifdefs 2016-01-16 22:02:49 +01:00
Twinaphex f8ea62e703 Merge pull request #2649 from pponso1/master
iOS: Adds support for Music.app while RetroArch is running
2016-01-16 21:58:10 +01:00
Phillip Ponson 48b99b1f48 Fixing a build issue. syntax errors. 😣
.
'
2016-01-16 12:48:33 -06:00
pponso1 a983c8269e iOS. Adding support for Music.app.
I had to comment out this line in the showPauseMenu function: 
  
ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_AUDIO_STOP);

This may actually be on the only change needed. 😜
2016-01-16 12:37:09 -06:00
pponso1 3ce5ad9243 iOS. Adding support for Music.app.
Users who want to play games while listening to music should enjoy these modifications. Not the cleanest; refactoring is needed.
2016-01-16 12:25:57 -06:00
pponso1 452c6afaf0 support for playing Music.app in background. 2016-01-16 12:09:44 -06:00
pponso1 212337c7c1 iOS audio support 2016-01-16 11:57:00 -06:00
twinaphex fcc8c5dae7 This is still necessary unfortunately 2016-01-16 16:46:20 +01:00
twinaphex 9f27b9b56d Remove another compile-time ifdef 2016-01-16 16:22:55 +01:00
Twinaphex fbdc30e7bb (OSX) Buildfix 2016-01-16 16:21:39 +01:00
twinaphex b4687fdb2b Check if convertRectToBacking is available at runtime instead
of compile-time
2016-01-16 16:20:19 +01:00
twinaphex a5c83da839 Simplify cocoagl_gfx_ctx_get_video_size 2016-01-16 16:14:25 +01:00
Twinaphex c824f7af15 get_video_size - don't need screen pointer anymore 2016-01-16 13:31:43 +01:00
twinaphex 6a1d423700 (OSX) Cleanup 2016-01-16 13:30:38 +01:00
twinaphex 14ec006412 Cleanup 2016-01-16 13:29:33 +01:00
neville 9a38ec28b0 Get rid of compile-time ifdefs inside get_chosen_screen 2016-01-16 13:23:00 +01:00
Twinaphex 2c42ad3c96 (cocoa_gl_ctx.m) Cleanups 2016-01-16 12:12:07 +01:00
Twinaphex dfe79c3fcd setWantsBestResolutionOpenGLSurface - determine at runtime if we can call
this instead of compile-time
2016-01-16 12:09:50 +01:00
Twinaphex 21dc363e0f backingScaleFactor - cut down on compile-time ifdef - attempt to detect it at runtime 2016-01-16 11:58:36 +01:00
Twinaphex 64fe30281c Cleanup 2016-01-16 11:51:24 +01:00
Twinaphex 302089e8d8 Cleanup 2016-01-16 11:50:44 +01:00
Twinaphex 5a4db266e8 (OSX) Change get_from_selector 2016-01-16 11:49:10 +01:00
Twinaphex 5cc163a10b (OSX) Cleanup 2016-01-16 11:40:48 +01:00
aliaspider 2fb7d32a53 (3DS) another build tools update. 2016-01-16 03:51:48 +01:00
aliaspider 4ec00de5c8 (3DS) update tool 2016-01-16 00:14:54 +01:00
Twinaphex 794bcc53c3 (iOS) Buildfix 2016-01-15 23:15:49 +01:00
twinaphex 4b9fea617c (OSX) Perform selectorOnMainThread - move to applicationDidFinishLaunching 2016-01-15 23:09:50 +01:00
Twinaphex 4fb78bf3cd Merge pull request #2647 from aliaspider/master
(3DS) fixes argv corruption when started from the homebrew launcher
2016-01-15 22:44:40 +01:00
aliaspider a7bd7f332d nit. 2016-01-15 22:35:00 +01:00
twinaphex e4533fb7ec (OSX/iOS) Cleanup 2016-01-15 22:33:25 +01:00
aliaspider 0b4fd4328d - add more heuristics to try to clean up the corrupted argv when using
the homebrew launcher.
- force align the stack pointer to 8 bytes.
- add --gc-sections to the link specs
2016-01-15 22:30:12 +01:00
Twinaphex 8c8a3085a5 (OSX) Buildfix 2016-01-15 22:22:37 +01:00
twinaphex 8323d06d3d (Cocoa) No more dependencies on get_chosen_screen or
get_backing_scale_factor
2016-01-15 22:20:46 +01:00
Twinaphex f35690e2e5 Fixes 2016-01-15 22:16:18 +01:00
twinaphex 09a183df3f (OSX) Create get_backing_scale_factor 2016-01-15 22:15:23 +01:00
Twinaphex 85575f4acc Merge pull request #2646 from diablodiab/master
Add handling of Nvidia Shield Virtual Controller
2016-01-15 21:32:50 +01:00
Diablodiab e738b57cf8 Add handling of Nvidia Shield Virtual Controller
The NVIDIA Button on the Nvidia Shield Controller and inputs received from CEC remotes
are detected as a "Virtual" controller on the Shield TV.

If a virtual controller is detected on the Shield TV before an actual game controller
then it will be configured as "Shield Virtual Device". This allows the use of the
buttons on a CEC remote to control the Retroarch menu and games.

When an actual controller is connected the Virtual Device will be overwritten and
the NVIDIA button of the Virtual device will be mapped to the controller as the
menu button.

This also fixes the situation where you press the NVIDIA Button before any other
button on the game controller and it does nothing. Now it will go into the
Retroarch menu even if it is the first button pressed.

A matching profile for "Nvidia Shield Virtual Controller" has been sent as a pull request to
the "retroarch-joypad-autoconfig" repository.
2016-01-15 18:41:17 +01:00
twinaphex e920e5f1b9 Add early return in case settings is NULL 2016-01-15 15:38:21 +01:00
twinaphex 039e2acc49 Make switch stop complaininig 2016-01-15 14:08:38 +01:00
twinaphex 5f513d2af0 (cocoa_gl_ctx.m) Cleanups 2016-01-15 14:03:56 +01:00
twinaphex 3427d08c34 Do early return in case get_chosen_screen returns NULL 2016-01-15 14:00:11 +01:00
Twinaphex 58ebbdeada Attempt to prevent race issue in get_chosen_screen 2016-01-15 13:58:16 +01:00
Twinaphex 26bcfa8d89 Revert "Refactor function get_float_from_selector - obsolete"
This reverts commit 1b2632e7fa.
2016-01-15 13:03:40 +01:00
twinaphex 1b2632e7fa Refactor function get_float_from_selector - obsolete
hardcoded ifdef
2016-01-15 12:53:33 +01:00
twinaphex 647438ae93 Hopeful buildfix 2016-01-15 12:40:56 +01:00
Twinaphex e2942f2de1 Merge pull request #2644 from diablodiab/master
Extends Android keyboard functionality to allow for more than one keyboard
2016-01-15 09:37:51 +01:00
Diablodiab 9245113738 Fix if clause that could result in a keyboard key being handled as gamepad input 2016-01-14 21:16:54 +01:00
Diablodiab 2c08dc0f4f Extends Android keyboard functionality to allow for up to three keyboards.
This solves the problem with volume buttons on phones being detected as
keyboards and blocking a real keyboard from being mapped afterwards.

Renamed id_1 and id_2 to pad_id1 and pad_id2
Renamed id_3 to kbd_id and change it to an array

Implement function is_keyboard_id(int id) which checks if an id is mapped as
a keyboard
2016-01-14 20:59:25 +01:00
12 changed files with 374 additions and 237 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
%rename link old_link
*link:
%(old_link) -T 3dsx.ld%s -d --emit-relocs --use-blx
%(old_link) -T 3dsx.ld%s -d --emit-relocs --use-blx --gc-sections
*startfile:
ctr/3dsx_custom_crt0%O%s crti%O%s crtbegin%O%s
+1 -3
View File
@@ -30,6 +30,7 @@ __system_runflags:
startup:
@ Save return address
mov r4, lr
bics sp, sp, #7
@ Clear the BSS section
ldr r0, =__bss_start__
@@ -39,7 +40,6 @@ startup:
@ System initialization
mov r0, r4
and r4, sp, #7
bl initSystem
@ Set up argc/argv arguments for main()
@@ -50,8 +50,6 @@ startup:
@ Jump to user code
ldr r3, =main
cmp r4, #0
ldrne r3, =ctr_request_update
ldr lr, =__ctru_exit
bx r3
-21
View File
@@ -195,23 +195,6 @@ void __attribute__((noreturn)) __ctru_exit(int rc)
__libctru_exit(rc);
}
int ctr_request_update(void)
{
gfxInit(GSP_BGR8_OES,GSP_RGB565_OES,false);
gfxSet3D(false);
consoleInit(GFX_BOTTOM, NULL);
printf("\n\nunsupported version\n\n");
printf("Please update your payload\n");
wait_for_input();
gfxExit();
return 0;
}
typedef union{
struct
{
@@ -263,10 +246,6 @@ void wait_for_input(void)
}
}
int usleep (useconds_t us)
{
svcSleepThread((int64_t)us * 1000);
}
long sysconf(int name)
{
Binary file not shown.
+3 -2
View File
@@ -16,7 +16,7 @@
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <boolean.h>
#include <3ds.h>
@@ -89,7 +89,8 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
*argc = 0;
while (i)
{
if(argv[i] && argv[i][0])
if(argv[i] && isalnum(argv[i][0])
&& strncmp(argv[i], "3dslink:/", 9))
{
argv[1] = argv[i];
argv[2] = NULL;
+91 -65
View File
@@ -26,6 +26,9 @@
#include <AppKit/NSOpenGL.h>
#elif defined(HAVE_COCOATOUCH)
#include <GLKit/GLKit.h>
#ifdef HAVE_AVFOUNDATION
#import <AVFoundation/AVFoundation.h>
#endif
#endif
#include <retro_assert.h>
@@ -41,6 +44,10 @@
#define GLFrameworkID CFSTR("com.apple.opengles")
#define RAScreen UIScreen
#ifndef UIUserInterfaceIdiomTV
#define UIUserInterfaceIdiomTV 2
#endif
@interface EAGLContext (OSXCompat) @end
@implementation EAGLContext (OSXCompat)
+ (void)clearCurrentContext { [EAGLContext setCurrentContext:nil]; }
@@ -115,34 +122,69 @@ void *glkitview_init(void)
#if defined(HAVE_COCOATOUCH)
void cocoagl_bind_game_view_fbo(void)
{
#ifdef HAVE_AVFOUNDATION
/* Implicitly initializes your audio session */
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];
[audioSession setActive:YES error:nil];
#endif
if (g_context)
[g_view bindDrawable];
}
#endif
static float get_from_selector(Class obj_class, id obj_id, SEL selector, CGFloat *ret)
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
[obj_class instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:obj_id];
[invocation invoke];
[invocation getReturnValue:ret];
return *ret;
}
void *get_chosen_screen(void)
{
#if defined(HAVE_COCOA) && !defined(MAC_OS_X_VERSION_10_6)
return [RAScreen mainScreen];
#else
settings_t *settings = config_get_ptr();
if (settings->video.monitor_index >= RAScreen.screens.count)
NSArray *screens = [RAScreen screens];
if (!screens || !settings)
return NULL;
if (settings->video.monitor_index >= screens.count)
{
RARCH_WARN("video_monitor_index is greater than the number of connected monitors; using main screen instead.\n");
#if __has_feature(objc_arc)
return (__bridge void*)RAScreen.mainScreen;
return (__bridge void*)screens;
#else
return (void*)RAScreen.mainScreen;
return (void*)screens;
#endif
}
NSArray *screens = [RAScreen screens];
#if __has_feature(objc_arc)
return ((__bridge void*)[screens objectAtIndex:settings->video.monitor_index]);
#else
return ((void*)[screens objectAtIndex:settings->video.monitor_index]);
#endif
}
float get_backing_scale_factor(void)
{
#if __has_feature(objc_arc)
RAScreen *screen = (__bridge RAScreen*)get_chosen_screen();
#else
RAScreen *screen = (RAScreen*)get_chosen_screen();
#endif
if (!screen)
return 0.0;
#ifdef HAVE_COCOA
CGFloat ret;
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
SEL selector = NSSelectorFromString(BOXSTRING("backingScaleFactor"));
if ([screen respondsToSelector:selector])
return (float)get_from_selector([[g_view window] class], [g_view window], selector, &ret);
#endif
return 1.0f;
}
void cocoagl_gfx_ctx_update(void)
@@ -162,9 +204,9 @@ static void *cocoagl_gfx_ctx_init(void *video_driver)
#if defined(HAVE_COCOA)
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
#if MAC_OS_X_VERSION_10_7
[g_view setWantsBestResolutionOpenGLSurface:YES];
#endif
if ([g_view respondsToSelector: @selector(setWantsBestResolutionOpenGLSurface:)])
[g_view setWantsBestResolutionOpenGLSurface:YES];
NSOpenGLPixelFormatAttribute attributes [] = {
NSOpenGLPFAColorSize, 24,
NSOpenGLPFADoubleBuffer,
@@ -310,20 +352,9 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
return true;
}
static float cocoagl_gfx_ctx_get_scale_from_selector(RAScreen *screen, SEL selector, float *ret)
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
[[screen class] instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:screen];
[invocation invoke];
[invocation getReturnValue:ret];
return *ret;
}
float cocoagl_gfx_ctx_get_native_scale(void)
{
static float ret = 0.0f;
static CGFloat ret = 0.0f;
SEL selector = NSSelectorFromString(BOXSTRING("nativeScale"));
#if __has_feature(objc_arc)
RAScreen *screen = (__bridge RAScreen*)get_chosen_screen();
@@ -337,41 +368,36 @@ float cocoagl_gfx_ctx_get_native_scale(void)
return 0.0f;
if ([screen respondsToSelector:selector])
return cocoagl_gfx_ctx_get_scale_from_selector(screen, selector, &ret);
return (float)get_from_selector([screen class], screen, selector, &ret);
ret = 1.0f;
if ([screen respondsToSelector:@selector(scale)])
ret = screen.scale;
ret = 1.0f;
selector = NSSelectorFromString(BOXSTRING("scale"));
if ([screen respondsToSelector:selector])
ret = screen.scale;
return ret;
}
static void cocoagl_gfx_ctx_get_video_size(void *data, unsigned* width, unsigned* height)
{
#if __has_feature(objc_arc)
RAScreen *screen = (__bridge RAScreen*)get_chosen_screen();
#else
RAScreen *screen = (RAScreen*)get_chosen_screen();
#endif
CGRect size = screen.bounds;
float screenscale = cocoagl_gfx_ctx_get_native_scale();
float screenscale = cocoagl_gfx_ctx_get_native_scale();
#if defined(HAVE_COCOA)
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
#if MAC_OS_X_VERSION_10_7
NSRect backingBounds = [g_view convertRectToBacking:[g_view bounds]];
GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width),
backingPixelHeight = (GLsizei)(backingBounds.size.height);
size = CGRectMake(0, 0, backingPixelWidth, backingPixelHeight);
#else
CGRect cgrect = NSRectToCGRect([g_view frame]);
size = CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect));
#endif
#else
size = g_view.bounds;
CGRect size;
GLsizei backingPixelWidth, backingPixelHeight;
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
CGRect cgrect = NSRectToCGRect([g_view frame]);
#if MAC_OS_X_VERSION_10_7
SEL selector = NSSelectorFromString(BOXSTRING("convertRectToBacking:"));
if ([g_view respondsToSelector:selector])
cgrect = NSRectToCGRect([g_view convertRectToBacking:[g_view bounds]]);
#endif
*width = CGRectGetWidth(size) * screenscale;
*height = CGRectGetHeight(size) * screenscale;
backingPixelWidth = CGRectGetWidth(cgrect);
backingPixelHeight = CGRectGetHeight(cgrect);
size = CGRectMake(0, 0, backingPixelWidth, backingPixelHeight);
#else
CGRect size = g_view.bounds;
#endif
*width = CGRectGetWidth(size) * screenscale;
*height = CGRectGetHeight(size) * screenscale;
}
static void cocoagl_gfx_ctx_update_window_title(void *data)
@@ -412,28 +438,30 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
float display_height = display_pixel_size.height;
float physical_width = display_physical_size.width;
float physical_height = display_physical_size.height;
#if MAC_OS_X_VERSION_10_7
float scale = screen.backingScaleFactor;
#else
float scale = 1.0f;
#endif
float scale = get_backing_scale_factor();
float dpi = (display_width/ physical_width) * 25.4f * scale;
#elif defined(HAVE_COCOATOUCH)
float scale = cocoagl_gfx_ctx_get_native_scale();
CGRect screen_rect = [screen bounds];
//float display_width = screen_rect.size.width;
float display_height = screen_rect.size.height;
float physical_width = screen_rect.size.width * scale;
float physical_height = screen_rect.size.height * scale;
float dpi = 0;
float dpi = 160 * scale;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
dpi = 132 * scale;
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
dpi = 163 * scale;
} else {
dpi = 160 * scale;
switch (UI_USER_INTERFACE_IDIOM())
{
case UIUserInterfaceIdiomUnspecified:
/* TODO */
break;
case UIUserInterfaceIdiomPad:
dpi = 132 * scale;
break;
case UIUserInterfaceIdiomPhone:
dpi = 163 * scale;
break;
case UIUserInterfaceIdiomTV:
/* TODO */
break;
}
#endif
@@ -507,11 +535,9 @@ static gfx_ctx_proc_t cocoagl_gfx_ctx_get_proc_address(const char *symbol_name)
{
return (gfx_ctx_proc_t)CFBundleGetFunctionPointerForName(CFBundleGetBundleWithIdentifier(GLFrameworkID),
(
#if MAC_OS_X_VERSION_10_7
#if __has_feature(objc_arc)
__bridge
#endif
#endif
CFStringRef)BOXSTRING(symbol_name)
);
}
+65 -44
View File
@@ -39,6 +39,7 @@
#endif
#define MAX_TOUCH 16
#define MAX_NUM_KEYBOARDS 3
typedef struct
{
@@ -53,9 +54,10 @@ struct input_pointer
int16_t full_x, full_y;
};
static int id_1 = -1;
static int id_2 = -1;
static int id_3 = -1;
static int pad_id1 = -1;
static int pad_id2 = -1;
static int kbd_id[MAX_NUM_KEYBOARDS];
static int kbd_num = 0;
enum
{
@@ -450,8 +452,8 @@ static bool android_input_init_handle(void)
RARCH_LOG("Set engine_handle_dpad to 'Get Axis Value' (for reading extra analog sticks)");
engine_handle_dpad = engine_handle_dpad_getaxisvalue;
}
id_1 = -1;
id_2 = -1;
pad_id1 = -1;
pad_id2 = -1;
return true;
}
@@ -549,6 +551,14 @@ static INLINE int android_input_poll_event_type_motion(
return 0;
}
bool is_keyboard_id(int id)
{
for(int i=0; i<kbd_num; i++)
if (id == kbd_id[i]) return true;
return false;
}
static INLINE void android_input_poll_event_type_keyboard(
AInputEvent *event, int keycode, int *handled)
{
@@ -668,6 +678,14 @@ static void handle_hotplug(android_input_data_t *android_data,
* Also group the NVIDIA button on the controller with the
* main controller inputs so it's usable. It's mapped to
* menu by default
*
* The NVIDIA button is identified as "Virtual" device when first
* pressed. CEC remote input is also identified as "Virtual" device.
* If a virtual device is detected before a controller then it will
* be assigned to port 0 as "SHIELD Virtual Controller". When a real
* controller is detected it will overwrite the virtual controller
* and be grouped with the NVIDIA button of the virtual device.
*
*/
if(strstr(device_model, "SHIELD Android TV") && (
strstr(device_name, "Virtual") ||
@@ -677,33 +695,34 @@ static void handle_hotplug(android_input_data_t *android_data,
RARCH_LOG("Special Device Detected: %s\n", device_model);
{
#if 0
RARCH_LOG("- Pads Mapped: %d\n- Device Name: %s\n- IDS: %d, %d, %d", android_data->pads_connected, device_name, id, id_1, id_2);
RARCH_LOG("- Pads Mapped: %d\n- Device Name: %s\n- IDS: %d, %d, %d", android_data->pads_connected, device_name, id, pad_id1, pad_id2);
#endif
/* remove the remote if it is mapped */
if (strstr(android_data->pad_states[0].name,"SHIELD Remote"))
/* remove the remote or virtual controller device if it is mapped */
if (strstr(android_data->pad_states[0].name,"SHIELD Remote") ||
strstr(android_data->pad_states[0].name,"SHIELD Virtual Controller"))
{
id_1 = -1;
id_2 = -1;
pad_id1 = -1;
pad_id2 = -1;
android_data->pads_connected = 0;
*port = 0;
strlcpy(name_buf, device_name, sizeof(name_buf));
}
/* early return, we don't want this to be mapped unless the actual controller has been mapped*/
/* if the actual controller has not been mapped yet, then configure Virtual device for now */
if (strstr(device_name, "Virtual") && android_data->pads_connected==0)
return;
strlcpy (name_buf, "SHIELD Virtual Controller", sizeof(name_buf));
else
strlcpy (name_buf, "NVIDIA SHIELD Controller", sizeof(name_buf));
/* apply the hack only for the first controller
* store the id for later use
*/
if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") && android_data->pads_connected==0)
id_1 = id;
else if (strstr(device_name, "Virtual") && id_1 != -1)
pad_id1 = id;
else if (strstr(device_name, "Virtual") && pad_id1 != -1)
{
id = id_1;
id = pad_id1;
return;
}
strlcpy (name_buf, "NVIDIA SHIELD Controller", sizeof(name_buf));
}
}
@@ -718,12 +737,12 @@ static void handle_hotplug(android_input_data_t *android_data,
/* only use the hack if the device is one of the built-in devices */
RARCH_LOG("Special Device Detected: %s\n", device_model);
{
if ( id_1 < 0 )
id_1 = id;
if ( pad_id1 < 0 )
pad_id1 = id;
else
id_2 = id;
pad_id2 = id;
if ( id_2 > 0)
if ( pad_id2 > 0)
return;
strlcpy (name_buf, "NVIDIA SHIELD Portable", sizeof(name_buf));
@@ -741,12 +760,12 @@ static void handle_hotplug(android_input_data_t *android_data,
/* only use the hack if the device is one of the built-in devices */
RARCH_LOG("Special Device Detected: %s\n", device_model);
{
if ( id_1 < 0 )
id_1 = id;
if ( pad_id1 < 0 )
pad_id1 = id;
else
id_2 = id;
pad_id2 = id;
if ( id_2 > 0)
if ( pad_id2 > 0)
return;
strlcpy (name_buf, "GPD XD", sizeof(name_buf));
@@ -764,12 +783,12 @@ static void handle_hotplug(android_input_data_t *android_data,
/* only use the hack if the device is one of the built-in devices */
RARCH_LOG("Special Device Detected: %s\n", device_model);
{
if ( id_1 < 0 )
id_1 = id;
if ( pad_id1 < 0 )
pad_id1 = id;
else
id_2 = id;
pad_id2 = id;
if ( id_2 > 0)
if ( pad_id2 > 0)
return;
strlcpy (name_buf, "XPERIA Play", sizeof(name_buf));
@@ -787,12 +806,12 @@ static void handle_hotplug(android_input_data_t *android_data,
/* only use the hack if the device is one of the built-in devices */
RARCH_LOG("ARCHOS GAMEPAD Detected: %s\n", device_model);
{
if ( id_1 < 0 )
id_1 = id;
if ( pad_id1 < 0 )
pad_id1 = id;
else
id_2 = id;
pad_id2 = id;
if ( id_2 > 0)
if ( pad_id2 > 0)
return;
strlcpy (name_buf, "ARCHOS GamePad", sizeof(name_buf));
@@ -846,17 +865,17 @@ static void handle_hotplug(android_input_data_t *android_data,
strlcpy(name_buf, "Moga IME", sizeof(name_buf));
// if device is keyboard only and didn't match any of the devices above
// then assume it is a keyboard, register the id, and return unless another
// keyboard is already registered
else if(source == AINPUT_SOURCE_KEYBOARD && id_3 == -1)
// then assume it is a keyboard, register the id, and return unless the
// maximum number of keyboards are already registered
else if(source == AINPUT_SOURCE_KEYBOARD && kbd_num < MAX_NUM_KEYBOARDS)
{
id_3 = id;
kbd_id[kbd_num] = id;
kbd_num++;
return;
}
// if device was not keyboard only, yet did not match any of the devices
// above or another keyboard was already mapped, then try to autoconfigure
// as gamepad based on device_name
// then try to autoconfigure as gamepad based on device_name
else if (!string_is_empty(device_name))
strlcpy(name_buf, device_name, sizeof(name_buf));
@@ -915,8 +934,8 @@ static int android_input_get_id(AInputEvent *event)
{
int id = AInputEvent_getDeviceId(event);
if (id == id_2)
id = id_1;
if (id == pad_id2)
id = pad_id1;
return id;
}
@@ -940,7 +959,7 @@ static void android_input_poll_input(void *data)
int id = android_input_get_id(event);
int port = android_input_get_id_port(android_data, id, source);
if (port < 0 && id != id_3)
if (port < 0 && !is_keyboard_id(id))
handle_hotplug(android_data, android_app,
&port, id, source);
@@ -955,8 +974,10 @@ static void android_input_poll_input(void *data)
{
int keycode = AKeyEvent_getKeyCode(event);
if (id == id_3 && !predispatched)
android_input_poll_event_type_keyboard(event, keycode, &handled);
if (is_keyboard_id(id))
{
if (!predispatched) android_input_poll_event_type_keyboard(event, keycode, &handled);
}
else
android_input_poll_event_type_key(android_app,
event, port, keycode, source, type_event, &handled);
+28 -6
View File
@@ -26,6 +26,9 @@
#include "../drivers_keyboard/keyboard_event_apple.h"
/* Forward declarations */
extern float get_backing_scale_factor(void);
int32_t cocoa_input_find_any_key(void)
{
cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data();
@@ -140,8 +143,16 @@ static void cocoa_input_poll(void *data)
{
uint32_t i;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
#ifndef IOS
float backing_scale_factor = get_backing_scale_factor();
#endif
for (i = 0; i < apple->touch_count; i++)
{
#ifndef IOS
apple->touches[i].screen_x *= backing_scale_factor;
apple->touches[i].screen_y *= backing_scale_factor;
#endif
input_translate_coord_viewport(
apple->touches[i].screen_x,
apple->touches[i].screen_y,
@@ -149,6 +160,7 @@ static void cocoa_input_poll(void *data)
&apple->touches[i].fixed_y,
&apple->touches[i].full_x,
&apple->touches[i].full_y);
}
if (apple->joypad)
apple->joypad->poll();
@@ -184,17 +196,27 @@ static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
static int16_t cocoa_mouse_state_screen(cocoa_input_data_t *apple,
unsigned id)
{
int16_t val;
#ifndef IOS
float backing_scale_factor = get_backing_scale_factor();
#endif
switch (id)
{
case RETRO_DEVICE_ID_MOUSE_X:
return apple->window_pos_x;
case RETRO_DEVICE_ID_MOUSE_Y:
return apple->window_pos_y;
default:
val = apple->window_pos_x;
break;
case RETRO_DEVICE_ID_MOUSE_Y:
val = apple->window_pos_y;
break;
default:
return cocoa_mouse_state(apple, id);
}
return cocoa_mouse_state(apple, id);
#ifndef IOS
val *= backing_scale_factor;
#endif
return val;
}
static int16_t cocoa_pointer_state(cocoa_input_data_t *apple,
@@ -314,7 +314,7 @@
"-DHAVE_HID",
"-DHAVE_XMB",
"-DHAVE_MMAP",
"-DHAVE_LIBRETRODB",
"-DHAVE_LIBRETRODB",
"-DHAVE_FILTERS_BUILTIN",
);
OTHER_LDFLAGS = "-lz";
+1
View File
@@ -74,6 +74,7 @@ extern apple_frontend_settings_t apple_frontend_settings;
- (void)showGameView;
- (void)toggleUI;
- (void)supportOtherAudioSessions;
- (void)refreshSystemConfig;
- (void)mainMenuPushPop: (bool)pushp;
+121 -90
View File
@@ -33,8 +33,6 @@
static id apple_platform;
void *get_chosen_screen(void);
void apple_rarch_exited(void)
{
[[NSApplication sharedApplication] terminate:nil];
@@ -107,31 +105,22 @@ void apple_rarch_exited(void)
{
NSPoint pos;
NSPoint mouse_pos;
CGFloat backing_scale_factor = 1.0f;
NSScreen *screen = (NSScreen*)get_chosen_screen();
apple = (cocoa_input_data_t*)input_driver_get_data();
apple = (cocoa_input_data_t*)input_driver_get_data();
if (!apple)
return;
(void)screen;
/* Relative */
apple->mouse_rel_x = event.deltaX;
apple->mouse_rel_y = event.deltaY;
#if MAC_OS_X_VERSION_10_7
backing_scale_factor = screen.backingScaleFactor;
#endif
/* Absolute */
pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];
apple->touches[0].screen_x = pos.x * backing_scale_factor;
apple->touches[0].screen_y = pos.y * backing_scale_factor;
apple->touches[0].screen_x = pos.x;
apple->touches[0].screen_y = pos.y;
mouse_pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];
apple->window_pos_x = (int16_t)mouse_pos.x * backing_scale_factor;
apple->window_pos_y = (int16_t)mouse_pos.y * backing_scale_factor;
apple->window_pos_x = (int16_t)mouse_pos.x;
apple->window_pos_y = (int16_t)mouse_pos.y;
}
break;
case NSScrollWheel:
@@ -173,14 +162,20 @@ static char** waiting_argv;
[super dealloc];
}
#define NS_WINDOW_COLLECTION_BEHAVIOR_FULLSCREEN_PRIMARY (1 << 17)
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
unsigned i;
apple_platform = self;
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
[self.window setCollectionBehavior:[self.window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary];
#endif
SEL selector = NSSelectorFromString(BOXSTRING("setCollectionBehavior:"));
SEL fsselector = NSSelectorFromString(BOXSTRING("toggleFullScreen:"));
apple_platform = self;
if ([self.window respondsToSelector:selector])
{
if ([self.window respondsToSelector:fsselector])
[self.window setCollectionBehavior:NS_WINDOW_COLLECTION_BEHAVIOR_FULLSCREEN_PRIMARY];
}
[self.window setAcceptsMouseMovedEvents: YES];
@@ -202,6 +197,8 @@ static char** waiting_argv;
apple_rarch_exited();
waiting_argc = 0;
[self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO];
}
static void poll_iteration(void)
@@ -235,7 +232,6 @@ static void poll_iteration(void)
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
[self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO];
}
- (void)applicationWillResignActive:(NSNotification *)notification
@@ -290,96 +286,123 @@ extern void action_ok_push_quick_menu(void);
}
}
static void open_core_handler(NSOpenPanel *panel, NSInteger result)
{
switch (result)
{
case NSOKButton:
if (panel.URL)
{
settings_t *settings = config_get_ptr();
NSURL *url = (NSURL*)panel.URL;
NSString *__core = url.path;
if (!__core)
return;
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)__core.UTF8String);
ui_companion_event_command(EVENT_CMD_LOAD_CORE);
if (menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL) && settings->core.set_supports_no_game_enable)
{
int ret = 0;
runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL);
ret = menu_common_load_content(NULL, NULL, false, CORE_TYPE_PLAIN);
if (ret == -1)
action_ok_push_quick_menu();
}
}
break;
case NSCancelButton:
break;
}
}
static void open_document_handler(NSOpenPanel *panel, NSInteger result)
{
switch (result)
{
case NSOKButton:
if (panel.URL)
{
struct retro_system_info *system = NULL;
NSURL *url = (NSURL*)panel.URL;
NSString *__core = url.path;
const char *core_name = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system);
if (system)
core_name = system->library_name;
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String);
if (core_name)
ui_companion_event_command(EVENT_CMD_LOAD_CONTENT);
}
break;
case NSCancelButton:
break;
}
}
- (IBAction)openCore:(id)sender {
NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel];
#if defined(MAC_OS_X_VERSION_10_6)
settings_t *settings = config_get_ptr();
NSString *startdir = BOXSTRING(settings->libretro_directory);
NSArray *filetypes = [[NSArray alloc] initWithObjects:BOXSTRING("dylib"), BOXSTRING("Core"), nil];
[panel setAllowedFileTypes:filetypes];
#if defined(MAC_OS_X_VERSION_10_6)
[panel setMessage:BOXSTRING("Load Core")];
[panel setDirectoryURL:[NSURL fileURLWithPath:startdir]];
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result)
{
[[NSApplication sharedApplication] stopModal];
switch (result)
{
case NSOKButton:
if (panel.URL)
{
settings_t *settings = config_get_ptr();
NSURL *url = (NSURL*)panel.URL;
NSString *__core = url.path;
if (!__core)
return;
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)__core.UTF8String);
ui_companion_event_command(EVENT_CMD_LOAD_CORE);
if (menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL) && settings->core.set_supports_no_game_enable)
{
int ret = 0;
runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL);
ret = menu_common_load_content(NULL, NULL, false, CORE_TYPE_PLAIN);
if (ret == -1)
action_ok_push_quick_menu();
}
}
break;
case NSCancelButton:
break;
}
open_core_handler(panel, result);
}];
#else
[panel beginSheetForDirectory:nil file:nil modalForWindopw:[self window] modalDelegate:self didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:) contextInfo:NULL];
#endif
[[NSApplication sharedApplication] runModalForWindow:panel];
#else
[panel setTitle:NSLocalizedString(BOXSTRING("Load Core"), BOXSTRING("open panel"))];
[panel setDirectory:startdir];
[panel setCanChooseDirectories:NO];
[panel setCanChooseFiles:YES];
[panel setAllowsMultipleSelection:NO];
[panel setTreatsFilePackagesAsDirectories:NO];
NSInteger result = [panel runModal];
if (result == 1)
open_core_handler(panel, result);
#endif
[g_context makeCurrentContext];
}
- (void)openDocument:(id)sender
{
NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel];
NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel];
settings_t *settings = config_get_ptr();
NSString *startdir = BOXSTRING(settings->menu_content_directory);
if (!startdir.length)
startdir = BOXSTRING("/");
#if defined(MAC_OS_X_VERSION_10_6)
settings_t *settings = config_get_ptr();
NSString *startdir = BOXSTRING(settings->menu_content_directory);
if (!startdir.length)
startdir = BOXSTRING("/");
[panel setDirectoryURL:[NSURL fileURLWithPath:startdir]];
[panel setMessage:BOXSTRING("Load Content")];
[panel setMessage:BOXSTRING("Load Content")];
[panel setDirectoryURL:[NSURL fileURLWithPath:startdir]];
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result)
{
[[NSApplication sharedApplication] stopModal];
switch (result)
{
case NSOKButton:
if (panel.URL)
{
struct retro_system_info *system = NULL;
NSURL *url = (NSURL*)panel.URL;
NSString *__core = url.path;
const char *core_name = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system);
if (system)
core_name = system->library_name;
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String);
if (core_name)
ui_companion_event_command(EVENT_CMD_LOAD_CONTENT);
}
break;
case NSCancelButton:
break;
}
open_document_handler(panel, result);
}];
#else
[panel beginSheetForDirectory:nil file:nil modalForWindopw:[self window] modalDelegate:self didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:) contextInfo:NULL];
#endif
[[NSApplication sharedApplication] runModalForWindow:panel];
#else
[panel setTitle:NSLocalizedString(BOXSTRING("Load Content"), BOXSTRING("open panel"))];
[panel setDirectory:startdir];
[panel setCanChooseDirectories:NO];
[panel setCanChooseFiles:YES];
[panel setAllowsMultipleSelection:NO];
[panel setTreatsFilePackagesAsDirectories:NO];
NSInteger result = [panel runModal];
if (result == 1)
open_document_handler(panel, result);
#endif
[g_context makeCurrentContext];
}
@@ -458,8 +481,16 @@ extern void action_ok_push_quick_menu(void);
int main(int argc, char *argv[])
{
if (argc == 2)
{
if (argv[1] != '\0')
if (!strncmp(argv[1], "-psn", 4))
argc = 1;
}
waiting_argc = argc;
waiting_argv = argv;
return NSApplicationMain(argc, (const char **) argv);
}
+62 -4
View File
@@ -27,7 +27,9 @@
#include "../../input/drivers/cocoa_input.h"
#include "../../input/drivers_keyboard/keyboard_event_apple.h"
#include "../../retroarch.h"
#ifdef HAVE_AVFOUNDATION
#import <AVFoundation/AVFoundation.h>
#endif
#include "../../frontend/frontend.h"
#include "../../runloop.h"
@@ -44,6 +46,12 @@ void apple_rarch_exited(void);
static void rarch_enable_ui(void)
{
#ifdef HAVE_AVFOUNDATION
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];
[audioSession setActive:YES error:nil];
#endif
bool boolean = true;
ui_companion_set_foreground(true);
@@ -62,6 +70,11 @@ static void rarch_disable_ui(void)
runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean);
runloop_ctl(RUNLOOP_CTL_SET_IDLE, &boolean);
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
#ifdef HAVE_AVFOUNDATION
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];
[audioSession setActive:YES error:nil];
#endif
}
static void ui_companion_cocoatouch_event_command(
@@ -314,6 +327,12 @@ enum
+ (RetroArch_iOS*)get
{
#ifdef HAVE_AVFOUNDATION
/* Implicitly initializes your audio session. */
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];
[audioSession setActive:YES error:nil];
#endif
return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate];
}
@@ -326,6 +345,11 @@ enum
if (rarch_main(0, NULL, NULL))
apple_rarch_exited();
#ifdef HAVE_AVFOUNDATION
/* Other background audio check */
[self supportOtherAudioSessions];
#endif
/* Setup window */
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
@@ -337,6 +361,10 @@ enum
[self refreshSystemConfig];
[self showGameView];
#ifdef HAVE_AVFOUNDATION
[self supportOtherAudioSessions];
#endif
if (rarch_main(0, NULL, NULL))
apple_rarch_exited();
@@ -352,7 +380,9 @@ enum
- (void)applicationDidEnterBackground:(UIApplication *)application
{
#ifdef HAVE_AVFOUNDATION
[self supportOtherAudioSessions];
#endif
}
- (void)applicationWillTerminate:(UIApplication *)application
@@ -365,7 +395,10 @@ enum
- (void)applicationDidBecomeActive:(UIApplication *)application
{
settings_t *settings = config_get_ptr();
#ifdef HAVE_AVFOUNDATION
[self supportOtherAudioSessions];
#endif
if (settings->ui.companion_start_on_boot)
return;
@@ -374,6 +407,9 @@ enum
- (void)applicationWillResignActive:(UIApplication *)application
{
#ifdef HAVE_AVFOUNDATION
[self supportOtherAudioSessions];
#endif
dispatch_async(dispatch_get_main_queue(),
^{
ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG);
@@ -385,7 +421,7 @@ enum
{
NSString *filename = (NSString*)url.path.lastPathComponent;
NSError *error = nil;
[[NSFileManager defaultManager] moveItemAtPath:[url path] toPath:[self.documentsDirectory stringByAppendingPathComponent:filename] error:&error];
if (error)
@@ -402,6 +438,10 @@ enum
- (void)showGameView
{
#ifdef HAVE_AVFOUNDATION
/* implicitly initializes your audio session */
[self supportOtherAudioSessions];
#endif
[self popToRootViewControllerAnimated:NO];
[self setToolbarHidden:true animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone];
@@ -414,7 +454,9 @@ enum
- (IBAction)showPauseMenu:(id)sender
{
#ifndef HAVE_AVFOUNDATION
ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_AUDIO_STOP);
#endif
rarch_enable_ui();
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone];
@@ -433,6 +475,9 @@ enum
{
[self showPauseMenu:self];
}
#ifdef HAVE_AVFOUNDATION
[self supportOtherAudioSessions];
#endif
}
- (void)refreshSystemConfig
@@ -471,6 +516,16 @@ enum
}
}
- (void)supportOtherAudioSessions
{
#ifdef HAVE_AVFOUNDATION
/* implicitly initializes your audio session */
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];
[audioSession setActive:YES error:nil];
#endif
}
- (void)mainMenuRenderMessageBox:(NSString *)msg
{
[self.mainmenu renderMessageBox:msg];
@@ -501,6 +556,9 @@ void apple_rarch_exited(void)
if (!ap)
return;
#ifdef HAVE_AVFOUNDATION
[ap supportOtherAudioSessions];
#endif
[ap showPauseMenu:ap];
}