(iOS, ObjC removal) Remove the RAInputResponder class, sendEvent in main.m now maintains and exports arrays of pressed keys and touches.
This commit is contained in:
parent
6cbe1bcb57
commit
a012045a2e
|
@ -20,9 +20,7 @@
|
|||
963F5AC216CC522F009BBD19 /* RASettingsSubList.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5ABE16CC522F009BBD19 /* RASettingsSubList.m */; };
|
||||
963F5AC316CC522F009BBD19 /* RASettingsList.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5ABF16CC522F009BBD19 /* RASettingsList.m */; };
|
||||
963F5AC816CC523B009BBD19 /* RAGameView.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5AC516CC523B009BBD19 /* RAGameView.m */; };
|
||||
966B9C8A16E40D44005B61E1 /* ios_input.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C8616E40D44005B61E1 /* ios_input.m */; };
|
||||
966B9C8B16E40D44005B61E1 /* ios_joypad.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C8716E40D44005B61E1 /* ios_joypad.m */; };
|
||||
966B9C8C16E40D44005B61E1 /* RAInputResponder.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C8916E40D44005B61E1 /* RAInputResponder.m */; };
|
||||
966B9CA216E418B7005B61E1 /* BTDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C9116E418B7005B61E1 /* BTDevice.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
966B9CA416E418B7005B61E1 /* BTstackManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C9C16E418B7005B61E1 /* BTstackManager.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
966B9CA616E418B7005B61E1 /* wiimote.c in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C9E16E418B7005B61E1 /* wiimote.c */; };
|
||||
|
@ -48,6 +46,7 @@
|
|||
96AFAE3816C1D4EA009DE44C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96AFAE3616C1D4EA009DE44C /* InfoPlist.strings */; };
|
||||
96C19C3016D7045700FE8D5A /* RAConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 96C19C2F16D7045700FE8D5A /* RAConfig.m */; };
|
||||
96F9C26A16F7D9E2002455B3 /* btdynamic.c in Sources */ = {isa = PBXBuildFile; fileRef = 96F9C26816F7D9E2002455B3 /* btdynamic.c */; };
|
||||
96F9C26F16F91A64002455B3 /* ios_input.c in Sources */ = {isa = PBXBuildFile; fileRef = 96F9C26E16F91A64002455B3 /* ios_input.c */; };
|
||||
D48581DE16F823F9004BEB17 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = D48581DD16F823F9004BEB17 /* griffin.c */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -70,10 +69,7 @@
|
|||
963F5ABF16CC522F009BBD19 /* RASettingsList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RASettingsList.m; sourceTree = "<group>"; };
|
||||
963F5AC516CC523B009BBD19 /* RAGameView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAGameView.m; sourceTree = "<group>"; };
|
||||
9664F4A116E4409100FB28F9 /* keycode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keycode.h; sourceTree = "<group>"; };
|
||||
966B9C8616E40D44005B61E1 /* ios_input.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ios_input.m; sourceTree = "<group>"; };
|
||||
966B9C8716E40D44005B61E1 /* ios_joypad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ios_joypad.m; sourceTree = "<group>"; };
|
||||
966B9C8816E40D44005B61E1 /* RAInputResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAInputResponder.h; sourceTree = "<group>"; };
|
||||
966B9C8916E40D44005B61E1 /* RAInputResponder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAInputResponder.m; sourceTree = "<group>"; };
|
||||
966B9C9016E418B7005B61E1 /* BTDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTDevice.h; sourceTree = "<group>"; };
|
||||
966B9C9116E418B7005B61E1 /* BTDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BTDevice.m; sourceTree = "<group>"; };
|
||||
966B9C9516E418B7005B61E1 /* btstack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btstack.h; sourceTree = "<group>"; };
|
||||
|
@ -120,6 +116,8 @@
|
|||
96C19C2F16D7045700FE8D5A /* RAConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAConfig.m; sourceTree = "<group>"; };
|
||||
96F9C26816F7D9E2002455B3 /* btdynamic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = btdynamic.c; sourceTree = "<group>"; };
|
||||
96F9C26916F7D9E2002455B3 /* btdynamic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btdynamic.h; sourceTree = "<group>"; };
|
||||
96F9C26B16F919CC002455B3 /* ios_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ios_input.h; sourceTree = "<group>"; };
|
||||
96F9C26E16F91A64002455B3 /* ios_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_input.c; sourceTree = "<group>"; };
|
||||
D48581DD16F823F9004BEB17 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../griffin/griffin.c; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
|
@ -157,11 +155,10 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
966B9C8F16E418B7005B61E1 /* BTStack */,
|
||||
966B9C8616E40D44005B61E1 /* ios_input.m */,
|
||||
96F9C26E16F91A64002455B3 /* ios_input.c */,
|
||||
96F9C26B16F919CC002455B3 /* ios_input.h */,
|
||||
966B9C8716E40D44005B61E1 /* ios_joypad.m */,
|
||||
9664F4A116E4409100FB28F9 /* keycode.h */,
|
||||
966B9C8816E40D44005B61E1 /* RAInputResponder.h */,
|
||||
966B9C8916E40D44005B61E1 /* RAInputResponder.m */,
|
||||
);
|
||||
path = input;
|
||||
sourceTree = "<group>";
|
||||
|
@ -422,9 +419,7 @@
|
|||
963F5AC816CC523B009BBD19 /* RAGameView.m in Sources */,
|
||||
96096DD816D1ABAF00BF4499 /* RAModuleInfoList.m in Sources */,
|
||||
96C19C3016D7045700FE8D5A /* RAConfig.m in Sources */,
|
||||
966B9C8A16E40D44005B61E1 /* ios_input.m in Sources */,
|
||||
966B9C8B16E40D44005B61E1 /* ios_joypad.m in Sources */,
|
||||
966B9C8C16E40D44005B61E1 /* RAInputResponder.m in Sources */,
|
||||
966B9CA216E418B7005B61E1 /* BTDevice.m in Sources */,
|
||||
966B9CA416E418B7005B61E1 /* BTstackManager.m in Sources */,
|
||||
966B9CA616E418B7005B61E1 /* wiimote.c in Sources */,
|
||||
|
@ -435,6 +430,7 @@
|
|||
966B9CB416E41C07005B61E1 /* RAModuleList.m in Sources */,
|
||||
96F9C26A16F7D9E2002455B3 /* btdynamic.c in Sources */,
|
||||
D48581DE16F823F9004BEB17 /* griffin.c in Sources */,
|
||||
96F9C26F16F91A64002455B3 /* ios_input.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2013 - Jason Fetters
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "RAInputResponder.h"
|
||||
#include "input/input_common.h"
|
||||
|
||||
extern NSString* const GSEventKeyDownNotification;
|
||||
extern NSString* const GSEventKeyUpNotification;
|
||||
|
||||
static RAInputResponder* g_inputInstance;
|
||||
|
||||
@implementation RAInputResponder
|
||||
{
|
||||
unsigned _touchCount;
|
||||
touch_data_t _touches[MAX_TOUCHES];
|
||||
bool _keys[MAX_KEYS];
|
||||
}
|
||||
|
||||
+ (RAInputResponder*)sharedInstance
|
||||
{
|
||||
if (!g_inputInstance)
|
||||
g_inputInstance = [RAInputResponder new];
|
||||
|
||||
return g_inputInstance;
|
||||
}
|
||||
|
||||
-(id)init
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyPressed:) name: GSEventKeyDownNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyReleased:) name: GSEventKeyUpNotification object:nil];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)reset
|
||||
{
|
||||
_touchCount = 0;
|
||||
memset(_touches, 0, sizeof(_touches));
|
||||
memset(_keys, 0, sizeof(_keys));
|
||||
}
|
||||
|
||||
- (void)poll
|
||||
{
|
||||
for (int i = 0; i != _touchCount; i ++)
|
||||
{
|
||||
input_translate_coord_viewport(_touches[i].screen_x, _touches[i].screen_y,
|
||||
&_touches[i].fixed_x, &_touches[i].fixed_y,
|
||||
&_touches[i].full_x, &_touches[i].full_y);
|
||||
}
|
||||
}
|
||||
|
||||
- (bool)isKeyPressed:(unsigned)index
|
||||
{
|
||||
return (index < MAX_KEYS) ? _keys[index] : NO;
|
||||
}
|
||||
|
||||
- (const touch_data_t*)getTouchDataAtIndex:(unsigned)index
|
||||
{
|
||||
return (index < _touchCount) ? &_touches[index] : 0;
|
||||
}
|
||||
|
||||
// Response handlers
|
||||
- (void)keyPressed:(NSNotification*)notification
|
||||
{
|
||||
int keycode = [[notification.userInfo objectForKey:@"keycode"] intValue];
|
||||
if (keycode < MAX_KEYS) _keys[keycode] = true;
|
||||
}
|
||||
|
||||
- (void)keyReleased:(NSNotification*)notification
|
||||
{
|
||||
int keycode = [[notification.userInfo objectForKey:@"keycode"] intValue];
|
||||
if (keycode < MAX_KEYS) _keys[keycode] = false;
|
||||
}
|
||||
|
||||
- (void)handleTouches:(NSArray*)touches
|
||||
{
|
||||
const int numTouches = [touches count];
|
||||
|
||||
_touchCount = 0;
|
||||
|
||||
for(int i = 0; i != numTouches && _touchCount != MAX_TOUCHES; i ++)
|
||||
{
|
||||
UITouch *touch = [touches objectAtIndex:i];
|
||||
CGPoint coord = [touch locationInView:touch.view];
|
||||
float scale = [[UIScreen mainScreen] scale];
|
||||
|
||||
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
|
||||
{
|
||||
_touches[_touchCount ].screen_x = coord.x * scale;
|
||||
_touches[_touchCount ++].screen_y = coord.y * scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
|
@ -13,10 +13,9 @@
|
|||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#import "RAInputResponder.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include "input/input_common.h"
|
||||
#include "ios_input.h"
|
||||
#include "general.h"
|
||||
#include "driver.h"
|
||||
|
||||
|
@ -25,13 +24,11 @@ static const rarch_joypad_driver_t* const g_joydriver = &ios_joypad;
|
|||
|
||||
static const struct rarch_key_map rarch_key_map_hidusage[];
|
||||
|
||||
static RAInputResponder* g_input_driver;
|
||||
|
||||
// Non-exported helpers
|
||||
static bool ios_key_pressed(enum retro_key key)
|
||||
{
|
||||
if ((int)key >= 0 && key < RETROK_LAST)
|
||||
return [g_input_driver isKeyPressed:input_translate_rk_to_keysym(key)];
|
||||
return ios_key_list[input_translate_rk_to_keysym(key)];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -44,16 +41,19 @@ static bool ios_is_pressed(unsigned port_num, const struct retro_keybind *key)
|
|||
// Exported input driver
|
||||
static void *ios_input_init(void)
|
||||
{
|
||||
g_input_driver = [RAInputResponder sharedInstance];
|
||||
[g_input_driver reset];
|
||||
|
||||
input_init_keyboard_lut(rarch_key_map_hidusage);
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
static void ios_input_poll(void *data)
|
||||
{
|
||||
[g_input_driver poll];
|
||||
for (int i = 0; i != ios_touch_count; i ++)
|
||||
{
|
||||
input_translate_coord_viewport(ios_touch_list[i].screen_x, ios_touch_list[i].screen_y,
|
||||
&ios_touch_list[i].fixed_x, &ios_touch_list[i].fixed_y,
|
||||
&ios_touch_list[i].full_x, &ios_touch_list[i].full_y);
|
||||
}
|
||||
|
||||
input_joypad_poll(g_joydriver);
|
||||
}
|
||||
|
||||
|
@ -66,13 +66,16 @@ static int16_t ios_input_state(void *data, const struct retro_keybind **binds, u
|
|||
|
||||
case RARCH_DEVICE_POINTER_SCREEN:
|
||||
{
|
||||
const touch_data_t* touch = [g_input_driver getTouchDataAtIndex:index];
|
||||
|
||||
switch (id)
|
||||
if (index < ios_touch_count && index < MAX_TOUCHES)
|
||||
{
|
||||
case RETRO_DEVICE_ID_POINTER_X: return touch ? touch->full_x : 0;
|
||||
case RETRO_DEVICE_ID_POINTER_Y: return touch ? touch->full_y : 0;
|
||||
case RETRO_DEVICE_ID_POINTER_PRESSED: return touch ? 1 : 0;
|
||||
const touch_data_t* touch = &ios_touch_list[index];
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_POINTER_PRESSED: return 1;
|
||||
case RETRO_DEVICE_ID_POINTER_X: return touch->full_x;
|
||||
case RETRO_DEVICE_ID_POINTER_Y: return touch->full_y;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -92,7 +95,6 @@ static bool ios_bind_button_pressed(void *data, int key)
|
|||
static void ios_input_free_input(void *data)
|
||||
{
|
||||
(void)data;
|
||||
g_input_driver = nil;
|
||||
}
|
||||
|
||||
const input_driver_t input_ios = {
|
|
@ -24,14 +24,7 @@ typedef struct touch_data
|
|||
int16_t full_x, full_y;
|
||||
} touch_data_t;
|
||||
|
||||
@interface RAInputResponder : NSObject
|
||||
+ (RAInputResponder*)sharedInstance;
|
||||
|
||||
- (void)reset;
|
||||
|
||||
- (void)handleTouches:(NSArray*)touches;
|
||||
|
||||
- (void)poll;
|
||||
- (bool)isKeyPressed:(unsigned)index;
|
||||
- (const touch_data_t*)getTouchDataAtIndex:(unsigned)index;
|
||||
@end
|
||||
// Defined in main.m, lists are filled by the sendEvent selector
|
||||
extern uint32_t ios_key_list[MAX_KEYS];
|
||||
extern uint32_t ios_touch_count;
|
||||
extern touch_data_t ios_touch_list[MAX_TOUCHES];
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#include "input/RAInputResponder.h"
|
||||
#include "input/ios_input.h"
|
||||
|
||||
#define GSEVENT_TYPE 2
|
||||
#define GSEVENT_FLAGS 12
|
||||
|
@ -22,30 +22,38 @@
|
|||
#define GSEVENT_TYPE_KEYDOWN 10
|
||||
#define GSEVENT_TYPE_KEYUP 11
|
||||
|
||||
NSString *const GSEventKeyDownNotification = @"GSEventKeyDownHackNotification";
|
||||
NSString *const GSEventKeyUpNotification = @"GSEventKeyUpHackNotification";
|
||||
|
||||
static RAInputResponder* inputResponder;
|
||||
uint32_t ios_key_list[MAX_KEYS];
|
||||
uint32_t ios_touch_count;
|
||||
touch_data_t ios_touch_list[MAX_TOUCHES];
|
||||
|
||||
@interface RApplication : UIApplication
|
||||
@end
|
||||
|
||||
@implementation RApplication
|
||||
|
||||
- (RApplication*)init
|
||||
{
|
||||
self = [super init];
|
||||
inputResponder = [RAInputResponder sharedInstance];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)sendEvent:(UIEvent *)event
|
||||
{
|
||||
[super sendEvent:event];
|
||||
|
||||
if ([[event allTouches] count])
|
||||
{
|
||||
[inputResponder handleTouches:[[event allTouches] allObjects]];
|
||||
NSArray* touches = [[event allTouches] allObjects];
|
||||
const int numTouches = [touches count];
|
||||
const float scale = [[UIScreen mainScreen] scale];
|
||||
|
||||
ios_touch_count = 0;
|
||||
|
||||
for(int i = 0; i != numTouches && ios_touch_count < MAX_TOUCHES; i ++)
|
||||
{
|
||||
UITouch* touch = [touches objectAtIndex:i];
|
||||
const CGPoint coord = [touch locationInView:touch.view];
|
||||
|
||||
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
|
||||
{
|
||||
ios_touch_list[ios_touch_count ].screen_x = coord.x * scale;
|
||||
ios_touch_list[ios_touch_count ++].screen_y = coord.y * scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html
|
||||
else if ([event respondsToSelector:@selector(_gsEvent)])
|
||||
|
@ -58,15 +66,9 @@ static RAInputResponder* inputResponder;
|
|||
// Read keycode from GSEventKey
|
||||
int tmp = eventMem[GSEVENTKEY_KEYCODE];
|
||||
UniChar *keycode = (UniChar *)&tmp;
|
||||
|
||||
// Post notification
|
||||
NSDictionary *inf = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSNumber numberWithShort:keycode[0]], @"keycode",
|
||||
nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:(eventType == GSEVENT_TYPE_KEYDOWN) ? GSEventKeyDownNotification : GSEventKeyUpNotification
|
||||
object:nil userInfo:inf];
|
||||
|
||||
if (keycode[0] < MAX_KEYS)
|
||||
ios_key_list[keycode[0]] = (eventType == GSEVENT_TYPE_KEYDOWN) ? 1 : 0;
|
||||
}
|
||||
|
||||
CFBridgingRelease(eventMem);
|
||||
|
|
|
@ -14,12 +14,11 @@
|
|||
*/
|
||||
|
||||
#import "settings.h"
|
||||
#include "../input/ios_input.h"
|
||||
#include "../input/keycode.h"
|
||||
#include "../input/BTStack/wiimote.h"
|
||||
#include "../input/BTStack/WiiMoteHelper.h"
|
||||
|
||||
extern NSString* const GSEventKeyUpNotification;
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char* const keyname;
|
||||
|
@ -74,15 +73,6 @@ static const struct
|
|||
{ "nul", 0x00},
|
||||
};
|
||||
|
||||
static NSString* get_key_config_name(uint32_t hid_id)
|
||||
{
|
||||
for (int i = 0; ios_key_name_map[i].hid_id; i ++)
|
||||
if (hid_id == ios_key_name_map[i].hid_id)
|
||||
return [NSString stringWithUTF8String:ios_key_name_map[i].keyname];
|
||||
|
||||
return @"nul";
|
||||
}
|
||||
|
||||
@implementation RAButtonGetter
|
||||
{
|
||||
RAButtonGetter* _me;
|
||||
|
@ -102,17 +92,13 @@ static NSString* get_key_config_name(uint32_t hid_id)
|
|||
_me = self;
|
||||
|
||||
_alert = [[UIAlertView alloc] initWithTitle:@"RetroArch"
|
||||
message:_value.label
|
||||
delegate:self
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:nil];
|
||||
message:_value.label
|
||||
delegate:self
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:nil];
|
||||
[_alert show];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(keyReleased:) name: GSEventKeyUpNotification object: nil];
|
||||
|
||||
if ([WiiMoteHelper haveBluetooth])
|
||||
_btTimer = [NSTimer scheduledTimerWithTimeInterval:.05f target:self selector:@selector(checkWiiMote) userInfo:nil repeats:YES];
|
||||
|
||||
_btTimer = [NSTimer scheduledTimerWithTimeInterval:.05f target:self selector:@selector(checkInput) userInfo:nil repeats:YES];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -122,13 +108,8 @@ static NSString* get_key_config_name(uint32_t hid_id)
|
|||
{
|
||||
_finished = true;
|
||||
|
||||
if (_btTimer)
|
||||
{
|
||||
[_btTimer invalidate];
|
||||
_btTimer = nil;
|
||||
}
|
||||
[_btTimer invalidate];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[_alert dismissWithClickedButtonIndex:0 animated:YES];
|
||||
[_view reloadData];
|
||||
|
||||
|
@ -141,8 +122,20 @@ static NSString* get_key_config_name(uint32_t hid_id)
|
|||
[self finish];
|
||||
}
|
||||
|
||||
- (void)checkWiiMote
|
||||
- (void)checkInput
|
||||
{
|
||||
// Keyboard
|
||||
for (int i = 0; ios_key_name_map[i].hid_id; i ++)
|
||||
{
|
||||
if (ios_key_list[ios_key_name_map[i].hid_id])
|
||||
{
|
||||
_value.msubValues[0] = [NSString stringWithUTF8String:ios_key_name_map[i].keyname];
|
||||
[self finish];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// WiiMote
|
||||
for (int i = 0; i != myosd_num_of_joys; i ++)
|
||||
{
|
||||
uint32_t buttons = joys[i].btns;
|
||||
|
@ -160,13 +153,5 @@ static NSString* get_key_config_name(uint32_t hid_id)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)keyReleased:(NSNotification*) notification
|
||||
{
|
||||
int keycode = [[notification.userInfo objectForKey:@"keycode"] intValue];
|
||||
_value.msubValues[0] = get_key_config_name(keycode);
|
||||
|
||||
[self finish];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in New Issue