Example #1
0
void moveToPause()
{
    send_audio_data(currentSong);
    send_audio_data(PLAY_PAUSE);
    currentScreen = 2;
    display_bitmap(currentScreen);
}
static Ret ftk_display_android_update(FtkDisplay* thiz, FtkBitmap* bitmap, FtkRect* rect, int xoffset, int yoffset)
{
	int i = 0;
	Ret ret = RET_OK;
	DECL_PRIV(thiz, priv);
	int width = rect->width;
	int height = rect->height;
	int src_width = ftk_bitmap_width(bitmap);
	int src_height = ftk_bitmap_height(bitmap);
	int dst_width = ftk_bitmap_width(priv->bitmap);
	int dst_height = ftk_bitmap_height(priv->bitmap);
	FtkColor* src = ftk_bitmap_lock(bitmap);
	FtkColor* dst = ftk_bitmap_lock(priv->bitmap);

	return_val_if_fail(rect->x < src_width && rect->y < src_height
		&& xoffset < dst_width && yoffset < dst_height, RET_FAIL);

	width = (xoffset + width) >= dst_width ? dst_width - xoffset : width;
	height = (yoffset + height) >= dst_height ? dst_height - yoffset : height;

	yoffset = dst_height  - yoffset - height - 1;
	src += rect->y * src_width + rect->x;
	dst += (yoffset + height) * dst_width + xoffset;

	for(i = 0; i < height; i++)
	{
		memcpy(dst, src, sizeof(FtkColor) * width);
		dst -= dst_width;
		src += src_width;
	}

#if 0
	display_bitmap(priv, priv->bitmap, xoffset, yoffset, width, height, xoffset, yoffset);
#else
	display_bitmap(priv, priv->bitmap, 0, 0, screen_width, screen_height, 0, 0);
#endif

	return ret;
}
Example #3
0
// =====================================================================
	void insmm::OnTest()
