Subversion Repositories eduke32

Rev

Rev 5000 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5000 Rev 5066
1
/*
1
/*
2
 *
2
 *
3
 * Designed by Emile Belanger
3
 * Designed by Emile Belanger
4
 *
4
 *
5
 */
5
 */
6
6
7
#include <stdlib.h>
7
#include <stdlib.h>
8
#include <stdio.h>
8
#include <stdio.h>
9
#include <string.h>
9
#include <string.h>
10
#include <jni.h>
10
#include <jni.h>
11
#include <android/log.h>
11
#include <android/log.h>
12
12
13
#include "SDL_scancode.h"
13
#include "SDL_scancode.h"
14
#include "SDL_main.h"
14
#include "SDL_main.h"
15
15
16
#include "TouchControlsContainer.h"
16
#include "TouchControlsContainer.h"
17
#include "JNITouchControlsUtils.h"
17
#include "JNITouchControlsUtils.h"
18
18
19
#ifdef GP_LIC
19
#ifdef GP_LIC
20
#include "s-setup/s-setup.h"
20
#include "s-setup/s-setup.h"
21
#endif
21
#endif
22
22
23
extern "C" {
23
extern "C" {
24
#define DEFAULT_FADE_FRAMES 10
24
#define DEFAULT_FADE_FRAMES 10
25
25
26
extern void SDL_Android_Init(JNIEnv *env, jclass cls);
26
extern void SDL_Android_Init(JNIEnv *env, jclass cls);
27
// This is a new function I put into SDL2, file SDL_androidgl.c
-
 
28
extern void SDL_SetSwapBufferCallBack(void (*pt2Func)(void));
-
 
29
-
 
30
extern char const *G_GetStringFromSavegame(const char *filename, int type);
27
extern char const *G_GetStringFromSavegame(const char *filename, int type);
31
extern int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
28
extern int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
32
29
33
#include "in_android.h"
30
#include "in_android.h"
34
#include "../function.h"
31
#include "../function.h"
35
32
36
#include "../GL/gl.h"
33
#include "../GL/gl.h"
37
34
38
// Copied from build.h, which didnt include here
35
// Copied from build.h, which didnt include here
39
enum rendmode_t
36
enum rendmode_t
40
{
37
{
41
    REND_CLASSIC,
38
    REND_CLASSIC,
42
    REND_POLYMOST = 3,
39
    REND_POLYMOST = 3,
43
    REND_POLYMER
40
    REND_POLYMER
44
};
41
};
45
42
46
enum dukeinv_t
43
enum dukeinv_t
47
{
44
{
48
    GET_STEROIDS,  // 0
45
    GET_STEROIDS,  // 0
49
    GET_SHIELD,
46
    GET_SHIELD,
50
    GET_SCUBA,
47
    GET_SCUBA,
51
    GET_HOLODUKE,
48
    GET_HOLODUKE,
52
    GET_JETPACK,
49
    GET_JETPACK,
53
    GET_DUMMY1,  // 5
50
    GET_DUMMY1,  // 5
54
    GET_ACCESS,
51
    GET_ACCESS,
55
    GET_HEATS,
52
    GET_HEATS,
56
    GET_DUMMY2,
53
    GET_DUMMY2,
57
    GET_FIRSTAID,
54
    GET_FIRSTAID,
58
    GET_BOOTS,  // 10
55
    GET_BOOTS,  // 10
59
    GET_MAX
56
    GET_MAX
60
};
57
};
61
58
62
59
63
#ifndef LOGI
60
#ifndef LOGI
64
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "DUKE", __VA_ARGS__))
61
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "DUKE", __VA_ARGS__))
65
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__))
62
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__))
66
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "DUKE", __VA_ARGS__))
63
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "DUKE", __VA_ARGS__))
67
#endif
64
#endif
68
65
69
#define REND_SOFT 0
66
#define REND_SOFT 0
70
#define REND_GL 1
67
#define REND_GL 1
71
68
72
droidsysinfo_t droidinfo;
69
droidsysinfo_t droidinfo;
73
70
74
static int curRenderer;
71
static int curRenderer;
75
72
76
static bool hideTouchControls = true;
73
static bool hideTouchControls = true;
77
static int weaponWheelVisible = false;
74
static int weaponWheelVisible = false;
78
75
79
76
80
static int controlsCreated = 0;
77
static int controlsCreated = 0;
81
touchcontrols::TouchControlsContainer controlsContainer;
78
touchcontrols::TouchControlsContainer controlsContainer;
82
79
83
touchcontrols::TouchControls *tcBlankTap = 0;
80
touchcontrols::TouchControls *tcBlankTap;
84
touchcontrols::TouchControls *tcYesNo = 0;
81
touchcontrols::TouchControls *tcYesNo;
85
touchcontrols::TouchControls *tcMenuMain = 0;
82
touchcontrols::TouchControls *tcMenuMain;
86
touchcontrols::TouchControls *tcGameMain = 0;
83
touchcontrols::TouchControls *tcGameMain;
87
touchcontrols::TouchControls *tcGameWeapons = 0;
84
touchcontrols::TouchControls *tcGameWeapons;
88
// touchcontrols::TouchControls *tcInventory=0;
85
// touchcontrols::TouchControls *tcInventory;
89
touchcontrols::TouchControls *tcAutomap = 0;
86
touchcontrols::TouchControls *tcAutomap;
90
87
91
88
92
touchcontrols::TouchJoy *touchJoyLeft;
89
touchcontrols::TouchJoy *touchJoyLeft;
93
touchcontrols::WheelSelect *weaponWheel;
90
touchcontrols::WheelSelect *weaponWheel;
94
91
95
extern JNIEnv *env_;
92
extern JNIEnv *env_;
96
JavaVM *jvm_;
93
JavaVM *jvm_;
97
94
98
touchcontrols::Button *inv_buttons[GET_MAX];
95
touchcontrols::Button *inv_buttons[GET_MAX];
99
96
100
std::string obbPath;
-
 
101
std::string gamePath;
97
std::string obbPath, gamePath;
102
98
103
void openGLStart()
99
void openGLStart()
104
{
100
{
105
    if (curRenderer == REND_GL)
101
    if (curRenderer == REND_GL)
106
    {
102
    {
107
        glPushMatrix();
103
        glPushMatrix();
108
104
109
        glMatrixMode(GL_PROJECTION);
105
        glMatrixMode(GL_PROJECTION);
110
        glLoadIdentity();
106
        glLoadIdentity();
111
        glOrthof(0, droidinfo.screen_width, droidinfo.screen_height, 0, 0, 1);
107
        glOrthof(0, droidinfo.screen_width, droidinfo.screen_height, 0, 0, 1);
112
108
113
        // glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
109
        // glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
114
        // glClear(GL_COLOR_BUFFER_BIT);
110
        // glClear(GL_COLOR_BUFFER_BIT);
115
        // LOGI("openGLStart");
111
        // LOGI("openGLStart");
116
        glDisable(GL_ALPHA_TEST);
112
        glDisable(GL_ALPHA_TEST);
117
        glDisable(GL_DEPTH_TEST);
113
        glDisable(GL_DEPTH_TEST);
118
        glDisable(GL_FOG);
114
        glDisable(GL_FOG);
119
        glEnable(GL_TEXTURE_2D);
115
        glEnable(GL_TEXTURE_2D);
120
        glEnable(GL_BLEND);
116
        glEnable(GL_BLEND);
121
117
122
        glColor4f(1, 1, 1, 1);
118
        glColor4f(1, 1, 1, 1);
123
119
124
        glDisableClientState(GL_COLOR_ARRAY);
120
        glDisableClientState(GL_COLOR_ARRAY);
125
        glEnableClientState(GL_VERTEX_ARRAY);
121
        glEnableClientState(GL_VERTEX_ARRAY);
126
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
122
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
127
123
128
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
124
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
129
125
130
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
126
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
131
127
132
        glDisable(GL_CULL_FACE);
128
        glDisable(GL_CULL_FACE);
133
129
134
        glMatrixMode(GL_MODELVIEW);
130
        glMatrixMode(GL_MODELVIEW);
135
131
136
        // nanoPushState();
132
        // nanoPushState();
137
    }
133
    }
138
/*
134
/*
139
    else  // software mode
135
    else  // software mode
140
    {
136
    {
141
        glDisable(GL_ALPHA_TEST);
137
        glDisable(GL_ALPHA_TEST);
142
        glDisableClientState(GL_COLOR_ARRAY);
138
        glDisableClientState(GL_COLOR_ARRAY);
143
        glEnableClientState(GL_VERTEX_ARRAY);
139
        glEnableClientState(GL_VERTEX_ARRAY);
144
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
140
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
145
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
141
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
146
        glEnable(GL_BLEND);
142
        glEnable(GL_BLEND);
147
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
143
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
148
        glEnable(GL_TEXTURE_2D);
144
        glEnable(GL_TEXTURE_2D);
149
        glDisable(GL_CULL_FACE);
145
        glDisable(GL_CULL_FACE);
150
        glMatrixMode(GL_MODELVIEW);
146
        glMatrixMode(GL_MODELVIEW);
151
    }
147
    }
152
*/
148
*/
153
}
149
}
154
150
155
void openGLEnd()
151
void openGLEnd()
156
{
152
{
157
    if (curRenderer == REND_GL)
153
    if (curRenderer == REND_GL)
158
    {
154
    {
159
        // glPopMatrix();
155
        // glPopMatrix();
160
        // nanoPopState();
156
        // nanoPopState();
161
        glPopMatrix();
157
        glPopMatrix();
162
    }
158
    }
163
/*
159
/*
164
    else  // Software mode
160
    else  // Software mode
165
    {
161
    {
166
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
162
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
167
        glMatrixMode(GL_MODELVIEW);
163
        glMatrixMode(GL_MODELVIEW);
168
    }
164
    }
169
*/
165
*/
170
}
166
}
171
167
172
void gameSettingsButton(int state)
168
void gameSettingsButton(int state)
173
{
169
{
174
    if (state == 1)
170
    if (state == 1)
175
    {
171
    {
176
        showTouchSettings();
172
        showTouchSettings();
177
    }
173
    }
178
}
174
}
179
175
180
// Because there is no Frame(), we need to check back to java each frame to see if the app hase paused
176
// Because there is no Frame(), we need to check back to java each frame to see if the app hase paused
181
177
182
/*
178
/*
183
static jclass NativeLibClass = 0;
179
static jclass NativeLibClass = 0;
184
static jmethodID checkPauseMethod = 0;
180
static jmethodID checkPauseMethod = 0;
185

181

186
void swapBuffers()
182
void swapBuffers()
187
{
183
{
188
    if (NativeLibClass == 0)
184
    if (NativeLibClass == 0)
189
    {
185
    {
190
        NativeLibClass = env_->FindClass("com/voidpoint/duke3d/engine/NativeLib");
186
        NativeLibClass = env_->FindClass("com/voidpoint/duke3d/engine/NativeLib");
191
        checkPauseMethod = env_->GetStaticMethodID(NativeLibClass, "swapBuffers", "()V");
187
        checkPauseMethod = env_->GetStaticMethodID(NativeLibClass, "swapBuffers", "()V");
192
    }
188
    }
193
    env_->CallStaticVoidMethod(NativeLibClass, checkPauseMethod);
189
    env_->CallStaticVoidMethod(NativeLibClass, checkPauseMethod);
194
}
190
}
195
*/
191
*/
196
192
197
// This is a bit of a hack, if the weapon wheel was selected, then an inv chosen instead, we need to cancel the weapon
193
// This is a bit of a hack, if the weapon wheel was selected, then an inv chosen instead, we need to cancel the weapon
198
// selection
194
// selection
199
// NOT needed actually, weapon wheel disabled before is get finger up anyway
195
// NOT needed actually, weapon wheel disabled before is get finger up anyway
200
// static bool invWasSelected = false;
196
// static bool invWasSelected = false;
201
197
202
void showWeaponsInventory(bool show)
198
void showWeaponsInventory(bool show)
203
{
199
{
204
    if (show)
200
    if (show)
205
    {
201
    {
206
        for (int n = 0; n < 10; n++)
202
        for (int n = 0; n < 10; n++)
207
        {
-
 
208
            weaponWheel->setSegmentEnabled(n, (PortableRead(READ_WEAPONS) >> n) & 0x1);
203
            weaponWheel->setSegmentEnabled(n, (PortableRead(READ_WEAPONS) >> n) & 0x1);
209
        }
-
 
210
204
211
        // Show inventory buttons
205
        // Show inventory buttons
212
        tcGameWeapons->setAllButtonsEnable(true);
206
        tcGameWeapons->setAllButtonsEnable(true);
213
207
214
        tcGameWeapons->fade(touchcontrols::FADE_IN, 5);  // fade in
208
        tcGameWeapons->fade(touchcontrols::FADE_IN, 5);  // fade in
215
        weaponWheelVisible = true;
209
        weaponWheelVisible = true;
216
    }
210
    }
217
    else  // hide
211
    else  // hide
218
    {
212
    {
219
        tcGameWeapons->setAllButtonsEnable(false);
213
        tcGameWeapons->setAllButtonsEnable(false);
220
        weaponWheel->setTapMode(false);
214
        weaponWheel->setTapMode(false);
221
        weaponWheelVisible = false;
215
        weaponWheelVisible = false;
222
    }
216
    }
223
}
217
}
224
218
225
void gameButton(int state, int code)
219
void gameButton(int state, int code)
226
{
220
{
227
    switch (code)
221
    switch (code)
228
    {
222
    {
229
        case gamefunc_Fire:
223
        case gamefunc_Fire:
230
            if (state && PortableRead(READ_SOMETHINGONPLAYER))
224
            if (state && PortableRead(READ_SOMETHINGONPLAYER))
231
            {
225
            {
232
                PortableAction(1, gamefunc_Quick_Kick);
226
                PortableAction(1, gamefunc_Quick_Kick);
233
                PortableAction(0, gamefunc_Quick_Kick);
227
                PortableAction(0, gamefunc_Quick_Kick);
234
            }
228
            }
235
            else PortableAction(state, code);
229
            else PortableAction(state, code);
236
            break;
230
            break;
237
231
238
        case KEY_SHOW_KBRD:
232
        case KEY_SHOW_KBRD:
239
            if (state)
233
            if (state)
240
                toggleKeyboard();
234
                toggleKeyboard();
241
235
242
            PortableKeyEvent(state, SDL_SCANCODE_GRAVE, 0);
236
            PortableKeyEvent(state, SDL_SCANCODE_GRAVE, 0);
243
            break;
237
            break;
244
238
245
        case KEY_QUICK_CMD:
239
        case KEY_QUICK_CMD:
246
            if (state == 1)
240
            if (state == 1)
247
                showCustomCommands();
241
                showCustomCommands();
248
            break;
242
            break;
249
243
250
        case KEY_SHOW_INVEN:
244
        case KEY_SHOW_INVEN:
251
            if (state)
245
            if (state)
252
            {
246
            {
253
                if (!weaponWheelVisible)
247
                if (!weaponWheelVisible)
254
                {
248
                {
255
                    weaponWheel->setTapMode(true);
249
                    weaponWheel->setTapMode(true);
256
                    showWeaponsInventory(true);
250
                    showWeaponsInventory(true);
257
                }
251
                }
258
                else
252
                else
259
                    showWeaponsInventory(false);
253
                    showWeaponsInventory(false);
260
            }
254
            }
261
            break;
255
            break;
262
256
263
        case KEY_QUICK_SAVE:
257
        case KEY_QUICK_SAVE:
264
            LOGI("QUICK SAVE");
258
            LOGI("QUICK SAVE");
265
            PortableKeyEvent(state, SDL_SCANCODE_F6, 0);
259
            PortableKeyEvent(state, SDL_SCANCODE_F6, 0);
266
            break;
260
            break;
267
261
268
        case KEY_QUICK_LOAD:
262
        case KEY_QUICK_LOAD:
269
            LOGI("QUICK LOAD");
263
            LOGI("QUICK LOAD");
270
            PortableKeyEvent(state, SDL_SCANCODE_F9, 0);
264
            PortableKeyEvent(state, SDL_SCANCODE_F9, 0);
271
            break;
265
            break;
272
266
273
        default: PortableAction(state, code); break;
267
        default: PortableAction(state, code); break;
274
    }
268
    }
275
}
269
}
276
270
277
void automapButton(int state, int code) { PortableAction(state, code); }
271
void automapButton(int state, int code) { PortableAction(state, code); }
278
272
279
void inventoryButton(int state, int code)
273
void inventoryButton(int state, int code)
280
{
274
{
281
    PortableAction(state, code);
275
    PortableAction(state, code);
282
    if (state == 0)
276
    if (state == 0)
283
    {
277
    {
284
        // Inventory chosen, hide them and wheel
278
        // Inventory chosen, hide them and wheel
285
        showWeaponsInventory(false);
279
        showWeaponsInventory(false);
286
    }
280
    }
287
}
281
}
288
282
289
void menuButton(int state, int code) { PortableKeyEvent(state, code, code); }
283
void menuButton(int state, int code) { PortableKeyEvent(state, code, code); }
290
284
291
void menuMouse(int action, float x, float y, float dx, float dy)
285
void menuMouse(int action, float x, float y, float dx, float dy)
292
{
286
{
293
    // PortableMouse(dx,dy);
287
    // PortableMouse(dx,dy);
294
    PortableMouseMenu(x * droidinfo.screen_width, y * droidinfo.screen_height);
288
    PortableMouseMenu(x * droidinfo.screen_width, y * droidinfo.screen_height);
295
289
296
    if (action == MULTITOUCHMOUSE_DOWN || action == MULTITOUCHMOUSE_UP)
290
    if (action == MULTITOUCHMOUSE_DOWN || action == MULTITOUCHMOUSE_UP)
297
        PortableMouseMenuButton(action == MULTITOUCHMOUSE_DOWN, 0);
291
        PortableMouseMenuButton(action == MULTITOUCHMOUSE_DOWN, 0);
298
}
292
}
299
293
300
void blankTapButton(int state, int code)
294
void blankTapButton(int state, int code)
301
{
295
{
302
    if (PortableRead(READ_IS_DEAD))  // if the player is dead we need to send a 'open' button
296
    if (PortableRead(READ_IS_DEAD))  // if the player is dead we need to send a 'open' button
303
    {
297
    {
304
        if (state)
298
        if (state)
305
        {
299
        {
306
            PortableAction(1, gamefunc_Open);
300
            PortableAction(1, gamefunc_Open);
307
            PortableAction(0, gamefunc_Open);
301
            PortableAction(0, gamefunc_Open);
308
        }
302
        }
309
    }
303
    }
310
    else  // everything else send a return key
304
    else  // everything else send a return key
311
        PortableKeyEvent(state, SDL_SCANCODE_RETURN, 0);
305
        PortableKeyEvent(state, SDL_SCANCODE_RETURN, 0);
312
}
306
}
313
307
314
void weaponWheelSelected(int enabled) { showWeaponsInventory(enabled ? true : false); }
308
void weaponWheelSelected(int enabled) { showWeaponsInventory(enabled ? true : false); }
315
309
316
void weaponWheelChosen(int segment)
310
void weaponWheelChosen(int segment)
317
{
311
{
318
    // LOGI("weaponWheel %d",segment);
312
    // LOGI("weaponWheel %d",segment);
319
    if (segment == -1 && droidinput.quickSelectWeapon)
313
    if (segment == -1 && droidinput.quickSelectWeapon)
320
        segment = PortableRead(READ_LASTWEAPON);
314
        segment = PortableRead(READ_LASTWEAPON);
321
315
322
    if (segment != -1)
316
    if (segment != -1)
323
        PortableAction(2, gamefunc_Weapon_1 + segment);
317
        PortableAction(2, gamefunc_Weapon_1 + segment);
324
}
318
}
325
319
326
void left_double_tap(int state)
320
void left_double_tap(int state)
327
{
321
{
328
    // LOGI("L double %d, droidinput.left_double_action = %d",state,droidinput.left_double_action);
322
    // LOGI("L double %d, droidinput.left_double_action = %d",state,droidinput.left_double_action);
329
    if (droidinput.left_double_action != -1)
323
    if (droidinput.left_double_action != -1)
330
        PortableAction(state, droidinput.left_double_action);
324
        PortableAction(state, droidinput.left_double_action);
331
}
325
}
332
326
333
void right_double_tap(int state)
327
void right_double_tap(int state)
334
{
328
{
335
    // LOGTOUCH("R double %d",state);
329
    // LOGTOUCH("R double %d",state);
336
    if (droidinput.right_double_action != -1)
330
    if (droidinput.right_double_action != -1)
337
        PortableAction(state, droidinput.right_double_action);
331
        PortableAction(state, droidinput.right_double_action);
338
}
332
}
339
333
340
void mouseMove(int action, float x, float y, float dx, float dy)
334
void mouseMove(int action, float x, float y, float dx, float dy)
341
{
335
{
342
    // LOGI(" mouse dx = %f, dy = %f",dx,dy);
336
    // LOGI(" mouse dx = %f, dy = %f",dx,dy);
343
    if (weaponWheelVisible)
337
    if (weaponWheelVisible)
344
        return;
338
        return;
345
339
346
    float const scale = .1f;
340
    float const scale = .1f;
347
341
348
    PortableLook(dx * droidinput.yaw_sens * scale, -dy * droidinput.pitch_sens * scale * (droidinput.invertLook ? -1.f : 1.f));
342
    PortableLook(dx * droidinput.yaw_sens * scale, -dy * droidinput.pitch_sens * scale * (droidinput.invertLook ? -1.f : 1.f));
349
}
343
}
350
344
351
void automap_multitouch_mouse_move(int action, float x, float y, float dx, float dy)
345
void automap_multitouch_mouse_move(int action, float x, float y, float dx, float dy)
352
{
346
{
353
    if (action == MULTITOUCHMOUSE_MOVE)
347
    if (action == MULTITOUCHMOUSE_MOVE)
354
        PortableAutomapControl(0, dx, dy);
348
        PortableAutomapControl(0, dx, dy);
355
    else if (action == MULTITOUCHMOUSE_ZOOM)
349
    else if (action == MULTITOUCHMOUSE_ZOOM)
356
        PortableAutomapControl(x, 0, 0);
350
        PortableAutomapControl(x, 0, 0);
357
}
351
}
358
352
359
void left_stick(float joy_x, float joy_y, float mouse_x, float mouse_y)
353
void left_stick(float joy_x, float joy_y, float mouse_x, float mouse_y)
360
{
354
{
361
    // LOGI("left_stick joy_x = %f, joy_y = %f",joy_x,joy_y);
355
    // LOGI("left_stick joy_x = %f, joy_y = %f",joy_x,joy_y);
362
    PortableMove(joy_y * droidinput.forward_sens, -joy_x * droidinput.strafe_sens);
356
    PortableMove(joy_y * droidinput.forward_sens, -joy_x * droidinput.strafe_sens);
363
}
357
}
364
358
365
/*
359
/*
366
void right_stick(float joy_x, float joy_y, float mouse_x, float mouse_y)
360
void right_stick(float joy_x, float joy_y, float mouse_x, float mouse_y)
367
{
361
{
368
    mouseMove(0, joy_x, joy_y, mouse_x, mouse_y);
362
    mouseMove(0, joy_x, joy_y, mouse_x, mouse_y);
369
}
363
}
370
*/
364
*/
371
365
372
void setHideSticks(bool v)
366
void setHideSticks(bool v)
373
{
367
{
374
    if (touchJoyLeft)
368
    if (touchJoyLeft)
375
        touchJoyLeft->setHideGraphics(v);
369
        touchJoyLeft->setHideGraphics(v);
376
}
370
}
377
371
378
void touchSettingsButton(int state)
372
void touchSettingsButton(int state)
379
{
373
{
380
    /*
374
    /*
381
    int32_t paused = PortableRead(READ_PAUSED);
375
    int32_t paused = PortableRead(READ_PAUSED);
382

376

383
    //We wanna pause the game when doing settings
377
    //We wanna pause the game when doing settings
384
    if (state && !paused || !state && paused)
378
    if (state && !paused || !state && paused)
385
    {
379
    {
386
        PortableKeyEvent(2, SDL_SCANCODE_PAUSE, 0);
380
        PortableKeyEvent(2, SDL_SCANCODE_PAUSE, 0);
387
    }
381
    }
388
     */
382
     */
389
}
383
}
390
384
391
void initControls(int width, int height, const char *graphics_path)
385
void initControls(int width, int height, const char *graphics_path)
392
{
386
{
393
    touchcontrols::GLScaleWidth = (float)width;
387
    touchcontrols::GLScaleWidth = (float)width;
394
    touchcontrols::GLScaleHeight = (float)-height;
388
    touchcontrols::GLScaleHeight = (float)-height;
395
389
396
    LOGI("initControls %d x %d,x path = %s", width, height, graphics_path);
390
    LOGI("initControls %d x %d,x path = %s", width, height, graphics_path);
397
391
398
    if (!controlsCreated)
392
    if (!controlsCreated)
399
    {
393
    {
400
        LOGI("creating controls");
394
        LOGI("creating controls");
401
395
402
        touchcontrols::setGraphicsBasePath(graphics_path);
396
        touchcontrols::setGraphicsBasePath(graphics_path);
403
397
404
        controlsContainer.openGL_start.connect(sigc::ptr_fun(&openGLStart));
398
        controlsContainer.openGL_start.connect(sigc::ptr_fun(&openGLStart));
405
        controlsContainer.openGL_end.connect(sigc::ptr_fun(&openGLEnd));
399
        controlsContainer.openGL_end.connect(sigc::ptr_fun(&openGLEnd));
406
        controlsContainer.signal_settings.connect(sigc::ptr_fun(&touchSettingsButton));
400
        controlsContainer.signal_settings.connect(sigc::ptr_fun(&touchSettingsButton));
407
401
408
        tcBlankTap = new touchcontrols::TouchControls("blank_tap", false, false);
402
        tcBlankTap = new touchcontrols::TouchControls("blank_tap", false, false);
409
        tcYesNo = new touchcontrols::TouchControls("yes_no", false, false);
403
        tcYesNo = new touchcontrols::TouchControls("yes_no", false, false);
410
        tcMenuMain = new touchcontrols::TouchControls("menu", false, false);
404
        tcMenuMain = new touchcontrols::TouchControls("menu", false, false);
411
        tcGameMain = new touchcontrols::TouchControls("game", false, true, 1, true);
405
        tcGameMain = new touchcontrols::TouchControls("game", false, true, 1, true);
412
        tcGameWeapons = new touchcontrols::TouchControls("weapons", false, true, 1, false);
406
        tcGameWeapons = new touchcontrols::TouchControls("weapons", false, true, 1, false);
413
        tcAutomap = new touchcontrols::TouchControls("automap", false, false);
407
        tcAutomap = new touchcontrols::TouchControls("automap", false, false);
414
        // tcInventory   = new touchcontrols::TouchControls("inventory", false,true,1,false);
408
        // tcInventory   = new touchcontrols::TouchControls("inventory", false,true,1,false);
415
409
416
        ///////////////////////// BLANK TAP SCREEN //////////////////////
410
        ///////////////////////// BLANK TAP SCREEN //////////////////////
417
411
418
        // One button on whole screen with no graphic, send a return key
412
        // One button on whole screen with no graphic, send a return key
419
        tcBlankTap->addControl(new touchcontrols::Button("whole_screen", touchcontrols::RectF(0, 0, 26, 16),
413
        tcBlankTap->addControl(new touchcontrols::Button("whole_screen", touchcontrols::RectF(0, 0, 26, 16),
420
                                                         "" /*std::string("test")*/, SDL_SCANCODE_RETURN));
414
                                                         "" /*std::string("test")*/, SDL_SCANCODE_RETURN));
421
        tcBlankTap->signal_button.connect(sigc::ptr_fun(&blankTapButton));  // Just reuse the menuButton function
415
        tcBlankTap->signal_button.connect(sigc::ptr_fun(&blankTapButton));  // Just reuse the menuButton function
422
416
423
417
424
        ///////////////////////// YES NO SCREEN /////////////////////
418
        ///////////////////////// YES NO SCREEN /////////////////////
425
419
426
        tcYesNo->addControl(
420
        tcYesNo->addControl(
427
        new touchcontrols::Button("enter", touchcontrols::RectF(16, 9, 18, 11), "yes", SDL_SCANCODE_RETURN));
421
        new touchcontrols::Button("enter", touchcontrols::RectF(16, 9, 18, 11), "yes", SDL_SCANCODE_RETURN));
428
        tcYesNo->addControl(
422
        tcYesNo->addControl(
429
        new touchcontrols::Button("esc", touchcontrols::RectF(8, 9, 10, 11), "no", SDL_SCANCODE_ESCAPE));
423
        new touchcontrols::Button("esc", touchcontrols::RectF(8, 9, 10, 11), "no", SDL_SCANCODE_ESCAPE));
430
        tcYesNo->signal_button.connect(sigc::ptr_fun(&menuButton));  // Just reuse the menuButton function
424
        tcYesNo->signal_button.connect(sigc::ptr_fun(&menuButton));  // Just reuse the menuButton function
431
425
432
426
433
        ///////////////////////// MAIN MENU SCREEN /////////////////////
427
        ///////////////////////// MAIN MENU SCREEN /////////////////////
434
428
435
        /*
429
        /*
436
        tcMenuMain->addControl(new touchcontrols::Button("down_arrow",  touchcontrols::RectF(22,14,24,16),
430
        tcMenuMain->addControl(new touchcontrols::Button("down_arrow",  touchcontrols::RectF(22,14,24,16),
437
        "arrow_down",   SDL_SCANCODE_DOWN,  true)); //Repeating buttons
431
        "arrow_down",   SDL_SCANCODE_DOWN,  true)); //Repeating buttons
438
        tcMenuMain->addControl(new touchcontrols::Button("up_arrow",    touchcontrols::RectF(22,12,24,14),  "arrow_up",
432
        tcMenuMain->addControl(new touchcontrols::Button("up_arrow",    touchcontrols::RectF(22,12,24,14),  "arrow_up",
439
        SDL_SCANCODE_UP,    true));
433
        SDL_SCANCODE_UP,    true));
440
        tcMenuMain->addControl(new touchcontrols::Button("left_arrow",  touchcontrols::RectF(20,14,22,16),
434
        tcMenuMain->addControl(new touchcontrols::Button("left_arrow",  touchcontrols::RectF(20,14,22,16),
441
        "arrow_left",   SDL_SCANCODE_LEFT,  true));
435
        "arrow_left",   SDL_SCANCODE_LEFT,  true));
442
        tcMenuMain->addControl(new touchcontrols::Button("right_arrow", touchcontrols::RectF(24,14,26,16),
436
        tcMenuMain->addControl(new touchcontrols::Button("right_arrow", touchcontrols::RectF(24,14,26,16),
443
        "arrow_right",  SDL_SCANCODE_RIGHT, true));
437
        "arrow_right",  SDL_SCANCODE_RIGHT, true));
444
        tcMenuMain->addControl(new touchcontrols::Button("enter",       touchcontrols::RectF(0,14,2,16),    "enter",
438
        tcMenuMain->addControl(new touchcontrols::Button("enter",       touchcontrols::RectF(0,14,2,16),    "enter",
445
        SDL_SCANCODE_RETURN));
439
        SDL_SCANCODE_RETURN));
446
        tcMenuMain->setAlpha(1);
440
        tcMenuMain->setAlpha(1);
447
         */
441
         */
448
442
449
        tcMenuMain->addControl(new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 2, 2, 4), "arrow_left",
443
        tcMenuMain->addControl(new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 2, 2, 4), "arrow_left",
450
            SDL_SCANCODE_ESCAPE));
444
            SDL_SCANCODE_ESCAPE));
