Пример #1
0
ZTimerFreeglut::ZTimerFreeglut() : interval(25), started(false) {
	static int globalID = 0;
	while (mapTimers.find(globalID) != mapTimers.end()) {
		globalID++;
	}

	timerID = globalID;
	mapTimers[timerID] = this;
}
Пример #2
0
static void _TimerFunc(int value)
{
	hmap::iterator it = mapTimers.find(value);
	if (it == mapTimers.end())
		return;
	ZTimerFreeglut* t = (*it).second;
	if (t->IsTimerStarted()) {
		glutTimerFunc(t->GetTimerInterval(), _TimerFunc, value);
		t->OnTimer();
	}
}
Пример #3
0
uint Synth::walk(DdNode *a_dd) {
    /**
    Walk given DdNode node (recursively).
    If a given node requires intermediate AND gates for its representation, the function adds them.
        Literal representing given input node is `not` added to the spec.

    :returns: literal representing input node
    **/

    // caching
    static hmap<DdNode*, uint> cache;
    {
        auto cached_lit = cache.find(Cudd_Regular(a_dd));
        if (cached_lit != cache.end())
            return Cudd_IsComplement(a_dd) ? NEGATED(cached_lit->second) : cached_lit->second;
    }
    // end of caching

    if (Cudd_IsConstant(a_dd))
        return (uint) (a_dd == cudd.bddOne().getNode());  // in aiger: 0 is False and 1 is True

    // get an index of the variable
    uint a_lit = aiger_by_cudd[Cudd_NodeReadIndex(a_dd)];

    DdNode *t_bdd = Cudd_T(a_dd);
    DdNode *e_bdd = Cudd_E(a_dd);

    uint t_lit = walk(t_bdd);
    uint e_lit = walk(e_bdd);

    // ite(a_bdd, then_bdd, else_bdd)
    // = a*then + !a*else
    // = !(!(a*then) * !(!a*else))
    // -> in general case we need 3 more ANDs

    uint a_t_lit = get_optimized_and_lit(a_lit, t_lit);

    uint na_e_lit = get_optimized_and_lit(NEGATED(a_lit), e_lit);

    uint n_a_t_lit = NEGATED(a_t_lit);
    uint n_na_e_lit = NEGATED(na_e_lit);

    uint and_lit = get_optimized_and_lit(n_a_t_lit, n_na_e_lit);

    uint res = NEGATED(and_lit);

    cache[Cudd_Regular(a_dd)] = res;

    if (Cudd_IsComplement(a_dd))
        res = NEGATED(res);

    return res;
}
Пример #4
0
	Key android2april(int androidKeyCode)
	{
		if (gKeyMap.hasKey(androidKeyCode))
		{
			return gKeyMap[androidKeyCode];
		}
#ifdef _DEBUG
		hlog::writef(logTag, "Unknown key code: %u", androidKeyCode);
#endif
		return april::AK_NONE;
	}
Пример #5
0
	Key kd2april(int kdKeyCode)
	{
		if (gKeyMap.has_key(kdKeyCode))
		{
			return gKeyMap[kdKeyCode];
		}
#ifdef _DEBUG
		hlog::writef(logTag, "Unknown key code: %u", kdKeyCode);
#endif
		return april::AK_NONE;
	}
Пример #6
0
    hidx (const Json& json) {

        const string expnFile = json["expnFile"].string_value();
        cx_mat expn_gam;
        if (expn_gam.load (expnFile, arma_ascii)) {
            expn = vectorise(expn_gam,1);
        } else {
            printf ("Error: expn_gam is not loaded!\n");
        }

        nind = expn.n_elem;
        lmax = json["lmax"].int_value();
        nmax = json["nmax"].int_value();
        ferr = json["ferr"].number_value();
        
        nddo = 1;
        lddo = 0;
        int ntot = static_cast<int>(get_nmax(nind,lmax));
        if (ntot < nmax) {
            nmax = ntot;
        }

        keys.set_size(nmax);
        keys(0) = string (nind,'0');
        for (int i=1; i<nmax; ++i) {
            keys(i) = string (nind,'!');
        }
        if (!maps.empty()) {
            printf ("Madan! maps is not empty!");
        }
        maps.emplace(keys(0),hnod());

        printf ("$InitHidx\n");
        printf ("nind = %d\n", nind);
        printf ("lddo = %d\n", lddo);
        printf ("nddo = %d\n", nddo);
        printf ("lmax = %d\n", lmax);
        printf ("nmax = %d\n", nmax);
        printf ("ferr = %g\n", ferr);
        printf ("$InitHidx\n\n");
    }
Пример #7
0
	void _makeButtonLabels(hstr* ok, hstr* yes, hstr* no, hstr* cancel,
		MessageBoxButton buttonMask, hmap<MessageBoxButton, hstr> customButtonTitles)
	{
		if ((buttonMask & MESSAGE_BUTTON_OK) && (buttonMask & MESSAGE_BUTTON_CANCEL))
		{
			*ok = customButtonTitles.tryGet(MESSAGE_BUTTON_OK, "OK");
			*cancel = customButtonTitles.tryGet(MESSAGE_BUTTON_CANCEL, "Cancel");
		}
		else if ((buttonMask & MESSAGE_BUTTON_YES) && (buttonMask & MESSAGE_BUTTON_NO) && (buttonMask & MESSAGE_BUTTON_CANCEL))
		{
			*yes = customButtonTitles.tryGet(MESSAGE_BUTTON_YES, "Yes");
			*no = customButtonTitles.tryGet(MESSAGE_BUTTON_NO, "No");
			*cancel = customButtonTitles.tryGet(MESSAGE_BUTTON_CANCEL, "Cancel");
		}
		else if (buttonMask & MESSAGE_BUTTON_OK)
		{
			*ok = customButtonTitles.tryGet(MESSAGE_BUTTON_OK, "OK");
		}
		else if ((buttonMask & MESSAGE_BUTTON_YES) && (buttonMask & MESSAGE_BUTTON_NO))
		{
			*yes = customButtonTitles.tryGet(MESSAGE_BUTTON_YES, "Yes");
			*no = customButtonTitles.tryGet(MESSAGE_BUTTON_NO, "No");
		}
	}
Пример #8
0
namespace april
{
	static hmap<int, Key> gKeyMap;
	
	Key android2april(int androidKeyCode)
	{
		if (gKeyMap.hasKey(androidKeyCode))
		{
			return gKeyMap[androidKeyCode];
		}
#ifdef _DEBUG
		hlog::writef(logTag, "Unknown key code: %u", androidKeyCode);
#endif
		return april::AK_NONE;
	}
	
