Commit 99b869fe authored by Sam Lantinga's avatar Sam Lantinga

Updated iPhone keyboard code (which builds and runs on the iPad and iPhone simulator now)

Updated iPhone demos (which build and run again)
parent 2c5a878c
...@@ -105,6 +105,13 @@ ...@@ -105,6 +105,13 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
04AB757011E563D200BE9753 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */;
remoteInfo = testsdl;
};
FD1B489D0E313154007AB34E /* PBXContainerItemProxy */ = { FD1B489D0E313154007AB34E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */; containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */;
...@@ -318,6 +325,7 @@ ...@@ -318,6 +325,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */, FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */,
04AB757111E563D200BE9753 /* testsdl.app */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -523,6 +531,13 @@ ...@@ -523,6 +531,13 @@
/* End PBXProject section */ /* End PBXProject section */
/* Begin PBXReferenceProxy section */ /* Begin PBXReferenceProxy section */
04AB757111E563D200BE9753 /* testsdl.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = testsdl.app;
remoteRef = 04AB757011E563D200BE9753 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */ = { FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */ = {
isa = PBXReferenceProxy; isa = PBXReferenceProxy;
fileType = archive.ar; fileType = archive.ar;
...@@ -731,7 +746,7 @@ ...@@ -731,7 +746,7 @@
OTHER_CFLAGS = ""; OTHER_CFLAGS = "";
PREBINDING = NO; PREBINDING = NO;
PRELINK_LIBS = ""; PRELINK_LIBS = "";
SDKROOT = iphoneos2.0; SDKROOT = iphoneos3.2;
}; };
name = Debug; name = Debug;
}; };
...@@ -749,7 +764,7 @@ ...@@ -749,7 +764,7 @@
OTHER_CFLAGS = ""; OTHER_CFLAGS = "";
PREBINDING = NO; PREBINDING = NO;
PRELINK_LIBS = ""; PRELINK_LIBS = "";
SDKROOT = iphoneos2.0; SDKROOT = iphoneos3.2;
}; };
name = Release; name = Release;
}; };
......
...@@ -430,9 +430,7 @@ main(int argc, char *argv[]) ...@@ -430,9 +430,7 @@ main(int argc, char *argv[])
done = 1; done = 1;
} }
if (event.type == SDL_MOUSEBUTTONDOWN) { if (event.type == SDL_MOUSEBUTTONDOWN) {
int which = event.button.which;
int x, y; int x, y;
SDL_SelectMouse(which);
SDL_GetMouseState(&x, &y); SDL_GetMouseState(&x, &y);
spawnEmitterParticle(x, y); spawnEmitterParticle(x, y);
} }
......
...@@ -124,10 +124,9 @@ handleMouseButtonDown(SDL_Event * event) ...@@ -124,10 +124,9 @@ handleMouseButtonDown(SDL_Event * event)
int x, y, mouseIndex, i, drumIndex; int x, y, mouseIndex, i, drumIndex;
mouseIndex = event->button.which; mouseIndex = 0;
drumIndex = -1; drumIndex = -1;
SDL_SelectMouse(mouseIndex);
SDL_GetMouseState(&x, &y); SDL_GetMouseState(&x, &y);
/* check if we hit any of the drum buttons */ /* check if we hit any of the drum buttons */
for (i = 0; i < NUM_DRUMS; i++) { for (i = 0; i < NUM_DRUMS; i++) {
...@@ -153,7 +152,7 @@ void ...@@ -153,7 +152,7 @@ void
handleMouseButtonUp(SDL_Event * event) handleMouseButtonUp(SDL_Event * event)
{ {
int i; int i;
int mouseIndex = event->button.which; int mouseIndex = 0;
/* check if this should cause any of the buttons to become unpressed */ /* check if this should cause any of the buttons to become unpressed */
for (i = 0; i < NUM_DRUMS; i++) { for (i = 0; i < NUM_DRUMS; i++) {
if (buttons[i].touchIndex == mouseIndex) { if (buttons[i].touchIndex == mouseIndex) {
......
...@@ -106,7 +106,6 @@ main(int argc, char *argv[]) ...@@ -106,7 +106,6 @@ main(int argc, char *argv[])
done = 1; done = 1;
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
SDL_SelectMouse(event.motion.which); /* select 'mouse' (touch) that moved */
state = SDL_GetMouseState(&x, &y); /* get its location */ state = SDL_GetMouseState(&x, &y); /* get its location */
SDL_GetRelativeMouseState(&dx, &dy); /* find how much the mouse moved */ SDL_GetRelativeMouseState(&dx, &dy); /* find how much the mouse moved */
if (state & SDL_BUTTON_LMASK) { /* is the mouse (touch) down? */ if (state & SDL_BUTTON_LMASK) { /* is the mouse (touch) down? */
......
...@@ -287,6 +287,13 @@ ...@@ -287,6 +287,13 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
0466EE6F11E565E4000198A4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */;
remoteInfo = testsdl;
};
FD1B48B70E3131CA007AB34E /* PBXContainerItemProxy */ = { FD1B48B70E3131CA007AB34E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */; containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */;
...@@ -298,9 +305,7 @@ ...@@ -298,9 +305,7 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
1D6058910D05DD3D006BFB54 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1D6058910D05DD3D006BFB54 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; };
56ED04F7118A8FCC00A56AA6 /* testpower-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "testpower-Info.plist"; sourceTree = "<group>"; };
56ED050D118A8FE400A56AA6 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; }; 56ED050D118A8FE400A56AA6 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; };
56ED050F118A8FE400A56AA6 /* Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info copy.plist"; sourceTree = "<group>"; };
56ED0510118A904200A56AA6 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testpower.c; path = ../../test/testpower.c; sourceTree = SOURCE_ROOT; }; 56ED0510118A904200A56AA6 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testpower.c; path = ../../test/testpower.c; sourceTree = SOURCE_ROOT; };
FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDLiPhoneOS.xcodeproj; path = ../SDL/SDLiPhoneOS.xcodeproj; sourceTree = SOURCE_ROOT; }; FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDLiPhoneOS.xcodeproj; path = ../SDL/SDLiPhoneOS.xcodeproj; sourceTree = SOURCE_ROOT; };
FDA8A7400E2D0F1600EA573E /* testalpha.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testalpha.c; path = ../../test/testalpha.c; sourceTree = SOURCE_ROOT; }; FDA8A7400E2D0F1600EA573E /* testalpha.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testalpha.c; path = ../../test/testalpha.c; sourceTree = SOURCE_ROOT; };
...@@ -861,14 +866,11 @@ ...@@ -861,14 +866,11 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
56ED0510118A904200A56AA6 /* testpower.c */,
FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */, FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */,
FDA8AAD60E2D339A00EA573E /* Resources */, FDA8AAD60E2D339A00EA573E /* Resources */,
FDA8A7C30E2D10FA00EA573E /* Linked Frameworks */, FDA8A7C30E2D10FA00EA573E /* Linked Frameworks */,
FDA8A73B0E2D0F0400EA573E /* src */, FDA8A73B0E2D0F0400EA573E /* src */,
19C28FACFE9D520D11CA2CBB /* Products */, 19C28FACFE9D520D11CA2CBB /* Products */,
56ED04F7118A8FCC00A56AA6 /* testpower-Info.plist */,
56ED050F118A8FE400A56AA6 /* Info copy.plist */,
); );
name = CustomTemplate; name = CustomTemplate;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -877,6 +879,7 @@ ...@@ -877,6 +879,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */, FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */,
0466EE7011E565E4000198A4 /* testsdl.app */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -910,6 +913,7 @@ ...@@ -910,6 +913,7 @@
FDA8A7540E2D0F1600EA573E /* testoverlay2.c */, FDA8A7540E2D0F1600EA573E /* testoverlay2.c */,
FDA8A7550E2D0F1600EA573E /* testpalette.c */, FDA8A7550E2D0F1600EA573E /* testpalette.c */,
FDA8A7560E2D0F1600EA573E /* testplatform.c */, FDA8A7560E2D0F1600EA573E /* testplatform.c */,
56ED0510118A904200A56AA6 /* testpower.c */,
FDA8A7570E2D0F1600EA573E /* testsem.c */, FDA8A7570E2D0F1600EA573E /* testsem.c */,
FDA8A7580E2D0F1600EA573E /* testsprite.c */, FDA8A7580E2D0F1600EA573E /* testsprite.c */,
FDA8A7590E2D0F1600EA573E /* testsprite2.c */, FDA8A7590E2D0F1600EA573E /* testsprite2.c */,
...@@ -1502,6 +1506,13 @@ ...@@ -1502,6 +1506,13 @@
/* End PBXProject section */ /* End PBXProject section */
/* Begin PBXReferenceProxy section */ /* Begin PBXReferenceProxy section */
0466EE7011E565E4000198A4 /* testsdl.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = testsdl.app;
remoteRef = 0466EE6F11E565E4000198A4 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */ = { FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */ = {
isa = PBXReferenceProxy; isa = PBXReferenceProxy;
fileType = archive.ar; fileType = archive.ar;
...@@ -2034,7 +2045,7 @@ ...@@ -2034,7 +2045,7 @@
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO; PREBINDING = NO;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos2.2.1; SDKROOT = iphoneos3.2;
}; };
name = Debug; name = Debug;
}; };
...@@ -2049,7 +2060,7 @@ ...@@ -2049,7 +2060,7 @@
HEADER_SEARCH_PATHS = ../../include; HEADER_SEARCH_PATHS = ../../include;
PREBINDING = NO; PREBINDING = NO;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos2.2.1; SDKROOT = iphoneos3.2;
}; };
name = Release; name = Release;
}; };
......
...@@ -145,12 +145,9 @@ typedef unsigned long uintptr_t; ...@@ -145,12 +145,9 @@ typedef unsigned long uintptr_t;
#define SDL_POWER_UIKIT 1 #define SDL_POWER_UIKIT 1
/* enable iPhone keyboard support */ /* enable iPhone keyboard support */
#define SDL_IPHONE_KEYBOARD 0 #define SDL_IPHONE_KEYBOARD 1
/* Enable emulation of multiple mice through multi-touch */ /* Set max recognized G-force from accelerometer
#define SDL_IPHONE_MULTIPLE_MICE 1
/* Set max recognized G-force from acceleromter
See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed
*/ */
#define SDL_IPHONE_MAX_GFORCE 5.0 #define SDL_IPHONE_MAX_GFORCE 5.0
......
...@@ -551,6 +551,10 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst) ...@@ -551,6 +551,10 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
int int
SDL_KeyboardInit(void) SDL_KeyboardInit(void)
{ {
SDL_Keyboard *keyboard = &SDL_keyboard;
/* Set the default keymap */
SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
return (0); return (0);
} }
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "SDL_uikitwindow.h" #include "SDL_uikitwindow.h"
#include "jumphack.h" #include "jumphack.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h"
#include "SDL_loadso.h" #include "SDL_loadso.h"
#include <dlfcn.h> #include <dlfcn.h>
...@@ -128,6 +130,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) ...@@ -128,6 +130,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
/* Make this window the current mouse focus for touch input */ /* Make this window the current mouse focus for touch input */
SDL_SetMouseFocus(window); SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
return view; return view;
} }
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_mouse.h"
#include "SDL_mouse_c.h"
#include "SDL_events.h" #include "SDL_events.h"
#if SDL_IPHONE_MULTIPLE_MICE #if SDL_IPHONE_MULTIPLE_MICE
......
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
#import "SDL_uikitview.h" #import "SDL_uikitview.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h"
#if SDL_IPHONE_KEYBOARD #if SDL_IPHONE_KEYBOARD
#import "SDL_keyboard_c.h"
#import "keyinfotable.h" #import "keyinfotable.h"
#import "SDL_uikitappdelegate.h" #import "SDL_uikitappdelegate.h"
#import "SDL_uikitwindow.h" #import "SDL_uikitwindow.h"
...@@ -33,7 +35,6 @@ ...@@ -33,7 +35,6 @@
- (void)dealloc { - (void)dealloc {
#if SDL_IPHONE_KEYBOARD #if SDL_IPHONE_KEYBOARD
SDL_DelKeyboard(0);
[textField release]; [textField release];
#endif #endif
[super dealloc]; [super dealloc];
...@@ -225,15 +226,6 @@ ...@@ -225,15 +226,6 @@
keyboardVisible = NO; keyboardVisible = NO;
/* add the UITextField (hidden) to our view */ /* add the UITextField (hidden) to our view */
[self addSubview: textField]; [self addSubview: textField];
/* create our SDL_Keyboard */
SDL_Keyboard keyboard;
SDL_zero(keyboard);
SDL_AddKeyboard(&keyboard, 0);
SDLKey keymap[SDL_NUM_SCANCODES];
SDL_GetDefaultKeymap(keymap);
SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
} }
/* reveal onscreen virtual keyboard */ /* reveal onscreen virtual keyboard */
...@@ -253,8 +245,8 @@ ...@@ -253,8 +245,8 @@
if ([string length] == 0) { if ([string length] == 0) {
/* it wants to replace text with nothing, ie a delete */ /* it wants to replace text with nothing, ie a delete */
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE); SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
} }
else { else {
/* go through all the characters in the string we've been sent /* go through all the characters in the string we've been sent
...@@ -280,14 +272,14 @@ ...@@ -280,14 +272,14 @@
if (mod & KMOD_SHIFT) { if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift down */ /* If character uses shift, press shift down */
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_LSHIFT); SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
} }
/* send a keydown and keyup even for the character */ /* send a keydown and keyup even for the character */
SDL_SendKeyboardKey( 0, SDL_PRESSED, code); SDL_SendKeyboardKey(SDL_PRESSED, code);
SDL_SendKeyboardKey( 0, SDL_RELEASED, code); SDL_SendKeyboardKey(SDL_RELEASED, code);
if (mod & KMOD_SHIFT) { if (mod & KMOD_SHIFT) {
/* If character uses shift, press shift back up */ /* If character uses shift, press shift back up */
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_LSHIFT); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment