Пример #1
0
void draw_scrollbar (ESContext *esContext, uint16_t page, uint16_t page_max, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	if (page_max > 0) {
		draw_box_f3(esContext, 1.3, -0.77, 0.002, 1.35, 0.77, 0.002, 255, 255, 255, 128);
		set_button("down", setup.view_mode, 1.3, -0.77, 1.35, -0.67, callback, -1.0, 0);
		set_button("down2", setup.view_mode, 1.3, -0.77, 1.35, 0.0, callback, -1.0, 0);
		draw_box_f3(esContext, 1.3, -0.77, 0.002, 1.35, -0.67, 0.002, 255, 255, 255, 128);
		draw_box_f3(esContext, 1.3, -0.77, 0.002, 1.35, -0.67, 0.002, 255, 255, 255, 128);
		draw_rect_f3(esContext, 1.3, -0.77, 0.002, 1.35, -0.67, 0.002, 255, 255, 255, 128);
		set_button("up", setup.view_mode, 1.3, 0.67, 1.35, 0.77, callback, 1.0, 0);
		set_button("up2", setup.view_mode, 1.3, 0.0, 1.35, 0.77, callback, 1.0, 0);
		if (page < 0) {
			page = 0;
		}
		if (page > page_max) {
			page = page_max;
		}
		draw_box_f3(esContext, 1.3, 0.67, 0.002, 1.35, 0.77, 0.002, 255, 255, 255, 128);
		draw_box_f3(esContext, 1.3, 0.77, 0.002, 1.35, 0.67, 0.002, 255, 255, 255, 128);
		draw_rect_f3(esContext, 1.3, 0.77, 0.002, 1.35, 0.67, 0.002, 255, 255, 255, 128);
		draw_box_f3(esContext, 1.3 - 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max) - 0.02, 0.002, 1.35 + 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max), 0.002, 255, 255, 255, 200);
		draw_rect_f3(esContext, 1.3 - 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max) - 0.02, 0.002, 1.35 + 0.01, -0.67 + (1.34) * (float)(page) / (float)(page_max), 0.002, 100, 100, 100, 128);
	}
}
Пример #2
0
static int tilt_func(void *data)
{
    wiimote_t   wiimote = WIIMOTE_INIT;
    const char *address = config_get_s(CONFIG_WIIMOTE_ADDR);

    if (strlen(address) > 0)
    {
        if (wiimote_connect(&wiimote, address) < 0)
            log_printf("Wiimote error (%s)\n", wiimote_get_error());
        else
        {
            int running = 1;

            wiimote.mode.bits = WIIMOTE_MODE_ACC;
            wiimote.led.one   = 1;

            SDL_mutexP(mutex);
            state.status = running;
            SDL_mutexV(mutex);

            while (mutex && running && wiimote_is_open(&wiimote))
            {
                if (wiimote_update(&wiimote) < 0)
                    break;

                SDL_mutexP(mutex);
                {
                    running = state.status;

                    set_button(&state.A,     wiimote.keys.a);
                    set_button(&state.B,     wiimote.keys.b);
                    set_button(&state.plus,  wiimote.keys.plus);
                    set_button(&state.minus, wiimote.keys.minus);
                    set_button(&state.home,  wiimote.keys.home);
                    set_button(&state.L,     wiimote.keys.left);
                    set_button(&state.R,     wiimote.keys.right);
                    set_button(&state.U,     wiimote.keys.up);
                    set_button(&state.D,     wiimote.keys.down);

                    if (isnormal(wiimote.tilt.y))
                    {
                        state.x = (state.x * (FILTER - 1) +
                                   wiimote.tilt.y) / FILTER;
                    }
                    if (isnormal(wiimote.tilt.x))
                    {
                        state.z = (state.z * (FILTER - 1) +
                                   wiimote.tilt.x) / FILTER;
                    }
                }
                SDL_mutexV(mutex);
            }

            wiimote_disconnect(&wiimote);
        }
    }
    return 0;
}
Пример #3
0
static void
score_start(ScoreStyleList style, guint x, guint y, guint max)
{
  max_score = max;
  set_button(BUTTON_SCORE, TRUE);
  update_score(0);
}
Пример #4
0
void draw_spinbox (ESContext *esContext, float x1, float y1, float w, float z, char *name, char *format, float value, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	float x2 = x1 + w;
	float h = 0.07;
	float y2 = y1 + h;
	char tmp_str[1024];
	sprintf(tmp_str, format, value);
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 + 0.005, z, x2 - 0.02, y1 + h / 2 + 0.005, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 + 0.005, z, x2 - h / 2, y1 + h / 2 + 0.02, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 + 0.02, z, x2 - 0.02, y1 + h / 2 + 0.005, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.005, z, x2 - 0.02, y1 + h / 2 - 0.005, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.005, z, x2 - h / 2, y1 + h / 2 - 0.02, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 - 0.02, z, x2 - 0.02, y1 + h / 2 - 0.005, z, 255, 255, 255, 255);
	draw_text_f3(esContext, x1 + 0.005, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, tmp_str);
	set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0);
}
Пример #5
0
void draw_pulldown (ESContext *esContext, float x1, float y1, float w, float z, char *name, EntryList *list, uint8_t open, uint8_t select, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	uint8_t n = 0;
	float x2 = x1 + w;
	float h = 0.07;
	float y2 = y1 + h;
	char tmp_str[1024];
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	if (open == 1) {
//		y1 -= select * h;
//		y2 -= select * h;
		while (list[n].name != NULL) {
			if (n == select) {
				draw_box_f3(esContext, x1 + 0.01, y1 + n * h, z, x2 - 0.01, y2 + n * h, z + 0.05, 200, 200, 200, 200);
			} else {
				draw_box_f3(esContext, x1 + 0.01, y1 + n * h, z, x2 - 0.01, y2 + n * h, z + 0.05, 255, 255, 255, 200);
			}
			draw_text_f3(esContext, x1 + 0.001 + 0.005, y1 + n * h + 0.005, z + 0.1, h - 0.01, h - 0.01, FONT_GREEN, list[n].name);
			sprintf(tmp_str, "%s_%i", name, n);
			set_button(tmp_str, setup.view_mode, x1 + 0.01, y1 + n * h, x2 + 0.01, y2 + n * h, callback, (float)(n + 1), 0);
			n++;
		}
		gui_ov_lock = 1;
	} else {
		draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.01, z, x2 - 0.02, y1 + h / 2 - 0.01, z, 255, 255, 255, 255);
		draw_line_f3(esContext, x2 - h + 0.02, y1 + h / 2 - 0.01, z, x2 - h / 2, y1 + h / 2 + 0.01, z, 255, 255, 255, 255);
		draw_line_f3(esContext, x2 - h / 2, y1 + h / 2 + 0.01, z, x2 - 0.02, y1 + h / 2 - 0.01, z, 255, 255, 255, 255);
		draw_text_f3(esContext, x1 + 0.005, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, list[select].name);
		sprintf(tmp_str, "%s", name);
		set_button(tmp_str, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0);
	}
}
Пример #6
0
int
add_key (KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keycode,
	 unsigned int button, unsigned int modifier, char *command, SCM function)
{
  Keys_t *keys_bis = NULL;
  int i;

  if (keysym == 0 && keycode == 0 && button == 0)
    {
      fprintf (stderr, "Warning: unkown key in RC file : %s\n", rc_file);
      return (-1);
    }

  /* make new array keys_bis */
  keys_bis = (Keys_t *) g_malloc ((nb_keys + 1) * sizeof (Keys_t));
  if (keys_bis == NULL)
    return (-1);

  if (keys != NULL)
    {
      /* copy keys in keys_bis */
      for (i = 0; i < nb_keys; i++)
	{
	  keys_bis[i] = keys[i];
	}

      /* delete old keys array */
      g_free (keys);
    }

  /* make keys_bis as keys */
  keys = keys_bis;

  modifier &= ~(numlock_mask | capslock_mask | scrolllock_mask);

  /* set key */
  if (type == SYM)
    {
      set_keysym (&keys[nb_keys], event_type, keysym, modifier, command, function);
    }
  else if (type == BUTTON)
    {
      set_button (&keys[nb_keys], event_type, button, modifier, command, function);
    }
  else
    {
      set_keycode (&keys[nb_keys], event_type, keycode, modifier, command, function);
    }

  /* new key */
  nb_keys += 1;

  return (0);
}
Пример #7
0
void draw_buttonbox (ESContext *esContext, char *name, uint8_t view_mode, char *text, float x1, float y1, float w, float z, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t), float data) {
#ifdef CONSOLE_ONLY
	return;
#endif
	float x2 = x1 + w;
	float h = 0.07;
	float y2 = y1 + h;
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	draw_text_f3(esContext, x1 + w / 2 - (h - 0.01) * 0.6 * strlen(text) / 2.0 - (h - 0.01) * 0.6 / 3.0, y1 + 0.005, z + 0.001, h - 0.01, h - 0.01, FONT_GREEN, text);
	set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0);
}
Пример #8
0
void draw_window (ESContext *esContext, float x1, float y1, float x2, float y2, float z, char *name, char *title, EntryList *list, uint8_t select, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	uint8_t n = 0;
	uint8_t m = 0;
	float tw = 0.6;
	float step = 0.4;
	char tmp_str[1024];
	while (list[m].name != NULL) {
		m++;
	}
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, 0.04, 55, 55, 255, 100);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, 0.04, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 55, 55, 255, 100);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	draw_line_f3(esContext, x1, y1 + 0.08, z, x1 + tw, y1 + 0.08, z, 255, 255, 255, 255);
	draw_line_f3(esContext, x1 + tw, y1 + 0.08, z, x1 + tw + 0.1, y1, z, 255, 255, 255, 255);
	draw_text_f3(esContext, x1 + 0.05, y1 + 0.01, z + 0.001, 0.07, 0.07, FONT_PINK, title);
	while (list[n].name != NULL) {
		sprintf(tmp_str, "%s%i", name, n);
		if (n == select) {
			draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x1 + tw + step * n + step, y1 + 0.08, z, 255, 255, 255, 100);
		} else {
			draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x1 + tw + step * n + step, y1 + 0.08, z, 255, 255, 255, 255);
		}
		draw_line_f3(esContext, x1 + tw + step * n + step, y1 + 0.08, z, x1 + tw + step * n + step + 0.1, y1, z, 255, 255, 255, 255);
		draw_text_f3(esContext, x1 + tw + step * n + 0.07, y1 + 0.02, z + 0.001, 0.06, 0.06, FONT_WHITE, list[n].name);
		set_button(tmp_str, setup.view_mode, x1 + tw + step * n, y1, x1 + tw + step * n + step, y1 + 0.08, callback, (float)n, 0);
		n++;
	}
	draw_line_f3(esContext, x1 + tw + step * n, y1 + 0.08, z, x2, y1 + 0.08, z, 255, 255, 255, 255);
}
Пример #9
0
void draw_checkbox (ESContext *esContext, float x1, float y1, float z, char *name, uint8_t check, uint8_t (*callback) (char *, float, float, int8_t, float, uint8_t)) {
#ifdef CONSOLE_ONLY
	return;
#endif
	float w = 0.07;
	float h = 0.07;
	float x2 = x1 + w;
	float y2 = y1 + h;
#ifdef SDLGL
#ifndef ANDROID
	draw_box_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 55);
	draw_rect_rounded_f3(esContext, x1, y1, z, x2, y2, z, h / 3, 255, 255, 255, 255);