451
        tcMenuMain->signal_button.connect(sigc::ptr_fun(&menuButton));
445
        tcMenuMain->signal_button.connect(sigc::ptr_fun(&menuButton));
452
446
453
        touchcontrols::MultitouchMouse *mouseMenu =
447
        touchcontrols::MultitouchMouse *mouseMenu =
454
        new touchcontrols::MultitouchMouse("mouse", touchcontrols::RectF(0, 0, 26, 16), "");
448
        new touchcontrols::MultitouchMouse("mouse", touchcontrols::RectF(0, 0, 26, 16), "");
455
        mouseMenu->setHideGraphics(true);
449
        mouseMenu->setHideGraphics(true);
456
        tcMenuMain->addControl(mouseMenu);
450
        tcMenuMain->addControl(mouseMenu);
457
        mouseMenu->signal_action.connect(sigc::ptr_fun(&menuMouse));
451
        mouseMenu->signal_action.connect(sigc::ptr_fun(&menuMouse));
458
452
459
        touchcontrols::Button *console_button = new touchcontrols::Button(
453
        touchcontrols::Button *console_button = new touchcontrols::Button(
460
            "keyboard", "Development console", touchcontrols::RectF(8, 0, 10, 2), "keyboard", KEY_SHOW_KBRD, false, true);
454
            "keyboard", "Development console", touchcontrols::RectF(8, 0, 10, 2), "keyboard", KEY_SHOW_KBRD, false, true);
461
455
462
        tcMenuMain->addControl(console_button);
456
        tcMenuMain->addControl(console_button);
463
457
464
        //////////////////////////// GAME SCREEN /////////////////////
458
        //////////////////////////// GAME SCREEN /////////////////////
465
        tcGameMain->setAlpha(droidinput.gameControlsAlpha);
459
        tcGameMain->setAlpha(droidinput.gameControlsAlpha);
466
        controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
460
        controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
467
       
461
       
468
        tcGameMain->addControl(
462
        tcGameMain->addControl(
469
        new touchcontrols::Button("game_menu", touchcontrols::RectF(0, 0, 2, 2), "settings_bars", MENU_BACK));
463
        new touchcontrols::Button("game_menu", touchcontrols::RectF(0, 0, 2, 2), "settings_bars", MENU_BACK));
470
464
471
        tcGameMain->addControl(
465
        tcGameMain->addControl(
472
        new touchcontrols::Button("use", touchcontrols::RectF(20, 4, 23, 7), "use", gamefunc_Open));
466
        new touchcontrols::Button("use", touchcontrols::RectF(20, 4, 23, 7), "use", gamefunc_Open));
473
        tcGameMain->addControl(
467
        tcGameMain->addControl(
474
        new touchcontrols::Button("attack", touchcontrols::RectF(20, 7, 23, 10), "fire2", gamefunc_Fire));
468
        new touchcontrols::Button("attack", touchcontrols::RectF(20, 7, 23, 10), "fire2", gamefunc_Fire));
475
        tcGameMain->addControl(
469
        tcGameMain->addControl(
476
        new touchcontrols::Button("jump", touchcontrols::RectF(23, 6, 26, 9), "jump", gamefunc_Jump));
470
        new touchcontrols::Button("jump", touchcontrols::RectF(23, 6, 26, 9), "jump", gamefunc_Jump));
477
        tcGameMain->addControl(
471
        tcGameMain->addControl(
478
        new touchcontrols::Button("crouch", touchcontrols::RectF(24, 12, 26, 14), "crouch", gamefunc_Crouch));
472
        new touchcontrols::Button("crouch", touchcontrols::RectF(24, 12, 26, 14), "crouch", gamefunc_Crouch));
479
        tcGameMain->addControl(new touchcontrols::Button("kick", "Mighty Foot", touchcontrols::RectF(23, 3, 26, 6),
473
        tcGameMain->addControl(new touchcontrols::Button("kick", "Mighty Foot", touchcontrols::RectF(23, 3, 26, 6),
480
                                                         "boot", gamefunc_Quick_Kick, false, true));
474
                                                         "boot", gamefunc_Quick_Kick, false, true));
481
475
482
        touchcontrols::Button *map_button = new touchcontrols::Button(
476
        touchcontrols::Button *map_button = new touchcontrols::Button(
483
        "map", "Overhead map", touchcontrols::RectF(6, 0, 8, 2), "map", gamefunc_Map, false, true);
477
        "map", "Overhead map", touchcontrols::RectF(6, 0, 8, 2), "map", gamefunc_Map, false, true);
484
        tcGameMain->addControl(map_button);
478
        tcGameMain->addControl(map_button);
485
        tcGameMain->addControl(new touchcontrols::Button("show_inventory", "Inventory",
479
        tcGameMain->addControl(new touchcontrols::Button("show_inventory", "Inventory",
486
                                                         touchcontrols::RectF(24, 0, 26, 2), "inv", KEY_SHOW_INVEN));
480
                                                         touchcontrols::RectF(24, 0, 26, 2), "inv", KEY_SHOW_INVEN));
487
        tcGameMain->addControl(new touchcontrols::Button("next_weapon", "Next weapon", touchcontrols::RectF(0, 3, 3, 5),
481
        tcGameMain->addControl(new touchcontrols::Button("next_weapon", "Next weapon", touchcontrols::RectF(0, 3, 3, 5),
488
                                                         "next_weap", gamefunc_Next_Weapon, false, true));
482
                                                         "next_weap", gamefunc_Next_Weapon, false, true));
489
        tcGameMain->addControl(new touchcontrols::Button("prev_weapon", "Previous weapon",
483
        tcGameMain->addControl(new touchcontrols::Button("prev_weapon", "Previous weapon",
490
                                                         touchcontrols::RectF(0, 5, 3, 7), "prev_weap",
484
                                                         touchcontrols::RectF(0, 5, 3, 7), "prev_weap",
491
                                                         gamefunc_Previous_Weapon, false, true));
485
                                                         gamefunc_Previous_Weapon, false, true));
492
        tcGameMain->addControl(new touchcontrols::Button("quick_save", "Save game", touchcontrols::RectF(22, 0, 24, 2),
486
        tcGameMain->addControl(new touchcontrols::Button("quick_save", "Save game", touchcontrols::RectF(22, 0, 24, 2),
493
                                                         "save", KEY_QUICK_SAVE, false, true));
487
                                                         "save", KEY_QUICK_SAVE, false, true));
