Exemplo n.º 1
0
void set_fullscreen(CVideo& video, const bool ison)
{
	_set_fullscreen(ison);

	const std::pair<int,int>& res = resolution();
	if(video.isFullScreen() != ison) {
		const int flags = ison ? FULL_SCREEN : 0;
		int bpp = video.bppForMode(res.first, res.second, flags);

		if(bpp > 0) {
			video.setMode(res.first,res.second,bpp,flags);
			if(disp) {
				disp->redraw_everything();
			}
		} else {
			int tmp_flags = flags;
			std::pair<int,int> tmp_res;
			if(detect_video_settings(video, tmp_res, bpp, tmp_flags)) {
				set_resolution(video, tmp_res.first, tmp_res.second);
			// TODO: see if below line is actually needed, possibly for displays that only support 16 bbp
			} else if(video.modePossible(1024,768,16,flags)) {
				set_resolution(video, 1024, 768);
			} else {
				gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
			}
			// We reinit color cursors, because SDL on Mac seems to forget the SDL_Cursor
			set_color_cursors(preferences::get("color_cursors", false));
		}
	}
}
Exemplo n.º 2
0
/**
 * This function decreases the current resolution, unless the world is
 * already at its lowest resolution.
 */
void GameWorld::prev_resolution()
{
	switch (currentResLevel) {
		case Resolution::MED:
			set_resolution(Resolution::LOW); 
      break;
		case Resolution::HIGH:
			set_resolution(Resolution::MED);
      break;
	}
}
Exemplo n.º 3
0
static void init_resolution(void) {
	if (set_resolution(1)) {
		DBG_LOG("Switching to failsafe video mode defaults");
		config_set_failsafe_video();
		config_save();

		if (set_resolution(1)) {
			exit(1);
		}
	}
}
Exemplo n.º 4
0
/**
 * This function increases the current resolution, unless the world is
 * already at its highest resolution.
 */
void GameWorld::next_resolution()
{
  int numCrystals = hero->crystals.size();
	switch (currentResLevel) {
      case Resolution::LOW:
			if(numCrystals>=1)
        set_resolution(Resolution::MED); 
      break;
		case Resolution::MED:
			if(numCrystals>=2)
        set_resolution(Resolution::HIGH);
      break;
	}
}
Exemplo n.º 5
0
static int init(const struct motion_sensor_t *s)
{
	int ret, resol;
	struct si114x_drv_data_t *data = SI114X_GET_DATA(s);

	/* initialize only once: light must be declared first. */
	if (s->type == MOTIONSENSE_TYPE_LIGHT) {
#ifdef CONFIG_ALS_SI114X_CHECK_REVISION
		ret = si114x_revisions(s);
		if (ret != EC_SUCCESS)
			return ret;
#endif
		ret = si114x_initialize(s);
		if (ret != EC_SUCCESS)
			return ret;

		data->state = SI114X_IDLE;
		resol = 7;
	} else {
		if (data->state == SI114X_NOT_READY)
			return EC_ERROR_ACCESS_DENIED;
		resol = 5;
	}

	set_range(s, s->default_range, 0);
	/*
	 * Sensor is most likely behind a glass.
	 * Max out the gain to get correct measurement
	 */
	set_resolution(s, resol, 0);

	CPRINTF("[%T %s: MS Done Init type:0x%X range:%d]\n",
			s->name, s->type, get_range(s));
	return EC_SUCCESS;
}
Exemplo n.º 6
0
// Break down the distance into 1, 1/2, 1/4/, and 1/8 steps
uint8_t resolve_distance(enum step_size resolution, float dist_mm, uint8_t pitch){
	
	
	float granularity = 1.8f*(1.0f/(float)resolution);	// 1.8, 0.9, 0.45, or 0.225 degrees
	float step_unit = ((granularity/360.0f)*(float)pitch);	// factor by pitch
	
	if((dist_mm / step_unit) >= 1.0f){	// at least 1 step can be performed at this resolution
		
		uint32_t step_count = (dist_mm / step_unit);
		float remaining_dist = dist_mm - (step_count * step_unit); // Deduct distance covered at this resolution
		
		set_resolution(resolution);
		perform_steps(step_count);
		
		if(remaining_dist >= (float)(FINEST_STEP*pitch))
			return resolve_distance((enum step_size)((uint8_t)resolution*2), remaining_dist, pitch);
			
	} else if(dist_mm >= (float)(FINEST_STEP*pitch)){
		// recursively call func with next finest resolution
		return resolve_distance((enum step_size)((uint8_t)resolution*2), dist_mm, pitch);
	}
	
	if(dist_mm > 0)
		return 0;	// Return 0 if specified distance could not be fully resolved
	else
		return 1;
}
Exemplo n.º 7
0
void
QcTiledZoomLevel::set_zoom_level(unsigned int zoom_level)
{
  m_zoom_level = zoom_level;
  double resolution = QcTileMatrixSet::resolution_for_level(m_map_size, m_tile_size, zoom_level); // unit is m/px
  set_resolution(resolution);
  // qInfo() << "set_zoom_level" << zoom_level << map_size_px;
}
Exemplo n.º 8
0
QcTiledZoomLevel &
QcTiledZoomLevel::operator=(const QcTiledZoomLevel & other)
{
  if (this != &other) {
    m_tile_size = other.m_tile_size;
    m_zoom_level = other.m_zoom_level;
    m_map_size = other.m_map_size;
    set_resolution(other.resolution());
  }

  return *this;
}
Exemplo n.º 9
0
void set_resolution(const std::pair<int,int>& resolution)
{
	if(disp) {
		set_resolution(disp->video(), resolution.first, resolution.second);
	} else {
		/* This part is needed when wesnoth is started with the -r parameter. */
		const std::string postfix = fullscreen() ? "resolution" : "windowsize";
		preferences::set(
				'x' + postfix, lexical_cast<std::string>(resolution.first));
		preferences::set(
				'y' + postfix, lexical_cast<std::string>(resolution.second));
	}
}
Exemplo n.º 10
0
static void parse_argv(int argc, char* argv[]){
	int op, option_index;
	while ( (op = getopt_long(argc, argv, shortopts, longopts, &option_index)) != -1 ){
		switch ( op ){
		case 0:   /* long opt*/
		case '?': /* invalid */
			break;

		case 'r': /* --resolution */
			set_resolution(optarg);

		case 'f': /* --fullscreen */
			fullscreen = true;
			break;

		case 'l':
			skip_load_scene = true;
			break;

		case 'w': /* --windowed */
			fullscreen = false;
			break;

		case 's': /* --seek */
			seek = atof(optarg);
			break;

		case 'n': /* --no-vsync */
			vsync = false;
			break;

		case 'v': /* --verbose */
			verbose_flag = true;
			break;

		case 'q': /* --quiet */
			verbose_flag = false;
			break;

		case 'h': /* --help */
			show_usage();
			exit(0);

		default:
			fprintf(stderr, "%s: declared but unhandled argument '%c' (0x%02X)\n", program_name, op, op);
			abort();
		}
	};
}
Exemplo n.º 11
0
theme::theme(const config& cfg, const SDL_Rect& screen)
	: theme_reset_event_("theme_reset")
	, cur_theme()
	, cfg_()
	, panels_()
	, labels_()
	, menus_()
	, actions_()
	, context_()
	, status_()
	, main_map_()
	, mini_map_()
	, unit_image_()
	, palette_()
	, border_()
{
	do_resolve_rects(expand_partialresolution(cfg), cfg_);
	set_resolution(screen);
}
Exemplo n.º 12
0
bool show_video_mode_dialog(display& disp)
{
	const resize_lock prevent_resizing;
	const events::event_context dialog_events_context;

	CVideo& video = disp.video();

	SDL_PixelFormat format = *video.getSurface()->format;
	format.BitsPerPixel = video.getBpp();

	const SDL_Rect* const * modes = SDL_ListModes(&format,FULL_SCREEN);

	// The SDL documentation says that a return value of -1
	// means that all dimensions are supported/possible.
	if(modes == reinterpret_cast<SDL_Rect**>(-1)) {
		std::cerr << "Can support any video mode\n";
		// SDL says that all modes are possible, so it's OK to use a
		// hardcoded list here. Include tiny and small gui since they
		// will be filtered out later if not needed.
		static const SDL_Rect scr_modes[] = {
			{ 0, 0,  320, 240  },
			{ 0, 0,  640, 480  },
			{ 0, 0,  800, 480  },	// small-gui (EeePC resolution)
			{ 0, 0,  800, 600  },
			{ 0, 0, 1024, 600  },	// used on many netbooks
			{ 0, 0, 1024, 768  },
			{ 0, 0, 1280, 960  },
			{ 0, 0, 1280, 1024 },
			{ 0, 0, 1366, 768  },	// 16:9 notebooks
			{ 0, 0, 1440, 900  },
			{ 0, 0, 1440, 1200 },
			{ 0, 0, 1600, 1200 },
			{ 0, 0, 1680, 1050 },
			{ 0, 0, 1920, 1080 },
			{ 0, 0, 1920, 1200 },
			{ 0, 0, 2560, 1600 }
		};
		static const SDL_Rect * const scr_modes_list[] = {
			&scr_modes[0],
			&scr_modes[1],
			&scr_modes[2],
			&scr_modes[3],
			&scr_modes[4],
			&scr_modes[5],
			&scr_modes[6],
			&scr_modes[7],
			&scr_modes[8],
			&scr_modes[9],
			&scr_modes[10],
			&scr_modes[11],
			&scr_modes[12],
			&scr_modes[13],
			&scr_modes[14],
			&scr_modes[15],
			NULL
		};

		modes = scr_modes_list;
	} else if(modes == NULL) {
		std::cerr << "No modes supported\n";
		gui2::show_transient_message(disp.video(),"",_("There are no alternative video modes available"));
		return false;
	}

	std::vector<std::pair<int,int> > resolutions;

	for(int i = 0; modes[i] != NULL; ++i) {
		if(modes[i]->w >= min_allowed_width() && modes[i]->h >= min_allowed_height()) {
			resolutions.push_back(std::pair<int,int>(modes[i]->w,modes[i]->h));
		}
	}

	const std::pair<int,int> current_res(video.getSurface()->w,video.getSurface()->h);
	resolutions.push_back(current_res);

	std::sort(resolutions.begin(),resolutions.end(),compare_resolutions);
	resolutions.erase(std::unique(resolutions.begin(),resolutions.end()),resolutions.end());

	std::vector<std::string> options;
	unsigned current_choice = 0;

	for(size_t k = 0; k < resolutions.size(); ++k) {
		std::pair<int, int> const& res = resolutions[k];
		std::ostringstream option;

		if (res == current_res)
			current_choice = static_cast<unsigned>(k);

		option << res.first << utils::unicode_multiplication_sign << res.second;
		/*widescreen threshold is 16:10*/
		if (static_cast<double>(res.first)/res.second >= 16.0/10.0)
		  option << _(" (widescreen)");
		options.push_back(option.str());
	}

	gui2::tsimple_item_selector dlg(_("Choose Resolution"), "", options);
	dlg.set_selected_index(current_choice);
	dlg.show(disp.video());

	int choice = dlg.selected_index();

	if(choice == -1 || resolutions[static_cast<size_t>(choice)] == current_res) {
		return false;
	}

	set_resolution(resolutions[static_cast<size_t>(choice)]);
	return true;
}
Exemplo n.º 13
0
static LRESULT CALLBACK window_handler( HWND window_handle, UINT message,
                                        WPARAM word_param, LPARAM long_param )
{
    bool result = false;

    switch (message)
    {
    case WM_SYSCOMMAND:
    {
        //the application doesn't seem to process sc_close correctly anymore. force an
        //exit of the game here. -ddn
        if (word_param == SC_CLOSE)
        {
            t_game_application::exit(0);
            PostQuitMessage(0);
            return 0;
        }
    }
    break;

    case WM_COMMAND:
        if (g_clearing_messages)
            break;
        if ( t_window::get_modal_window())
        {
            if (t_window::get_modal_window()->menu_click( LOWORD( word_param )))
                return 0;
        }
        else if ( t_window::get_main_window() )
        {
            if ( t_window::get_main_window()->menu_click( LOWORD( word_param ) ) )
                return 0;
        }
        else if ( g_game && g_game->menu_click( LOWORD(word_param) ))
            return 0;
        break;

    case WM_DESTROY:
        t_game_application::exit(0);
        PostQuitMessage(0);
        return 0;

    case WM_LBUTTONDBLCLK:
        if (g_clearing_messages)
            break;

        left_double_click( window_handle, word_param, long_param );
        return 0;

    case WM_LBUTTONDOWN:
        if (g_clearing_messages)
            break;

        left_button_down( window_handle, word_param, long_param );
        return 0;

    case WM_LBUTTONUP:
        if (g_clearing_messages)
            break;

        left_button_up( window_handle, word_param, long_param );
        return 0;

    case WM_MOVE:
        // handle_move( LOWORD(long_param), HIWORD(long_param) );
        return 0;

    case WM_MOUSEMOVE:
        mouse_move( window_handle, word_param, long_param );
        return 0;

    case WM_PAINT:
    {
        PAINTSTRUCT   ps;
        HDC           device_context = BeginPaint(window_handle, &ps);
        t_screen_rect rect = from_windows_rect( ps.rcPaint );
        t_window::invalidate_main_window( rect );
        g_dc = device_context;
        paint_windows();
        EndPaint(window_handle, &ps);
        return 0;
    }

    case WM_RBUTTONDBLCLK:
        if (g_clearing_messages)
            break;
        right_double_click( window_handle, word_param, long_param );
        return 0;

    case WM_RBUTTONDOWN:
        if (g_clearing_messages)
            break;
        right_button_down( window_handle, word_param, long_param );
        return 0;

    case WM_RBUTTONUP:
        if (g_clearing_messages)
            break;
        right_button_up( window_handle, word_param, long_param );
        return 0;

    case WM_SIZE:
        // handle_size( word_param, LOWORD(long_param), HIWORD(long_param) );
        return 0;

    case WM_ACTIVATE:
        if ( (LOWORD(word_param) == WA_ACTIVE)  || (LOWORD(word_param) == 	WA_CLICKACTIVE))
        {
            set_resolution(g_window_width , g_window_height, true);
            handle_adventure_sound_minimization(false);
        }


        if ( LOWORD(word_param) == 	WA_INACTIVE )
        {
            handle_adventure_sound_minimization(true);
        }
        break;

    case WM_DISPLAYCHANGE:
        break;
    }
    return DefWindowProc(window_handle, message, word_param, long_param);
}
Exemplo n.º 14
0
void t_game::initialize()
{
	t_window_ptr window;

	load_options();	

	//== writen by sunjun ==//
	// add_resource_file( "data/new.h4r" );
	// add_resource_file( "data/updates.h4r" );
	add_resource_file( "data/text.h4r" );
	add_resource_file( "data/music.h4r" );
	add_resource_file( "data/movies.h4r" );
	add_resource_folder( "data" );
	if (!add_resource_file( "data/heroes4.h4r" ))
	{
		fatal_error( "Unable to open data/heroes4.h4r" );
		exit(0);
	}

	t_pointer_cache< t_string_table > string_table_cache( "text" );
	t_pointer_cache< t_string_table > movie_string_table_cache( "intro voice over text" );
	t_pointer_cache< t_string_table > credits_string_table_cache( "credits" );

	t_external_string::add_table( *string_table_cache.get() );
	t_external_string::add_table( *movie_string_table_cache.get() );
	t_external_string::add_table( *credits_string_table_cache.get() );

	// this is a once-off shutdown for pre-release code
#ifdef k_useless_serialized_version
	fatal_error( k_text_serial_failure );
	exit(0);
#endif

	std::string cheat_text;

	if (get_command_line_argument( k_text_cheat_menu, cheat_text ))
	{		
		set_show_cheat_menus( true );
	}

	t_screen_point screen_size = get_desktop_size();

	m_frame_window = new t_gray_window(t_screen_rect(0, 0, g_window_width, g_window_height));

	t_mouse_window* cursor = new t_mouse_window;
	t_window*       animation = new t_animated_window( g_sample_cursor.get(), 
		                                               t_screen_point(0,0), 100, cursor );
	m_frame_window->set_cursor( cursor );
	
	set_resolution(g_window_width, g_window_height, false);

	initialize_platform();

	// Play the logo cinematics
	t_sound_cache music = get_music_playing();
	stop_music();

	play_music( music );

	t_main_menu* main_menu = new t_main_menu( m_frame_window );	
}
Exemplo n.º 15
0
RectViewport::RectViewport(Quad port, Vector2i new_resolution): port(port) {
	set_resolution(new_resolution);
	recompute_cell_properties();
}
Exemplo n.º 16
0
int
main(int argc, char **argv)
{
	struct libevdev *dev = NULL;
	int fd = -1;
	int rc = EXIT_FAILURE;
	enum mode mode;
	const char *path;
	struct input_absinfo absinfo;
	int axis = -1;
	int led = -1;
	int led_state = -1;
	unsigned int changes = 0; /* bitmask of changes */
	int xres = 0,
	    yres = 0;

	mode = parse_options_mode(argc, argv);
	switch (mode) {
		case MODE_HELP:
			rc = EXIT_SUCCESS;
			/* fallthrough */
		case MODE_NONE:
			usage();
			goto out;
		case MODE_ABS:
			rc = parse_options_abs(argc, argv, &changes, &axis,
					       &absinfo);
			break;
		case MODE_LED:
			rc = parse_options_led(argc, argv, &led, &led_state);
			break;
		case MODE_RESOLUTION:
			rc = parse_options_resolution(argc, argv, &xres,
						      &yres);
			break;
		default:
			fprintf(stderr,
				"++?????++ Out of Cheese Error. Redo From Start.\n");
			goto out;
	}

	if (rc != EXIT_SUCCESS)
		goto out;

	if (optind >= argc) {
		rc = EXIT_FAILURE;
		usage();
		goto out;
	}

	path = argv[optind];

	fd = open(path, O_RDWR);
	if (fd < 0) {
		rc = EXIT_FAILURE;
		perror("Failed to open device");
		goto out;
	}

	rc = libevdev_new_from_fd(fd, &dev);
	if (rc < 0) {
		fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc));
		goto out;
	}

	switch (mode) {
		case MODE_ABS:
			set_abs(dev, changes, axis, &absinfo);
			break;
		case MODE_LED:
			set_led(dev, led, led_state);
			break;
		case MODE_RESOLUTION:
			set_resolution(dev, xres, yres);
			break;
		default:
			break;
	}

out:
	libevdev_free(dev);
	if (fd != -1)
		close(fd);

	return rc;
}
Exemplo n.º 17
0
void loop()
{
	int value;

	// display menu to user
	display_menu();

	// wait for user to enter something
	while( !Serial.available() ) {
		delay(20);
	}

	// get character from user
	value = Serial.read();

	switch( value ) {

		case 'c' :
			// display all config
			display_config();
			break;

		case 'f' :
			// set frame rate
			set_frame_rate();
			break;

		case 'i' :
			// display image
			display_image();
			break;

		case 'I' :
			// display image continuously
			display_image_continuously();
			break;

		case 'm' :
			// display motion
			display_motion();
			break;

		case 'r' :
			// set resolution
			set_resolution();
			break;

		case 's' :
			// set shutter speed
			set_shutter_speed();
			break;

		case 'z' :
			// clear and reset everything
			flowSensor.clear_motion();
			break;

		default:
			Serial.println("unrecognised command");
			Serial.println();
			break;
	}
}
Exemplo n.º 18
0
//  extern int wifi_direct;// = 0;//1;//0;
  int HUServer::hu_handle_ServiceDiscoveryRequest (int chan, byte * buf, int len) {                  // Service Discovery Request

    HU::ServiceDiscoveryRequest request;
    if (!request.ParseFromArray(buf, len))
      loge ("Service Discovery Request: %x", buf [2]);
    else
      logd ("Service Discovery Request: %s", request.phone_name().c_str());                               // S 0 CTR b src: HU  lft:   113  msg_type:     6 Service Discovery Response    S 0 CTR b 00000000 0a 08 08 01 12 04 0a 02 08 0b 0a 13 08 02 1a 0f

    HU::ServiceDiscoveryResponse carInfo;
    carInfo.set_head_unit_name("Mazda Connect");
    carInfo.set_car_model("Mazda");
    carInfo.set_car_year("2016");
    carInfo.set_car_serial("0001");
    carInfo.set_driver_pos(true);
    carInfo.set_headunit_make("Mazda");
    carInfo.set_headunit_model("Connect");
    carInfo.set_sw_build("SWB1");
    carInfo.set_sw_version("SWV1");
    carInfo.set_can_play_native_media_during_vr(false);
    carInfo.set_hide_clock(false);

    carInfo.mutable_channels()->Reserve(AA_CH_MAX);

    HU::ChannelDescriptor* inputChannel = carInfo.add_channels();
    inputChannel->set_channel_id(AA_CH_TOU);
    {
      auto inner = inputChannel->mutable_input_event_channel();
      auto tsConfig = inner->mutable_touch_screen_config();
      tsConfig->set_width(800);
      tsConfig->set_height(480);

      //No idea what these mean since they aren't the same as HU_INPUT_BUTTON
      inner->add_keycodes_supported(HUIB_MENU); // 0x01 Open menu
      inner->add_keycodes_supported(HUIB_MIC1); // 0x02 Mic
      inner->add_keycodes_supported(HUIB_HOME); // 0x03 AA home
      inner->add_keycodes_supported(HUIB_BACK); // 0x04 Back
      inner->add_keycodes_supported(HUIB_PHONE); // 0x05 Phone screen
      inner->add_keycodes_supported(HUIB_CALLEND); // 0x06 End call??
      //inner->add_keycodes_supported(HUIB_NAV); // 0x07 Nav (This one is not correct)
      inner->add_keycodes_supported(HUIB_UP); // 0x13 Up
      inner->add_keycodes_supported(HUIB_DOWN); // 0x14 Down
      inner->add_keycodes_supported(HUIB_LEFT); // 0x15 Menu again
      inner->add_keycodes_supported(HUIB_RIGHT); // 0x16 Mic again
      inner->add_keycodes_supported(HUIB_ENTER); // 0x17 Select
      inner->add_keycodes_supported(HUIB_MIC); // 0x54 Mic again
      inner->add_keycodes_supported(HUIB_PLAYPAUSE); // 0x55 Play/Pause
      inner->add_keycodes_supported(HUIB_NEXT); // 0x57 Next track
      inner->add_keycodes_supported(HUIB_PREV); // 0x58 Prev Track
      inner->add_keycodes_supported(HUIB_SCROLLWHEEL);
      // Might as well include these even if we dont use them
      inner->add_keycodes_supported(HUIB_START); // 0x7E (126) Start media
      inner->add_keycodes_supported(HUIB_STOP); // 0x7F (127) Stop media

      callbacks.CustomizeInputConfig(*inner);

    }

    HU::ChannelDescriptor* sensorChannel = carInfo.add_channels();
    sensorChannel->set_channel_id(AA_CH_SEN);
    {
      auto inner = sensorChannel->mutable_sensor_channel();
      inner->add_sensor_list()->set_type(HU::SENSOR_TYPE_DRIVING_STATUS);
      inner->add_sensor_list()->set_type(HU::SENSOR_TYPE_NIGHT_DATA);
      inner->add_sensor_list()->set_type(HU::SENSOR_TYPE_LOCATION);

      callbacks.CustomizeSensorConfig(*inner);
    }

    HU::ChannelDescriptor* videoChannel = carInfo.add_channels();
    videoChannel->set_channel_id(AA_CH_VID);
    {
      auto inner = videoChannel->mutable_output_stream_channel();
      inner->set_type(HU::STREAM_TYPE_VIDEO);
      auto videoConfig = inner->add_video_configs();
      videoConfig->set_resolution(HU::ChannelDescriptor::OutputStreamChannel::VideoConfig::VIDEO_RESOLUTION_800x480);
      videoConfig->set_frame_rate(HU::ChannelDescriptor::OutputStreamChannel::VideoConfig::VIDEO_FPS_30);
      videoConfig->set_margin_width(0);
      videoConfig->set_margin_height(0);
      videoConfig->set_dpi(140);
      inner->set_available_while_in_call(true);

      callbacks.CustomizeOutputChannel(AA_CH_VID, *inner);
    }

    HU::ChannelDescriptor* audioChannel0 = carInfo.add_channels();
    audioChannel0->set_channel_id(AA_CH_AUD);
    {
      auto inner = audioChannel0->mutable_output_stream_channel();
      inner->set_type(HU::STREAM_TYPE_AUDIO);
      inner->set_audio_type(HU::AUDIO_TYPE_MEDIA);
      auto audioConfig = inner->add_audio_configs();
      audioConfig->set_sample_rate(48000);
      audioConfig->set_bit_depth(16);
      audioConfig->set_channel_count(2);
      inner->set_available_while_in_call(true);

      callbacks.CustomizeOutputChannel(AA_CH_AUD, *inner);
    }

    HU::ChannelDescriptor* audioChannel1 = carInfo.add_channels();
    audioChannel1->set_channel_id(AA_CH_AU1);
    {
      auto inner = audioChannel1->mutable_output_stream_channel();
      inner->set_type(HU::STREAM_TYPE_AUDIO);
      inner->set_audio_type(HU::AUDIO_TYPE_SPEECH);
      auto audioConfig = inner->add_audio_configs();
      audioConfig->set_sample_rate(16000);
      audioConfig->set_bit_depth(16);
      audioConfig->set_channel_count(1);

      callbacks.CustomizeOutputChannel(AA_CH_AU1, *inner);
    }

#ifdef PLAY_GUIDANCE_FROM_PHONE_SPEAKER
    HU::ChannelDescriptor* audioChannel2 = carInfo.add_channels();
    audioChannel2->set_channel_id(AA_CH_AU2);
    {
      auto inner = audioChannel1->mutable_output_stream_channel();
      inner->set_type(HU::STREAM_TYPE_AUDIO);
      inner->set_audio_type(HU::AUDIO_TYPE_SYSTEM);
      auto audioConfig = inner->add_audio_configs();
      audioConfig->set_sample_rate(16000);
      audioConfig->set_bit_depth(16);
      audioConfig->set_channel_count(1);

      callbacks.CustomizeOutputChannel(AA_CH_AU2, *inner);
    }
#endif

    HU::ChannelDescriptor* micChannel = carInfo.add_channels();
    micChannel->set_channel_id(AA_CH_MIC);
    {
      auto inner = micChannel->mutable_input_stream_channel();
      inner->set_type(HU::STREAM_TYPE_AUDIO);
      auto audioConfig = inner->mutable_audio_config();
      audioConfig->set_sample_rate(16000);
      audioConfig->set_bit_depth(16);
      audioConfig->set_channel_count(1);
      callbacks.CustomizeInputChannel(AA_CH_MIC, *inner);
    }

    callbacks.CustomizeCarInfo(carInfo);

    std::string carBTAddress = callbacks.GetCarBluetoothAddress();
    if (carBTAddress.size() > 0)
    {
        logw("Found BT address %s. Exposing Bluetooth service", carBTAddress.c_str());
        HU::ChannelDescriptor* btChannel = carInfo.add_channels();
        btChannel->set_channel_id(AA_CH_BT);
        {
          auto inner = btChannel->mutable_bluetooth_service();
          inner->set_car_address(carBTAddress);
          inner->add_supported_pairing_methods(HU::ChannelDescriptor_BluetoothService::BLUETOOTH_PARING_METHOD_A2DP);
          inner->add_supported_pairing_methods(HU::ChannelDescriptor_BluetoothService::BLUETOOTH_PARING_METHOD_HFP);
          callbacks.CustomizeBluetoothService(AA_CH_BT, *inner);
        }
    }
    else
    {
        logw("No Bluetooth or finding BT address failed. Not exposing Bluetooth service");
    }

    return hu_aap_enc_send_message(0, chan, HU_PROTOCOL_MESSAGE::ServiceDiscoveryResponse, carInfo);
  }