#else
	draw_box_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 55);
	draw_rect_f3(esContext, x1, y1, z, x2, y2, z, 255, 255, 255, 255);
#endif
#endif
	if (check == 1) {
		draw_line_f3(esContext, x1 + 0.02, y1 + 0.02, z, x2 - 0.02, y2 - 0.02, z, 255, 255, 255, 255);
		draw_line_f3(esContext, x1 + 0.02, y2 - 0.02, z, x2 - 0.02, y1 + 0.02, z, 255, 255, 255, 255);
	}
	set_button(name, setup.view_mode, x1, y1, x2, y2, callback, 0.0, 0);
}
Пример #10
0
void RichTextEdit::showBar()
{
    if (m_bar)
        return;
    m_bar = new QToolBar(this);

    btnBG = new ColorToolButton(m_bar, m_edit->background());
    set_button(btnBG, "bgcolor", I18N_NOOP("Bac&kground color"));
    connect(btnBG, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor)));

    btnFG = new ColorToolButton(m_bar, m_edit->foreground());
    set_button(btnFG, "fgcolor", I18N_NOOP("&Text color"));
    connect(btnFG, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor)));
    connect(btnFG, SIGNAL(aboutToShow()), this, SLOT(showFgPopup()));

    m_bar->addSeparator();

    btnBold = new QToolButton(m_bar);
    set_button(btnBold, "text_bold", I18N_NOOP("&Bold"));
    btnBold->setToggleButton(true);
    connect(btnBold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));

    btnItalic = new QToolButton(m_bar);
    set_button(btnItalic, "text_italic", I18N_NOOP("&Italic"));
    btnItalic->setToggleButton(true);
    connect(btnItalic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));

    btnUnderline = new QToolButton(m_bar);
    set_button(btnUnderline, "text_under", I18N_NOOP("&Underline"));
    btnUnderline->setToggleButton(true);
    connect(btnUnderline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));

    m_bar->addSeparator();

    QToolButton *btn = new QToolButton(m_bar);
    set_button(btn, "text", I18N_NOOP("Text &font"));
    connect(btn, SIGNAL(clicked()), this, SLOT(selectFont()));

    connect(m_edit, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(fontChanged(const QFont&)));
}
Пример #11
0
static void input_work_func(struct work_struct *work)
{
	int adc_value = -1;
	int val = 0;
	ktime_t temptime;

	adc_value = auxadc_access(2);
	val = readl(io_p2v(REG_ANACR12));
//	printk("%s: REG_ANACR2=%d, REG_ANACR12=%d\n", __func__,adc_value , val);

	if(val >= KEY_PRESS_THRESHOLD && adc_value >= KEY1_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U)
	{
		temptime = ktime_get();
		temptime = ktime_sub(temptime, mic.hsbtime);

		if(temptime.tv.nsec < VALID_RELEASE_REF_TIME && mic.keypressing == PRESS)
		{
			if ( adc_value >= KEY1_THRESHOLD_L && adc_value < KEY1_THRESHOLD_U )
			{
				mic.key_count[0]++;
				printk ("KEY_BCM_HEADSET_BUTTON \n");
			}
			else if ( adc_value >= KEY2_THRESHOLD_L && adc_value < KEY2_THRESHOLD_U ) 
			{
				mic.key_count[1]++;
				printk ("KEY_VOLUMEUP \n");
			}
			else if ( adc_value >= KEY3_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U ) 
			{
				mic.key_count[2]++;
				printk ("KEY_VOLUMEDOWN \n");
			}
		}
		else
		{
			if(mic.keypressing == PRESS && (mic.key_count[0] + mic.key_count[1] + mic.key_count[2]))
			{
				input_report_key(mic.headset_button_idev, Return_valid_key(mic.key_count), PRESS);
				input_sync(mic.headset_button_idev);

				set_button(1); 
				mic.keypressing = RELEASE;
			}
		}

		cancel_delayed_work(&(mic.input_work));
		queue_delayed_work(mic.headset_workqueue, &(mic.input_work), KEY_PRESS_REF_TIME);
	}
	else
	{
		if(mic.keypressing == RELEASE && (mic.key_count[0] + mic.key_count[1] + mic.key_count[2]))
		{			
			printk ("%s: RELEASE key_count [%d, %d, %d] \n", __func__,  mic.key_count[0], mic.key_count[1], mic.key_count[2]);
			input_report_key(mic.headset_button_idev, Return_valid_key(mic.key_count), RELEASE);
			input_sync(mic.headset_button_idev);
		}
		else
		{
			printk("%s: NO PRESS\n",  __func__);
		}

		if(FactoryMode == DISABLE)
		{
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE | SYSCFG_DISABLE);
			sync_use_mic = DISABLE;		
		}
		
		set_button(0); 
		mic.keypressing = NONE;
	}
}
Пример #12
0
static void input_work_func(struct work_struct *work)
{
	int adc_value = -1;
	int val = 0;
	ktime_t temptime;

	adc_value = auxadc_access(2);
	val = readl(io_p2v(REG_ANACR12));
//	printk("%s: REG_ANACR2=%d, REG_ANACR12=%d\n", __func__,adc_value , val);

#ifdef USE_SERVICEMODE
	if(val >= KEY_PRESS_THRESHOLD && adc_value >= Min_threshold && adc_value < Max_threshold)
	{
#else
	if(val >= KEY_PRESS_THRESHOLD && adc_value >= KEY1_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U)
	{
#endif
		temptime = ktime_get();
		temptime = ktime_sub(temptime, mic.hsbtime);

		if(temptime.tv.nsec < VALID_RELEASE_REF_TIME && mic.keypressing == PRESS)
		{
			if ( adc_value >= KEY1_THRESHOLD_L && adc_value < KEY1_THRESHOLD_U )
			{
				mic.key_count[0]++;
				printk ("KEY_BCM_HEADSET_BUTTON \n");
			}
			else if ( adc_value >= KEY2_THRESHOLD_L && adc_value < KEY2_THRESHOLD_U ) 
			{
				mic.key_count[1]++;
				printk ("KEY_VOLUMEUP \n");
			}
			else if ( adc_value >= KEY3_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U ) 
			{
				mic.key_count[2]++;
				printk ("KEY_VOLUMEDOWN \n");
			}
		}
		else
		{
			if(mic.keypressing == PRESS && (mic.key_count[0] + mic.key_count[1] + mic.key_count[2]))
			{
				input_report_key(mic.headset_button_idev, Return_valid_key(mic.key_count), PRESS);
				input_sync(mic.headset_button_idev);

				set_button(1); 
				mic.keypressing = RELEASE;
			}
		}

		cancel_delayed_work(&(mic.input_work));
		queue_delayed_work(mic.headset_workqueue, &(mic.input_work), KEY_PRESS_REF_TIME);
	}
	else
	{
		if(mic.keypressing == RELEASE && (mic.key_count[0] + mic.key_count[1] + mic.key_count[2]))
		{			
			printk ("%s: RELEASE key_count [%d, %d, %d] \n", __func__,  mic.key_count[0], mic.key_count[1], mic.key_count[2]);
			input_report_key(mic.headset_button_idev, Return_valid_key(mic.key_count), RELEASE);
			input_sync(mic.headset_button_idev);
		}
		else
		{
			printk("%s: NO PRESS\n",  __func__);
		}

		if(FactoryMode == DISABLE)
		{
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE | SYSCFG_DISABLE);
			sync_use_mic = DISABLE;		
		}
		
		set_button(0); 
		mic.keypressing = NONE;
	}
}

/*------------------------------------------------------------------------------
Function name   : hs_buttonisr
Description     : interrupt handler

Return type     : irqreturn_t
------------------------------------------------------------------------------*/
irqreturn_t hs_buttonisr(int irq, void *dev_id)
{
	struct mic_t *p = &mic;
	int val = 0;
	ktime_t temptime;
	
#ifdef USE_SERVICEMODE
	if(TestMode == ENABLE)
	{
		if(p->headset_state == HEADSET_4_POLE)
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
		
		return IRQ_NONE;
	}
#endif
	
	if(mic.keypressing == INIT)
	{
		temptime = ktime_get();
		temptime = ktime_sub(temptime, mic.hsbtime);
		if(temptime.tv.sec >= 1 || temptime.tv.nsec >= KEY_INTERRUPT_REF_TIME)
			mic.keypressing = NONE;
		else
		{
		 	printk("%s: Initializing HSB ISR\n", __func__ );
			return IRQ_NONE;
		}
	}	

	if(p->pluging ==  ENABLE || p->keypressing != NONE)
	{
		printk("%s: Headset pluging OR keypressing\n", __func__ );
		return IRQ_NONE;
	}

	val = readl(io_p2v(REG_ANACR12));
	if(val < KEY_PRESS_THRESHOLD)
	{
		printk("%s: False button interrupt\n", __func__ );
		return IRQ_NONE;	
	}
	
	if (p->headset_state == HEADSET_4_POLE)
	{	
		p->hsbtime = ktime_get();
		
		board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
		
		memset(mic.key_count, 0, sizeof(mic.key_count));
		p->keypressing = PRESS;
		sync_use_mic = ENABLE;

		cancel_delayed_work(&(mic.input_work));
		queue_delayed_work(mic.headset_workqueue, &(p->input_work), KEY_BEFORE_PRESS_REF_TIME);
	}

	 return IRQ_HANDLED;
}