494
        tcGameMain->addControl(new touchcontrols::Button("quick_load", "Load game", touchcontrols::RectF(20, 0, 22, 2),
488
        tcGameMain->addControl(new touchcontrols::Button("quick_load", "Load game", touchcontrols::RectF(20, 0, 22, 2),
495
                                                         "load", KEY_QUICK_LOAD, false, true));
489
                                                         "load", KEY_QUICK_LOAD, false, true));
496
490
497
        tcGameMain->addControl(console_button);
491
        tcGameMain->addControl(console_button);
498
        /*
492
        /*
499
                //quick actions binds
493
                //quick actions binds
500
                tcGameMain->addControl(new
494
                tcGameMain->addControl(new
501
           touchcontrols::Button("quick_key_1",touchcontrols::RectF(4,3,6,5),"quick_key_1",KEY_QUICK_KEY1,false,true));
495
           touchcontrols::Button("quick_key_1",touchcontrols::RectF(4,3,6,5),"quick_key_1",KEY_QUICK_KEY1,false,true));
502
                tcGameMain->addControl(new
496
                tcGameMain->addControl(new
503
           touchcontrols::Button("quick_key_2",touchcontrols::RectF(6,3,8,5),"quick_key_2",KEY_QUICK_KEY2,false,true));
497
           touchcontrols::Button("quick_key_2",touchcontrols::RectF(6,3,8,5),"quick_key_2",KEY_QUICK_KEY2,false,true));
504
                tcGameMain->addControl(new
498
                tcGameMain->addControl(new
505
           touchcontrols::Button("quick_key_3",touchcontrols::RectF(8,3,10,5),"quick_key_3",KEY_QUICK_KEY3,false,true));
499
           touchcontrols::Button("quick_key_3",touchcontrols::RectF(8,3,10,5),"quick_key_3",KEY_QUICK_KEY3,false,true));
506
                tcGameMain->addControl(new
500
                tcGameMain->addControl(new
507
           touchcontrols::Button("quick_key_4",touchcontrols::RectF(10,3,12,5),"quick_key_4",KEY_QUICK_KEY4,false,true));
501
           touchcontrols::Button("quick_key_4",touchcontrols::RectF(10,3,12,5),"quick_key_4",KEY_QUICK_KEY4,false,true));
508
         */
502
         */
509
        // Left stick
503
        // Left stick
510
        touchJoyLeft = new touchcontrols::TouchJoy("stick", touchcontrols::RectF(0, 7, 8, 16), "strafe_arrow");
504
        touchJoyLeft = new touchcontrols::TouchJoy("stick", touchcontrols::RectF(0, 7, 8, 16), "strafe_arrow");
511
        tcGameMain->addControl(touchJoyLeft);
505
        tcGameMain->addControl(touchJoyLeft);
512
        touchJoyLeft->signal_move.connect(sigc::ptr_fun(&left_stick));
506
        touchJoyLeft->signal_move.connect(sigc::ptr_fun(&left_stick));
513
        touchJoyLeft->signal_double_tap.connect(sigc::ptr_fun(&left_double_tap));
507
        touchJoyLeft->signal_double_tap.connect(sigc::ptr_fun(&left_double_tap));
514
508
515
        // Right stick (not used)
509
        // Right stick (not used)
516
        // touchJoyRight = new touchcontrols::TouchJoy("touch",touchcontrols::RectF(17,7,26,16),"look_arrow");
510
        // touchJoyRight = new touchcontrols::TouchJoy("touch",touchcontrols::RectF(17,7,26,16),"look_arrow");
517
        // tcGameMain->addControl(touchJoyRight);
511
        // tcGameMain->addControl(touchJoyRight);
518
        // touchJoyRight->signal_move.connect(sigc::ptr_fun(&right_stick) );
512
        // touchJoyRight->signal_move.connect(sigc::ptr_fun(&right_stick) );
519
        // touchJoyRight->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap) );
513
        // touchJoyRight->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap) );
520
        // touchJoyRight->setEnabled(false);
514
        // touchJoyRight->setEnabled(false);
521
515
522
516
523
        // Mouse look for whole screen
517
        // Mouse look for whole screen
524
        touchcontrols::Mouse *mouse = new touchcontrols::Mouse("mouse", touchcontrols::RectF(3, 0, 26, 16), "");
518
        touchcontrols::Mouse *mouse = new touchcontrols::Mouse("mouse", touchcontrols::RectF(3, 0, 26, 16), "");
525
        mouse->signal_action.connect(sigc::ptr_fun(&mouseMove));
519
        mouse->signal_action.connect(sigc::ptr_fun(&mouseMove));
526
        mouse->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap));
520
        mouse->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap));
527
521
528
        mouse->setHideGraphics(true);
522
        mouse->setHideGraphics(true);
529
        tcGameMain->addControl(mouse);
523
        tcGameMain->addControl(mouse);
530
524
531
        tcGameMain->signal_button.connect(sigc::ptr_fun(&gameButton));
525
        tcGameMain->signal_button.connect(sigc::ptr_fun(&gameButton));
532
        tcGameMain->signal_settingsButton.connect(sigc::ptr_fun(&gameSettingsButton));
526
        tcGameMain->signal_settingsButton.connect(sigc::ptr_fun(&gameSettingsButton));
533
527
534
        ///////////////////////// AUTO MAP SCREEN ///////////////////////
528
        ///////////////////////// AUTO MAP SCREEN ///////////////////////
535
529
536
530
537
        // Automap
531
        // Automap
538
        touchcontrols::MultitouchMouse *multimouse =
532
        touchcontrols::MultitouchMouse *multimouse =
539
        new touchcontrols::MultitouchMouse("gamemouse", touchcontrols::RectF(0, 0, 26, 16), "");
533
        new touchcontrols::MultitouchMouse("gamemouse", touchcontrols::RectF(0, 0, 26, 16), "");
540
        multimouse->setHideGraphics(true);
534
        multimouse->setHideGraphics(true);
541
        tcAutomap->addControl(multimouse);
535
        tcAutomap->addControl(multimouse);
542
        multimouse->signal_action.connect(sigc::ptr_fun(&automap_multitouch_mouse_move));
536
        multimouse->signal_action.connect(sigc::ptr_fun(&automap_multitouch_mouse_move));
543
        tcAutomap->addControl(map_button);
537
        tcAutomap->addControl(map_button);
544
        tcAutomap->signal_button.connect(sigc::ptr_fun(&gameButton));
538
        tcAutomap->signal_button.connect(sigc::ptr_fun(&gameButton));
545
        tcAutomap->setAlpha(0.5);
539
        tcAutomap->setAlpha(0.5);
546
540
547
        // Now inventory in the weapons control group!
541
        // Now inventory in the weapons control group!
548
542
549
        inv_buttons[GET_JETPACK] = new touchcontrols::Button("jetpack", touchcontrols::RectF(0, 3, 2, 5), "jetpack",
543
        inv_buttons[GET_JETPACK] = new touchcontrols::Button("jetpack", touchcontrols::RectF(0, 3, 2, 5), "jetpack",
550
                                                             gamefunc_Jetpack, false, false, true);
544
                                                             gamefunc_Jetpack, false, false, true);
551
        inv_buttons[GET_FIRSTAID] = new touchcontrols::Button("medkit", touchcontrols::RectF(0, 5, 2, 7), "medkit",
545
        inv_buttons[GET_FIRSTAID] = new touchcontrols::Button("medkit", touchcontrols::RectF(0, 5, 2, 7), "medkit",
552
                                                              gamefunc_MedKit, false, false, true);
546
                                                              gamefunc_MedKit, false, false, true);
553
        inv_buttons[GET_HEATS] = new touchcontrols::Button("nightv", touchcontrols::RectF(0, 7, 2, 9), "nightvision",
547
        inv_buttons[GET_HEATS] = new touchcontrols::Button("nightv", touchcontrols::RectF(0, 7, 2, 9), "nightvision",
554
                                                           gamefunc_NightVision, false, false, true);
548
                                                           gamefunc_NightVision, false, false, true);
555
        inv_buttons[GET_HOLODUKE] = new touchcontrols::Button("holoduke", touchcontrols::RectF(0, 9, 2, 11), "holoduke",
549
        inv_buttons[GET_HOLODUKE] = new touchcontrols::Button("holoduke", touchcontrols::RectF(0, 9, 2, 11), "holoduke",
556
                                                              gamefunc_Holo_Duke, false, false, true);
550
                                                              gamefunc_Holo_Duke, false, false, true);
557
        inv_buttons[GET_STEROIDS] = new touchcontrols::Button("steroids", touchcontrols::RectF(0, 11, 2, 13),
551
        inv_buttons[GET_STEROIDS] = new touchcontrols::Button("steroids", touchcontrols::RectF(0, 11, 2, 13),
558
                                                              "steroids", gamefunc_Steroids, false, false, true);
552
                                                              "steroids", gamefunc_Steroids, false, false, true);
559
553
560
        tcGameWeapons->addControl(inv_buttons[GET_JETPACK]);
554
        tcGameWeapons->addControl(inv_buttons[GET_JETPACK]);
561
        tcGameWeapons->addControl(inv_buttons[GET_FIRSTAID]);
555
        tcGameWeapons->addControl(inv_buttons[GET_FIRSTAID]);
562
        tcGameWeapons->addControl(inv_buttons[GET_HEATS]);
556
        tcGameWeapons->addControl(inv_buttons[GET_HEATS]);
563
        tcGameWeapons->addControl(inv_buttons[GET_HOLODUKE]);
557
        tcGameWeapons->addControl(inv_buttons[GET_HOLODUKE]);
