Merge branch 'master' of github.com:libretro/RetroArch into upstream

This commit is contained in:
Themaister 2013-08-11 14:50:54 +02:00
commit 8862908040
5 changed files with 105 additions and 47 deletions

View File

@ -51,9 +51,9 @@ public class MainMenuActivity extends PreferenceActivity {
if (!detectDevice(false))
{
AlertDialog.Builder alert = new AlertDialog.Builder(this)
.setTitle("Two modes of play - pick one")
.setMessage("RetroArch has two modes of play: synchronize to refreshrate, and threaded video.\n\nSynchronize to refreshrate gives the most accurate results and can produce the smoothest results. However, it is hard to configure right and might result in unpleasant audio crackles when it has been configured wrong.\n\nThreaded video should work fine on most devices, but applies some adaptive video jittering to achieve this.\n\nChoose which of the two you want to use. (If you don't know, go for Threaded video). ")
.setPositiveButton("Threaded video", new DialogInterface.OnClickListener() {
.setTitle("Welcome to RetroArch")
.setMessage("This is your first time starting up RetroArch. RetroArch will now be preconfigured for the best possible gameplay experience. Please be aware that it might take some time until all shader and overlay assets are extracted.\n\nNOTE: Advanced users who want to finetune for the best possible audio/video experience should use static synchronization and turn off threaded video. Be aware that this is hard to configure right and might result in unpleasant audio crackles when it has been configured wrong.\n\nThreaded video should work fine on most devices, but applies some adaptive video jittering to achieve this. ")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
@ -61,17 +61,6 @@ public class MainMenuActivity extends PreferenceActivity {
edit.putBoolean("video_threaded", true);
edit.commit();
}
})
.setNegativeButton("Synchronize to refreshrate", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("video_threaded", false);
edit.commit();
Intent i = new Intent(getBaseContext(), DisplayRefreshRateTest.class);
startActivity(i);
}
});
alert.show();
}
@ -176,7 +165,7 @@ public class MainMenuActivity extends PreferenceActivity {
{
AlertDialog.Builder alert = new AlertDialog.Builder(this)
.setTitle("NVidia Shield detected")
.setMessage("Would you like to set up the ideal configuration options for your device?\nNOTE: For optimal performance, turn off Google Account sync, GPS and Wifi in your Android settings menu.\n\nNOTE: If you know what you are doing, it is advised to turn 'Threaded Video' off afterwards and try running games without it. In theory it will be smoother, but your mileage varies depending on your device and configuration.")
.setMessage("Would you like to set up the ideal configuration options for your device?\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -196,7 +185,7 @@ public class MainMenuActivity extends PreferenceActivity {
{
AlertDialog.Builder alert = new AlertDialog.Builder(this)
.setTitle("Nexus 7 2013 detected")
.setMessage("Would you like to set up the ideal configuration options for your device?\nNOTE: For optimal performance, turn off Google Account sync, GPS and Wifi in your Android settings menu. \n\nNOTE: If you know what you are doing, it is advised to turn 'Threaded Video' off afterwards and try running games without it. In theory it will be smoother, but your mileage varies depending on your device and configuration.")
.setMessage("Would you like to set up the ideal configuration options for your device?\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

View File

@ -16,40 +16,66 @@
#include <IOKit/hid/IOHIDManager.h>
#include "../RetroArch/apple_input.h"
// NOTE: I pieced this together through trial and error, any corrections are welcome
static IOHIDManagerRef g_hid_manager;
static void hid_input_callback(void* inContext, IOReturn inResult, void* inSender, IOHIDValueRef inIOHIDValueRef)
{
IOHIDElementRef element = IOHIDValueGetElement(inIOHIDValueRef);
uint32_t slot = (uint32_t)inContext;
if (slot >= 4)
return;
IOHIDDeviceRef device = IOHIDElementGetDevice(element);
uint32_t type = IOHIDElementGetType(element);
uint32_t page = IOHIDElementGetUsagePage(element);
uint32_t use = IOHIDElementGetUsage(element);
if (type == 2 && page == 9)
// Mouse handler
if (IOHIDDeviceConformsTo(device, kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse))
{
CFIndex state = IOHIDValueGetIntegerValue(inIOHIDValueRef);
if (state) g_current_input_data.pad_buttons[slot] |= (1 << (use - 1));
else g_current_input_data.pad_buttons[slot] &= ~(1 << (use - 1));
}
else if (page == 1)
{
static const uint32_t axis_use_ids[4] = { 48, 49, 50, 53 };
for (int i = 0; i < 4; i ++)
if (type == kIOHIDElementTypeInput_Button && page == kHIDPage_Button)
{
if (use == axis_use_ids[i])
CFIndex state = IOHIDValueGetIntegerValue(inIOHIDValueRef);
if (state) g_current_input_data.mouse_buttons |= (1 << (use - 1));
else g_current_input_data.mouse_buttons &= ~(1 << (use - 1));
}
else if (type == kIOHIDElementTypeInput_Misc && page == kHIDPage_GenericDesktop)
{
static const uint32_t axis_use_ids[2] = { 48, 49 };
for (int i = 0; i < 2; i ++)
if (use == axis_use_ids[i])
g_current_input_data.mouse_delta[i] += IOHIDValueGetIntegerValue(inIOHIDValueRef);
}
}
// Joystick handler
else if (IOHIDDeviceConformsTo(device, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick))
{
uint32_t slot = (uint32_t)inContext;
if (slot >= 4)
return;
if (type == kIOHIDElementTypeInput_Button && page == kHIDPage_Button)
{
CFIndex state = IOHIDValueGetIntegerValue(inIOHIDValueRef);
if (state) g_current_input_data.pad_buttons[slot] |= (1 << (use - 1));
else g_current_input_data.pad_buttons[slot] &= ~(1 << (use - 1));
}
else if (type == kIOHIDElementTypeInput_Axis && page == kHIDPage_GenericDesktop)
{
static const uint32_t axis_use_ids[4] = { 48, 49, 50, 53 };
for (int i = 0; i < 4; i ++)
{
CFIndex min = IOHIDElementGetPhysicalMin(element);
CFIndex max = IOHIDElementGetPhysicalMax(element) - min;
CFIndex state = IOHIDValueGetIntegerValue(inIOHIDValueRef) - min;
if (use == axis_use_ids[i])
{
CFIndex min = IOHIDElementGetPhysicalMin(element);
CFIndex max = IOHIDElementGetPhysicalMax(element) - min;
CFIndex state = IOHIDValueGetIntegerValue(inIOHIDValueRef) - min;
float val = (float)state / (float)max;
g_current_input_data.pad_axis[slot][i] = ((val * 2.0f) - 1.0f) * 32767.0f;
float val = (float)state / (float)max;
g_current_input_data.pad_axis[slot][i] = ((val * 2.0f) - 1.0f) * 32767.0f;
}
}
}
}
@ -67,25 +93,38 @@ static void hid_device_removed(void* inContext, IOReturn inResult, void* inSende
IOHIDDeviceClose(inDevice, kIOHIDOptionsTypeNone);
}
static CFMutableDictionaryRef build_matching_dictionary(uint32_t page, uint32_t use)
{
CFMutableDictionaryRef matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFNumberRef pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsagePageKey), pagen);
CFRelease(pagen);
CFNumberRef usen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &use);
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsageKey), usen);
CFRelease(usen);
return matcher;
}
void osx_pad_init()
{
if (!g_hid_manager)
{
g_hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
CFMutableDictionaryRef matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
uint32_t page = kHIDPage_GenericDesktop;
uint32_t use = kHIDUsage_GD_Joystick;
CFMutableArrayRef matcher = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
CFNumberRef pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsagePageKey), pagen);
CFRelease(pagen);
CFMutableDictionaryRef mouse = build_matching_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse);
CFArrayAppendValue(matcher, mouse);
CFRelease(mouse);
CFNumberRef usen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &use);
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsageKey), usen);
CFRelease(usen);
CFMutableDictionaryRef joystick = build_matching_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
CFArrayAppendValue(matcher, joystick);
CFRelease(joystick);
IOHIDManagerSetDeviceMatching(g_hid_manager, matcher);
IOHIDManagerSetDeviceMatchingMultiple(g_hid_manager, matcher);
CFRelease(matcher);
IOHIDManagerRegisterDeviceMatchingCallback(g_hid_manager, hid_device_attached, 0);