/* 	1 : SIM_DUAL_FIRST,
	2 : SIM_DUAL_SECOND */
static void getIMSI_work_func(struct work_struct *work)
{
	SIMLOCK_SIM_DATA_t* simdata = NULL; 
	int first = DISABLE;
	int second = DISABLE;

	simdata = GetSIMData(SIM_DUAL_FIRST);
	first = ((simdata == NULL) || (strncmp(simdata->imsi_string, TEST_SIM_IMSI, IMSI_DIGITS) != 0)) ?  DISABLE : ENABLE;
	simdata = GetSIMData(SIM_DUAL_SECOND);
	second = ((simdata == NULL) || (strncmp(simdata->imsi_string, TEST_SIM_IMSI, IMSI_DIGITS) != 0)) ?  DISABLE : ENABLE;

	FactoryMode = (first == ENABLE || second == ENABLE) ? ENABLE : DISABLE;
	printk("%s: Factorymode %d\n", __func__, FactoryMode);

	if(FactoryMode == ENABLE)
	{
		if(mic.headset_state == HEADSET_4_POLE)
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);
	}
}
Пример #13
0
/*
 * this function is called upon all reports
 * so that we can filter contact point information,
 * decide whether we are in multi or single touch mode
 * and call input_mt_sync after each point if necessary
 */
static int ntrig_usbhid_event(struct hid_device *hid, struct hid_field *field,
			struct hid_usage *usage, __s32 value)
{
	struct usb_interface*		intf	 = to_usb_interface(hid->dev.parent);
	struct usb_host_interface*	interface= intf->cur_altsetting;
	struct usb_endpoint_descriptor*	endpoint = &interface->endpoint[0].desc;
	__s32				btn	 = BTN_UNPRESSED;	
	static __u16 ncp_report_counter = 0;

