(OSX) Start keybind setting support

This commit is contained in:
meancoot 2013-08-26 22:12:22 -04:00
parent dbc1758a99
commit 29b8a6f8e4
7 changed files with 1238 additions and 524 deletions

384
apple/OSX/InputBinder.xib Normal file
View File

@ -0,0 +1,384 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12E55</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">3084</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBNSLayoutConstraint</string>
<string>NSButton</string>
<string>NSButtonCell</string>
<string>NSCustomObject</string>
<string>NSTextField</string>
<string>NSTextFieldCell</string>
<string>NSView</string>
<string>NSWindowTemplate</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">NSWindowController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="1005">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{196, 240}, {480, 109}}</string>
<int key="NSWTFlags">544735232</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">RAInputBinder</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSTextField" id="693377980">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 72}, {446, 17}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="606338068"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="270729776">
<int key="NSCellFlags">68157504</int>
<int key="NSCellFlags2">138413056</int>
<string key="NSContents">Press a Key, Joystick Button, or move a Joystick Axis</string>
<object class="NSFont" key="NSSupport" id="965449829">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:1535</string>
<reference key="NSControlView" ref="693377980"/>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
<object class="NSButton" id="606338068">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{384, 13}, {82, 32}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="548104382">
<int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Cancel</string>
<reference key="NSSupport" ref="965449829"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="606338068"/>
<int key="NSButtonFlags">-2038284288</int>
<int key="NSButtonFlags2">129</int>
<reference key="NSAlternateImage" ref="965449829"/>
<string key="NSAlternateContents"/>
<string type="base64-UTF8" key="NSKeyEquivalent">Gw</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
</array>
<string key="NSFrameSize">{480, 109}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="693377980"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="1005"/>
</object>
<int key="connectionID">3</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">goAway:</string>
<reference key="source" ref="1005"/>
<reference key="destination" ref="606338068"/>
</object>
<int key="connectionID">20</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="1005"/>
<array class="NSMutableArray" key="children">
<reference ref="1006"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="1006"/>
<array class="NSMutableArray" key="children">
<object class="IBNSLayoutConstraint" id="952757161">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">4</int>
<int key="relation">0</int>
<reference key="secondItem" ref="606338068"/>
<int key="secondAttribute">4</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="1024300700">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">6</int>
<int key="relation">0</int>
<reference key="secondItem" ref="606338068"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="547048879">
<reference key="firstItem" ref="693377980"/>
<int key="firstAttribute">3</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">3</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="101981711">
<reference key="firstItem" ref="1006"/>
<int key="firstAttribute">6</int>
<int key="relation">0</int>
<reference key="secondItem" ref="693377980"/>
<int key="secondAttribute">6</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="362753409">
<reference key="firstItem" ref="693377980"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1006"/>
<int key="secondAttribute">5</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1006"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<reference ref="693377980"/>
<reference ref="606338068"/>
</array>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="693377980"/>
<array class="NSMutableArray" key="children">
<reference ref="270729776"/>
</array>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="270729776"/>
<reference key="parent" ref="693377980"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">9</int>
<reference key="object" ref="362753409"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="101981711"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">11</int>
<reference key="object" ref="547048879"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">12</int>
<reference key="object" ref="606338068"/>
<array class="NSMutableArray" key="children">
<reference ref="548104382"/>
</array>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="548104382"/>
<reference key="parent" ref="606338068"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="1024300700"/>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="952757161"/>
<reference key="parent" ref="1006"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1.IBWindowTemplateEditedContentRect">{{357, 418}, {480, 270}}</string>
<boolean value="NO" key="1.NSWindowTemplate.visibleAtLaunch"/>
<string key="10.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="11.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="12.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="12.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="13.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="15.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<array key="2.IBNSViewMetadataConstraints">
<reference ref="362753409"/>
<reference ref="101981711"/>
<reference ref="547048879"/>
<reference ref="1024300700"/>
<reference ref="952757161"/>
</array>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="4.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="9.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">20</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">RAInputBinder</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/RAInputBinder.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<bool key="IBDocument.UseAutolayout">YES</bool>
</data>
</archive>

