Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
95c839f4
Commit
95c839f4
authored
Mar 10, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug 1163 (SDL_TEXTINPUT not being received on iPhoneOS)
parent
608ec7da
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
175 additions
and
47 deletions
+175
-47
project.pbxproj
Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
+96
-2
SDL_uikitview.m
src/video/uikit/SDL_uikitview.m
+1
-0
checkkeys.c
test/checkkeys.c
+78
-45
No files found.
Xcode-iPhoneOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
View file @
95c839f4
This diff is collapsed.
Click to expand it.
src/video/uikit/SDL_uikitview.m
View file @
95c839f4
...
@@ -290,6 +290,7 @@
...
@@ -290,6 +290,7 @@
SDL_SendKeyboardKey
(
SDL_RELEASED
,
SDL_SCANCODE_LSHIFT
);
SDL_SendKeyboardKey
(
SDL_RELEASED
,
SDL_SCANCODE_LSHIFT
);
}
}
}
}
SDL_SendKeyboardText
([
string
UTF8String
]);
}
}
return
NO
;
/* don't allow the edit! (keep placeholder text there) */
return
NO
;
/* don't allow the edit! (keep placeholder text there) */
}
}
...
...
test/checkkeys.c
View file @
95c839f4
...
@@ -19,92 +19,124 @@ quit(int rc)
...
@@ -19,92 +19,124 @@ quit(int rc)
}
}
static
void
static
void
print_modifiers
(
void
)
print_string
(
char
**
text
,
size_t
*
maxlen
,
const
char
*
fmt
,
...)
{
int
len
;
va_list
ap
;
va_start
(
ap
,
fmt
);
len
=
SDL_vsnprintf
(
*
text
,
*
maxlen
,
fmt
,
ap
);
if
(
len
>
0
)
{
*
text
+=
len
;
if
(
len
<
*
maxlen
)
{
*
maxlen
-=
len
;
}
else
{
*
maxlen
=
0
;
}
}
va_end
(
ap
);
}
static
void
print_modifiers
(
char
**
text
,
size_t
*
maxlen
)
{
{
int
mod
;
int
mod
;
print
f
(
" modifiers:"
);
print
_string
(
text
,
maxlen
,
" modifiers:"
);
mod
=
SDL_GetModState
();
mod
=
SDL_GetModState
();
if
(
!
mod
)
{
if
(
!
mod
)
{
print
f
(
" (none)"
);
print
_string
(
text
,
maxlen
,
" (none)"
);
return
;
return
;
}
}
if
(
mod
&
KMOD_LSHIFT
)
if
(
mod
&
KMOD_LSHIFT
)
print
f
(
" LSHIFT"
);
print
_string
(
text
,
maxlen
,
" LSHIFT"
);
if
(
mod
&
KMOD_RSHIFT
)
if
(
mod
&
KMOD_RSHIFT
)
print
f
(
" RSHIFT"
);
print
_string
(
text
,
maxlen
,
" RSHIFT"
);
if
(
mod
&
KMOD_LCTRL
)
if
(
mod
&
KMOD_LCTRL
)
print
f
(
" LCTRL"
);
print
_string
(
text
,
maxlen
,
" LCTRL"
);
if
(
mod
&
KMOD_RCTRL
)
if
(
mod
&
KMOD_RCTRL
)
print
f
(
" RCTRL"
);
print
_string
(
text
,
maxlen
,
" RCTRL"
);
if
(
mod
&
KMOD_LALT
)
if
(
mod
&
KMOD_LALT
)
print
f
(
" LALT"
);
print
_string
(
text
,
maxlen
,
" LALT"
);
if
(
mod
&
KMOD_RALT
)
if
(
mod
&
KMOD_RALT
)
print
f
(
" RALT"
);
print
_string
(
text
,
maxlen
,
" RALT"
);
if
(
mod
&
KMOD_LGUI
)
if
(
mod
&
KMOD_LGUI
)
print
f
(
" LGUI"
);
print
_string
(
text
,
maxlen
,
" LGUI"
);
if
(
mod
&
KMOD_RGUI
)
if
(
mod
&
KMOD_RGUI
)
print
f
(
" RGUI"
);
print
_string
(
text
,
maxlen
,
" RGUI"
);
if
(
mod
&
KMOD_NUM
)
if
(
mod
&
KMOD_NUM
)
print
f
(
" NUM"
);
print
_string
(
text
,
maxlen
,
" NUM"
);
if
(
mod
&
KMOD_CAPS
)
if
(
mod
&
KMOD_CAPS
)
print
f
(
" CAPS"
);
print
_string
(
text
,
maxlen
,
" CAPS"
);
if
(
mod
&
KMOD_MODE
)
if
(
mod
&
KMOD_MODE
)
print
f
(
" MODE"
);
print
_string
(
text
,
maxlen
,
" MODE"
);
}
}
static
void
static
void
PrintKey
(
SDL_Keysym
*
sym
,
SDL_bool
pressed
,
SDL_bool
repeat
)
PrintKey
(
SDL_Keysym
*
sym
,
SDL_bool
pressed
,
SDL_bool
repeat
)
{
{
char
message
[
512
];
char
*
spot
;
size_t
left
;
spot
=
message
;
left
=
sizeof
(
message
);
/* Print the keycode, name and state */
/* Print the keycode, name and state */
if
(
sym
->
sym
)
{
if
(
sym
->
sym
)
{
printf
(
"Key %s: scancode %d = %s, keycode 0x%08X = %s "
,
print_string
(
&
spot
,
&
left
,
pressed
?
"pressed "
:
"released"
,
"Key %s: scancode %d = %s, keycode 0x%08X = %s "
,
sym
->
scancode
,
pressed
?
"pressed "
:
"released"
,
SDL_GetScancodeName
(
sym
->
scancode
),
sym
->
scancode
,
sym
->
sym
,
SDL_GetKeyName
(
sym
->
sym
));
SDL_GetScancodeName
(
sym
->
scancode
),
sym
->
sym
,
SDL_GetKeyName
(
sym
->
sym
));
}
else
{
}
else
{
printf
(
"Unknown Key (scancode %d = %s) %s "
,
print_string
(
&
spot
,
&
left
,
sym
->
scancode
,
"Unknown Key (scancode %d = %s) %s "
,
SDL_GetScancodeName
(
sym
->
scancode
),
sym
->
scancode
,
pressed
?
"pressed"
:
"released"
);
SDL_GetScancodeName
(
sym
->
scancode
),
pressed
?
"pressed"
:
"released"
);
}
}
/* Print the translated character, if one exists */
/* Print the translated character, if one exists */
if
(
sym
->
unicode
)
{
if
(
sym
->
unicode
)
{
/* Is it a control-character? */
/* Is it a control-character? */
if
(
sym
->
unicode
<
' '
)
{
if
(
sym
->
unicode
<
' '
)
{
print
f
(
" (^%c)"
,
sym
->
unicode
+
'@'
);
print
_string
(
&
spot
,
&
left
,
" (^%c)"
,
sym
->
unicode
+
'@'
);
}
else
{
}
else
{
#ifdef UNICODE
#ifdef UNICODE
print
f
(
" (%c)"
,
sym
->
unicode
);
print
_string
(
&
spot
,
&
left
,
" (%c)"
,
sym
->
unicode
);
#else
#else
/* This is a Latin-1 program, so only show 8-bits */
/* This is a Latin-1 program, so only show 8-bits */
if
(
!
(
sym
->
unicode
&
0xFF00
))
if
(
!
(
sym
->
unicode
&
0xFF00
))
print
f
(
" (%c)"
,
sym
->
unicode
);
print
_string
(
&
spot
,
&
left
,
" (%c)"
,
sym
->
unicode
);
else
else
print
f
(
" (0x%X)"
,
sym
->
unicode
);
print
_string
(
&
spot
,
&
left
,
" (0x%X)"
,
sym
->
unicode
);
#endif
#endif
}
}
}
}
print_modifiers
();
print_modifiers
(
&
spot
,
&
left
);
if
(
repeat
)
{
if
(
repeat
)
{
print
f
(
" (repeat)"
);
print
_string
(
&
spot
,
&
left
,
" (repeat)"
);
}
}
printf
(
"
\n
"
);
SDL_Log
(
"%s"
,
message
);
}
}
static
void
static
void
PrintText
(
char
*
text
)
PrintText
(
char
*
text
)
{
{
printf
(
"Text: %s
\n
"
,
text
);
SDL_Log
(
"Text: %s
"
,
text
);
}
}
#if __IPHONEOS__
extern
DECLSPEC
int
SDLCALL
SDL_iPhoneKeyboardShow
(
SDL_Window
*
window
);
#endif
int
int
main
(
int
argc
,
char
*
argv
[])
main
(
int
argc
,
char
*
argv
[])
{
{
SDL_Window
*
window
;
SDL_Event
event
;
SDL_Event
event
;
int
done
;
int
done
;
Uint32
videoflags
;
/* Initialize SDL */
/* Initialize SDL */
if
(
SDL_Init
(
SDL_INIT_VIDEO
)
<
0
)
{
if
(
SDL_Init
(
SDL_INIT_VIDEO
)
<
0
)
{
...
@@ -112,24 +144,23 @@ main(int argc, char *argv[])
...
@@ -112,24 +144,23 @@ main(int argc, char *argv[])
return
(
1
);
return
(
1
);
}
}
videoflags
=
SDL_SWSURFACE
;
while
(
argc
>
1
)
{
--
argc
;
if
(
argv
[
argc
]
&&
!
strcmp
(
argv
[
argc
],
"-fullscreen"
))
{
videoflags
|=
SDL_FULLSCREEN
;
}
else
{
fprintf
(
stderr
,
"Usage: %s [-fullscreen]
\n
"
,
argv
[
0
]);
quit
(
1
);
}
}
/* Set 640x480 video mode */
/* Set 640x480 video mode */
if
(
SDL_SetVideoMode
(
640
,
480
,
0
,
videoflags
)
==
NULL
)
{
window
=
SDL_CreateWindow
(
"CheckKeys Test"
,
fprintf
(
stderr
,
"Couldn't set 640x480 video mode: %s
\n
"
,
SDL_WINDOWPOS_CENTERED
,
SDL_WINDOWPOS_CENTERED
,
640
,
480
,
0
);
if
(
!
window
)
{
fprintf
(
stderr
,
"Couldn't create 640x480 window: %s
\n
"
,
SDL_GetError
());
SDL_GetError
());
quit
(
2
);
quit
(
2
);
}
}
#if __IPHONEOS__
/* Creating the context creates the view, which we need to show keyboard */
SDL_GL_CreateContext
(
window
);
SDL_iPhoneKeyboardShow
(
window
);
#endif
/* Watch keystrokes */
/* Watch keystrokes */
done
=
0
;
done
=
0
;
while
(
!
done
)
{
while
(
!
done
)
{
...
@@ -156,3 +187,5 @@ main(int argc, char *argv[])
...
@@ -156,3 +187,5 @@ main(int argc, char *argv[])
SDL_Quit
();
SDL_Quit
();
return
(
0
);
return
(
0
);
}
}
/* vi: set ts=4 sw=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment