+static void IN_Move_TouchScreen_SteelStorm(void)
+{
+ // ELUAN
+ int i, numfingers;
+ float xscale, yscale;
+ float move[3], aim[3];
+ static qboolean oldbuttons[128];
+ static qboolean buttons[128];
+ keydest_t keydest = (key_consoleactive & KEY_CONSOLEACTIVE_USER) ? key_console : key_dest;
+ memcpy(oldbuttons, buttons, sizeof(oldbuttons));
+ memset(multitouchs, 0, sizeof(multitouchs));
+
+ for (i = 0, numfingers = 0; i < MAXFINGERS - 1; i++)
+ if (multitouch[i][0])
+ numfingers++;
+
+ /*
+ Enable this to use a mouse as a touch device (it may conflict with the iamexclusive parameter if a finger is also reported as a mouse at the same location
+ if (numfingers == 1)
+ {
+ multitouch[MAXFINGERS-1][0] = SDL_GetMouseState(&x, &y) ? 11 : 0;
+ multitouch[MAXFINGERS-1][1] = (float)x / vid.width;
+ multitouch[MAXFINGERS-1][2] = (float)y / vid.height;
+ }
+ else
+ {
+ // disable it so it doesn't get stuck, because SDL seems to stop updating it if there are more than 1 finger on screen
+ multitouch[MAXFINGERS-1][0] = 0;
+ }*/
+
+ // TODO: make touchscreen areas controlled by a config file or the VMs. THIS IS A MESS!
+ // TODO: can't just clear buttons[] when entering a new keydest, some keys would remain pressed
+ // SS:BR menuqc has many peculiarities, including that it can't accept more than one command per frame and pressing and releasing on the same frame
+
+ // Tuned for the SGS3, use it's value as a base. CLEAN THIS.
+ xscale = vid_touchscreen_density.value / 2.0f;
+ yscale = vid_touchscreen_density.value / 2.0f;
+ switch(keydest)
+ {
+ case key_console:
+ Vid_ClearAllTouchscreenAreas(14);
+ VID_TouchscreenArea( 0, 0, 160, 64, 64, "gfx/gui/touch_menu_button.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, false);
+ break;
+ case key_game:
+ if (steelstorm_showing_map && steelstorm_showing_map->integer) // FIXME: another hack to be removed when touchscreen areas go to QC
+ {
+ VID_TouchscreenArea( 0, 0, 0, vid_conwidth.value, vid_conheight.value, NULL , 0.0f, NULL, NULL, &buttons[10], (keynum_t)'m', NULL, 0, 0, 0, false);
+ Vid_ClearAllTouchscreenAreas(10);
+ }
+ else if (steelstorm_showing_mousecursor && steelstorm_showing_mousecursor->integer)
+ {
+ // in_windowmouse_x* is in screen resolution coordinates, not console resolution
+ VID_TouchscreenCursor((float)in_windowmouse_x/vid_width.value*vid_conwidth.value, (float)in_windowmouse_y/vid_height.value*vid_conheight.value, 192*xscale, 192*yscale, &buttons[0], K_MOUSE1);
+ Vid_ClearAllTouchscreenAreas(0);
+ }
+ else
+ {
+ VID_TouchscreenCursor(0, 0, 0, 0, &buttons[0], K_MOUSE1);
+
+ VID_TouchscreenArea( 2,16*xscale,-240*yscale, 224*xscale, 224*yscale, "gfx/gui/touch_l_thumb_dpad.tga", 0.0f, NULL, move, &buttons[1], (keynum_t)0, NULL, 0.15, 112*xscale, 112*yscale, false);
+
+ VID_TouchscreenArea( 3,-240*xscale,-160*yscale, 224*xscale, 128*yscale, "gfx/gui/touch_r_thumb_turn_n_shoot.tga" , 0.0f, NULL, NULL, 0, (keynum_t)0, NULL, 0, 56*xscale, 0, false);
+ VID_TouchscreenArea( 3,-240*xscale,-256*yscale, 224*xscale, 224*yscale, NULL , 0.0f, NULL, aim, &buttons[2], (keynum_t)0, NULL, 0.2, 56*xscale, 0, false);
+
+ VID_TouchscreenArea( 2, (vid_conwidth.value / 2) - 128,-80, 256, 80, NULL, 0.0f, NULL, NULL, &buttons[3], K_SHIFT, NULL, 0, 0, 0, true);
+
+ VID_TouchscreenArea( 3,-240*xscale,-256*yscale, 224*xscale, 64*yscale, "gfx/gui/touch_secondary_slide.tga", 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 56*xscale, 0, false);
+ VID_TouchscreenArea( 3,-240*xscale,-256*yscale, 224*xscale, 160*yscale, NULL , 0.0f, NULL, NULL, &buttons[9], K_MOUSE3, NULL, 0.2, 56*xscale, 0, false);
+
+ VID_TouchscreenArea( 1,-100, 0, 100, 100, NULL , 0.0f, NULL, NULL, &buttons[10], (keynum_t)'m', NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 1,-100, 120, 100, 100, NULL , 0.0f, NULL, NULL, &buttons[11], (keynum_t)'b', NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[12], (keynum_t)'q', NULL, 0, 0, 0, true);
+ if (developer.integer)
+ VID_TouchscreenArea( 0, 0, 96, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
+ else
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, false);
+ VID_TouchscreenArea( 0, 0, 160, 64, 64, "gfx/gui/touch_menu_button.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
+ switch(cl.activeweapon)
+ {
+ case 14:
+ VID_TouchscreenArea( 2, 16*xscale,-320*yscale, 224*xscale, 64*yscale, "gfx/gui/touch_booster.tga" , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, true);
+ break;
+ case 12:
+ VID_TouchscreenArea( 2, 16*xscale,-320*yscale, 224*xscale, 64*yscale, "gfx/gui/touch_shockwave.tga" , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, true);
+ break;
+ default:
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[15], K_SPACE, NULL, 0, 0, 0, false);
+ }
+ }
+ break;
+ default:
+ if (!steelstorm_showing_mousecursor || !steelstorm_showing_mousecursor->integer)
+ {
+ Vid_ClearAllTouchscreenAreas(14);
+ // this way we can skip cutscenes
+ VID_TouchscreenArea( 0, 0, 0, vid_conwidth.value, vid_conheight.value, NULL , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, false);
+ }
+ else
+ {
+ // in_windowmouse_x* is in screen resolution coordinates, not console resolution
+ VID_TouchscreenCursor((float)in_windowmouse_x/vid_width.value*vid_conwidth.value, (float)in_windowmouse_y/vid_height.value*vid_conheight.value, 192*xscale, 192*yscale, &buttons[0], K_MOUSE1);
+ Vid_ClearAllTouchscreenAreas(0);
+ }
+ break;
+ }
+
+ if (VID_ShowingKeyboard() && (float)in_windowmouse_y > vid_height.value / 2 - 10)
+ in_windowmouse_y = 128;
+
+ cl.cmd.forwardmove -= move[1] * cl_forwardspeed.value;
+ cl.cmd.sidemove += move[0] * cl_sidespeed.value;
+ cl.viewangles[0] += aim[1] * cl_pitchspeed.value * cl.realframetime;
+ cl.viewangles[1] -= aim[0] * cl_yawspeed.value * cl.realframetime;
+}
+
+static void IN_Move_TouchScreen_Quake(void)
+{
+ int x, y;
+ float move[3], aim[3], click[3];
+ static qboolean oldbuttons[128];
+ static qboolean buttons[128];
+ keydest_t keydest = (key_consoleactive & KEY_CONSOLEACTIVE_USER) ? key_console : key_dest;
+ memcpy(oldbuttons, buttons, sizeof(oldbuttons));
+ memset(multitouchs, 0, sizeof(multitouchs));
+
+ // simple quake controls
+ multitouch[MAXFINGERS-1][0] = SDL_GetMouseState(&x, &y);
+ multitouch[MAXFINGERS-1][1] = x * 32768 / vid.width;
+ multitouch[MAXFINGERS-1][2] = y * 32768 / vid.height;
+
+ // top of screen is toggleconsole and K_ESCAPE
+ switch(keydest)
+ {
+ case key_console:
+ VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 64, 0, 64, 64, "gfx/touch_menu.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
+ if (!VID_ShowingKeyboard())
+ {
+ // user entered a command, close the console now
+ Con_ToggleConsole_f();
+ }
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[15], (keynum_t)0, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, aim, &buttons[1], K_MOUSE5, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, click,&buttons[2], K_MOUSE1, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[3], K_SPACE, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, true);
+ break;
+ case key_game:
+ VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 64, 0, 64, 64, "gfx/touch_menu.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 2, 0,-128, 128, 128, "gfx/touch_movebutton.tga" , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 3,-128,-128, 128, 128, "gfx/touch_aimbutton.tga" , 0.0f, NULL, aim, &buttons[1], K_MOUSE5, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 2, 0,-160, 64, 32, "gfx/touch_jumpbutton.tga" , 0.0f, NULL, NULL, &buttons[3], K_SPACE, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 3,-128,-160, 64, 32, "gfx/touch_attackbutton.tga" , 0.0f, NULL, NULL, &buttons[2], K_MOUSE1, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 3, -64,-160, 64, 32, "gfx/touch_attack2button.tga", 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, true);
+ buttons[15] = false;
+ break;
+ default:
+ VID_TouchscreenArea( 0, 0, 0, 64, 64, NULL , 0.0f, NULL, NULL, &buttons[13], (keynum_t)'`', NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 64, 0, 64, 64, "gfx/touch_menu.tga" , 0.0f, NULL, NULL, &buttons[14], K_ESCAPE, NULL, 0, 0, 0, true);
+ // in menus, an icon in the corner activates keyboard
+ VID_TouchscreenArea( 2, 0, -32, 32, 32, "gfx/touch_keyboard.tga" , 0.0f, NULL, NULL, &buttons[15], (keynum_t)0, NULL, 0, 0, 0, true);
+ if (buttons[15])
+ VID_ShowKeyboard(true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, aim, &buttons[1], K_MOUSE5, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea(16, -320,-480,640, 960, NULL , 0.0f, NULL, click,&buttons[2], K_MOUSE1, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[3], K_SPACE, NULL, 0, 0, 0, true);
+ VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[4], K_MOUSE2, NULL, 0, 0, 0, true);
+ if (buttons[2])
+ {
+ in_windowmouse_x = x;
+ in_windowmouse_y = y;
+ }
+ break;
+ }
+
+ cl.cmd.forwardmove -= move[1] * cl_forwardspeed.value;
+ cl.cmd.sidemove += move[0] * cl_sidespeed.value;
+ cl.viewangles[0] += aim[1] * cl_pitchspeed.value * cl.realframetime;
+ cl.viewangles[1] -= aim[0] * cl_yawspeed.value * cl.realframetime;
+}
+