File diff suppressed because it is too large Load Diff

View File

@ -94,7 +94,7 @@ static void hid_device_attached(void* inContext, IOReturn inResult, void* inSend
}
IOHIDDeviceOpen(inDevice, kIOHIDOptionsTypeNone);
IOHIDDeviceScheduleWithRunLoop(inDevice, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDDeviceScheduleWithRunLoop(inDevice, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
IOHIDDeviceRegisterInputValueCallback(inDevice, hid_input_callback, context);
}
@ -139,7 +139,7 @@ void osx_pad_init()
IOHIDManagerRegisterDeviceMatchingCallback(g_hid_manager, hid_device_attached, 0);
IOHIDManagerRegisterDeviceRemovalCallback(g_hid_manager, hid_device_removed, 0);
IOHIDManagerScheduleWithRunLoop(g_hid_manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDManagerScheduleWithRunLoop(g_hid_manager, CFRunLoopGetMain(), kCFRunLoopCommonModes);
IOHIDManagerOpen(g_hid_manager, kIOHIDOptionsTypeNone);
}
@ -150,7 +150,7 @@ void osx_pad_quit()
if (g_hid_manager)
{
IOHIDManagerClose(g_hid_manager, kIOHIDOptionsTypeNone);
IOHIDManagerUnscheduleFromRunLoop(g_hid_manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDManagerUnscheduleFromRunLoop(g_hid_manager, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
CFRelease(g_hid_manager);
}

View File

@ -251,7 +251,8 @@
- (IBAction)showPreferences:(id)sender
{
[[[NSWindowController alloc] initWithWindowNibName:@"Settings"] window];
NSWindowController* wc = [[NSWindowController alloc] initWithWindowNibName:@"Settings"];
[NSApp runModalForWindow:wc.window];
}
- (IBAction)basicEvent:(id)sender

View File

@ -16,17 +16,65 @@
#import <objc/runtime.h>
#import "../RetroArch/RetroArch_Apple.h"
#include "../RetroArch/setting_data.h"
#include "../RetroArch/apple_input.h"
#include "driver.h"
#include "input/input_common.h"
struct settings fake_settings;
struct global fake_extern;
static const void* associated_name_tag = (void*)&associated_name_tag;
#define BINDFOR(s) (*(struct retro_keybind*)(&s)->value)
static const char* key_name_for_id(uint32_t hidkey)
{
for (int i = 0; apple_key_name_map[i].hid_id; i ++)
if (apple_key_name_map[i].hid_id == hidkey)
return apple_key_name_map[i].keyname;
return "nul";
}
static uint32_t key_id_for_name(const char* name)
{
for (int i = 0; apple_key_name_map[i].hid_id; i ++)
if (strcmp(name, apple_key_name_map[i].keyname) == 0)
return apple_key_name_map[i].hid_id;
return 0;
}
#define key_name_for_rk(X) key_name_for_id(input_translate_rk_to_keysym(X))
#define key_rk_for_name(X) input_translate_keysym_to_rk(key_id_for_name(X))
@interface RAInputBinder : NSWindow
@end
@implementation RAInputBinder
- (IBAction)goAway:(id)sender
{
[NSApp endSheet:self];
[self orderOut:nil];
}
// Stop the annoying sound when pressing a key
- (void)keyDown:(NSEvent*)theEvent
{
}
@end
@interface RASettingCell : NSTableCellView
@property (nonatomic) const rarch_setting_t* setting;
@property (nonatomic) NSString* stringValue;
@property (nonatomic) IBOutlet NSNumber* numericValue;
@property (nonatomic) bool booleanValue;
@property (nonatomic) const rarch_setting_t* setting;
@property (nonatomic) NSTimer* bindTimer;
@end
@implementation RASettingCell
@ -44,6 +92,7 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
case ST_STRING: self.stringValue = @((const char*)aSetting->value); break;
case ST_PATH: self.stringValue = @((const char*)aSetting->value); break;
case ST_BOOL: self.booleanValue = *(bool*)aSetting->value; break;
case ST_BIND: [self updateInputString]; break;
}
}
@ -61,9 +110,9 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
_numericValue = numericValue;
if (_setting && _setting->type == ST_INT)
*(int*)_setting->value = [_numericValue intValue];
*(int*)_setting->value = _numericValue.intValue;
else if (_setting && _setting->type == ST_FLOAT)
*(float*)_setting->value = [_numericValue floatValue];
*(float*)_setting->value = _numericValue.floatValue;
}
- (void)setBooleanValue:(bool)booleanValue
@ -82,6 +131,63 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
strlcpy(_setting->value, _stringValue.UTF8String, _setting->size);
}
// Input Binding
- (void)updateInputString
{
self.stringValue = [NSString stringWithFormat:@"[KB:%s] [JS:%lld] [AX:nul]", key_name_for_rk(BINDFOR(*_setting).key),
BINDFOR(*_setting).joykey];
}
- (void)dismissBinder
{
[self.bindTimer invalidate];
self.bindTimer = nil;
[self updateInputString];
[(id)self.window.attachedSheet goAway:nil];
}
- (void)checkBind:(NSTimer*)send
{
// Keyboard
for (int i = 0; apple_key_name_map[i].hid_id; i++)
{
if (g_current_input_data.keys[apple_key_name_map[i].hid_id])
{
BINDFOR(*_setting).key = input_translate_keysym_to_rk(apple_key_name_map[i].hid_id);
[self dismissBinder];
return;
}
}
// Joystick
if (g_current_input_data.pad_buttons[0])
{
for (int i = 0; i != 32; i ++)
{
if (g_current_input_data.pad_buttons[0] & (1 << i))
{
BINDFOR(*_setting).joykey = i;
[self dismissBinder];
return;
}
}
}
}
- (IBAction)doGetBind:(id)sender
{
static NSWindowController* controller;
if (!controller)
controller = [[NSWindowController alloc] initWithWindowNibName:@"InputBinder"];
self.bindTimer = [NSTimer timerWithTimeInterval:.1f target:self selector:@selector(checkBind:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.bindTimer forMode:NSModalPanelRunLoopMode];
[NSApp beginSheet:controller.window modalForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:nil];
}
@end
@protocol RASettingView
@ -89,12 +195,13 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
@end
@interface RASettingsDelegate : NSObject<NSTableViewDataSource, NSTableViewDelegate,
NSOutlineViewDataSource, NSOutlineViewDelegate>
NSOutlineViewDataSource, NSOutlineViewDelegate,
NSWindowDelegate>
@end
@implementation RASettingsDelegate
{
NSWindow IBOutlet* _window;
NSWindow IBOutlet* _inputWindow;
NSTableView IBOutlet* _table;
NSOutlineView IBOutlet* _outline;
@ -152,9 +259,6 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
}
[self load];
[NSApplication.sharedApplication beginSheet:_window modalForWindow:RetroArch_OSX.get->window modalDelegate:nil didEndSelector:nil contextInfo:nil];
[NSApplication.sharedApplication runModalForWindow:_window];
}
- (void)load
@ -169,6 +273,12 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
case ST_FLOAT: config_set_float (conf, setting_data[i].name, *(float*)setting_data[i].value); break;
case ST_PATH: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
case ST_STRING: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
case ST_BIND: input_config_parse_key(conf, "input_player1", input_config_bind_map[0].base, setting_data[i].value);
input_config_parse_joy_button(conf, "input_player1", input_config_bind_map[0].base, setting_data[i].value);
input_config_parse_joy_axis(conf, "input_player1", input_config_bind_map[0].base, setting_data[i].value);
break;
case ST_HEX: break;
default: break;
}
@ -176,7 +286,7 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
config_file_free(conf);
}
- (IBAction)close:(id)sender
- (void)windowWillClose:(NSNotification *)notification
{
config_file_t* conf = config_file_new(0);
for (int i = 0; setting_data[i].type; i ++)
@ -188,6 +298,13 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
case ST_FLOAT: config_set_float (conf, setting_data[i].name, *(float*)setting_data[i].value); break;
case ST_PATH: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
case ST_STRING: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
case ST_BIND:
{
config_set_string(conf, setting_data[i].name, key_name_for_rk(BINDFOR(setting_data[i]).key));
break;
}
case ST_HEX: break;
default: break;
}
@ -197,32 +314,7 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
apple_refresh_config();
[NSApplication.sharedApplication stopModal];
[NSApplication.sharedApplication endSheet:_window returnCode:0];
[_window orderOut:nil];
}
- (void)readConfigFile:(const char*)path
{
config_file_t* conf = config_file_new(path);
if (conf)
{
for (int i = 0; setting_data[i].type; i ++)
{
switch (setting_data[i].type)
{
case ST_BOOL: config_get_bool (conf, setting_data[i].name, (bool*)setting_data[i].value); break;
case ST_INT: config_get_int (conf, setting_data[i].name, (int*)setting_data[i].value); break;
case ST_FLOAT: config_get_float(conf, setting_data[i].name, (float*)setting_data[i].value); break;
case ST_PATH: config_get_array(conf, setting_data[i].name, (char*)setting_data[i].value, setting_data[i].size); break;
case ST_STRING: config_get_array(conf, setting_data[i].name, (char*)setting_data[i].value, setting_data[i].size); break;
case ST_HEX: break;
default: break;
}
}
config_file_free(conf);
}
[NSApp stopModal];
}
#pragma mark View Builders
@ -295,6 +387,7 @@ static const void* associated_name_tag = (void*)&associated_name_tag;
case ST_FLOAT: s = [outlineView makeViewWithIdentifier:@"RANumericSetting" owner:nil]; break;
case ST_PATH: s = [outlineView makeViewWithIdentifier:@"RAPathSetting" owner:nil]; break;
case ST_STRING: s = [outlineView makeViewWithIdentifier:@"RAStringSetting" owner:nil]; break;
case ST_BIND: s = [outlineView makeViewWithIdentifier:@"RABindSetting" owner:nil]; break;
}
s.setting = setting;
return s;

View File

@ -18,8 +18,8 @@
#include "general.h"
enum setting_type { ST_NONE, ST_BOOL, ST_INT, ST_FLOAT, ST_PATH, ST_STRING, ST_HEX, ST_GROUP, ST_SUB_GROUP,
ST_END_GROUP, ST_END_SUB_GROUP };
enum setting_type { ST_NONE, ST_BOOL, ST_INT, ST_FLOAT, ST_PATH, ST_STRING, ST_HEX, ST_BIND,
ST_GROUP, ST_SUB_GROUP, ST_END_GROUP, ST_END_SUB_GROUP };
typedef struct
{
@ -52,14 +52,13 @@ extern struct global fake_extern;
#define END_GROUP() { ST_END_GROUP },
#define START_SUB_GROUP(NAME) { ST_SUB_GROUP, NAME },
#define END_SUB_GROUP() { ST_END_SUB_GROUP },
#define START_GROUP(NAME) { ST_GROUP, NAME, 0, 0, 0, 0, 0, 0, 0.0, 0.0, false },
#define END_GROUP() { ST_END_GROUP, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, false },
#define CONFIG_BOOL(TARGET, NAME, SHORT) { ST_BOOL, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
#define CONFIG_INT(TARGET, NAME, SHORT) { ST_INT, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
#define CONFIG_FLOAT(TARGET, NAME, SHORT) { ST_FLOAT, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
#define CONFIG_PATH(TARGET, NAME, SHORT) { ST_PATH, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
#define CONFIG_STRING(TARGET, NAME, SHORT) { ST_STRING, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
#define CONFIG_HEX(TARGET, NAME, SHORT) { ST_HEX, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
#define CONFIG_BIND(TARGET, NAME, SHORT) { ST_BIND, NAME, &TARGET, sizeof(TARGET), SHORT },
const rarch_setting_t setting_data[] =
{
@ -100,7 +99,6 @@ const rarch_setting_t setting_data[] =
END_GROUP()
/*************/
/* EMULATION */
/*************/
@ -183,6 +181,25 @@ const rarch_setting_t setting_data[] =
CONFIG_INT(g_settings.input.icade_profile[3], "input_autodetect_icade_profile_pad4", "iCade 4")
#endif
END_SUB_GROUP()
START_SUB_GROUP("Player 1")
CONFIG_BIND(g_settings.input.binds[0][ 0], "input_player1_b", "B button (down)")
CONFIG_BIND(g_settings.input.binds[0][ 1], "input_player1_y", "Y button (left)")
CONFIG_BIND(g_settings.input.binds[0][ 2], "input_player1_select", "Select button")
CONFIG_BIND(g_settings.input.binds[0][ 3], "input_player1_start", "Start button")
CONFIG_BIND(g_settings.input.binds[0][ 4], "input_player1_up", "Up D-pad")
CONFIG_BIND(g_settings.input.binds[0][ 5], "input_player1_down", "Down D-pad")
CONFIG_BIND(g_settings.input.binds[0][ 6], "input_player1_left", "Left D-pad")
CONFIG_BIND(g_settings.input.binds[0][ 7], "input_player1_right", "Right D-pad")
CONFIG_BIND(g_settings.input.binds[0][ 8], "input_player1_a", "A button (right)")
CONFIG_BIND(g_settings.input.binds[0][ 9], "input_player1_x", "X button (top)")
CONFIG_BIND(g_settings.input.binds[0][10], "input_player1_l", "L button (left shoulder)")
CONFIG_BIND(g_settings.input.binds[0][11], "input_player1_r", "R button (right shoulder)")
CONFIG_BIND(g_settings.input.binds[0][12], "input_player1_l2", "L2 button (left shoulder #2)")
CONFIG_BIND(g_settings.input.binds[0][13], "input_player1_r2", "R2 button (right shoulder #2)")
CONFIG_BIND(g_settings.input.binds[0][14], "input_player1_l3", "L3 button (left analog button)")
CONFIG_BIND(g_settings.input.binds[0][15], "input_player1_r3", "R3 button (right analog button)")
END_SUB_GROUP()
END_GROUP()
/*********/
@ -275,7 +292,63 @@ const rarch_setting_t setting_data[] =
};
// HACK
#undef g_settings fake_settings
#undef g_extern fake_extern
#undef g_settings
#undef g_extern
// Keyboard
#include "keycode.h"
static const struct
{
const char* const keyname;
const uint32_t hid_id;
} apple_key_name_map[] = {
{ "left", KEY_Left }, { "right", KEY_Right },
{ "up", KEY_Up }, { "down", KEY_Down },
{ "enter", KEY_Enter }, { "kp_enter", KP_Enter },
{ "space", KEY_Space }, { "tab", KEY_Tab },
{ "shift", KEY_LeftShift }, { "rshift", KEY_RightShift },
{ "ctrl", KEY_LeftControl }, { "alt", KEY_LeftAlt },
{ "escape", KEY_Escape }, { "backspace", KEY_DeleteForward },
{ "backquote", KEY_Grave }, { "pause", KEY_Pause },
{ "f1", KEY_F1 }, { "f2", KEY_F2 },
{ "f3", KEY_F3 }, { "f4", KEY_F4 },
{ "f5", KEY_F5 }, { "f6", KEY_F6 },
{ "f7", KEY_F7 }, { "f8", KEY_F8 },
{ "f9", KEY_F9 }, { "f10", KEY_F10 },
{ "f11", KEY_F11 }, { "f12", KEY_F12 },
{ "num0", KEY_0 }, { "num1", KEY_1 },
{ "num2", KEY_2 }, { "num3", KEY_3 },
{ "num4", KEY_4 }, { "num5", KEY_5 },
{ "num6", KEY_6 }, { "num7", KEY_7 },
{ "num8", KEY_8 }, { "num9", KEY_9 },
{ "insert", KEY_Insert }, { "del", KEY_DeleteForward },
{ "home", KEY_Home }, { "end", KEY_End },
{ "pageup", KEY_PageUp }, { "pagedown", KEY_PageDown },
{ "add", KP_Add }, { "subtract", KP_Subtract },
{ "multiply", KP_Multiply }, { "divide", KP_Divide },
{ "keypad0", KP_0 }, { "keypad1", KP_1 },
{ "keypad2", KP_2 }, { "keypad3", KP_3 },
{ "keypad4", KP_4 }, { "keypad5", KP_5 },
{ "keypad6", KP_6 }, { "keypad7", KP_7 },
{ "keypad8", KP_8 }, { "keypad9", KP_9 },
{ "period", KEY_Period }, { "capslock", KEY_CapsLock },
{ "numlock", KP_NumLock }, { "print_screen", KEY_PrintScreen },
{ "scroll_lock", KEY_ScrollLock },
{ "a", KEY_A }, { "b", KEY_B }, { "c", KEY_C }, { "d", KEY_D },
{ "e", KEY_E }, { "f", KEY_F }, { "g", KEY_G }, { "h", KEY_H },
{ "i", KEY_I }, { "j", KEY_J }, { "k", KEY_K }, { "l", KEY_L },
{ "m", KEY_M }, { "n", KEY_N }, { "o", KEY_O }, { "p", KEY_P },
{ "q", KEY_Q }, { "r", KEY_R }, { "s", KEY_S }, { "t", KEY_T },
{ "u", KEY_U }, { "v", KEY_V }, { "w", KEY_W }, { "x", KEY_X },
{ "y", KEY_Y }, { "z", KEY_Z },
{ "nul", 0x00},
};
#endif

View File

@ -12,6 +12,7 @@
962EE0E2178B3DF6004224FF /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 962EE0E1178B3DF6004224FF /* IOKit.framework */; };
96355CE31788E72A0010DBFA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96355CE21788E72A0010DBFA /* Cocoa.framework */; };
9646869817BBC14E00C5EA69 /* platform.m in Sources */ = {isa = PBXBuildFile; fileRef = 9646869617BBC14E00C5EA69 /* platform.m */; };
965A44C817CC114D0086F78F /* InputBinder.xib in Resources */ = {isa = PBXBuildFile; fileRef = 965A44C717CC114D0086F78F /* InputBinder.xib */; };
967894931788ECDB00D6CA69 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9678948F1788ECDB00D6CA69 /* InfoPlist.strings */; };
967894941788ECDB00D6CA69 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 967894911788ECDB00D6CA69 /* MainMenu.xib */; };
967894961788ED1100D6CA69 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 967894951788ED1100D6CA69 /* main.m */; };
@ -38,6 +39,7 @@
96355CE71788E72A0010DBFA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
9646869617BBC14E00C5EA69 /* platform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = platform.m; path = OSX/platform.m; sourceTree = SOURCE_ROOT; };
9646869717BBC14E00C5EA69 /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = platform.h; path = OSX/platform.h; sourceTree = SOURCE_ROOT; };
965A44C717CC114D0086F78F /* InputBinder.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = InputBinder.xib; path = OSX/InputBinder.xib; sourceTree = "<group>"; };
9678948D1788ECCA00D6CA69 /* RetroArch-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "RetroArch-Info.plist"; path = "OSX/RetroArch-Info.plist"; sourceTree = SOURCE_ROOT; };
967894901788ECDB00D6CA69 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = OSX/en.lproj/InfoPlist.strings; sourceTree = SOURCE_ROOT; };
967894921788ECDB00D6CA69 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = OSX/en.lproj/MainMenu.xib; sourceTree = SOURCE_ROOT; };
@ -144,6 +146,7 @@
967894911788ECDB00D6CA69 /* MainMenu.xib */,
C15874EE178F2094001171D4 /* RetroArch.icns */,
9620F6641790004F001B3B81 /* Settings.xib */,
965A44C717CC114D0086F78F /* InputBinder.xib */,
);
name = Assets;
sourceTree = "<group>";
@ -203,6 +206,7 @@
967894E9178A2EB400D6CA69 /* modules in Resources */,
C15874EF178F2094001171D4 /* RetroArch.icns in Resources */,
9620F6651790004F001B3B81 /* Settings.xib in Resources */,
965A44C817CC114D0086F78F /* InputBinder.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};