summaryrefslogtreecommitdiff
path: root/examples/example_custom.c
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2018-07-02 10:34:09 +0300
committerGitHub <noreply@github.com>2018-07-02 10:34:09 +0300
commit7aec12156a3dc3df570855cb1c3fa03792f77030 (patch)
tree6b1d66e504982e24dcf79c710126ce96457c75ef /examples/example_custom.c
parentf602daa42a2a9135daa9b9a57e177edfb0c767ba (diff)
parent5973307722d4531dd24ff7ada8ab11111f5ee378 (diff)
Merge pull request #42 from katajakasa/source-cleanups
Source cleanups + RWOps
Diffstat (limited to 'examples/example_custom.c')
-rw-r--r--examples/example_custom.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/examples/example_custom.c b/examples/example_custom.c
index 43ae40a..e365850 100644
--- a/examples/example_custom.c
+++ b/examples/example_custom.c
@@ -22,14 +22,6 @@ int read_callback(void *userdata, uint8_t *buf, int buf_size) {
return -1;
}
-int64_t seek_callback(void *userdata, int64_t offset, int whence) {
- FILE *fd = (FILE*)userdata;
- if(fseek(fd, offset, whence)) {
- return -1;
- }
- return ftell(fd);
-}
-
int main(int argc, char *argv[]) {
int err = 0, ret = 0;
const char* filename = NULL;
@@ -83,8 +75,8 @@ int main(int argc, char *argv[]) {
return 1;
}
- // Open up the custom source. Declare read & seek callbacks, and transport FD in userdata.
- src = Kit_CreateSourceFromCustom(read_callback, seek_callback, fd);
+ // Open up the custom source. Declare read callback, and transport FD in userdata.
+ src = Kit_CreateSourceFromCustom(read_callback, NULL, fd);
if(src == NULL) {
fprintf(stderr, "Unable to load file '%s': %s\n", filename, Kit_GetError());
return 1;
@@ -171,6 +163,12 @@ int main(int argc, char *argv[]) {
case SDL_QUIT:
run = false;
break;
+ case SDL_KEYUP:
+ if(event.key.keysym.sym == SDLK_RIGHT)
+ Kit_PlayerSeek(player, Kit_GetPlayerPosition(player) + 10);
+ if(event.key.keysym.sym == SDLK_LEFT)
+ Kit_PlayerSeek(player, Kit_GetPlayerPosition(player) - 10);
+ break;
}
}