564
        tcGameWeapons->addControl(inv_buttons[GET_STEROIDS]);
558
        tcGameWeapons->addControl(inv_buttons[GET_STEROIDS]);
565
        // Inventory are the only buttons so safe to do this
559
        // Inventory are the only buttons so safe to do this
566
        tcGameWeapons->signal_button.connect(sigc::ptr_fun(&inventoryButton));
560
        tcGameWeapons->signal_button.connect(sigc::ptr_fun(&inventoryButton));
567
561
568
        // Weapons
562
        // Weapons
569
        weaponWheel = new touchcontrols::WheelSelect("weapon_wheel", touchcontrols::RectF(7, 2, 19, 14),
563
        weaponWheel = new touchcontrols::WheelSelect("weapon_wheel", touchcontrols::RectF(7, 2, 19, 14),
570
                                                     "weapon_wheel_orange_blank", 10);
564
                                                     "weapon_wheel_orange_blank", 10);
571
        weaponWheel->signal_selected.connect(sigc::ptr_fun(&weaponWheelChosen));
565
        weaponWheel->signal_selected.connect(sigc::ptr_fun(&weaponWheelChosen));
572
        weaponWheel->signal_enabled.connect(sigc::ptr_fun(&weaponWheelSelected));
566
        weaponWheel->signal_enabled.connect(sigc::ptr_fun(&weaponWheelSelected));
573
        tcGameWeapons->addControl(weaponWheel);
567
        tcGameWeapons->addControl(weaponWheel);
574
        tcGameWeapons->setAlpha(0.9);
568
        tcGameWeapons->setAlpha(0.9);
575
569
576
        /////////////////////////////////////////////////////////////
570
        /////////////////////////////////////////////////////////////
577
571
578
572
579
        controlsContainer.addControlGroup(tcMenuMain);
573
        controlsContainer.addControlGroup(tcMenuMain);
580
        controlsContainer.addControlGroup(tcGameMain);
574
        controlsContainer.addControlGroup(tcGameMain);
581
        //        controlsContainer.addControlGroup(tcInventory);//Need to be above tcGameMain incase buttons over stick
575
        //        controlsContainer.addControlGroup(tcInventory);//Need to be above tcGameMain incase buttons over stick
582
        controlsContainer.addControlGroup(tcGameWeapons);
576
        controlsContainer.addControlGroup(tcGameWeapons);
583
        controlsContainer.addControlGroup(tcAutomap);
577
        controlsContainer.addControlGroup(tcAutomap);
584
        controlsContainer.addControlGroup(tcYesNo);
578
        controlsContainer.addControlGroup(tcYesNo);
585
        controlsContainer.addControlGroup(tcBlankTap);
579
        controlsContainer.addControlGroup(tcBlankTap);
586
        controlsCreated = 1;
580
        controlsCreated = 1;
587
581
588
        tcGameMain->setAlpha(droidinput.gameControlsAlpha);
582
        tcGameMain->setAlpha(droidinput.gameControlsAlpha);
589
        controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
583
        controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
590
        tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
584
        tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
591
        tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
585
        tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
592
586
593
        tcGameMain->setXMLFile(gamePath + "/control_layout_main.xml");
587
        tcGameMain->setXMLFile(gamePath + "/control_layout_main.xml");
594
        tcGameWeapons->setXMLFile(gamePath + "/control_layout_weapons.xml");
588
        tcGameWeapons->setXMLFile(gamePath + "/control_layout_weapons.xml");
595
        tcAutomap->setXMLFile(gamePath + "/control_layout_automap.xml");
589
        tcAutomap->setXMLFile(gamePath + "/control_layout_automap.xml");
596
        // tcInventory->setXMLFile((std::string)graphics_path +  "/inventory.xml");
590
        // tcInventory->setXMLFile((std::string)graphics_path +  "/inventory.xml");
597
591
598
        setControlsContainer(&controlsContainer);
592
        setControlsContainer(&controlsContainer);
599
    }
593
    }
600
    else
594
    else
601
        LOGI("NOT creating controls");
595
        LOGI("NOT creating controls");
602
596
603
    // controlsContainer.initGL();
597
    // controlsContainer.initGL();
604
}
598
}
605
599
606
void updateTouchScreenMode(touchscreemode_t mode)
600
void updateTouchScreenMode(touchscreemode_t mode)
607
{
601
{
608
    // LOGI("updateTouchScreenModeA %d",mode);
602
    // LOGI("updateTouchScreenModeA %d",mode);
609
603
610
    static touchscreemode_t lastMode = TOUCH_SCREEN_BLANK;
604
    static touchscreemode_t lastMode = TOUCH_SCREEN_BLANK;
611
605
612
    if (mode != lastMode)
606
    if (mode != lastMode)
613
    {
607
    {
614
        // first disable the last screen and fade out is necessary
608
        // first disable the last screen and fade out is necessary
615
        switch (lastMode)
609
        switch (lastMode)
616
        {
610
        {
617
            case TOUCH_SCREEN_BLANK:  // Does not exist yet break;
611
            case TOUCH_SCREEN_BLANK:  // Does not exist yet break;
618
            case TOUCH_SCREEN_BLANK_TAP:
612
            case TOUCH_SCREEN_BLANK_TAP:
619
                tcBlankTap->resetOutput();
613
                tcBlankTap->resetOutput();
620
                tcBlankTap->setEnabled(false);  // Dont fade out as no graphics
614
                tcBlankTap->setEnabled(false);  // Dont fade out as no graphics
621
                break;
615
                break;
622
            case TOUCH_SCREEN_YES_NO:
616
            case TOUCH_SCREEN_YES_NO:
623
                tcYesNo->resetOutput();
617
                tcYesNo->resetOutput();
624
                tcYesNo->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
618
                tcYesNo->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
625
                break;
619
                break;
626
            case TOUCH_SCREEN_MENU:
620
            case TOUCH_SCREEN_MENU:
627
                tcMenuMain->resetOutput();
621
                tcMenuMain->resetOutput();
628
                tcMenuMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
622
                tcMenuMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
629
                break;
623
                break;
630
            case TOUCH_SCREEN_GAME:
624
            case TOUCH_SCREEN_GAME:
631
                tcGameMain->resetOutput();
625
                tcGameMain->resetOutput();
632
626
633
                tcGameMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
627
                tcGameMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
634
                tcGameWeapons->setEnabled(false);
628
                tcGameWeapons->setEnabled(false);
635
                break;
629
                break;
636
            case TOUCH_SCREEN_AUTOMAP:
630
            case TOUCH_SCREEN_AUTOMAP:
637
                tcAutomap->resetOutput();
631
                tcAutomap->resetOutput();
638
                tcAutomap->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
632
                tcAutomap->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
639
                break;
633
                break;
640
            case TOUCH_SCREEN_CONSOLE: break;
634
            case TOUCH_SCREEN_CONSOLE: break;
641
        }
635
        }
642
636
643
        // Enable the current new screen
637
        // Enable the current new screen
644
        switch (mode)
638
        switch (mode)
645
        {
639
        {
646
            case TOUCH_SCREEN_BLANK:  // Does not exist yet break;
640
            case TOUCH_SCREEN_BLANK:  // Does not exist yet break;
647
            case TOUCH_SCREEN_BLANK_TAP: tcBlankTap->setEnabled(true); break;
641
            case TOUCH_SCREEN_BLANK_TAP: tcBlankTap->setEnabled(true); break;
648
            case TOUCH_SCREEN_YES_NO:
642
            case TOUCH_SCREEN_YES_NO:
649
                tcYesNo->setEnabled(true);
643
                tcYesNo->setEnabled(true);
650
                tcYesNo->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
644
                tcYesNo->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
651
                break;
645
                break;
652
            case TOUCH_SCREEN_MENU:
646
            case TOUCH_SCREEN_MENU:
653
                tcMenuMain->setEnabled(true);
647
                tcMenuMain->setEnabled(true);
654
                tcMenuMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
648
                tcMenuMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
655
649
656
                // This is a bit of a hack, we need to enable the inventory buttons so they can be edited, they will not
650
                // This is a bit of a hack, we need to enable the inventory buttons so they can be edited, they will not
657
                // be seen anyway
651
                // be seen anyway
658
                showWeaponsInventory(true);
652
                showWeaponsInventory(true);
659
                break;
653
                break;
660
            case TOUCH_SCREEN_GAME:
654
            case TOUCH_SCREEN_GAME:
661
                tcGameMain->setEnabled(true);
655
                tcGameMain->setEnabled(true);
662
                tcGameMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
656
                tcGameMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
663
                tcGameWeapons->setEnabled(true);
657
                tcGameWeapons->setEnabled(true);
664
                showWeaponsInventory(false);
658
                showWeaponsInventory(false);
665
                break;
659
                break;
666
            case TOUCH_SCREEN_AUTOMAP:
660
            case TOUCH_SCREEN_AUTOMAP:
667
                tcAutomap->setEnabled(true);
661
                tcAutomap->setEnabled(true);
668
                tcAutomap->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
662
                tcAutomap->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
669
                break;
663
                break;
670
            case TOUCH_SCREEN_CONSOLE: break;
664
            case TOUCH_SCREEN_CONSOLE: break;
671
        }
665
        }
672
666
673
        lastMode = mode;
667
        lastMode = mode;
674
    }
668
    }
675
669
676
    int inv = PortableRead(READ_INVENTORY);
670
    int inv = PortableRead(READ_INVENTORY);
677
671
678
    for (int i = 0; i < GET_MAX; ++i)
672
    for (int i = 0; i < GET_MAX; ++i)
679
        if (inv_buttons[i])
673
        if (inv_buttons[i])
680
            inv_buttons[i]->setAlpha(tcGameWeapons->getFadedAlpha() * ((inv & (1 << i)) ? 1.f : 0.3f));
674
            inv_buttons[i]->setAlpha(tcGameWeapons->getFadedAlpha() * ((inv & (1 << i)) ? 1.f : 0.3f));
681
}
675
}
682
676
683
677
684
#ifdef GP_LIC
678
#ifdef GP_LIC
685
#define GP_LIC_INC 1
679
#define GP_LIC_INC 1
686
#include "s-setup/gp_lic_include.h"
680
#include "s-setup/gp_lic_include.h"
687
#endif
681
#endif
688
682
689
extern char videomodereset;
683
extern char videomodereset;
690
extern int mobile_halted;
684
extern int mobile_halted;
691
685
692
void frameControls()
686
void frameControls()
693
{
687
{
694
    if (mobile_halted) return;
688
    if (mobile_halted) return;
695
689
696
    static int loadedGLImages = 0;
690
    static int loadedGLImages = 0;
697
691
698
    if (videomodereset)
692
    if (videomodereset)
699
    {
693
    {
700
        loadedGLImages = -1;
694
        loadedGLImages = -1;
701
        return;
695
        return;
702
    }
696
    }
703
697
704
    // We need to do this here now because duke loads a new gl context
698
    // We need to do this here now because duke loads a new gl context
705
699
706
    if (loadedGLImages <= 0)
700
    if (loadedGLImages <= 0)
707
    {
701
    {
708
        controlsContainer.initGL(loadedGLImages == -1);
702
        controlsContainer.initGL(loadedGLImages == -1);
709
        loadedGLImages = 1;
703
        loadedGLImages = 1;
710
    }
704
    }
711
705
712
    //  LOGI("frameControls");
706
    //  LOGI("frameControls");
713
707
714
    curRenderer = (PortableRead(READ_RENDERER) != REND_CLASSIC);
708
    curRenderer = (PortableRead(READ_RENDERER) != REND_CLASSIC);
715
709
716
    updateTouchScreenMode((touchscreemode_t)PortableRead(READ_SCREEN_MODE));
710
    updateTouchScreenMode((touchscreemode_t)PortableRead(READ_SCREEN_MODE));
717
711
718
    setHideSticks(droidinput.hideStick);
712
    setHideSticks(droidinput.hideStick);
719
713
720
    if (tcGameMain)
714
    if (tcGameMain)
721
    {
715
    {
722
        tcGameMain->setAlpha(droidinput.gameControlsAlpha);
716
        tcGameMain->setAlpha(droidinput.gameControlsAlpha);
723
        controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
717
        controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
724
        tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
718
        tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
725
        tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
719
        tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
726
        // tcInventory->setAlpha(droidinput.gameControlsAlpha);
720
        // tcInventory->setAlpha(droidinput.gameControlsAlpha);
727
    }
721
    }
728
722
729
    controlsContainer.draw();
723
    controlsContainer.draw();
730
724
731
#ifdef GP_LIC
725
#ifdef GP_LIC
732
#undef GP_LIC_INC
726
#undef GP_LIC_INC
733
#define GP_LIC_INC 2
727
#define GP_LIC_INC 2
734
#include "s-setup/gp_lic_include.h"
728
#include "s-setup/gp_lic_include.h"
735
#endif
729
#endif
736
}
730
}
737
731
738
void setTouchSettings(int other)
732
void setTouchSettings(int other)
739
{
733
{
740
    // TODO: defined names for these values
734
    // TODO: defined names for these values
741
    hideTouchControls = other & 0x80000000 ? true : false;
735
    hideTouchControls = other & 0x80000000 ? true : false;
742
736
743
    // keep in sync with Duke3d/res/values/strings.xml
737
    // keep in sync with Duke3d/res/values/strings.xml
744
    int doubletap_options[5] = { -1, gamefunc_Quick_Kick, gamefunc_AutoRun, gamefunc_MedKit, gamefunc_Jetpack };
738
    int doubletap_options[5] = { -1, gamefunc_Quick_Kick, gamefunc_AutoRun, gamefunc_MedKit, gamefunc_Jetpack };
745
739
746
    droidinput.left_double_action = doubletap_options[((other >> 4) & 0xF)];
740
    droidinput.left_double_action = doubletap_options[((other >> 4) & 0xF)];
747
    droidinput.right_double_action = doubletap_options[((other >> 8) & 0xF)];
741
    droidinput.right_double_action = doubletap_options[((other >> 8) & 0xF)];
748
742
749
    LOGI("setTouchSettings left_double_action = %d", droidinput.left_double_action);
743
    LOGI("setTouchSettings left_double_action = %d", droidinput.left_double_action);
750
}
744
}
751
745
752
#define EXPORT_ME __NDK_FPABI__ __attribute__((visibility("default")))
746
#define EXPORT_ME __NDK_FPABI__ __attribute__((visibility("default")))
753
747
754
JNIEnv *env_;
748
JNIEnv *env_;
755
749
756
int argc = 1;
750
int argc = 1;
757
const char *argv[32];
751
const char *argv[32];
758
752
759
static inline const char *getGamePath() { return gamePath.c_str(); }
753
static inline const char *getGamePath() { return gamePath.c_str(); }
760
754
761
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobject thiz, jstring graphics_dir,
755
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobject thiz, jstring graphics_dir,
762
                                                               jint audio_rate, jint audio_buffer_size,
756
                                                               jint audio_rate, jint audio_buffer_size,
763
                                                               jobjectArray argsArray, jint renderer,
757
                                                               jobjectArray argsArray, jint renderer,
764
                                                               jstring jduke3d_path)
758
                                                               jstring jduke3d_path)
765
{
759
{
766
    env_ = env;
760
    env_ = env;
767
761
768
#ifdef GP_LIC
762
#ifdef GP_LIC
769
    getGlobalClasses(env_);
763
    getGlobalClasses(env_);
770
#endif
764
#endif
771
765
772
    droidinfo.audio_sample_rate = audio_rate;
766
    droidinfo.audio_sample_rate = audio_rate;
773
    droidinfo.audio_buffer_size = audio_buffer_size;
767
    droidinfo.audio_buffer_size = audio_buffer_size;
774
768
775
    // curRenderer = renderer;
769
    // curRenderer = renderer;
776
    curRenderer = REND_GL;
770
    curRenderer = REND_GL;
777
771
778
    argv[0] = "eduke32";
772
    argv[0] = "eduke32";
779
    int argCount = (env)->GetArrayLength(argsArray);
773
    int argCount = (env)->GetArrayLength(argsArray);
780
    LOGI("argCount = %d", argCount);
774
    LOGI("argCount = %d", argCount);
781
    for (int i = 0; i < argCount; i++)
775
    for (int i = 0; i < argCount; i++)
782
    {
776
    {
783
        jstring string = (jstring)(env)->GetObjectArrayElement(argsArray, i);
777
        jstring string = (jstring)(env)->GetObjectArrayElement(argsArray, i);
784
        argv[argc] = (char *)(env)->GetStringUTFChars(string, 0);
778
        argv[argc] = (char *)(env)->GetStringUTFChars(string, 0);
785
        LOGI("arg = %s", argv[argc]);
779
        LOGI("arg = %s", argv[argc]);
786
        argc++;
780
        argc++;
787
    }
781
    }
788
782
789
    gamePath = std::string(env->GetStringUTFChars(jduke3d_path, NULL));
783
    gamePath = std::string(env->GetStringUTFChars(jduke3d_path, NULL));
790
784
791
    // Change working dir, save games etc
785
    // Change working dir, save games etc
792
    // FIXME: potentially conflicts with chdirs in -game_dir support
786
    // FIXME: potentially conflicts with chdirs in -game_dir support
793
    chdir(getGamePath());
787
    chdir(getGamePath());
794
    char timidity_env[512];
788
    char timidity_env[512];
795
789
796
    sprintf(timidity_env, "TIMIDITY_CFG=%s/../timidity.cfg", getGamePath());
790
    sprintf(timidity_env, "TIMIDITY_CFG=%s/../timidity.cfg", getGamePath());
797
    putenv(timidity_env);
791
    putenv(timidity_env);
798
792
799
    LOGI("duke3d_path = %s", getGamePath());
793
    LOGI("duke3d_path = %s", getGamePath());
800
794
801
    const char *p = env->GetStringUTFChars(graphics_dir, NULL);
795
    const char *p = env->GetStringUTFChars(graphics_dir, NULL);
802
    obbPath = std::string(p);
796
    obbPath = std::string(p);
803
797
804
    LOGI("obbPath = %s", obbPath.c_str());
798
    LOGI("obbPath = %s", obbPath.c_str());
805
799
806
    initControls(droidinfo.screen_width, droidinfo.screen_height, (obbPath + "/assets/").c_str());
800
    initControls(droidinfo.screen_width, droidinfo.screen_height, (obbPath + "/assets/").c_str());
807
801
808
    PortableInit(argc, argv);
802
    PortableInit(argc, argv);
809
803
810
    return 0;
804
    return 0;
811
}
805
}
812
806
813
807
814
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_frame(JNIEnv *env, jobject thiz)
808
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_frame(JNIEnv *env, jobject thiz)
815
{
809
{
816
    LOGI("Java_com_voidpoint_duke3d_engine_NativeLib_frame");
810
    LOGI("Java_com_voidpoint_duke3d_engine_NativeLib_frame");
817
811
818
//    frameControls();
812
//    frameControls();
819
    return 0;
813
    return 0;
820
}
814
}
821
815
822
__attribute__((visibility("default"))) jint JNI_OnLoad(JavaVM *vm, void *reserved)
816
__attribute__((visibility("default"))) jint JNI_OnLoad(JavaVM *vm, void *reserved)
823
{
817
{
824
    LOGI("JNI_OnLoad");
818
    LOGI("JNI_OnLoad");
825
    setTCJNIEnv(vm);
819
    setTCJNIEnv(vm);
826
    jvm_ = vm;
820
    jvm_ = vm;
827
    return JNI_VERSION_1_4;
821
    return JNI_VERSION_1_4;
828
}
822
}
829
823
830
824
831
void EXPORT_ME
825
void EXPORT_ME
832
Java_com_voidpoint_duke3d_engine_NativeLib_keypress(JNIEnv *env, jobject obj, jint down, jint keycode, jint unicode)
826
Java_com_voidpoint_duke3d_engine_NativeLib_keypress(JNIEnv *env, jobject obj, jint down, jint keycode, jint unicode)
833
{
827
{
834
    LOGI("keypress %d", keycode);
828
    LOGI("keypress %d", keycode);
835
    if (controlsContainer.isEditing())
829
    if (controlsContainer.isEditing())
836
    {
830
    {
837
        if (down && (keycode == SDL_SCANCODE_ESCAPE))
831
        if (down && (keycode == SDL_SCANCODE_ESCAPE))
838
            controlsContainer.finishEditing();
832
            controlsContainer.finishEditing();
839
        return;
833
        return;
840
    }
834
    }
841
835
842
    PortableKeyEvent(down, keycode, unicode);
836
    PortableKeyEvent(down, keycode, unicode);
843
}
837
}
844
838
845
839
846
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_touchEvent(JNIEnv *env, jobject obj, jint action, jint pid,
840
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_touchEvent(JNIEnv *env, jobject obj, jint action, jint pid,
847
                                                                     jfloat x, jfloat y)
841
                                                                     jfloat x, jfloat y)