Exemplo n.º 19
0
void BlenderSync::sync_curves(Mesh *mesh,
                              BL::Mesh& b_mesh,
                              BL::Object& b_ob,
                              bool motion,
                              int motion_step)
{
	if(!motion) {
		/* Clear stored curve data */
		mesh->curve_keys.clear();
		mesh->curve_radius.clear();
		mesh->curve_first_key.clear();
		mesh->curve_shader.clear();
		mesh->curve_attributes.clear();
	}

	/* obtain general settings */
	const bool use_curves = scene->curve_system_manager->use_curves;

	if(!(use_curves && b_ob.mode() != b_ob.mode_PARTICLE_EDIT)) {
		if(!motion)
			mesh->compute_bounds();
		return;
	}

	const int primitive = scene->curve_system_manager->primitive;
	const int triangle_method = scene->curve_system_manager->triangle_method;
	const int resolution = scene->curve_system_manager->resolution;
	const size_t vert_num = mesh->verts.size();
	const size_t tri_num = mesh->num_triangles();
	int used_res = 1;

	/* extract particle hair data - should be combined with connecting to mesh later*/

	ParticleCurveData CData;

	if(!preview)
		set_resolution(&b_ob, &b_scene, true);

	ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, !preview);

	/* add hair geometry to mesh */
	if(primitive == CURVE_TRIANGLES) {
		if(triangle_method == CURVE_CAMERA_TRIANGLES) {
			/* obtain camera parameters */
			float3 RotCam;
			Camera *camera = scene->camera;
			Transform &ctfm = camera->matrix;
			if(camera->type == CAMERA_ORTHOGRAPHIC) {
				RotCam = -make_float3(ctfm.x.z, ctfm.y.z, ctfm.z.z);
			}
			else {
				Transform tfm = get_transform(b_ob.matrix_world());
				Transform itfm = transform_quick_inverse(tfm);
				RotCam = transform_point(&itfm, make_float3(ctfm.x.w,
				                                            ctfm.y.w,
				                                            ctfm.z.w));
			}
			bool is_ortho = camera->type == CAMERA_ORTHOGRAPHIC;
			ExportCurveTrianglePlanes(mesh, &CData, RotCam, is_ortho);
		}
		else {
			ExportCurveTriangleGeometry(mesh, &CData, resolution);
			used_res = resolution;
		}
	}
	else {
		if(motion)
			ExportCurveSegmentsMotion(mesh, &CData, motion_step);
		else
			ExportCurveSegments(scene, mesh, &CData);
	}

	/* generated coordinates from first key. we should ideally get this from
	 * blender to handle deforming objects */
	if(!motion) {
		if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
			float3 loc, size;
			mesh_texture_space(b_mesh, loc, size);

			if(primitive == CURVE_TRIANGLES) {
				Attribute *attr_generated = mesh->attributes.add(ATTR_STD_GENERATED);
				float3 *generated = attr_generated->data_float3();

				for(size_t i = vert_num; i < mesh->verts.size(); i++)
					generated[i] = mesh->verts[i]*size - loc;
			}
			else {
				Attribute *attr_generated = mesh->curve_attributes.add(ATTR_STD_GENERATED);
				float3 *generated = attr_generated->data_float3();

				for(size_t i = 0; i < mesh->num_curves(); i++) {
					float3 co = mesh->curve_keys[mesh->get_curve(i).first_key];
					generated[i] = co*size - loc;
				}
			}
		}
	}

	/* create vertex color attributes */
	if(!motion) {
		BL::Mesh::tessface_vertex_colors_iterator l;
		int vcol_num = 0;

		for(b_mesh.tessface_vertex_colors.begin(l); l != b_mesh.tessface_vertex_colors.end(); ++l, vcol_num++) {
			if(!mesh->need_attribute(scene, ustring(l->name().c_str())))
				continue;

			ObtainCacheParticleVcol(mesh, &b_mesh, &b_ob, &CData, !preview, vcol_num);

			if(primitive == CURVE_TRIANGLES) {
				Attribute *attr_vcol = mesh->attributes.add(
					ustring(l->name().c_str()), TypeDesc::TypeColor, ATTR_ELEMENT_CORNER_BYTE);

				uchar4 *cdata = attr_vcol->data_uchar4();

				ExportCurveTriangleVcol(&CData, tri_num * 3, used_res, cdata);
			}
			else {
				Attribute *attr_vcol = mesh->curve_attributes.add(
					ustring(l->name().c_str()), TypeDesc::TypeColor, ATTR_ELEMENT_CURVE);

				float3 *fdata = attr_vcol->data_float3();

				if(fdata) {
					size_t i = 0;

					for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++)
						if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f))
							fdata[i++] = color_srgb_to_scene_linear_v3(CData.curve_vcol[curve]);
				}
			}
		}
	}

	/* create UV attributes */
	if(!motion) {
		BL::Mesh::tessface_uv_textures_iterator l;
		int uv_num = 0;

		for(b_mesh.tessface_uv_textures.begin(l); l != b_mesh.tessface_uv_textures.end(); ++l, uv_num++) {
			bool active_render = l->active_render();
			AttributeStandard std = (active_render)? ATTR_STD_UV: ATTR_STD_NONE;
			ustring name = ustring(l->name().c_str());

			/* UV map */
			if(mesh->need_attribute(scene, name) || mesh->need_attribute(scene, std)) {
				Attribute *attr_uv;

				ObtainCacheParticleUV(mesh, &b_mesh, &b_ob, &CData, !preview, uv_num);

				if(primitive == CURVE_TRIANGLES) {
					if(active_render)
						attr_uv = mesh->attributes.add(std, name);
					else
						attr_uv = mesh->attributes.add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CORNER);

					float3 *uv = attr_uv->data_float3();

					ExportCurveTriangleUV(&CData, tri_num * 3, used_res, uv);
				}
				else {
					if(active_render)
						attr_uv = mesh->curve_attributes.add(std, name);
					else
						attr_uv = mesh->curve_attributes.add(name, TypeDesc::TypePoint,  ATTR_ELEMENT_CURVE);

					float3 *uv = attr_uv->data_float3();

					if(uv) {
						size_t i = 0;

						for(size_t curve = 0; curve < CData.curve_uv.size(); curve++)
							if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f))
								uv[i++] = CData.curve_uv[curve];
					}
				}
			}
		}
	}

	if(!preview)
		set_resolution(&b_ob, &b_scene, false);

	mesh->compute_bounds();
}
Exemplo n.º 20
0
/*!
   A function version of the program mc by Thomas Lewiner
   see main.c in ./MarchingCubes
*/
SUMA_SurfaceObject *SUMA_MarchingCubesSurface(
                        SUMA_GENERIC_PROG_OPTIONS_STRUCT * Opt)
{
   static char FuncName[]={"SUMA_MarchingCubesSurface"};
   SUMA_SurfaceObject *SO=NULL;
   int nxx, nyy, nzz, cnt, i, j, k, *FaceSetList=NULL;
   float *NodeList=NULL;
   SUMA_NEW_SO_OPT *nsoopt = NULL;
   THD_fvec3 fv, iv;
   MCB *mcp ;
   
   SUMA_ENTRY;
   
   if (Opt->obj_type < 0) {
      nxx = DSET_NX(Opt->in_vol);
      nyy = DSET_NY(Opt->in_vol);
      nzz = DSET_NZ(Opt->in_vol);

      if (Opt->debug) {
         fprintf(SUMA_STDERR,
                 "%s:\nNxx=%d\tNyy=%d\tNzz=%d\n", FuncName, nxx, nyy, nzz);
      }

      mcp = MarchingCubes(-1, -1, -1);
      set_resolution( mcp, nxx, nyy, nzz ) ;
      init_all(mcp) ;
      if (Opt->debug) fprintf(SUMA_STDERR,"%s:\nSetting data...\n", FuncName);
      cnt = 0;
      for(  k = 0 ; k < mcp->size_z ; k++ ) {
         for(  j = 0 ; j < mcp->size_y ; j++ ) {
            for(  i = 0 ; i < mcp->size_x ; i++ ) {
               SUMA_SET_MC_DATA ( mcp, Opt->mcdatav[cnt], i, j, k); 
               ++cnt;
            }
         }
      }

   } else {
      /* built in */
      nxx = nyy = nzz = Opt->obj_type_res;
      mcp = MarchingCubes(-1, -1, -1);
      set_resolution( mcp, nxx, nyy, nzz) ;
      init_all(mcp) ;
      compute_data( *mcp , Opt->obj_type) ;
   }

   
   if (Opt->debug) 
      fprintf(SUMA_STDERR,"%s:\nrunning MarchingCubes...\n", FuncName);
   run(mcp) ;
   clean_temps(mcp) ;

   if (Opt->debug > 1) {
      fprintf(SUMA_STDERR,"%s:\nwriting out NodeList and FaceSetList...\n", 
                         FuncName);
      write1Dmcb(mcp);
   }

   if (Opt->debug) {
      fprintf(SUMA_STDERR,"%s:\nNow creating SO...\n", FuncName);
   }

   NodeList = (float *)SUMA_malloc(sizeof(float)*3*mcp->nverts);
   FaceSetList = (int *)SUMA_malloc(sizeof(int)*3*mcp->ntrigs);
   if (!NodeList || !FaceSetList)  {
      SUMA_SL_Crit("Failed to allocate!");
      SUMA_RETURN(SO);
   }
   
   nsoopt = SUMA_NewNewSOOpt();
   if (Opt->obj_type < 0) {
      nsoopt->LargestBoxSize = -1;
      if (Opt->debug) {
         fprintf(SUMA_STDERR,
                  "%s:\nCopying vertices, changing to DICOM \n"
                  "Orig:(%f %f %f) \nD:(%f %f %f)...\n", 
            FuncName, 
            DSET_XORG(Opt->in_vol), 
            DSET_YORG(Opt->in_vol), DSET_ZORG(Opt->in_vol),
            DSET_DX(Opt->in_vol), 
            DSET_DY(Opt->in_vol), DSET_DZ(Opt->in_vol));
      }
      for ( i = 0; i < mcp->nverts; i++ ) {
         j = 3*i; /* change from index coordinates to mm DICOM, next three lines are equivalent of SUMA_THD_3dfind_to_3dmm*/
         fv.xyz[0] = DSET_XORG(Opt->in_vol) + mcp->vertices[i].x * DSET_DX(Opt->in_vol);
         fv.xyz[1] = DSET_YORG(Opt->in_vol) + mcp->vertices[i].y * DSET_DY(Opt->in_vol);
         fv.xyz[2] = DSET_ZORG(Opt->in_vol) + mcp->vertices[i].z * DSET_DZ(Opt->in_vol);
         /* change mm to RAI coords */
		   iv = SUMA_THD_3dmm_to_dicomm( Opt->in_vol->daxes->xxorient, Opt->in_vol->daxes->yyorient, Opt->in_vol->daxes->zzorient, fv );
         NodeList[j  ] = iv.xyz[0];
         NodeList[j+1] = iv.xyz[1];
         NodeList[j+2] = iv.xyz[2];
      }
      for ( i = 0; i < mcp->ntrigs; i++ ) {
         j = 3*i;
         FaceSetList[j  ] = mcp->triangles[i].v3;
         FaceSetList[j+1] = mcp->triangles[i].v2;
         FaceSetList[j+2] = mcp->triangles[i].v1;
      }
   } else {
      nsoopt->LargestBoxSize = 100;
      /* built in */
      for ( i = 0; i < mcp->nverts; i++ ) {
         j = 3*i;
         NodeList[j  ] = mcp->vertices[i].x;
         NodeList[j+1] = mcp->vertices[i].y;
         NodeList[j+2] = mcp->vertices[i].z;
      }   
      for ( i = 0; i < mcp->ntrigs; i++ ) {
         j = 3*i;
         FaceSetList[j  ] = mcp->triangles[i].v3;
         FaceSetList[j+1] = mcp->triangles[i].v2;
         FaceSetList[j+2] = mcp->triangles[i].v1;
      }
   }
   

   SO = SUMA_NewSO(&NodeList, mcp->nverts, &FaceSetList, mcp->ntrigs, nsoopt);
   if (Opt->obj_type < 0) {
      /* not sure if anything needs to be done here ...*/
   } else {
      if (Opt->obj_type == 0) SO->normdir = 1;
      else SO->normdir = -1;
   }
   
   if (Opt->debug) {
      fprintf(SUMA_STDERR,"%s:\nCleaning mcp...\n", FuncName);
   }
   clean_all(mcp) ;
   free(mcp);
   nsoopt=SUMA_FreeNewSOOpt(nsoopt); 

   SUMA_RETURN(SO);
}
Exemplo n.º 21
0
bool show_video_mode_dialog(display& disp)
{
	CVideo& video = disp.video();

	SDL_PixelFormat format = *video.getSurface()->format;
	format.BitsPerPixel = video.getBpp();

	bool fullScreen = fullscreen();

	std::vector<std::pair<int,int> > resolutions;
	int display = SDL_GetWindowDisplayIndex(disp.video().getWindow());
	int modes = SDL_GetNumDisplayModes(display);
	SDL_DisplayMode mode = {SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
	SDL_Rect screen_rect = disp.video().bound();
	for (int n = 0; n < modes; n ++) {
		SDL_GetDisplayMode(display, n, &mode);
		if (SDL_BYTESPERPIXEL(mode.format) != SDL_BYTESPERPIXEL(video.getformat())) {
			continue;
		}
#if defined(_WIN32)
		if (!fullScreen && (mode.w >= screen_rect.w || mode.h >= screen_rect.h)) {
			continue;
		}
#endif
		if (mode.w >= min_allowed_width() && mode.h >= min_allowed_height()) {
			resolutions.push_back(std::pair<int, int>(mode.w, mode.h));
		}
	}

	if (resolutions.empty()) {
		gui2::show_transient_message(disp.video(), "", _("There are no alternative video modes available"));
		return false;
	}

	const std::pair<int,int> current_res(video.getSurface()->w, video.getSurface()->h);
	resolutions.push_back(current_res);
	if (!fullScreen) {
		resolutions.push_back(std::make_pair(480, 320));
		resolutions.push_back(std::make_pair(568, 320));
		resolutions.push_back(std::make_pair(800, 480));
		resolutions.push_back(std::make_pair(854, 480));
		resolutions.push_back(std::make_pair(1280, 720));
		resolutions.push_back(std::make_pair(1280, 800));
	}

	std::sort(resolutions.begin(),resolutions.end(),compare_resolutions);
	resolutions.erase(std::unique(resolutions.begin(),resolutions.end()),resolutions.end());

	std::vector<std::string> options;
	unsigned current_choice = 0;

	for(size_t k = 0; k < resolutions.size(); ++k) {
		std::pair<int, int> const& res = resolutions[k];
		std::ostringstream option;

		if (res == current_res) {
			current_choice = static_cast<unsigned>(k);		
		}

		option << res.first << "x" << res.second;
		// widescreen threshold is 16:10
		if ((double)res.first/res.second >= 16.0/10.0) {
			option << _(" (widescreen)");
		}
		options.push_back(option.str());
	}

	gui2::tsimple_item_selector dlg(_("Choose Resolution"), "", options);
	dlg.set_selected_index(current_choice);
	dlg.show(disp.video());

	int choice = dlg.selected_index();

	if (choice == -1 || resolutions[static_cast<size_t>(choice)] == current_res) {
		return false;
	}

	std::pair<int, int>& res = resolutions[static_cast<size_t>(choice)];
	set_resolution(disp, res.first, res.second);
	return true;
}
Exemplo n.º 22
0
void toggle_fullscreen(void) {
	option_t *option = config_get_option("full_screen");
	option_select_value_by_index(option, 1 - option->selected->index);
	set_resolution(0);
}
Exemplo n.º 23
0
QcMapResolution::QcMapResolution(double resolution)
  : m_resolution(qQNaN())
{
  set_resolution(resolution);
}