mirror of
https://github.com/google/pebble.git
synced 2025-05-18 17:34:59 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
72
applib-targets/sdl/sdl_app.c
Normal file
72
applib-targets/sdl/sdl_app.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "sdl_app.h"
|
||||
#include "sdl_graphics.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern int app_main(void);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (!sdl_app_init()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
app_main();
|
||||
sdl_app_deinit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
bool sdl_app_init(void) {
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
printf("Error: Failed to init SDL\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sdl_graphics_init()) {
|
||||
printf("Error: Failed to init graphics\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void sdl_app_deinit(void) {
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void sdl_app_event_loop(void) {
|
||||
SDL_Event event;
|
||||
int keypress = 0;
|
||||
|
||||
while (!keypress) {
|
||||
sdl_graphics_render();
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT:
|
||||
keypress = 1;
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
keypress = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue