//int g_temp = 0xf2; int drawTouchscreenKeyboard() { int i; extern clientStatic_t cls; //extern int keydown[256]; if(!g_use_touchscreen_icon){ //LOGI("no need to paint "); return 0; } if(cls.state != CA_ACTIVE) { return 0; } int blendFactor = 0; for(i = 0; i<4; i++) { //blendFactor += keydown[arrowkeys[i]]?1:0; } beginDrawingTex(); //draw the dpad and turn arrow if( blendFactor == 0 ) { drawCharTex( &arrowImages, NULL, &arrow, 255, 255, 255, transparency ); } else { drawCharTex( &arrowImages, NULL, &arrow, 255, 255, 255, transparency / blendFactor ); } for( i = 0; i < nbuttons; i++ ) { if(button_pressed[i] == 0) {//not pressed drawCharTex( &buttonImages[2*i], NULL, &buttons[i], 255, 255, 255, transparency ); } else { //pressed drawCharTex( &buttonImages[2*i+1], NULL, &buttons[i], 255, 255, 255, transparency ); } } if(show_gun) { int i; SDL_Rect gun_position={0, 0, 32, 32}; int tap = (screen_width-32*9)/9; for(i = 0; i < 9; i++) { gun_position.x = tap/2+(32+tap)*i; drawCharTex(&buttonImages[i+nbuttons*2], NULL, &gun_position, 255, 255, 255, transparency); } } endDrawingTex(); return 1; }
int SDL_ANDROID_drawTouchscreenKeyboard() { int i; if( !SDL_ANDROID_isTouchscreenKeyboardUsed || !touchscreenKeyboardShown ) return 0; if( touchscreenKeyboardTheme == 0 ) { beginDrawingWireframe(); // Draw arrow keys drawCharWireframe( FONT_LEFT, arrows.x + arrows.w / 4, arrows.y + arrows.h / 2, 0, 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 255 : 0, 128 ); drawCharWireframe( FONT_RIGHT, arrows.x + arrows.w / 4 * 3, arrows.y + arrows.h / 2, 0, 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 255 : 0, 128 ); drawCharWireframe( FONT_UP, arrows.x + arrows.w / 2, arrows.y + arrows.h / 4, 0, 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 255 : 0, 128 ); drawCharWireframe( FONT_DOWN, arrows.x + arrows.w / 2, arrows.y + arrows.h / 4 * 3, 0, 255, 255, SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 255 : 0, 128 ); // Draw buttons for( i = 0; i < nbuttons; i++ ) { drawCharWireframe( FONT_BTN1 + i, buttons[i].x + buttons[i].w / 2, buttons[i].y + buttons[i].h / 2, ( i < AutoFireButtonsNum ? ButtonAutoFireRot[i] * 0x10000 : 0 ), ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? 0 : 255, 255, SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? 255 : 0, 128 ); } endDrawingWireframe(); } else { int blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 1 : 0 ) + ( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) + ( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) + ( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 ); beginDrawingTex(); if( blendFactor == 0 ) drawCharTex( &arrowImages[0], NULL, &arrows, 255, 255, 255, 128 ); else { if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ) drawCharTex( &arrowImages[1], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ) drawCharTex( &arrowImages[2], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ) drawCharTex( &arrowImages[3], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ) drawCharTex( &arrowImages[4], NULL, &arrows, 255, 255, 255, 128 / blendFactor ); } for( i = 0; i < nbuttons; i++ ) { if( i < AutoFireButtonsNum ) { if( ButtonAutoFire[i] == 1 && SDL_GetTicks() - ButtonAutoFireDecay[i] > 1000 ) { ButtonAutoFire[i] = 0; } if( ! ButtonAutoFire[i] && SDL_GetTicks() - ButtonAutoFireDecay[i] > 300 ) { if( ButtonAutoFireX[i*2] > 0 ) ButtonAutoFireX[i*2] --; if( ButtonAutoFireX[i*2+1] > 0 ) ButtonAutoFireX[i*2+1] --; ButtonAutoFireDecay[i] = SDL_GetTicks(); } } if( i < AutoFireButtonsNum && ! ButtonAutoFire[i] && ( ButtonAutoFireX[i*2] > 0 || ButtonAutoFireX[i*2+1] > 0 ) ) { int pos1src = buttonImages[i*2+1].w / 2 - ButtonAutoFireX[i*2]; int pos1dst = buttons[i].w * pos1src / buttonImages[i*2+1].w; int pos2src = buttonImages[i*2+1].w - ( buttonImages[i*2+1].w / 2 - ButtonAutoFireX[i*2+1] ); int pos2dst = buttons[i].w * pos2src / buttonImages[i*2+1].w; SDL_Rect autoFireCrop = { 0, 0, pos1src, buttonImages[i*2+1].h }; SDL_Rect autoFireDest = buttons[i]; autoFireDest.w = pos1dst; drawCharTex( &buttonImages[i*2+1], &autoFireCrop, &autoFireDest, 255, 255, 255, 128 ); autoFireCrop.x = pos2src; autoFireCrop.w = buttonImages[i*2+1].w - pos2src; autoFireDest.x = buttons[i].x + pos2dst; autoFireDest.w = buttons[i].w - pos2dst; drawCharTex( &buttonImages[i*2+1], &autoFireCrop, &autoFireDest, 255, 255, 255, 128 ); autoFireCrop.x = pos1src; autoFireCrop.w = pos2src - pos1src; autoFireDest.x = buttons[i].x + pos1dst; autoFireDest.w = pos2dst - pos1dst; drawCharTex( &buttonAutoFireImages[i*2+1], &autoFireCrop, &autoFireDest, 255, 255, 255, 128 ); } else { drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i*2] : &buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? (i * 2 + 1) : (i * 2) ], NULL, &buttons[i], 255, 255, 255, 128 ); } } endDrawingTex(); } return 1; };