View File

@ -31,6 +31,8 @@ static UIView* g_pause_indicator_view;
#elif defined(OSX)
#include "apple_input.h"
static RAGameView* g_instance;
static NSOpenGLContext* g_context;
@ -87,20 +89,31 @@ static float g_screen_scale = 1.0f;
return YES;
}
- (BOOL)isFlipped
{
return YES;
}
- (void)keyDown:(NSEvent*)theEvent
{
}
- (void)mouseDown:(NSEvent*)theEvent
{
g_current_input_data.touch_count = 1;
[self mouseDragged:theEvent];
}
- (void)mouseUp:(NSEvent*)theEvent
{
g_current_input_data.touch_count = 0;
}
- (void)mouseMoved:(NSEvent *)theEvent
- (void)mouseDragged:(NSEvent*)theEvent
{
NSPoint pos = [self convertPoint:[theEvent locationInWindow] fromView:nil];
g_current_input_data.touches[0].screen_x = pos.x;
g_current_input_data.touches[0].screen_y = pos.y;
}
#elif defined(IOS) // < iOS Pause menu and lifecycle

View File

@ -132,6 +132,9 @@ static void apple_input_poll(void *data)
input_joypad_poll(g_joydriver);
g_polled_input_data.pad_buttons[0] |= icade_buttons;
g_current_input_data.mouse_delta[0] = 0;
g_current_input_data.mouse_delta[1] = 0;
});
}
@ -147,6 +150,17 @@ static int16_t apple_input_state(void *data, const struct retro_keybind **binds,
case RETRO_DEVICE_KEYBOARD:
return apple_key_pressed(id);
case RETRO_DEVICE_MOUSE:
{
switch (id)
{
case RETRO_DEVICE_ID_MOUSE_X: return g_polled_input_data.mouse_delta[0];
case RETRO_DEVICE_ID_MOUSE_Y: return g_polled_input_data.mouse_delta[1];
case RETRO_DEVICE_ID_MOUSE_LEFT: return g_polled_input_data.mouse_buttons & 1;
case RETRO_DEVICE_ID_MOUSE_RIGHT: return g_polled_input_data.mouse_buttons & 2;
}
}
case RETRO_DEVICE_POINTER:
case RARCH_DEVICE_POINTER_SCREEN:

View File

@ -33,6 +33,9 @@ typedef struct
apple_touch_data_t touches[MAX_TOUCHES];
uint32_t touch_count;
uint32_t mouse_buttons;
int16_t mouse_delta[2];
uint32_t keys[MAX_KEYS];
uint32_t pad_buttons[MAX_PADS];