	/* ntrig_dbg("%s: us=%4X, ap=%4X, ep=%4X, cl=%4X val=%4X\n ", 
			  __FUNCTION__, usage->hid, field->application, endpoint->bEndpointAddress, hid->claimed, value); */
	if ( NCP_EP_ADDRESS == endpoint->bEndpointAddress ) {
	    switch (ncp_report_counter) {
		case NCP_HEADER: 
		  /* We Do Nothing with this, because each report as a diffrent start address */
		  break; 
		case NCP_HOSTADD_LSB: 
		  ncp.host_address = value;
		  break;
		case NCP_HOSTADD_MSB:
		  ncp.host_address |= value << 8;
		  break;
		case NCP_MSG_LEN_LSB: 
		  ncp.msg_length = value;
		  break;
		case NCP_MSG_LEN_MSB: 
		  ncp.msg_length |= value << 8;
		  break;
		case NCP_MSG_TYPE: 
		  ncp.msg_type = value;
		case NCP_CODE: 
		  ncp.msg_group_code = value;
		  break;
		case NCP_GROUP: 
		  ncp.msg_group_code |= value << 8;
		  break;
		case NCP_RTN_CODE_1:
		case NCP_RTN_CODE_2:
		case NCP_RTN_CODE_3:
		case NCP_RTN_CODE_4:
		    ncp.return_code[ncp_report_counter - 8] = value;
		    break;
		case NCP_RESERVED_LSB:
		    ncp.reserved = value;
		    break;
		case NCP_RESERVED_MSB:
		    ncp.reserved |= value << 8;
		    break;  
		default:
		    ncp.payload[ncp_report_counter -14] = value;
		  break;
	    }
	    if (++ncp_report_counter == field->report_count)
		ncp_report_counter = 0;
	    return 1;
	}
	if (hid->claimed & HID_CLAIMED_INPUT) {
	    struct ntrig_usbhid_data*	nd	= hid_get_drvdata(hid);
	    struct input_dev*		input	= field->hidinput->input;

	    /* We attach multi touch to dispatcher if there is no multi touch queue*/
	    if(!check_multi_touch(nd->sensor_id)) {
		ntrig_dbg("%s Attach Multi Touch device to dispatcher\n", __FUNCTION__);
		attach_multi_touch(nd->sensor_id, input);
	    }	

	    /* We attach multi touch to dispatcher if there is no single touch queue */
	    if(!check_single_touch(nd->sensor_id)) {
		ntrig_dbg("%s Attach Single Touch device to dispatcher\n", __FUNCTION__);
		attach_single_touch(nd->sensor_id, input);
	    }	

	    switch (usage->hid) {
		case HID_GD_X:
		/* ntrig_dbg("%s: HID_GD_X=%d\n", __FUNCTION__, value); */
		nd->x = value;
		break;
	    case HID_GD_Y:
		/* ntrig_dbg("%s: HID_GD_Y=%d\n", __FUNCTION__, value); */
		nd->y = value;
		break;
	    }
	    if (field->application == HID_DG_PEN) {
		switch (usage->hid) {
			case HID_DG_INRANGE:
//	ntrig_dbg("%s: HID_DG_PEN: HID_DG_INRANGE=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->events = value;
				break;
			case HID_DG_TIPSWITCH:
//	ntrig_dbg("%s: HID_DG_PEN: HID_DG_TIPSWITCH=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->events |= (value << 1);
				break;
			case HID_DG_BARRELSWITCH:
//	ntrig_dbg("%s: HID_DG_PEN: HID_DG_BARRELSWITCH=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->events |= (value << 2);
				break;
			case HID_DG_INVERT:
//	ntrig_dbg("%s: HID_DG_PEN: HID_DG_INVERT=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->events |= (value << 3);
				break;
			case HID_DG_ERASER:
//	ntrig_dbg("%s: HID_DG_PEN: HID_DG_ERASER=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->events |= (value << 4);
				break;
			case HID_DG_TIPPRESSURE:
//	ntrig_dbg("%s: HID_DG_PEN: HID_DG_TIPPRESSURE=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->pressure = value;
				btn = (int) nd->events;
				/* process button information and send to dispatcher if required */			
				set_button(nd, btn); 
				/* send pen data to dispatcher */ 
				send_pen  (nd);	   
				/* print button and pen data */
//				ntrig_dbg("Privet X=%d Y=%d Button=%d Pressure=%d\n", 
//					nd->x, 
//					nd->y, 
//					nd->btn_pressed, 
//					nd->pressure);
				break;
#if 0
			case PEN_BATTERY_STATUS:
//	ntrig_dbg("%s: HID_DG_PEN: PEN_BATTERY_STATUS=%x, value %d\n", __FUNCTION__, usage->hid, value);
				if (nd->events & 0x01)	// TIPSWITCH == true --> pen is touching the screen --> battery_status value is valid
					nd->battery_status = value;
				else			// TIPSWITCH == false --> pen is not touching the screen --> battery_status value is not valid
					nd->battery_status = PEN_BUTTON_BATTERY_NOT_AVAILABLE;
	ntrig_dbg("%s: HID_DG_PEN: PEN_BATTERY_STATUS=%x, value %d, batter_status = %d, \n", __FUNCTION__, usage->hid, value, nd->battery_status);
				break;
#endif
			default:
//				ntrig_dbg("%s: HID_DG_PEN: default=%x, value %d\n", __FUNCTION__, usage->hid, value);
				break;
		}
	   } else { /* MultiTouch Report */
			switch (usage->hid) {
			case HID_DG_CONTACTCOUNT:
				nd->contact_count = value;
				/* end of report (this field always comes last) - send to dispatcher*/
				send_multi_touch(nd);
				break;
			case MTM_FRAME_INDEX: /* Index 1 */
//				ntrig_dbg("%s: MultiTouch Report: MTM_FRAME_INDEX=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->frame_index = value;
				break;
			case HID_DG_TIPSWITCH:	/* FALLTHRU */
			case HID_DG_INRANGE:	/* FALLTHRU */
			case HID_DG_CONFIDENCE: /* Not Relevant-Index 2 - 4 */
				break;
			case HID_DG_CONTACTID: /* Index 5 */
				nd->finger_id = value;
				break;
			case HID_DG_WIDTH:/* Index 6 - 7*/
				nd->dx = value;
				break;
			case HID_DG_HEIGHT:/* Index 8 - 9 */
				nd->dy = value;
				/* Start The Sequence of MSC bytes */
				nd->msc_cnt = 0;
				break;
			case MTM_PROPRIETARY:/* Index 10 - 14 */
//				ntrig_dbg("%s: MultiTouch Report: v=%x, value %d\n", __FUNCTION__, usage->hid, value);
				nd->msc_cnt++;
//				ntrig_dbg("%s: MTM_PROPRIETARY msc_cnt=%d val=%d\n", __FUNCTION__, nd->msc_cnt, value);
				switch (nd->msc_cnt) {
				case REPORT_GENERIC1:
					nd->generic_byte = value;
					break;
				case REPORT_MT:
					nd->blob_id = value;
					break;
				case REPORT_PALM:
					nd->isPalm = value;
					break;
				case REPORT_GENERIC2:
					/* end of single finger part of report */
					 /* process multi touch finger data */
					process_multi_touch_finger(nd);
					/* Print finger data */						
					ntrig_dbg("Frame=%x Finger=%d X=%d Y=%d DX=%d DY=%d FirstOccur=%d Palm=%d Press=%d Blob=%d\n",
							nd->frame_index, 
							nd->finger_id, 
							nd->x,
							nd->y, 
							nd->dx, 
							nd->dy,
							nd->generic_byte, 
							nd->isPalm, 
							nd->pressure,
							nd->blob_id);
					break;
				}
				break;
			}
		}
	}
	/* we have handled the hidinput part, now remains hiddev */
	if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event)
		hid->hiddev_hid_event(hid, field, usage, value);
	return 1;
}
/*------------------------------------------------------------------------------
Function name   : hs_buttonisr
Description     : interrupt handler

Return type     : irqreturn_t
------------------------------------------------------------------------------*/
irqreturn_t hs_buttonisr(int irq, void *dev_id)
{
	ktime_t r, temp;
	unsigned int val = 0;
#ifdef REG_DEBUG
	unsigned long val_anacr2, val_cmc, val_auxen;
#endif

	printk ("%s: HS_BUTTONISR (<<<) : status=%d \n", __func__, mic.hsbst);

	if (mic.hsbst == DISABLE || mic.headset_state != HEADSET_4_POLE)
		return IRQ_HANDLED;

	/* Read the ANACR12 register value to check if the interrupt being
	* serviced by the ISR is spurious */
	val = readl(io_p2v(REG_ANACR12));
	temp = ktime_get();
	r = ktime_sub(temp,mic.hsbtime);
	if((r.tv.sec > 0) || (r.tv.nsec > REF_TIME))
	{
		mic.hsbtime = temp;
	}
	else
	{
		printk ("%s: HS_BUTTONISR appeared frequently (r.tv.sec=%d, r.tv.nsec=%d) status=%d \n", __func__, r.tv.sec, r.tv.nsec, mic.hsbst);
		// return IRQ_HANDLED;
	}
	/* If the value read from the ANACR12 register is greater than the
	* threshold, schedule the workqueue */
	printk("%s: REG_ANACR12=%x\n", __func__,val);

#ifdef REG_DEBUG
	val_anacr2 = readl(io_p2v(REG_ANACR2));
	val_cmc = readl(io_p2v(REG_AUXMIC_CMC));
	val_auxen = readl(io_p2v(REG_AUXMIC_AUXEN));
	printk("%s: REG_ANACR2=%x, REG_AUXMIC_CMC=%x, REG_AUXMIC_AUXEN=%x\n", __func__, val_anacr2, val_cmc, val_auxen);
#endif

	if (val >= KEY_PRESS_THRESHOLD)
	{
		board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE);

		key_resolved = 0;
		key_count[0] = key_count[1] = key_count[2] = 0;

		sync_use_mic = ENABLE;
		schedule_delayed_work(&(mic.input_work), KEY_BEFORE_PRESS_REF_TIME);
		printk("%s: set_button => PRESS\n", __func__);
		set_button(PRESS); 
	}
	else
	{
		pr_info("Headset Button press detected for a illegal interrupt\n");
		printk("%s: set_button => RELEASE\n", __func__);
		set_button(RELEASE);
	}

	printk ("%s: HS_BUTTONISR (>>>) : status=%d \n", __func__, mic.hsbst);

	return IRQ_HANDLED;
}
static void input_work_func(struct work_struct *work)
{
	int delta = 0;
	unsigned long val = 0;
#ifdef REG_DEBUG
	unsigned long val_anacr2, val_cmc, val_auxen;
#endif
	static int key_status = RELEASE;
	int adc_value = auxadc_access(2);	
	printk("%s: input_work adc_value=%d\n", __func__, adc_value);

	/* If the key_status is 0, send the event for a key press */
	if(key_status == RELEASE)
	{
		delta = check_delta(mic.hsbtime,mic.hstime);
		if((mic.headset_state == HEADSET_4_POLE) && (delta == 0))
		{
			if (!key_resolved)
			{
				if ( adc_value >= KEY1_THRESHOLD_L && adc_value < KEY1_THRESHOLD_U )
				{
					key_count[0]++;
					if (key_count[0] >= KEYCOUNT_THRESHOLD)
						key_resolved = 1;
					key_type = KEY_BCM_HEADSET_BUTTON;
					printk ("KEY_BCM_HEADSET_BUTTON \n");
				}
				if ( adc_value >= KEY2_THRESHOLD_L && adc_value < KEY2_THRESHOLD_U ) 
				{	
					key_count[1]++;
					if (key_count[1] >= KEYCOUNT_THRESHOLD)
						key_resolved = 1;
					key_type = KEY_VOLUMEUP;
					printk ("KEY_VOLUMEUP \n");
				}
				if ( adc_value >= KEY3_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U ) 
				{
					key_count[2]++;
					if (key_count[2] >= KEYCOUNT_THRESHOLD)
						key_resolved = 1;
					key_type = KEY_VOLUMEDOWN;
					printk ("KEY_VOLUMEDOWN \n");
				}
			}
			else
				input_report_key(mic.headset_button_idev, key_type, PRESS);

			input_sync(mic.headset_button_idev);
			printk("%s: set_button => PRESS\n", __func__);
			set_button(PRESS);
			printk("%s: button pressed : ear_adc=%d\n", __func__, adc_value);
		}
	}

	/* Check if the value read from ANACR12 is greater than the
	* threshold. If so, the key is still pressed and schedule the work
	* queue till the value is less than the threshold */
	val = readl(io_p2v(REG_ANACR12));
	printk("%s: REG_ANACR12=%x\n", __func__,val);

	if (val >= KEY_PRESS_THRESHOLD && (adc_value >= KEY1_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U))
	{
		key_status = PRESS;

		if (!key_resolved)
		{
			if ( adc_value >= KEY1_THRESHOLD_L && adc_value < KEY1_THRESHOLD_U )
			{
				key_count[0]++;
				if (key_count[0] >= KEYCOUNT_THRESHOLD)
					key_resolved = 1;
				key_type = KEY_BCM_HEADSET_BUTTON;
				printk ("KEY_BCM_HEADSET_BUTTON\n");
			}
			if ( adc_value >= KEY2_THRESHOLD_L && adc_value < KEY2_THRESHOLD_U ) 
			{	
				key_count[1]++;
				if (key_count[1] >= KEYCOUNT_THRESHOLD)
					key_resolved = 1;
				key_type = KEY_VOLUMEUP;
				printk ("KEY_VOLUMEUP\n");
			}
			if ( adc_value >= KEY3_THRESHOLD_L && adc_value < KEY3_THRESHOLD_U ) 
			{
				key_count[2]++;
				if (key_count[2] >= KEYCOUNT_THRESHOLD)
					key_resolved = 1;
				key_type = KEY_VOLUMEDOWN;
				printk ("KEY_VOLUMEDOWN\n");
			}
		}
		else
			input_report_key(mic.headset_button_idev, key_type, PRESS);

		schedule_delayed_work(&(mic.input_work), KEY_PRESS_REF_TIME);
		printk("%s: set_button => PRESS\n", __func__);
		set_button(PRESS);
	}
	/* Once the value read from ANACR12 is less than the threshold, send
	* the event for a button release */
	else
	{
		key_status = RELEASE;
		printk ("%s: key_count [%d, %d, %d] \n", __func__, key_count[0], key_count[1], key_count[2]);

		if ( key_count[0] >= KEYCOUNT_THRESHOLD )
		{
			printk("SEND/END RELEASE\n");
			input_report_key(mic.headset_button_idev, KEY_BCM_HEADSET_BUTTON, RELEASE);
			input_sync(mic.headset_button_idev);
		}
		else if ( key_count[1] >= KEYCOUNT_THRESHOLD )
		{	
			printk("VOLUP RELEASE\n");
			input_report_key(mic.headset_button_idev, KEY_VOLUMEUP, RELEASE);
			input_sync(mic.headset_button_idev);
		}
		else if ( key_count[2] >= KEYCOUNT_THRESHOLD )
		{
			printk("VOLDOWN RELEASE\n");
			input_report_key(mic.headset_button_idev, KEY_VOLUMEDOWN, RELEASE);
			input_sync(mic.headset_button_idev);
		}

		printk("%s: set_button => RELEASE\n", __func__);
		set_button(RELEASE);	 
		key_resolved = 0;
		key_count[0] = key_count[1] = key_count[2] = 0;

		if(FactoryMode == DISABLE)
		{
			board_sysconfig(SYSCFG_AUXMIC, SYSCFG_ENABLE | SYSCFG_DISABLE);
		sync_use_mic = DISABLE;
		}

#ifdef REG_DEBUG
		val_anacr2 = readl(io_p2v(REG_ANACR2));
		val_cmc = readl(io_p2v(REG_AUXMIC_CMC));
		val_auxen = readl(io_p2v(REG_AUXMIC_AUXEN));
		printk("%s: REG_ANACR2=%x, REG_AUXMIC_CMC=%x, REG_AUXMIC_AUXEN=%x\n", __func__, val_anacr2, val_cmc, val_auxen);
#endif
	}
}
Пример #16
0
void screen_overview(ESContext *esContext) {
#ifndef SDLGL
	ESMatrix modelview;
	UserData *userData = esContext->userData;
#endif
	char tmp_str[1024];
	uint8_t n = 0;
#ifndef SDLGL
	esMatrixLoadIdentity(&modelview);
	esMatrixMultiply(&userData->mvpMatrix, &modelview, &userData->perspective);
#endif
	reset_buttons();
	int x = 0;
	int y = 0;
	for (n = 0; n < VIEW_MODE_LAST; n++) {
		if (x >= 4) {
			x = 0;
			y += 1;
		}
#ifndef WINDOWS
#ifndef ANDROID
		draw_to_buffer();
		if (n == VIEW_MODE_HUD) {
			screen_hud(esContext);
		} else if (n == VIEW_MODE_TELEMETRY) {
			screen_telemetry(esContext);
		} else if (n == VIEW_MODE_MODEL) {
			screen_model(esContext);
		} else if (n == VIEW_MODE_RCFLOW) {
			screen_rcflow(esContext);
		} else if (n == VIEW_MODE_FMS) {
			screen_fms(esContext);
		} else if (n == VIEW_MODE_WPEDIT) {
			screen_wpedit(esContext);
		} else if (n == VIEW_MODE_MAP) {
			screen_map(esContext, lat, lon, zoom);
		} else if (n == VIEW_MODE_SYSTEM) {
			screen_system(esContext);
#ifndef ANDROID
		} else if (n == VIEW_MODE_VIDEOLIST) {
			screen_videolist(esContext);
#ifdef USE_TCL
		} else if (n == VIEW_MODE_TCL) {
			screen_tcl(esContext);
#endif
#endif
		} else if (n == VIEW_MODE_TRACKER) {
			screen_tracker(esContext);
		} else if (n == VIEW_MODE_FCMENU) {
			if (ModelData[ModelActive].teletype == TELETYPE_MULTIWII_21) {
				screen_mwi_menu(esContext);
			} else if (ModelData[ModelActive].teletype == TELETYPE_BASEFLIGHT) {
				screen_mwi_menu(esContext);
			} else if (ModelData[ModelActive].teletype == TELETYPE_GPS_NMEA) {
				screen_graph(esContext);
			} else if (ModelData[ModelActive].teletype == TELETYPE_OPENPILOT) {
				screen_openpilot(esContext);
			} else {
				screen_mavlink_menu(esContext);
			}
		}
		draw_to_screen();
		draw_buffer_to_screen(-1.422 + x * 0.71, -0.99 + y * 0.66, -1.422 + x * 0.71 + 0.71, -0.99 + y * 0.66 + 0.66, 0.002, 1.0);
		sprintf(tmp_str, "%s", view_names[n]);
		if (setup.view_mode == n) {
			draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str, FONT_GREEN, -1.422 + 0.35 + x * 0.71, -0.99 + y * 0.66, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, overview_set, (float)n);
		} else {
			draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str, FONT_WHITE, -1.422 + 0.35 + x * 0.71, -0.99 + y * 0.66, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, overview_set, (float)n);
		}
#else
		sprintf(tmp_str, "%s", view_names[n]);
		draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str, FONT_WHITE, -1.422 + 0.35 + x * 0.71, -0.99 + y * 0.66 + 0.3, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, overview_set, (float)n);
#endif
#else
		sprintf(tmp_str, "%s", view_names[n]);
		draw_text_button(esContext, tmp_str, setup.view_mode, tmp_str, FONT_WHITE, -1.422 + 0.35 + x * 0.71, -0.99 + y * 0.66 + 0.3, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, overview_set, (float)n);
#endif
		reset_buttons();
		x++;
	}
	x = 0;
	y = 0;
	for (n = 0; n < VIEW_MODE_LAST; n++) {
		if (x >= 4) {
			x = 0;
			y += 1;
		}
		//		draw_rect_f3(esContext, -1.3 + x * 0.5, -0.8 + y * 0.4, 0.002, -1.3 + x * 0.5 + 0.5, -0.8 + y * 0.4 + 0.4, 0.002, 255, 255, 255, 255);
		//		set_button(view_names[n], setup.view_mode, -1.3 + x * 0.5, -0.8 + y * 0.4, -1.3 + x * 0.5 + 0.5, -0.8 + y * 0.4 + 0.4, overview_set, (float)n, 0);
		draw_rect_f3(esContext, -1.422 + x * 0.71, -0.99 + y * 0.66, 0.002, -1.422 + x * 0.71 + 0.71, -0.99 + y * 0.66 + 0.66, 0.002, 255, 255, 255, 255);
		set_button(view_names[n], setup.view_mode, -1.422 + x * 0.71, -0.99 + y * 0.66, -1.422 + x * 0.71 + 0.71, -0.99 + y * 0.66 + 0.66, overview_set, (float)n, 0);
		x++;
	}
	draw_text_button(esContext, "Options", setup.view_mode, "Options", FONT_PINK, 1.05, 0.55 + -2 * 0.1, 0.002, 0.08, ALIGN_CENTER, ALIGN_TOP, overview_set, (float)0);
	n = 0;
	if (setup.speak == 1) {
		draw_text_button(esContext, "SPEAK", setup.view_mode, "SPEAK", FONT_GREEN, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
	} else {
		draw_text_button(esContext, "SPEAK", setup.view_mode, "SPEAK", FONT_WHITE, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
	}
	if (logmode == 1) {
		draw_text_button(esContext, "LOGGING", setup.view_mode, "LOGGING", FONT_GREEN, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
	} else {
		draw_text_button(esContext, "LOGGING", setup.view_mode, "LOGGING", FONT_WHITE, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
	}
#ifndef OSX
	if (logplay == 1) {
		draw_text_button(esContext, "LOGPLAYER", setup.view_mode, "LOGPLAYER", FONT_GREEN, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
	} else {
		draw_text_button(esContext, "LOGPLAYER", setup.view_mode, "LOGPLAYER", FONT_WHITE, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
	}
#endif
	if (clientmode != 1 && setup.webport != 0) {
		if (webserv_is_running() == 1) {
			draw_text_button(esContext, "WEBSERV", setup.view_mode, "stop Webserver", FONT_GREEN, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
		} else {
			draw_text_button(esContext, "WEBSERV", setup.view_mode, "start Webserver", FONT_WHITE, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
		}
	}
	draw_text_button(esContext, "EXIT", setup.view_mode, "EXIT", FONT_GREEN, 1.05, 0.45 + n++ * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, option_cmd, 0.0);
}
Пример #17
0
static void
score_end()
{
  max_score = 0;
  set_button(BUTTON_SCORE, FALSE);
}
Пример #18
0
MsgGen::MsgGen(CToolCustom *parent, Message *msg)
        : QObject(parent)
{
    m_client = msg->client();
    m_edit = NULL;
    for (QWidget *p = parent->parentWidget(); p; p = p->parentWidget()){
        if (p->inherits("MsgEdit")){
            m_edit = static_cast<MsgEdit*>(p);
            break;
        }
    }
    connect(m_edit->m_userWnd, SIGNAL(multiplyChanged()), this, SLOT(textChanged()));
    parent->setText(i18n(" "));
    m_edit->m_edit->setTextFormat(RichText);
    QString text = msg->getRichText();
    if (!text.isEmpty()){
        m_edit->m_edit->setText(text);
        m_edit->m_edit->moveCursor(QTextEdit::MoveEnd, false);
        if ((msg->getBackground() != msg->getForeground()) && !CorePlugin::m_plugin->getOwnColors()){
            m_edit->m_edit->setBackground(msg->getBackground());
            m_edit->m_edit->setForeground(msg->getForeground());
        }
    }
    Command cmd;
    cmd->id    = CmdSend;
    cmd->param = m_edit;
    Event e(EventCommandWidget, cmd);
    btnSend = (QToolButton*)(e.process());

    QToolButton *btn = new ColorToolButton(parent, QColor(CorePlugin::m_plugin->getEditBackground()));
    set_button(btn, "bgcolor", I18N_NOOP("Bac&kground color"));
    connect(btn, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor)));
    parent->addWidget(btn);
    btn->show();

    btn = new ColorToolButton(parent, QColor(CorePlugin::m_plugin->getEditForeground()));
    set_button(btn, "fgcolor", I18N_NOOP("&Text color"));
    connect(btn, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor)));
    parent->addWidget(btn);
    btn->show();

    btnBold = new QToolButton(parent);
    set_button(btnBold, "text_bold", I18N_NOOP("&Bold"));
    btnBold->setToggleButton(true);
    connect(btnBold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
    parent->addWidget(btnBold);
    btnBold->show();

    btnItalic = new QToolButton(parent);
    set_button(btnItalic, "text_italic", I18N_NOOP("&Italic"));
    btnItalic->setToggleButton(true);
    connect(btnItalic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
    parent->addWidget(btnItalic);
    btnItalic->show();

    btnUnderline = new QToolButton(parent);
    set_button(btnUnderline, "text_under", I18N_NOOP("&Underline"));
    btnUnderline->setToggleButton(true);
    connect(btnUnderline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
    parent->addWidget(btnUnderline);
    btnUnderline->show();

    btn = new QToolButton(parent);
    set_button(btn, "text", I18N_NOOP("Text &font"));
    connect(btn, SIGNAL(clicked()), this, SLOT(selectFont()));
    parent->addWidget(btn);
    btn->show();

    connect(m_edit->m_edit, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(fontChanged(const QFont&)));
    connect(m_edit->m_edit, SIGNAL(textChanged()), this, SLOT(textChanged()));
    fontChanged(m_edit->m_edit->font());
    textChanged();
}
Пример #19
0
static void
bar_set_flags(const GComprisBarFlags flags)
{
  GcomprisBoard *board = gc_board_get_current();

  set_button(BUTTON_HELP, flags & GC_BAR_HELP || gc_help_has_board(board));
  set_button(BUTTON_ABOUT, flags & GC_BAR_ABOUT);

  set_button(BUTTON_PREV, flags & GC_BAR_LEVEL);
  set_button(BUTTON_LEVEL, flags & GC_BAR_LEVEL);
  set_button(BUTTON_NEXT, flags & GC_BAR_LEVEL);

  set_button(BUTTON_REFRESH, flags & (GC_BAR_REPEAT | GC_BAR_REPEAT_ICON));
  set_button(BUTTON_CONFIG, flags & GC_BAR_CONFIG);

  set_button(BUTTON_EXPANDER_1, TRUE);
  set_button(BUTTON_SCORE, max_score);
  set_button(BUTTON_EXPANDER_2, TRUE);

  set_button(BUTTON_ZOOM, TRUE);
  set_button(BUTTON_SEPARATOR, TRUE);
  set_button(BUTTON_BACK, board && board->previous_board);
  set_button(BUTTON_STOP, TRUE);
}