Skip to content

Commit f7b3be8

Browse files
committed
Add touch support and full screen.
1 parent 165c1ca commit f7b3be8

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

plugins/media/media.c

+23-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <unistd.h>
3939

4040

41+
4142
/* Old Windows versions lack these functions
4243
*
4344
* credit: Petar Korponaić
@@ -1153,7 +1154,6 @@ ctr_object* ctr_media_screen(ctr_object* myself, ctr_argument* argumentList) {
11531154
controllableObject = NULL;
11541155
focusObject = NULL;
11551156
CtrMediaSteps = 0;
1156-
SDL_StartTextInput();
11571157
SDL_Rect dimensions;
11581158
SDL_Texture* texture;
11591159
char* imageFileStr = ctr_heap_allocate_cstring(ctr_internal_cast2string(argumentList->object));
@@ -1261,6 +1261,24 @@ ctr_object* ctr_media_screen(ctr_object* myself, ctr_argument* argumentList) {
12611261
}
12621262
if (ctr_internal_media_mouse_down(event)) return CtrStdFlow;
12631263
break;
1264+
case SDL_FINGERDOWN:
1265+
if (event.tfinger.x * windowWidth > player->x) {
1266+
ctr_internal_media_keydown_right(&dir);
1267+
}
1268+
else if (event.tfinger.x * windowWidth < player->x - (player->w/player->anims)) {
1269+
ctr_internal_media_keydown_left(&dir);
1270+
}
1271+
if (event.tfinger.y * windowHeight > player->y - player->h) {
1272+
ctr_internal_media_keydown_down(&dir, &c4speed);
1273+
}
1274+
else if (event.tfinger.y * windowHeight < player->y - player->h) {
1275+
ctr_internal_media_keydown_up(&dir, &c4speed);
1276+
}
1277+
break;
1278+
case SDL_FINGERUP:
1279+
ctr_internal_media_keyup_right(&dir, &c4speed);
1280+
ctr_internal_media_keyup_down(&dir, &c4speed);
1281+
break;
12641282
case SDL_CONTROLLERBUTTONDOWN:
12651283
if (CtrMediaEventListenFlagGamePadBtnDown) {
12661284
ctr_media_event(myself, CTR_DICT_ON_GAMEPAD_DOWN, SDL_GameControllerGetStringForButton(event.cbutton.button));
@@ -3388,7 +3406,11 @@ void ctr_internal_media_init() {
33883406
CtrMediaAudioVolume = MIX_MAX_VOLUME;
33893407
if (SDL_Init(SDL_INIT_VIDEO) < 0) ctr_internal_media_fatalerror("SDL failed to init", SDL_GetError());
33903408
IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG);
3409+
#ifdef FULLSCREEN
3410+
CtrMediaWindow = SDL_CreateWindow("Citrine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 100, 100, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN);
3411+
#else
33913412
CtrMediaWindow = SDL_CreateWindow("Citrine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 100, 100, SDL_WINDOW_OPENGL);
3413+
#endif
33923414
if (CtrMediaWindow == NULL) ctr_internal_media_fatalerror("Unable to create window", SDL_GetError());
33933415
CtrMediaRenderer = SDL_CreateRenderer(CtrMediaWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
33943416
if (!CtrMediaRenderer) {

0 commit comments

Comments
 (0)