mirror of https://github.com/encounter/SDL.git
More cleanup of the iOS keyboard demo.
This commit is contained in:
parent
a0a09f646c
commit
efc43a1d88
|
@ -157,7 +157,6 @@ drawGlyph(int glyph, int positionIndex)
|
||||||
SDL_Texture*
|
SDL_Texture*
|
||||||
loadFont(void)
|
loadFont(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
|
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
|
||||||
|
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
|
@ -208,18 +207,18 @@ draw()
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int index; /* index of last key we pushed in the bitmap font */
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
SDL_Event event; /* last event received */
|
SDL_Event event; /* last event received */
|
||||||
SDL_Scancode scancode; /* scancode of last key we pushed */
|
SDL_Scancode scancode; /* scancode of last key we pushed */
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
int done;
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
printf("Error initializing SDL: %s", SDL_GetError());
|
printf("Error initializing SDL: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
/* create window */
|
/* create window */
|
||||||
window = SDL_CreateWindow("iPhone keyboard test", 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
|
window = SDL_CreateWindow("iOS keyboard test", 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
/* create renderer */
|
/* create renderer */
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||||
|
|
||||||
|
@ -229,16 +228,13 @@ main(int argc, char *argv[])
|
||||||
/* load up our font */
|
/* load up our font */
|
||||||
loadFont();
|
loadFont();
|
||||||
|
|
||||||
int done = 0;
|
done = 0;
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
done = 1;
|
done = 1;
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
|
||||||
break;
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
if (event.key.keysym.scancode == SDL_SCANCODE_BACKSPACE) {
|
if (event.key.keysym.scancode == SDL_SCANCODE_BACKSPACE) {
|
||||||
if (numChars > 0) {
|
if (numChars > 0) {
|
||||||
|
@ -269,5 +265,6 @@ main(int argc, char *argv[])
|
||||||
SDL_DestroyTexture(texture);
|
SDL_DestroyTexture(texture);
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue