mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-14 14:28:47 +00:00
ios: Add a simple input driver draft; tracks only one touch for now.
This commit is contained in:
parent
1d727e50e7
commit
7e4e028fc8
@ -72,6 +72,7 @@ enum
|
||||
INPUT_WII,
|
||||
INPUT_XINPUT,
|
||||
INPUT_LINUXRAW,
|
||||
INPUT_IOS,
|
||||
INPUT_NULL
|
||||
};
|
||||
|
||||
@ -157,6 +158,8 @@ enum
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_WII
|
||||
#elif defined(HAVE_XVIDEO)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_X
|
||||
#elif defined(IOS)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_IOS
|
||||
#else
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_NULL
|
||||
#endif
|
||||
|
3
driver.c
3
driver.c
@ -150,6 +150,9 @@ static const input_driver_t *input_drivers[] = {
|
||||
#if defined(__linux__) && !defined(ANDROID)
|
||||
&input_linuxraw,
|
||||
#endif
|
||||
#ifdef IOS
|
||||
&input_ios,
|
||||
#endif
|
||||
#ifdef HAVE_NULLINPUT
|
||||
&input_null,
|
||||
#endif
|
||||
|
1
driver.h
1
driver.h
@ -373,6 +373,7 @@ extern const input_driver_t input_xenon360;
|
||||
extern const input_driver_t input_gx;
|
||||
extern const input_driver_t input_xinput;
|
||||
extern const input_driver_t input_linuxraw;
|
||||
extern const input_driver_t input_ios;
|
||||
extern const input_driver_t input_null;
|
||||
|
||||
#include "driver_funcs.h"
|
||||
|
@ -72,6 +72,7 @@
|
||||
96AFAFDD16C2149A009DE44C /* ioseagl_ctx.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFDC16C2149A009DE44C /* ioseagl_ctx.m */; };
|
||||
96CF014F16C2BB9E00ABF9C9 /* libretro.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 96CF014A16C2BA1900ABF9C9 /* libretro.dylib */; };
|
||||
96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCE16C1FBC0009DE44C /* overlay.c */; };
|
||||
96CF015C16C2F72900ABF9C9 /* ios_input.c in Sources */ = {isa = PBXBuildFile; fileRef = 96CF015B16C2F72900ABF9C9 /* ios_input.c */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -263,6 +264,7 @@
|
||||
96AFAFD216C1FBC0009DE44C /* x11_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = x11_input.c; sourceTree = "<group>"; };
|
||||
96AFAFDC16C2149A009DE44C /* ioseagl_ctx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ioseagl_ctx.m; sourceTree = "<group>"; };
|
||||
96CF014A16C2BA1900ABF9C9 /* libretro.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libretro.dylib; sourceTree = "<group>"; };
|
||||
96CF015B16C2F72900ABF9C9 /* ios_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_input.c; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -326,6 +328,7 @@
|
||||
96AFAE4C16C1D4EA009DE44C /* ViewController_iPhone.xib */,
|
||||
96AFAE4F16C1D4EA009DE44C /* ViewController_iPad.xib */,
|
||||
96AFAE3416C1D4EA009DE44C /* Supporting Files */,
|
||||
96CF015B16C2F72900ABF9C9 /* ios_input.c */,
|
||||
);
|
||||
path = RetroArch;
|
||||
sourceTree = "<group>";
|
||||
@ -769,6 +772,7 @@
|
||||
96AFAFD716C1FBC0009DE44C /* null.c in Sources */,
|
||||
96AFAFDD16C2149A009DE44C /* ioseagl_ctx.m in Sources */,
|
||||
96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */,
|
||||
96CF015C16C2F72900ABF9C9 /* ios_input.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -920,7 +924,6 @@
|
||||
"-DRARCH_PERFORMANCE_MODE",
|
||||
"-DPACKAGE_VERSION=\\\"1.0\\\"",
|
||||
"-DHAVE_AL",
|
||||
"-DHAVE_NULLINPUT",
|
||||
"-DHAVE_DYNAMIC",
|
||||
"-DHAVE_OVERLAY",
|
||||
"-DHAVE_ZLIB",
|
||||
@ -958,7 +961,6 @@
|
||||
"-DRARCH_PERFORMANCE_MODE",
|
||||
"-DPACKAGE_VERSION=\\\"1.0\\\"",
|
||||
"-DHAVE_AL",
|
||||
"-DHAVE_NULLINPUT",
|
||||
"-DHAVE_DYNAMIC",
|
||||
"-DHAVE_OVERLAY",
|
||||
"-DHAVE_ZLIB",
|
||||
|
@ -11,6 +11,13 @@
|
||||
|
||||
#include "general.h"
|
||||
|
||||
|
||||
extern bool IOS_is_down;
|
||||
extern int16_t IOS_touch_x, IOS_fix_x;
|
||||
extern int16_t IOS_touch_y, IOS_fix_y;
|
||||
extern int16_t IOS_full_x, IOS_full_y;
|
||||
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (const char*)generate_config
|
||||
@ -70,6 +77,36 @@
|
||||
[self performSelector:@selector(runMain:) withObject:nil afterDelay:0.2f];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
UITouch *touch = [[event allTouches] anyObject];
|
||||
CGPoint coord = [touch locationInView:self.viewController.view];
|
||||
|
||||
IOS_is_down = true;
|
||||
IOS_touch_x = coord.x;
|
||||
IOS_touch_y = coord.y;
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
UITouch *touch = [[event allTouches] anyObject];
|
||||
CGPoint coord = [touch locationInView:self.viewController.view];
|
||||
|
||||
IOS_is_down = true;
|
||||
IOS_touch_x = coord.x;
|
||||
IOS_touch_y = coord.y;
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
IOS_is_down = false;
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
IOS_is_down = false;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
@ -98,3 +135,4 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
83
ios/RetroArch/ios_input.c
Normal file
83
ios/RetroArch/ios_input.c
Normal file
@ -0,0 +1,83 @@
|
||||
// Input Driver Below
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "../../input/input_common.h"
|
||||
#include "../../performance.h"
|
||||
#include "../../general.h"
|
||||
#include "../../driver.h"
|
||||
|
||||
#define MAX_TOUCH 16
|
||||
|
||||
bool IOS_is_down;
|
||||
int16_t IOS_touch_x, IOS_fix_x;
|
||||
int16_t IOS_touch_y, IOS_fix_y;
|
||||
int16_t IOS_full_x, IOS_full_y;
|
||||
|
||||
static void *ios_input_init(void)
|
||||
{
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
static void ios_input_poll(void *data)
|
||||
{
|
||||
input_translate_coord_viewport(IOS_touch_x, IOS_touch_y,
|
||||
&IOS_fix_x, &IOS_fix_y,
|
||||
&IOS_full_x, &IOS_full_y);
|
||||
}
|
||||
|
||||
static int16_t ios_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
if (index != 0) return 0;
|
||||
switch (device)
|
||||
{
|
||||
case RARCH_DEVICE_POINTER_SCREEN:
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_POINTER_X:
|
||||
return IOS_full_x;
|
||||
case RETRO_DEVICE_ID_POINTER_Y:
|
||||
return IOS_full_y;
|
||||
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
||||
return IOS_is_down;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static bool ios_input_key_pressed(void *data, int key)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ios_input_free_input(void *data)
|
||||
{
|
||||
(void)data;
|
||||
}
|
||||
|
||||
const input_driver_t input_ios = {
|
||||
ios_input_init,
|
||||
ios_input_poll,
|
||||
ios_input_state,
|
||||
ios_input_key_pressed,
|
||||
ios_input_free_input,
|
||||
"ios_input",
|
||||
};
|
||||
|
@ -130,6 +130,8 @@ const char *config_get_default_input(void)
|
||||
return "gx";
|
||||
case INPUT_LINUXRAW:
|
||||
return "linuxraw";
|
||||
case INPUT_IOS:
|
||||
return "ios_input";
|
||||
case INPUT_NULL:
|
||||
return "null";
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user