	void initAndroidKeyMap()
	{
		hmap<int, Key>& m = gKeyMap;

		// codes obtained from http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_0
		m[-1] = AK_UNKNOWN;
		m[0] = AK_NONE;
		
		// LBUTTON and RBUTTON are necessary
		m[1] = AK_LBUTTON;
		m[2] = AK_RBUTTON;
		// these mostly don't exist on Android
		//m[0] = AK_CANCEL;
		//m[0] = AK_MBUTTON;
		//m[168] = AK_WHEELUP; // ZOOM_IN
		//m[169] = AK_WHEELDN; // ZOOM_OUT
		//m[0] = AK_DOUBLETAP;
		
		// most common keys; some not supported
		m[67] = AK_BACK;
		m[61] = AK_TAB;
		m[28] = AK_CLEAR;
		m[66] = AK_RETURN;
		//m[0] = AK_SHIFT;
		//m[0] = AK_CONTROL;
		m[82] = AK_MENU;
		//m[0] = AK_PAUSE;
		m[115] = AK_CAPITAL;
		
		// various keys for asian keyboards not supported
		//m[0] = AK_KANA;
		//m[0] = AK_HANGEUL;
		//m[0] = AK_HANGUL;
		//m[0] = AK_JUNJA;
		//m[0] = AK_FINAL;
		//m[0] = AK_HANJA;
		//m[0] = AK_KANJI;
		m[4] = AK_ESCAPE; // using Android's back button for this
		//m[0] = AK_CONVERT;
		//m[0] = AK_NONCONVERT;
		//m[0] = AK_ACCEPT;
		//m[0] = AK_MODECHANGE;
		
		// Mac CMD keys; they aren't used so they will act like CTRL
		//m[113] = AK_LCOMMAND;
		//m[114] = AK_RCOMMAND;
		
		// space
		m[62] = AK_SPACE;
		
		// don't exist on Android
		//m[0] = AK_PRIOR;
		//m[0] = AK_NEXT;
		//m[0] = AK_END;
		//m[0] = AK_HOME;
		
		// don't exist on Android
		//m[0] = AK_LEFT;
		//m[0] = AK_UP;
		//m[0] = AK_RIGHT;
		//m[0] = AK_DOWN;
		
		// don't exist on Android
		//m[0] = AK_SELECT;
		//m[0] = AK_PRINT;
		//m[0] = AK_EXECUTE;
		//m[0] = AK_SNAPSHOT;
		
		// some more keys
		m[124] = AK_INSERT;
		m[112] = AK_DELETE;
		//m[0] = AK_HELP;
		
		// '0'-'9'
		m[7] = AK_0;
		m[8] = AK_1;
		m[9] = AK_2;
		m[10] = AK_3;
		m[11] = AK_4;
		m[12] = AK_5;
		m[13] = AK_6;
		m[14] = AK_7;
		m[15] = AK_8;
		m[16] = AK_9;
		
		// 'A'-'Z'
		m[29] = AK_A;
		m[30] = AK_B;
		m[31] = AK_C;
		m[32] = AK_D;
		m[33] = AK_E;
		m[34] = AK_F;
		m[35] = AK_G;
		m[36] = AK_H;
		m[37] = AK_I;
		m[38] = AK_J;
		m[39] = AK_K;
		m[40] = AK_L;
		m[41] = AK_M;
		m[42] = AK_N;
		m[43] = AK_O;
		m[44] = AK_P;
		m[45] = AK_Q;
		m[46] = AK_R;
		m[47] = AK_S;
		m[48] = AK_T;
		m[49] = AK_U;
		m[50] = AK_V;
		m[51] = AK_W;
		m[52] = AK_X;
		m[53] = AK_Y;
		m[54] = AK_Z;
		
		// don't exist on Android
		//m[0] = AK_LWIN 0;
		//m[0] = AK_RWIN 0;
		//m[0] = AK_APPS 0;
		//m[0] = AK_SLEEP 0;
		
		// numpad
		m[144] = AK_NUMPAD0;
		m[145] = AK_NUMPAD1;
		m[146] = AK_NUMPAD2;
		m[147] = AK_NUMPAD3;
		m[148] = AK_NUMPAD4;
		m[149] = AK_NUMPAD5;
		m[150] = AK_NUMPAD6;
		m[151] = AK_NUMPAD7;
		m[152] = AK_NUMPAD8;
		m[153] = AK_NUMPAD9;
		m[155] = AK_MULTIPLY;
		m[157] = AK_ADD;
		m[159] = AK_SEPARATOR;
		m[156] = AK_SUBTRACT;
		m[158] = AK_DECIMAL;
		m[154] = AK_DIVIDE;
		
		// F-keys
		m[131] = AK_F1;
		m[132] = AK_F2;
		m[133] = AK_F3;
		m[134] = AK_F4;
		m[135] = AK_F5;
		m[136] = AK_F6;
		m[137] = AK_F7;
		m[138] = AK_F8;
		m[139] = AK_F9;
		m[140] = AK_F10;
		m[141] = AK_F11;
		m[142] = AK_F12;
		// don't exist on Android
		m[0] = AK_F13;
		m[0] = AK_F14;
		m[0] = AK_F15;
		m[0] = AK_F16;
		m[0] = AK_F17;
		m[0] = AK_F18;
		m[0] = AK_F19;
		m[0] = AK_F20;
		m[0] = AK_F21;
		m[0] = AK_F22;
		m[0] = AK_F23;
		m[0] = AK_F24;
		
		// don't exist on Android
		m[143] = AK_NUMLOCK;
		m[116] = AK_SCROLL;
		
		// specific left-and-right-shift keys
		m[59] = AK_LSHIFT;
		m[60] = AK_RSHIFT;
		m[113] = AK_LCONTROL;
		m[114] = AK_RCONTROL;
		m[57] = AK_LMENU;
		m[58] = AK_RMENU;
		
		// browser control keys
		//m[4] = AK_BROWSER_BACK;
		//m[125] = AK_BROWSER_FORWARD;
		//m[0] = AK_BROWSER_REFRESH;
		//m[0] = AK_BROWSER_STOP;
		//m[84] = AK_BROWSER_SEARCH;
		//m[0] = AK_BROWSER_FAVORITES;
		//m[0] = AK_BROWSER_HOME;
		
		// volume keys
		m[164] = AK_VOLUME_MUTE;
		m[25] = AK_VOLUME_DOWN;
		m[24] = AK_VOLUME_UP;
		
		// don't exist on Android
		//m[0] = AK_MEDIA_NEXT_TRACK;
		//m[0] = AK_MEDIA_PREV_TRACK;
		//m[0] = AK_MEDIA_STOP;
		//m[0] = AK_MEDIA_PLAY_PAUSE;
		
		// don't exist on Android
		//m[0] = AK_LAUNCH_MAIL;
		//m[0] = AK_LAUNCH_MEDIA_SELECT;
		//m[0] = AK_LAUNCH_APP1;
		//m[0] = AK_LAUNCH_APP2;
		
		// don't exist on Android
		//m[0] = AK_OEM_2;
		//m[0] = AK_OEM_3;
		//m[0] = AK_OEM_4;
		//m[0] = AK_OEM_5;
		//m[0] = AK_OEM_6;
		//m[0] = AK_OEM_7;
		//m[0] = AK_OEM_8;
		//m[0] = AK_OEM_102;
		
		// don't exist on Android
		//m[0] = AK_PACKET;
		//m[0] = AK_ATTN;
		//m[0] = AK_CRSEL;
		//m[0] = AK_EXSEL;
		//m[0] = AK_EREOF;
		
		// don't exist on Android
		//m[0] = AK_PLAY;
		//m[0] = AK_ZOOM;
		
		// don't exist on Android
		//m[0] = AK_NONAME;
		//m[0] = AK_PA1;
		//m[0] = AK_OEM_CLEAR;
	}
}
Пример #9
0
ZTimerFreeglut::~ZTimerFreeglut() {
	mapTimers.erase(timerID);
}
Пример #10
0
namespace april
{
	static hmap<int, Key> gKeyMap;
	
	Key kd2april(int kdKeyCode)
	{
		if (gKeyMap.has_key(kdKeyCode))
		{
			return gKeyMap[kdKeyCode];
		}
#ifdef _DEBUG
		hlog::writef(logTag, "Unknown key code: %u", kdKeyCode);
#endif
		return april::AK_NONE;
	}
	
	void initOpenKODEKeyMap()
	{
		hmap<int, Key>& m = gKeyMap;
		m[KD_INPUT_KEYS_LBUTTON] = AK_LBUTTON;
		m[KD_INPUT_KEYS_RBUTTON] = AK_RBUTTON;
		m[KD_INPUT_KEYS_MBUTTON] = AK_MBUTTON;
		m[KD_INPUT_KEYS_ESCAPE] = AK_ESCAPE;
		m[KD_INPUT_KEYS_BACKSPACE] = AK_BACK;
		m[KD_INPUT_KEYS_TAB] = AK_TAB;
		m[KD_INPUT_KEYS_ENTER] = AK_RETURN;
		m[KD_INPUT_KEYS_SPACE] = AK_SPACE;
		m[KD_INPUT_KEYS_SHIFT] = AK_SHIFT;
		m[KD_INPUT_KEYS_CTRL] = AK_CONTROL;
		m[KD_INPUT_KEYS_ALT] = AK_MENU;
		m[KD_INPUT_KEYS_LWIN] = AK_LCOMMAND;
		m[KD_INPUT_KEYS_RWIN] = AK_RCOMMAND;
		m[KD_INPUT_KEYS_APPS] = AK_APPS;
		m[KD_INPUT_KEYS_PAUSE] = AK_PAUSE;
		m[KD_INPUT_KEYS_CAPSLOCK] = AK_CAPITAL;
		m[KD_INPUT_KEYS_NUMLOCK] = AK_NUMLOCK;
		m[KD_INPUT_KEYS_PGUP] = AK_PRIOR;
		m[KD_INPUT_KEYS_PGDN] = AK_NEXT;
		m[KD_INPUT_KEYS_HOME] = AK_HOME;
		m[KD_INPUT_KEYS_END] = AK_END;
		m[KD_INPUT_KEYS_INSERT] = AK_INSERT;
		m[KD_INPUT_KEYS_DELETE] = AK_DELETE;
		m[KD_INPUT_KEYS_LEFT] = AK_LEFT;
		m[KD_INPUT_KEYS_UP] = AK_UP;
		m[KD_INPUT_KEYS_RIGHT] = AK_RIGHT;
		m[KD_INPUT_KEYS_DOWN] = AK_DOWN;
		m[KD_INPUT_KEYS_0] = AK_0;
		m[KD_INPUT_KEYS_1] = AK_1;
		m[KD_INPUT_KEYS_2] = AK_2;
		m[KD_INPUT_KEYS_3] = AK_3;
		m[KD_INPUT_KEYS_4] = AK_4;
		m[KD_INPUT_KEYS_5] = AK_5;
		m[KD_INPUT_KEYS_6] = AK_6;
		m[KD_INPUT_KEYS_7] = AK_7;
		m[KD_INPUT_KEYS_8] = AK_8;
		m[KD_INPUT_KEYS_9] = AK_9;
		m[KD_INPUT_KEYS_A] = AK_A;
		m[KD_INPUT_KEYS_B] = AK_B;
		m[KD_INPUT_KEYS_C] = AK_C;
		m[KD_INPUT_KEYS_D] = AK_D;
		m[KD_INPUT_KEYS_E] = AK_E;
		m[KD_INPUT_KEYS_F] = AK_F;
		m[KD_INPUT_KEYS_G] = AK_G;
		m[KD_INPUT_KEYS_H] = AK_H;
		m[KD_INPUT_KEYS_I] = AK_I;
		m[KD_INPUT_KEYS_J] = AK_J;
		m[KD_INPUT_KEYS_K] = AK_K;
		m[KD_INPUT_KEYS_L] = AK_L;
		m[KD_INPUT_KEYS_M] = AK_M;
		m[KD_INPUT_KEYS_N] = AK_N;
		m[KD_INPUT_KEYS_O] = AK_O;
		m[KD_INPUT_KEYS_P] = AK_P;
		m[KD_INPUT_KEYS_Q] = AK_Q;
		m[KD_INPUT_KEYS_R] = AK_R;
		m[KD_INPUT_KEYS_S] = AK_S;
		m[KD_INPUT_KEYS_T] = AK_T;
		m[KD_INPUT_KEYS_U] = AK_U;
		m[KD_INPUT_KEYS_V] = AK_V;
		m[KD_INPUT_KEYS_W] = AK_W;
		m[KD_INPUT_KEYS_X] = AK_X;
		m[KD_INPUT_KEYS_Y] = AK_Y;
		m[KD_INPUT_KEYS_Z] = AK_Z;
		m[KD_INPUT_KEYS_NUMPAD0] = AK_NUMPAD0;
		m[KD_INPUT_KEYS_NUMPAD1] = AK_NUMPAD1;
		m[KD_INPUT_KEYS_NUMPAD2] = AK_NUMPAD2;
		m[KD_INPUT_KEYS_NUMPAD3] = AK_NUMPAD3;
		m[KD_INPUT_KEYS_NUMPAD4] = AK_NUMPAD4;
		m[KD_INPUT_KEYS_NUMPAD5] = AK_NUMPAD5;
		m[KD_INPUT_KEYS_NUMPAD6] = AK_NUMPAD6;
		m[KD_INPUT_KEYS_NUMPAD7] = AK_NUMPAD7;
		m[KD_INPUT_KEYS_NUMPAD8] = AK_NUMPAD8;
		m[KD_INPUT_KEYS_NUMPAD9] = AK_NUMPAD9;
		m[KD_INPUT_KEYS_MULTIPLY] = AK_MULTIPLY;
		m[KD_INPUT_KEYS_DIVIDE] = AK_DIVIDE;
		m[KD_INPUT_KEYS_ADD] = AK_ADD;
		m[KD_INPUT_KEYS_SUBTRACT] = AK_SUBTRACT;
		m[KD_INPUT_KEYS_DECIMAL] = AK_DECIMAL;
		m[KD_INPUT_KEYS_F1] = AK_F1;
		m[KD_INPUT_KEYS_F2] = AK_F2;
		m[KD_INPUT_KEYS_F3] = AK_F3;
		m[KD_INPUT_KEYS_F4] = AK_F4;
		m[KD_INPUT_KEYS_F5] = AK_F5;
		m[KD_INPUT_KEYS_F6] = AK_F6;
		m[KD_INPUT_KEYS_F7] = AK_F7;
		m[KD_INPUT_KEYS_F8] = AK_F8;
		m[KD_INPUT_KEYS_F9] = AK_F9;
		m[KD_INPUT_KEYS_F10] = AK_F10;
		m[KD_INPUT_KEYS_F11] = AK_F11;
		m[KD_INPUT_KEYS_F12] = AK_F12;
		m[KD_INPUT_KEYS_UNKNOWN] = AK_UNKNOWN;
		
//		m[KD_INPUT_KEYS_SCROLLLOCK] = AK_;
//		m[KD_INPUT_KEYS_GRAVE] = AK_;
//		m[KD_INPUT_KEYS_MINUS] = AK_;
//		m[KD_INPUT_KEYS_EQUALS] = AK_;
//		m[KD_INPUT_KEYS_BACKSLASH] = AK_;
//		m[KD_INPUT_KEYS_LBRACKET] = AK_;
//		m[KD_INPUT_KEYS_RBRACKET] = AK_;
//		m[KD_INPUT_KEYS_SEMICOLON] = AK_;
//		m[KD_INPUT_KEYS_APOSTROPHE] = AK_;
//		m[KD_INPUT_KEYS_COMMA] = AK_;
//		m[KD_INPUT_KEYS_PERIOD] = AK_;
//		m[KD_INPUT_KEYS_SLASH] = AK_;
	}
}