848
{
842
{
849
    // LOGI("TOUCHED");
843
    // LOGI("TOUCHED");
850
    controlsContainer.processPointer(action, pid, x, y);
844
    controlsContainer.processPointer(action, pid, x, y);
851
}
845
}
852
846
853
847
854
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_doAction(JNIEnv *env, jobject obj, jint state, jint action)
848
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_doAction(JNIEnv *env, jobject obj, jint state, jint action)
855
{
849
{
856
    LOGI("doAction %d %d", state, action);
850
    LOGI("doAction %d %d", state, action);
857
851
858
    // gamepadButtonPressed();
852
    // gamepadButtonPressed();
859
    if (hideTouchControls && tcGameMain)
853
    if (hideTouchControls && tcGameMain)
860
    {
854
    {
861
        if (tcGameMain->isEnabled())
855
        if (tcGameMain->isEnabled())
862
            tcGameMain->animateOut(30);
856
            tcGameMain->animateOut(30);
863
857
864
        if (tcGameWeapons->isEnabled())
858
        if (tcGameWeapons->isEnabled())
865
            tcGameWeapons->animateOut(30);
859
            tcGameWeapons->animateOut(30);
866
    }
860
    }
867
861
868
    PortableAction(state, action);
862
    PortableAction(state, action);
869
}
863
}
870
864
871
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogFwd(JNIEnv *env, jobject obj, jfloat v)
865
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogFwd(JNIEnv *env, jobject obj, jfloat v)
872
{
866
{
873
    PortableMove(v, NAN);
867
    PortableMove(v, NAN);
874
}
868
}
875
869
876
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogSide(JNIEnv *env, jobject obj, jfloat v)
870
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogSide(JNIEnv *env, jobject obj, jfloat v)
877
{
871
{
878
    PortableMove(NAN, v);
872
    PortableMove(NAN, v);
879
}
873
}
880
874
881
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogPitch(JNIEnv *env, jobject obj, jint mode, jfloat v)
875
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogPitch(JNIEnv *env, jobject obj, jint mode, jfloat v)
882
{
876
{
883
    PortableLookJoystick(NAN, v);
877
    PortableLookJoystick(NAN, v);
884
}
878
}
885
879
886
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogYaw(JNIEnv *env, jobject obj, jint mode, jfloat v)
880
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogYaw(JNIEnv *env, jobject obj, jint mode, jfloat v)
887
{
881
{
888
    PortableLookJoystick(v, NAN);
882
    PortableLookJoystick(v, NAN);
889
}
883
}
890
884
891
void EXPORT_ME
885
void EXPORT_ME
892
Java_com_voidpoint_duke3d_engine_NativeLib_setTouchSettings(JNIEnv *env, jobject obj, int other)
886
Java_com_voidpoint_duke3d_engine_NativeLib_setTouchSettings(JNIEnv *env, jobject obj, int other)
893
{
887
{
894
    setTouchSettings(other);
888
    setTouchSettings(other);
895
}
889
}
896
890
897
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_resetTouchSettings(JNIEnv *env, jobject obj)
891
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_resetTouchSettings(JNIEnv *env, jobject obj)
898
{
892
{
899
    controlsContainer.resetDefaults();
893
    controlsContainer.resetDefaults();
900
}
894
}
901
895
902
std::string quickCommandString;
896
std::string quickCommandString;
903
897
904
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_quickCommand(JNIEnv *env, jobject obj, jstring command)
898
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_quickCommand(JNIEnv *env, jobject obj, jstring command)
905
{
899
{
906
    const char *p = env->GetStringUTFChars(command, NULL);
900
    const char *p = env->GetStringUTFChars(command, NULL);
907
    quickCommandString = std::string(p) + "\n";
901
    quickCommandString = std::string(p) + "\n";
908
    env->ReleaseStringUTFChars(command, p);
902
    env->ReleaseStringUTFChars(command, p);
909
    PortableCommand(quickCommandString.c_str());
903
    PortableCommand(quickCommandString.c_str());
910
}
904
}
911
905
912
void EXPORT_ME
906
void EXPORT_ME
913
Java_com_voidpoint_duke3d_engine_NativeLib_setScreenSize(JNIEnv *env, jobject thiz, jint width, jint height)
907
Java_com_voidpoint_duke3d_engine_NativeLib_setScreenSize(JNIEnv *env, jobject thiz, jint width, jint height)
914
{
908
{
915
    droidinfo.screen_width = width;
909
    droidinfo.screen_width = width;
916
    droidinfo.screen_height = height;
910
    droidinfo.screen_height = height;
917
}
911
}
918
912
919
void EXPORT_ME Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv *env, jclass cls)
913
void EXPORT_ME Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv *env, jclass cls)
920
{
914
{
921
    /* This interface could expand with ABI negotiation, calbacks, etc. */
915
    /* This interface could expand with ABI negotiation, calbacks, etc. */
922
    SDL_Android_Init(env, cls);
916
    SDL_Android_Init(env, cls);
923
    SDL_SetMainReady();
917
    SDL_SetMainReady();
924
    // SDL_EventState(SDL_TEXTINPUT,SDL_ENABLE);
918
    // SDL_EventState(SDL_TEXTINPUT,SDL_ENABLE);
925
}
919
}
926
920
927
jstring EXPORT_ME
921
jstring EXPORT_ME
928
Java_com_voidpoint_duke3d_engine_NativeLib_getSavetext(JNIEnv *env, jobject obj, jstring jfile, jint type)
922
Java_com_voidpoint_duke3d_engine_NativeLib_getSavetext(JNIEnv *env, jobject obj, jstring jfile, jint type)
929
{
923
{
930
    const char *p = env->GetStringUTFChars(jfile, NULL);
924
    const char *p = env->GetStringUTFChars(jfile, NULL);
931
925
932
    jstring ret = env->NewStringUTF(G_GetStringFromSavegame(p, type));
926
    jstring ret = env->NewStringUTF(G_GetStringFromSavegame(p, type));
933
    env->ReleaseStringUTFChars(jfile, p);
927
    env->ReleaseStringUTFChars(jfile, p);
934
928
935
    return ret;
929
    return ret;
936
}
930
}
937
931
938
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_getScreenshot(JNIEnv *env, jobject obj, jstring jfile,
932
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_getScreenshot(JNIEnv *env, jobject obj, jstring jfile,
939
                                                                        jobject jpal, jobject jdataOut)
933
                                                                        jobject jpal, jobject jdataOut)
940
{
934
{
941
    const char *p = env->GetStringUTFChars(jfile, NULL);
935
    const char *p = env->GetStringUTFChars(jfile, NULL);
942
936
943
    jbyte *bb = (jbyte *)env->GetDirectBufferAddress(jdataOut);
937
    jbyte *bb = (jbyte *)env->GetDirectBufferAddress(jdataOut);
944
    jbyte *pb = (jbyte *)env->GetDirectBufferAddress(jpal);
938
    jbyte *pb = (jbyte *)env->GetDirectBufferAddress(jpal);
945
939
946
    int ret = G_GetScreenshotFromSavegame(p, (char *)pb, (char *)bb);
940
    int ret = G_GetScreenshotFromSavegame(p, (char *)pb, (char *)bb);
947
941
948
    env->ReleaseStringUTFChars(jfile, p);
942
    env->ReleaseStringUTFChars(jfile, p);
949
    return ret;
943
    return ret;
950
}
944
}
951
945
952
#ifdef GP_LIC
946
#ifdef GP_LIC
953
#undef GP_LIC_INC
947
#undef GP_LIC_INC
954
#define GP_LIC_INC 3
948
#define GP_LIC_INC 3
955
#include "s-setup/gp_lic_include.h"
949
#include "s-setup/gp_lic_include.h"
956
#endif
950
#endif
957
}
951
}
958
 
952