// =====================================================================
{
CString fname;
char	mmdir[300];
int		sel;

	UpdateData(1);
	GET_SELID(IDC_LIST);
	get_token(mmstuff.GetString(sel),0,fname);
	make_path(mmdir,gc.MultimedPath,fname);
	if (m_mmtype==0)
	{
		display_bitmap(mmdir);
		force_bmp_display_update();
	}
	else
		test_sound(mmdir);
}
//***********************************
//***********************************
//********** MAIN FUNCTION **********
//***********************************
//***********************************
int main (void)
{
	BYTE display_html_file_name[12];
	DWORD file_size;

	//**********************
	//**********************
	//***** INITIALISE *****
	//**********************
	//**********************
	initialise();





	//*********************
	//*********************
	//***** MAIN LOOP *****
	//*********************
	//*********************
	while(1)						//(Do forever)
	{
		//----- RESET THE WATCHDOG TIMEOUT TIMER -----
		ClearWDT();


		switches_1_new = 0;
		if (do_10ms_functions)
		{
			do_10ms_functions = 0;
		
			//----- READ SWITCHES -----
			read_switches();

		}


		//------------------------------------
		//----- CHECK FOR SWITCH PRESSES -----
		//------------------------------------
		if (SWITCH_UP_NEW_PRESS)
		{
			//----- UP PRESSED -----
			
			//Load the index.htm file
			if (display_html_setup_read_file(index_htm, 0, &file_size))			//Find HTML file ready to display it
				display_html_file(file_size);
		}
		else if (SWITCH_DOWN_NEW_PRESS)
		{
			//----- DOWN PRESSED -----
			
			//Load text1.htm using name as a variable to demonstrate finding file by name at run time
			display_html_file_name[0] = 'T';
			display_html_file_name[1] = 'E';
			display_html_file_name[2] = 'X';
			display_html_file_name[3] = 'T';
			display_html_file_name[4] = '1';
			display_html_file_name[5] = '.';
			display_html_file_name[6] = 'H';
			display_html_file_name[7] = 'T';
			display_html_file_name[8] = 'M';
			display_html_file_name[9] = 0x00;
			
			if (display_html_setup_read_file(0, display_html_file_name, &file_size))
			{
				display_html_file(file_size);
			}

		}
		else if (SWITCH_LEFT_NEW_PRESS)
		{
			//----- LEFT PRESSED -----
			
			//Load dynamic text demo HTML file - the text is added by the html_get_dynamic_text_character function below
			if (display_html_setup_read_file(dyntext_htm, 0, &file_size))
				display_html_file(file_size);
		}
		else if (SWITCH_RIGHT_NEW_PRESS)
		{
			//----- RIGHT PRESSED -----
			
			//Load text2.htm
			if (display_html_setup_read_file(text2_htm, 0, &file_size))
				display_html_file(file_size);
		}
		else if (SWITCH_FIRE_NEW_PRESS)
		{
			//----- FIRE PRESSED -----


			//Generate content using code instead of HTML
			display_clear_screen(DISPLAY_COLOUR_WHITE);
			
			display_bitmap(indeximg_bmp, 0, 0, 0x00ffffff);		//p_bitmap, x_coord, y_coord, transparency_colour(0xffffffff to not use)
		
		

			display_foreground_colour = DISPLAY_COLOUR_RED;
			display_background_colour = DISPLAY_COLOUR_TURQUOISE;
			display_const_string (disp_font_5w_7h, DISPLAY_TEXT_ALIGN_LEFT,				//Font, Options
									2, 2,												//Hoz padding, vertical padding
									20, 50,												//X start coord, Y start coord
									0, 0,												//X end coord, Y end coord (0 if area containment not required)
									string1);											//Text
	
	
			display_const_string(disp_font_5w_11h, DISPLAY_TEXT_ALIGN_LEFT,				//Font, Options
									2, 2,												//Hoz padding, vertical padding
									20, 70,												//X start coord, Y start coord
									0, 0,												//X end coord, Y end coord (0 if area containment not required)
									string1);											//Text


			display_foreground_colour = DISPLAY_COLOUR_VIOLET;
			display_background_colour = DISPLAY_COLOUR_YELLOW;
			display_const_string(disp_font_22h, DISPLAY_TEXT_ALIGN_CENTRE,				//Font, Options
									2, 2,												//Hoz padding, vertical padding
									20, 105,											//X start coord, Y start coord
									200, 160,											//X end coord, Y end coord (0 if area containment not required)
									string1);											//Text



			display_foreground_colour = DISPLAY_COLOUR_BLACK;
			display_background_colour = DISPLAY_COLOUR_NULL;							//(DISPLAY_COLOUR_NULL == no background colour / leave existing colour)
	
			display_const_string(disp_font_15h, DISPLAY_TEXT_ALIGN_LEFT,				//Font, Options
									2, 2,												//Hoz padding, vertical padding
									176, 134,											//X start coord, Y start coord
									0, 0,												//X end coord, Y end coord (0 if area containment not required)
									string1);											//Text


			display_foreground_colour = DISPLAY_COLOUR_WHITE;
			display_background_colour = DISPLAY_COLOUR_BLUE;
			display_const_string(disp_font_42h, DISPLAY_TEXT_ALIGN_CENTRE,				//Font, Options
									2, 2,												//Hoz padding, vertical padding
									0, 170,												//X start coord, Y start coord
									319, 0,												//X end coord, Y end coord (0 if area containment not required)
									string1);											//Text
									

		}

		
	}
}
                // Trial using bitmap copying
                // Caller must create and destroy the bitmap
int bitmap_recording_trial(HBITMAP gbm, UINT32 time_limit)
{
  UINT32 trial_start;	// trial start time (for timeout) 
  UINT32 drawing_time;  // retrace-to-draw delay
  int button;		// the button pressed (0 if timeout) 
  int error;            // trial result code

    // NOTE: TRIALID AND TITLE MUST HAVE BEEN SET BEFORE DRIFT CORRECTION!
    // FAILURE TO INCLUDE THESE MAY CAUSE INCOMPATIBILITIES WITH ANALYSIS SOFTWARE!

	   // DO PRE-TRIAL DRIFT CORRECTION 
	   // We repeat if ESC key pressed to do setup. 
  while(1)
    {              // Check link often so we can exit if tracker stopped
      if(!eyelink_is_connected()) return ABORT_EXPT;
	   // We let do_drift_correct() draw target in this example
	   // 3rd argument would be 0 if we already drew the fixation target
      error = do_drift_correct((INT16)(SCRWIDTH/2), (INT16)(SCRHEIGHT/2), 1, 1);
           // repeat if ESC was pressed to access Setup menu 
      if(error!=27) break;
    }

  clear_full_screen_window(target_background_color);  // make sure display is blank
  
	// Start data recording to EDF file, BEFORE DISPLAYING STIMULUS 
	// You should always start recording 50-100 msec before required
	// otherwise you may lose a few msec of data 
  error = start_recording(1,1,0,0);   // record samples and events to EDF file only
  if(error != 0) return error;        // ERROR: couldn't start recording

                              // record for 100 msec before displaying stimulus 
  begin_realtime_mode(100);   // Windows 2000/XP: no interruptions till display start marked

    // DISPLAY OUR IMAGE TO SUBJECT  by copying bitmap to display
    // Because of faster drawing speeds and good refresh locking,
    // we now place the stimulus onset message just after display refresh 
    // and before drawing the stimulus.  This is accurate and will allow 
    // drawing a new stimulus each display refresh.
    // However, we do NOT send the message after the retrace--this may take too long
    // instead, we add a number to the message that represents the delay 
    // from the event to the message in msec
  wait_for_video_refresh();	// synchronize before drawing so all seen at once
  drawing_time = current_msec();                  // time of retrace
  trial_start = drawing_time;  // record the display onset time 
  
  display_bitmap(full_screen_window, gbm, 0, 0);  // COPY BITMAP to display
  wait_for_drawing(full_screen_window);    // wait till bitmap copy finished

  drawing_time = current_msec()-drawing_time;    // delay from retrace (time to draw)
  eyemsg_printf("%d DISPLAY ON", drawing_time);	 // message for RT recording in analysis 
  eyemsg_printf("SYNCTIME %d", drawing_time);	 // message marks zero-plot time for EDFVIEW 

                        // we would stay in realtime mode if timing is critical   
                        // for example, if a dynamic (changing) stimulus was used
                        // or if display duration accuracy of 1 video refresh. was needed
  end_realtime_mode();  // we don't care as much about time now, allow keyboard to work
     
                                 // Now get ready for trial loop
  eyelink_flush_keybuttons(0);   // reset keys and buttons from tracker 

                       // we don't use getkey() especially in a time-critical trial
                       // as Windows may interrupt us and cause an unpredicatable delay
                       // so we would use buttons or tracker keys only  

     // Trial loop: till timeout or response 
  while(1)   
    {                            // First, check if recording aborted 
      if((error=check_recording())!=0) return error;  
                                 // Check if trial time limit expired
      if(current_time() > trial_start+time_limit)
        {
          eyemsg_printf("TIMEOUT");    // message to log the timeout 
	  end_trial();                 // local function to stop recording
	  button = 0;                  // trial result message is 0 if timeout 
	  break;                       // exit trial loop
	}
      if(break_pressed())     // check for program termination or ALT-F4 or CTRL-C keys
	{
	   end_trial();         // local function to stop recording
	   return ABORT_EXPT;   // return this code to terminate experiment
	 }

      if(escape_pressed())    // check for local ESC key to abort trial (useful in debugging)   
         {
	   end_trial();         // local function to stop recording
	   return SKIP_TRIAL;   // return this code if trial terminated
         }

		/* BUTTON RESPONSE TEST */
		// Check for eye-tracker buttons pressed
		// This is the preferred way to get response data or end trials	
      button = eyelink_last_button_press(NULL);
      if(button!=0)       // button number, or 0 if none pressed
	{
	   eyemsg_printf("ENDBUTTON %d", button);  // message to log the button press
	   end_trial();                            // local function to stop recording
	   break;                                  // exit trial loop
	 }
    }                       // END OF RECORDING LOOP
  end_realtime_mode();      // safety cleanup code
  while(getkey());          // dump any accumulated key presses

			   // report response result: 0=timeout, else button number
  eyemsg_printf("TRIAL_RESULT %d", button);
			   // Call this at the end of the trial, to handle special conditions
  return check_record_exit();
}
Example #6
0
short main(int argc, char *argv[])
{
	MFDB dest;
	short my_AppId, x, y, w, h;
	short work_in[11] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2};
	short work_out[57], msg[16], w_id1;
	short open_windows = 1, dummy;
	short wx, wy, ww, wh, clip[4], pnt[4];
	char win1_name[20];
	unsigned short logo_trnfrm[LOGO_DATASIZE];
	GRECT dirty, walk;
	short e = 0, evx, evy, a, kc_shstate, kc_key, click_count;

	my_AppId = appl_init();
	my_handle = graf_handle(&x, &y, &w, &h);		/* Open a virtual workstation */
	v_opnvwk(work_in, &my_handle, work_out);

	logo_bm.fd_w = LOGO_W;
	logo_bm.fd_h = LOGO_H;
	logo_bm.fd_wdwidth = 12;
	logo_bm.fd_nplanes = 4;
	logo_bm.fd_stand = 1;
	dest = logo_bm;
	dest.fd_stand = 0;

	logo_bm.fd_addr = (void *)x_logo;
	dest.fd_addr = (void *)logo_trnfrm;
	vr_trnfm(my_handle, &logo_bm, &dest);
	logo_bm.fd_addr = (void *)logo_trnfrm;

	w_id1 = wind_create(NAME|CLOSE|MOVER, 0, 0, LOGO_W + 40, LOGO_H + 40);

	if (argc > 1)
		sprintf(win1_name,"%s", argv[1]);
	else
		sprintf(win1_name,"Welcome to...", argv[1]);
		
	wind_set(w_id1, WF_NAME, ADDR(win1_name));

	x = (work_out[0] - (LOGO_W + 40)) / 2;
	y = (work_out[1] - (LOGO_H + 40)) / 2;
	wind_open(w_id1, x, y, LOGO_W + 40, LOGO_H + 40);

	while((open_windows) && (!(e & MU_TIMER))) {
		e = evnt_multi(MU_MESAG|MU_TIMER, 258, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			msg, 15000, 0, &evx, &evy, &a, &kc_shstate, &kc_key, &click_count);

		if (e & MU_MESAG) {
			dummy = msg[0];
			switch(dummy) {
			case WM_CLOSED:	/* Did someone close one of our windows? */
				wind_close(msg[3]);
				open_windows--;
				break;
			case WM_MOVED:
				wind_set(msg[3], WF_CURRXYWH, msg[4], msg[5], msg[6], msg[7]);
				break;
			case WM_REDRAW:
				dirty.g_x = msg[4];
				dirty.g_y = msg[5];
				dirty.g_w = msg[6];
				dirty.g_h = msg[7];
				wind_update(BEG_UPDATE);
				wind_get(msg[3], WF_WORKXYWH, &wx, &wy, &ww, &wh);
				walk.g_x = wx;
				walk.g_y = wy;
				walk.g_w = ww;
				walk.g_h = wh;
				pnt[0] = wx;
				pnt[1] = wy;
				pnt[2] = wx + ww;
				pnt[3] = wy + wh;
				wind_get(msg[3], WF_FIRSTXYWH, &x, &y, &w, &h);
				rc_intersect(&walk, &dirty);
				graf_mouse(M_OFF, NULL);
				while(h) {
					walk.g_x = x;
					walk.g_y = y;
					walk.g_w = w;
					walk.g_h = h;
					if (rc_intersect(&dirty, &walk)) {
						clip[0] = walk.g_x;
						clip[1] = walk.g_y;
						clip[2] = walk.g_x + walk.g_w;
						clip[3] = walk.g_y + walk.g_h;
						vs_clip(my_handle, 1, clip);
						vsf_color(my_handle, LWHITE);
						v_bar(my_handle, pnt);
						display_bitmap(wx, wy);
					}
					wind_get(msg[3], WF_NEXTXYWH, &x, &y, &w, &h);
				}
				vs_clip(my_handle, 0, clip);
				graf_mouse(M_ON, NULL);
				wind_update(END_UPDATE);
				break;
			case WM_TOPPED:
				wind_set(msg[3], WF_TOP, 0, 0, 0, 0);
				break;
			case WM_BOTTOMED:
				wind_set(msg[3], WF_BOTTOM, 0, 0, 0, 0);
				break;
			}
		}
	}
	
	v_clsvwk(my_handle);
	
	appl_exit();
	
	return 0;
}
Example #7
0
void moveToMenu()
{
    send_audio_data(STOP);
    currentScreen = 0;
    display_bitmap(currentScreen);
}
Example #8
0
void moveToPlay()
{
    send_audio_data(STOP);
    currentScreen = 1;
    display_bitmap(currentScreen);
}
Example #9
0
// =====================================================================
	void handle_mm_stuff(char *mailbuf,int fromwhere)
