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 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
04AB757011E563D200BE9753 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */;
remoteInfo = testsdl;
};
FD1B489D0E313154007AB34E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FD1B48920E313154007AB34E /* SDLiPhoneOS.xcodeproj */;
......@@ -318,6 +325,7 @@
isa = PBXGroup;
children = (
FD1B489E0E313154007AB34E /* libSDLiPhoneOS.a */,
04AB757111E563D200BE9753 /* testsdl.app */,
);
name = Products;
sourceTree = "<group>";
......@@ -523,6 +531,13 @@
/* End PBXProject 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 */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
......@@ -731,7 +746,7 @@
OTHER_CFLAGS = "";
PREBINDING = NO;
PRELINK_LIBS = "";
SDKROOT = iphoneos2.0;
SDKROOT = iphoneos3.2;
};
name = Debug;
};
......@@ -749,7 +764,7 @@
OTHER_CFLAGS = "";
PREBINDING = NO;
PRELINK_LIBS = "";
SDKROOT = iphoneos2.0;
SDKROOT = iphoneos3.2;
};
name = Release;
};
......
......@@ -430,9 +430,7 @@ main(int argc, char *argv[])
done = 1;
}
if (event.type == SDL_MOUSEBUTTONDOWN) {
int which = event.button.which;
int x, y;
SDL_SelectMouse(which);
SDL_GetMouseState(&x, &y);
spawnEmitterParticle(x, y);
}
......
......@@ -124,10 +124,9 @@ handleMouseButtonDown(SDL_Event * event)
int x, y, mouseIndex, i, drumIndex;
mouseIndex = event->button.which;
mouseIndex = 0;
drumIndex = -1;
SDL_SelectMouse(mouseIndex);
SDL_GetMouseState(&x, &y);
/* check if we hit any of the drum buttons */
for (i = 0; i < NUM_DRUMS; i++) {
......@@ -153,7 +152,7 @@ void
handleMouseButtonUp(SDL_Event * event)
{
int i;
int mouseIndex = event->button.which;
int mouseIndex = 0;
/* check if this should cause any of the buttons to become unpressed */
for (i = 0; i < NUM_DRUMS; i++) {
if (buttons[i].touchIndex == mouseIndex) {
......
......@@ -106,7 +106,6 @@ main(int argc, char *argv[])
done = 1;
break;
case SDL_MOUSEMOTION:
SDL_SelectMouse(event.motion.which); /* select 'mouse' (touch) that moved */
state = SDL_GetMouseState(&x, &y); /* get its location */
SDL_GetRelativeMouseState(&dx, &dy); /* find how much the mouse moved */
if (state & SDL_BUTTON_LMASK) { /* is the mouse (touch) down? */
......
......@@ -287,6 +287,13 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
0466EE6F11E565E4000198A4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 006E982211955059001DE610 /* testsdl.app */;
remoteInfo = testsdl;
};
FD1B48B70E3131CA007AB34E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */;
......@@ -298,9 +305,7 @@
/* Begin PBXFileReference section */
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; };
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; };
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; };
......@@ -861,14 +866,11 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
56ED0510118A904200A56AA6 /* testpower.c */,
FD1B48AC0E3131CA007AB34E /* SDLiPhoneOS.xcodeproj */,
FDA8AAD60E2D339A00EA573E /* Resources */,
FDA8A7C30E2D10FA00EA573E /* Linked Frameworks */,
FDA8A73B0E2D0F0400EA573E /* src */,
19C28FACFE9D520D11CA2CBB /* Products */,
56ED04F7118A8FCC00A56AA6 /* testpower-Info.plist */,
56ED050F118A8FE400A56AA6 /* Info copy.plist */,
);
name = CustomTemplate;
sourceTree = "<group>";
......@@ -877,6 +879,7 @@
isa = PBXGroup;
children = (
FD1B48B80E3131CA007AB34E /* libSDLiPhoneOS.a */,
0466EE7011E565E4000198A4 /* testsdl.app */,
);
name = Products;
sourceTree = "<group>";
......@@ -910,6 +913,7 @@
FDA8A7540E2D0F1600EA573E /* testoverlay2.c */,
FDA8A7550E2D0F1600EA573E /* testpalette.c */,
FDA8A7560E2D0F1600EA573E /* testplatform.c */,
56ED0510118A904200A56AA6 /* testpower.c */,
FDA8A7570E2D0F1600EA573E /* testsem.c */,
FDA8A7580E2D0F1600EA573E /* testsprite.c */,
FDA8A7590E2D0F1600EA573E /* testsprite2.c */,
......@@ -1502,6 +1506,13 @@
/* End PBXProject 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 */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
......@@ -2034,7 +2045,7 @@
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos2.2.1;
SDKROOT = iphoneos3.2;
};
name = Debug;
};
......@@ -2049,7 +2060,7 @@
HEADER_SEARCH_PATHS = ../../include;
PREBINDING = NO;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos2.2.1;
SDKROOT = iphoneos3.2;
};
name = Release;
};
......
......@@ -145,12 +145,9 @@ typedef unsigned long uintptr_t;
#define SDL_POWER_UIKIT 1
/* enable iPhone keyboard support */
#define SDL_IPHONE_KEYBOARD 0
#define SDL_IPHONE_KEYBOARD 1
/* Enable emulation of multiple mice through multi-touch */
#define SDL_IPHONE_MULTIPLE_MICE 1
/* Set max recognized G-force from acceleromter
/* Set max recognized G-force from accelerometer
See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed
*/
#define SDL_IPHONE_MAX_GFORCE 5.0
......
......@@ -551,6 +551,10 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
int
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);
}
......
......@@ -26,6 +26,8 @@
#include "SDL_uikitwindow.h"
#include "jumphack.h"
#include "SDL_sysvideo.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h"
#include "SDL_loadso.h"
#include <dlfcn.h>
......@@ -128,6 +130,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
/* Make this window the current mouse focus for touch input */
SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
return view;
}
......
......@@ -22,8 +22,6 @@
#import <UIKit/UIKit.h>
#include "SDL_stdinc.h"
#include "SDL_mouse.h"
#include "SDL_mouse_c.h"
#include "SDL_events.h"
#if SDL_IPHONE_MULTIPLE_MICE
......
......@@ -22,8 +22,10 @@
#import "SDL_uikitview.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h"
#if SDL_IPHONE_KEYBOARD
#import "SDL_keyboard_c.h"
#import "keyinfotable.h"
#import "SDL_uikitappdelegate.h"
#import "SDL_uikitwindow.h"
......@@ -33,7 +35,6 @@
- (void)dealloc {
#if SDL_IPHONE_KEYBOARD
SDL_DelKeyboard(0);
[textField release];
#endif
[super dealloc];
......@@ -225,15 +226,6 @@
keyboardVisible = NO;
/* add the UITextField (hidden) to our view */
[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 */
......@@ -253,8 +245,8 @@
if ([string length] == 0) {
/* it wants to replace text with nothing, ie a delete */
SDL_SendKeyboardKey( 0, SDL_PRESSED, SDL_SCANCODE_DELETE);
SDL_SendKeyboardKey( 0, SDL_RELEASED, SDL_SCANCODE_DELETE);
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
}
else {
/* go through all the characters in the string we've been sent
......@@ -280,14 +272,14 @@
if (mod & KMOD_SHIFT) {
/* 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 */
SDL_SendKeyboardKey( 0, SDL_PRESSED, code);
SDL_SendKeyboardKey( 0, SDL_RELEASED, code);
SDL_SendKeyboardKey(SDL_PRESSED, code);
SDL_SendKeyboardKey(SDL_RELEASED, code);
if (mod & KMOD_SHIFT) {
/* 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