Ejemplo n.º 1
0
	bool InputManager::injectKeyPress(KeyCode _key)
	{
		// проверка на переключение языков
		detectLangShift(_key, true);
		// запоминаем клавишу
		storeKey(_key);

		bool wasFocusKey = isFocusKey();

		//Pass keystrokes to the current active text widget
		if (isFocusKey()) {
			Char ch;
			/*if (mUseOISKeyLayout) {
				ch = _arg.text;
				if (std::find (mCurrentLanguage->second.begin(), mCurrentLanguage->second.end(), ch) == mCurrentLanguage->second.end())
					ch = 0;
			}
			else {*/
				ch = getKeyChar(_key);
			//}
			mWidgetKeyFocus->_onKeyButtonPressed(_key, ch);
		}

		return wasFocusKey;
	}
Ejemplo n.º 2
0
	void InputManager::_frameEntered(float _frame)
	{
		if ( mHoldKey == KC_UNASSIGNED) return;
		if ( false == isFocusKey() ) {
			mHoldKey = KC_UNASSIGNED;
			//mFirstPressKey = true;
			//mTimerKey = 0.0f;
			return;
		}

		mTimerKey += _frame;

		if (mFirstPressKey) {
			if (mTimerKey > INPUT_DELAY_FIRST_KEY) {
				mFirstPressKey = false;
				mTimerKey = 0.0f;
			}
		} else {
			if (mTimerKey > INPUT_INTERVAL_KEY) {
				mTimerKey -= INPUT_INTERVAL_KEY;
				mWidgetKeyFocus->_onKeyButtonPressed(mHoldKey, getKeyChar(mHoldKey));
				// focus can be dropped in _onKeyButtonPressed
				if ( isFocusKey() ) mWidgetKeyFocus->_onKeyButtonReleased(mHoldKey);
			}
		}

	}
Ejemplo n.º 3
0
int main() {
   GWindow gw = newGWindow(600, 400);
   GRect rect = NULL;
   bool dragging = false;
   double startX = 0.0;
   double startY = 0.0;
   while (true) {
      GEvent e = waitForEvent(MOUSE_EVENT | KEY_EVENT);
      if (getEventType(e) == MOUSE_PRESSED) {
         startX = getX(e);
         startY = getY(e);
         rect = getGObjectAt(gw, startX, startY);
         dragging = (rect != NULL);
         if (!dragging) {
            rect = newGRect(startX, startY, 0, 0);
            setFilled(rect, true);
            add(gw, rect);
         }
      } else if (getEventType(e) == MOUSE_DRAGGED) {
         double x = getX(e);
         double y = getY(e);
         if (dragging) {
            move(rect, x - startX, y - startY);
            startX = x;
            startY = y;
         } else {
            double width = fabs(x - startX);
            double height = fabs(y - startY);
            x = fmin(x, startX);
            y = fmin(y, startY);
            setBounds(rect, x, y, width, height);
         }
      } else if (getEventType(e) == MOUSE_CLICKED) {
         if (rect != NULL) sendToFront(rect);
      } else if (getEventType(e) == KEY_TYPED) {
         if (rect != NULL) {
            string color = "BLACK";
            switch (getKeyChar(e)) {
             case 'b': color = "BLUE"; break;
             case 'c': color = "CYAN"; break;
             case 'g': color = "GREEN"; break;
             case 'm': color = "MAGENTA"; break;
             case 'o': color = "ORANGE"; break;
             case 'r': color = "RED"; break;
             case 'w': color = "WHITE"; break;
             case 'y': color = "YELLOW"; break;
            }
            setColor(rect, color);
         }
      }
   }
}
Ejemplo n.º 4
0
Object *
opoppen(ULONG key,ULONG title,ULONG help)
{
    return PoppenObject,
           //MUIA_FixWidthTxt,  (ULONG)"nn",
           //MUIA_FixHeightTxt, (ULONG)"\n",
           MUIA_Window_Title, (ULONG)getString(title),
           MUIA_ControlChar,  getKeyChar(getString(key)),
           MUIA_Draggable,    TRUE,
           MUIA_CycleChain,   1,
           MUIA_ShortHelp,    getString(help),
           End;
}
Ejemplo n.º 5
0
Object *
opopfri(ULONG key,ULONG title,ULONG help)
{
    return MUI_NewObject("Popfrimage.mui",
                         MUIA_Window_Title,     (ULONG)getString(title),
                         MUIA_ControlChar,      (ULONG)getKeyChar(getString(key)),
                         MUIA_CycleChain,       TRUE,
                         MUIA_ShortHelp,        (ULONG)getString(help),
                         0x80421794, 0,
                         0x8042a547, 0,
                         0x80426a55, 1,
                         0x8042a92b, 0,
                         End;
}
Ejemplo n.º 6
0
Object *
opop(ULONG type,ULONG key)
{
    register Object *obj;

    if (!(lib_flags & BASEFLG_MUI4) && (type==MUII_PopFont))
        type = MUII_PopUp;

    if (obj = MUI_MakeObject(MUIO_PopButton,type))
    {
        set(obj,MUIA_CycleChain,TRUE);

        if (key)
        {
            ULONG k;

            if (k = getKeyChar(getString(key)))
                set(obj,MUIA_ControlChar,ToLower(k));
        }
    }

    return obj;
}
Ejemplo n.º 7
0
Archivo: demo1.c Proyecto: Iryaz/leso6
int main() {
	//! Инициализация портов для светодиодов.
	DDRF |= (1 << DDF0 | 1 << DDF1 | 1 << DDF2 | 1 << DDF3);
	//! Инициализация порта для пьезоизлучателя.
	DDRB |= (1 << DDB0);
	//! Инициализация портов для строк клавиатуры. Строки на ввод.
	DDRD &= ~(1 << DDD4 | 1 << DDD5 | 1 << DDD6 | 1 << DDD7);
	//! Инициализация портов для строк клавиатуры. Поддяжка к питанию.
	PORTD |= (1 << PD4 | 1 << PD5 | 1 << PD6 | 1 << PD7);
	//! Инициализация портов для столбцоы клавиатуры. столбцы на вывод.
	DDRG |= (1 << DDG0 | 1 << DDG1 | 1 << DDG2);

	//! Инициализация таймера для излучателя звука.
	TCCR3A = 0;
	TCCR3A = 0;
	TCCR3B = 0;
	TCCR3B_struct.cs3 = 0x01;		// Предделитель: F_CPU/1
	TIMSK3_struct.toie3 = 1;		// Разрешаем прерывание по переполнению
	TCNT3 = -8000;					// 8000 тактов центрального проессора ~ 500 мкс.

	//! Инициализация таймера для смены режимов.
	TCCR4A = 0;
	TCCR4A = 0;
	TCCR4B = 0;

	uint8_t key1, key2 = 0;			//!< Переменные для хранения кода нажатых клавишь.
	uint8_t i;
	char tx_buff_str[16];


	//! Структура для чтения времени.
	//! Перед первым использованием должна быть инициализирована.
	ds18b20_memory_t ds18b20_memory = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	int16_t temper = 0;

	//! Структура для чтения времени.
	//! Перед первым использованием должна быть инициализирована.
	rtc_data_r_t time = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	//rtc_data_w_t time_w = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //!< Структура для установки времени.
	uint8_t sec;

	I2C_Master_Initialise(); 			//!< Инициализация I2C интерфейса.
	ds18b20_convert();					//!< Запуск преобразование температуры.
	uart_init();						//!< Инициализируем UART.
	uart_set_input_cb(uart_rx_cb);// Устанавливаем функцию обратного вызова на прием байта по UART.

	printf("\n\rLESO laboratory (c) 2014\r\nDemo test program\r\n");
	printf("LESO6 ATMEGA128RFA1\r\n");
	fprintf(stderr, "stderr: NO ERRORS\r\n");

	//! Массив с описанием символа градуса.
	uint8_t ch[8] = {
	0x06, /*x x x 0 0 1 1 0*/
	0x09, /*x x x 0 1 0 0 1*/
	0x09, /*x x x 0 1 0 0 1*/
	0x06, /*x x x 0 0 1 1 0*/
	0x00, /*x x x 0 0 0 0 0*/
	0x00, /*x x x 0 0 0 0 0*/
	0x00, /*x x x 0 0 0 0 0*/
	0x00  /*x x x 0 0 0 0 0*/
	};

	//! Управлящая структура для ЖКИ.
	lcd_t lcd = { 0, 0, 0, 0, 0 };
	lcdInit(&lcd);								//!< Инициализируем ЖКИ;
	lcdCursor(&lcd, 0);							//!< Выключаем курсор.
	lcdCursorBlink(&lcd, 0);					//!< Выключаем мерцание курсора.
	sprintf(tx_buff_str, " LESO6 \n 2014%c  ", 0xb4);
	lcdPuts(&lcd, tx_buff_str);
	lcdCharDef(&lcd, 1, ch);					//!< Определяем новый символ.

	for (i = 0; i < 75; i++)
		_delay_ms(10);
	getTimeDS1338(&time);						//!< Читаем время.
	ds18b20_read(&ds18b20_memory);				//!< Читаем температуру.
	sec = time.Second;

	TIMSK3_struct.toie3 = 0;// Запрещаем прерывание при переполнении таймера 3.
	off(BIP);									// Выключаем звук.

	lcdClear(&lcd);
	lcdCursor(&lcd, 1);
	lcdPuts(&lcd, "Text:\n");
	while (1) {
		while (key_mode)		// В режиме набора текст:
		{
			key1 = getKeyChar();
			for(i=0; i<5; i++) _delay_ms(10);
			key2 = getKeyChar();

			if (key1 == '\n') continue;
			else if (key1 != key2) continue;

			TCNT4 = 0;				// Дополнительное время работы в этом режиме
			if((lcd.cx) == lcd.cols)// закончились символы в строке
			{
				lcdPuts(&lcd,"\r        \r");// стираем строку, возвращаем курсор в начало
				printf("\r\033[0K");// стираем строку в терминале
			}
			lcdPutchar(&lcd, key1);
			LEDS &= ~0x0F;
			LEDS |= 0x0F&key1;
			putchar(key1);
			TIMSK3_struct.toie3 = 1;			// пик
			for(i=0; i<20; i++) _delay_ms(10);
			TIMSK3_struct.toie3 = 0;
		}

		printf("\r\033[0K%02u:%02u:%02u",time.Hour, time.Minute ,time.Second);
		sprintf(tx_buff_str, "%02u:%02u:%02u\n",time.Hour, time.Minute ,time.Second);
		lcdHome(&lcd);
		lcdPuts(&lcd, tx_buff_str);

		if(ds18b20_crc8((uint8_t *)&ds18b20_memory, sizeof(ds18b20_memory)))
		fprintf(stderr,"ERROR read DS18B20\r\n");
		else
		{
			temper = (ds18b20_memory.temper_MSB << 8) | ds18b20_memory.temper_LSB;
			printf(" T= %d.%u",temper>>4, ((temper&0xf)*1000)/(16));
			sprintf(tx_buff_str,"%02d.%u%cC  ",temper>>4, ((temper&0xf)*1000)/(16), 0x01);
			lcdPuts(&lcd, tx_buff_str);
		}

		ds18b20_convert();		// Запуск преобразование температуры.
		while(sec == time.Second)
		{
			if (getTimeDS1338(&time))
			{
				fprintf(stderr,"ERROR: read date fail..!\n\r");
				continue;
			}

			key1 = getKeyChar();
			if (key1 != '\n')
			{
				key_mode = 1;
				lcdClear(&lcd);
				lcdCursor(&lcd, 1);
				lcdPuts(&lcd,"Text:\n");

				TCCR4B_struct.cs4 = 0x04;		// Предделитель: F_CPU/256
				TIMSK4_struct.toie4 = 1;// Разрешаем прерывание по переполнению
				TCNT4 = 0;
				printf("\r\033[0K");// стираем строку в терминале
				break;
			}
			for(i=0; i<20; i++) _delay_ms(10);
		}
		sec = time.Second;
		ds18b20_read(&ds18b20_memory);
		if(ds18b20_crc8((uint8_t *)&ds18b20_memory, sizeof(ds18b20_memory)))
		fprintf(stderr,"ERROR read DS18B20\r\n");
	}

	return 0;
}