// =====================================================================
{
static int preflen=strlen(MM_PREFIX);
char	*p,*t;
char	name[300];
char	mmcod[MAX_PATH],mmbase[MAX_PATH];

	if (GetKeyState(VK_CONTROL) & 0x80000000)
		return;

// WAVES
// Format: 	MM_PREFIX|mmtype|whentoplay|name
	p=mailbuf;
handle_wav:
	if ((gc.sound_enabled && !gc.sound_already_done) || fromwhere==3)
	{
find_ag1:
		p=strstr(p,MM_PREFIX);
		if (p)
		{
			p+=preflen;
			switch (*p)
			{
				case 'W':
				case 'w':
					break;
				case 'B':
				case 'b':
					if ((gc.bmps_enabled && !gc.bmps_already_done) || fromwhere==3)
					{
						p-=preflen;
						goto handle_bmp;
					}
					goto find_ag1;
				case '\0':
					return;
				default:
					goto find_ag1;
			}

			p++;
			if (fromwhere!=3)
			{
				switch (*p)	// 1-Play on display , 2-Play on income
				{
					case '1':
						if (fromwhere!=1)
							goto handle_bmp;
						break;
					case '2':
						if (fromwhere!=2)
							goto handle_bmp;
						break;
					default:
						goto handle_bmp;
				}
			}
			p++;
			name[0]=0;
			sscanf(p,"%s",name);
			if (!name[0] || strlen(name)>8)
				goto handle_bmp;

			t=name;
			while (*t)
			{
				if (!isxdigit(*t))
					goto handle_bmp;
				t++;
			}
			strcpy(mmcod,"00000000");
			memcpy(mmcod+(8-strlen(name)),name,strlen(name));
//			strcpy(mmcod,name);
			strcat(mmcod,".WAV");
			make_path(mmbase,gc.MultimedPath,mmcod);
			if (access(mmbase,0))
			{
				if (gc.no_error)
					err_out("W_CNFMMXF",mmbase);
				goto handle_bmp;
			}
			gc.sound_already_done=1;
			test_sound(mmbase);
		}
		else
			return;
	}

// BITMAPS
// Format: 	MM_PREFIX|mmtype|whentoplay|name with ending NULL
handle_bmp:
	if ((gc.bmps_enabled && !gc.bmps_already_done) || fromwhere==3)
	{
find_ag2:
		p=strstr(p,MM_PREFIX);
		if (p)
		{
			p+=preflen;
			switch (*p)
			{
				case 'W':
				case 'w':
					if ((gc.sound_enabled && !gc.sound_already_done) || fromwhere==3)
					{
						p-=preflen;
						goto handle_wav;
					}
					goto find_ag2;
				case 'B':
				case 'b':
					break;
				case '\0':
					return;
				default:
					goto find_ag2;
			}
			p++;
			if (fromwhere!=3)
			{
				switch (*p)	// 1=Play on display , 2=Play on income
				{
					case '1':
						if (fromwhere!=1)
							goto handle_wav;
						break;
					case '2':
						if (fromwhere!=2)
							goto handle_wav;
						break;
					default:
						goto handle_wav;
				}
			}
			p++;
			name[0]=0;
			sscanf(p,"%s",name);
			if (!name[0] || strlen(name)>8)
				goto handle_wav;

			t=name;
			while (*t)
			{
				if (!isxdigit(*t))
					goto handle_wav;
				t++;
			}
			strcpy(mmcod,"00000000");
			memcpy(mmcod+(8-strlen(name)),name,strlen(name));
			strcpy(mmcod,name);
			strcat(mmcod,".BMP");
			make_path(mmbase,gc.MultimedPath,mmcod);
			if (access(mmbase,0))
			{
				if (gc.no_error)
					err_out("W_CNFMMXF",mmbase);
				goto handle_wav;
			}
			gc.bmps_already_done=1;
			display_bitmap(mmbase);
		}
		else
			return;
		
		goto handle_wav;
	}
}