Exemple #1
0
  bool LRSPublicKey::Verify(const QByteArray &data, const LRSSignature &sig) const
  {
    if(!sig.IsValid()) {
      qDebug() << "Invalid signature";
      return false;
    }

    if(sig.SignatureCount() != GetKeys().count()) {
      qDebug() << "Incorrect amount of keys used to generate signature.";
      return false;
    }

    CppHash hash;
    hash.Update(GetGroupGenerator().GetByteArray());
    hash.Update(sig.GetTag().GetByteArray());
    hash.Update(data);
    QByteArray precompute = hash.ComputeHash();

    Integer tcommit = sig.GetCommit1();

    QVector<Integer> keys = GetKeys();
    for(int idx = 0; idx < keys.count(); idx++) {
      Integer z_p = (GetGenerator().Pow(sig.GetSignature(idx), GetModulus()) *
          _keys[idx].Pow(tcommit, GetModulus())) % GetModulus();
      Integer z_pp = (GetGroupGenerator().Pow(sig.GetSignature(idx), GetModulus()) *
          sig.GetTag().Pow(tcommit, GetModulus())) % GetModulus();

      hash.Update(precompute);
      hash.Update(z_p.GetByteArray());
      hash.Update(z_pp.GetByteArray());
      tcommit = Integer(hash.ComputeHash()) % GetSubgroup();
    }

    return tcommit == sig.GetCommit1();
  }
Exemple #2
0
int main() {
	Handle splash = 0;
	CreateImage(splash, splash_png, sizeof(splash_png));
	DrawImage(splash, 0, 0);
	UpdateScreen();
	do {
		Wait(WAIT_KEY);
		if(GetKeys() & MAK_FIRE)
			break;
	} while(1);
	DestroyObject(splash);

	Handle backg = 0;
	CreateImage(backg, ttsdemo_png, sizeof(ttsdemo_png));
	DrawImage(backg, 0, 0);
	UpdateScreen();

	int oldKeys = GetKeys();
	while(1) {
		Wait(WAIT_KEY);
		int newKeys = GetKeys();
		int downedKeys = newKeys & (~oldKeys);
		oldKeys = newKeys;

		if(downedKeys)
			StopSpeaking();

		if(downedKeys & MAK_FIRE) {
			StartSpeaking("Du står i korsningen Götgatan Åsögatan riktning Slussen. En meter till "
				"vänster om dig är ett övergångställe, för passage över Götgatan med "
				"tryckknapp för gångtrafikanter. Vid trottoarkanten löper en cykelväg.");
		}
		if(downedKeys & MAK_DOWN) {
			StartSpeaking("Tre meter bakom dig i riktning Skanstull är ett övergångställe för "
				"passage över Åsögatan.");
		}
		if(downedKeys & MAK_UP) {
			StartSpeaking("Trottoaren rakt framfortsätter 50 meter till nästa korsning Folkungagatan. "
				"På andra sidan av övergångstället finns ingångar till tunnelbanestation "
				"medborgarplatsen.");
		}
		/*if(downedKeys & MAK_RIGHT) {
		StartSpeaking("Am I right? Of course I'm right.");
		}
		if(downedKeys & MAK_LEFT) {
		StartSpeaking("No one is left behind.");
		}*/
	}
	return 0;
}
Exemple #3
0
/* wait for MacTCP to finish whatever it's doing, with user cancel
 */
static short tcp_wait(struct tcpstate *ts, tcpinfo *tcp)
{
	KeyMap mapkeys;
#define keys ((unsigned char *)mapkeys)
	short percent;

	while (!tcp_checkdriver()
		|| (tcp && (tcp->state & TCP_DNSINUSE) && ! (volatile) tcp->dnrdone)
		|| (tcp && (tcp->state & TCP_PBINUSE) && (volatile short) tcp->pb.ioResult == 1)) {
		if (ts) {
			if (!ts->waiticks) return (0);
			percent = ((TickCount() - ts->waitstart) * 100) / ts->waiticks;
			if (percent > 100) percent = 100;
			if (percent != ts->waitpercent) {
				(*ts->tcp_initp)(ts->waitpercent = percent);
			}
			if (percent == 100) return (0);
		}
		SystemTask();
		GetKeys(mapkeys);
		if ((keys[0x37 >> 3] >> (0x37 & 7))
			& (keys[0x2f >> 3] >> (0x2f & 7)) & 1) {
			return (0);
		}
	}
	
	return (1);
}
Exemple #4
0
pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow,
                                           void *handlerRefCon,
                                           DragReference theDrag)
{ 
    MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon;
    if ( trackingGlobals->m_currentTarget )
    {
        Point mouse,localMouse ;
        int localx,localy ;
        
        trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
        GetDragMouse(theDrag, &mouse, 0L);
        localMouse = mouse;
        GlobalToLocal(&localMouse);
        localx = localMouse.h ;
        localy = localMouse.v ;
        //TODO : should we use client coordinates
        if ( trackingGlobals->m_currentTargetWindow )
            trackingGlobals->m_currentTargetWindow->MacRootWindowToWindow( &localx , &localy ) ;
        if ( trackingGlobals->m_currentTarget->OnDrop( localx , localy ) )
        {
            KeyMap keymap;
            GetKeys(keymap);
            bool optionDown = keymap[1] & 4;
            wxDragResult result = optionDown ? wxDragCopy : wxDragMove;
            trackingGlobals->m_currentTarget->OnData( localx , localy , result ) ;
        }
    }
    return(noErr);
}
Exemple #5
0
void PhantomJSHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser)
{
  CEF_REQUIRE_UI_THREAD();

  qCDebug(handler) << browser->GetIdentifier();

  auto& browserInfo = m_browsers[browser->GetIdentifier()];
  browserInfo.browser = browser;
  if (!m_popupToParentMapping.isEmpty()) {
    auto parentBrowser = m_popupToParentMapping.dequeue();
    // we don't open about:blank for popups
    browserInfo.firstLoadFinished = true;
    emitSignal(m_browsers.value(parentBrowser).browser, QStringLiteral("onPopupCreated"),
               {browser->GetIdentifier()}, true);
  }

#if CHROME_VERSION_BUILD >= 2526
  if (PRINT_SETTINGS) {
    auto prefs = browser->GetHost()->GetRequestContext()->GetAllPreferences(true);
    CefDictionaryValue::KeyList keys;
    prefs->GetKeys(keys);
    for (const auto& key : keys) {
      printValue(key, prefs->GetValue(key));
    }
  }
#endif
}
Exemple #6
0
static int key_mac_init(void)
{

#if (TRACE_MAC_KBRD)
   fprintf(stdout, "key_mac_init()\n");
   fflush(stdout);
#endif
   GetKeys(KeyNow);
   _key_shifts=0;
   if(BitTst(KeyNow,k_apple_shift) || BitTst(KeyNow,k_apple_rshift))_key_shifts |= KB_SHIFT_FLAG;
   if(BitTst(KeyNow,k_apple_alt) || BitTst(KeyNow,k_apple_altgr))_key_shifts |= KB_ALT_FLAG;
   if(BitTst(KeyNow,k_apple_control) || BitTst(KeyNow,k_apple_rcontrol))_key_shifts |= KB_CTRL_FLAG;
   _mouse2nd=BitTst(KeyNow,k_2nd);
   LOCK_VARIABLE(KeyNow);
   LOCK_VARIABLE(KeyOld);
   LOCK_VARIABLE(key_apple_to_allegro);
   LOCK_VARIABLE(modifier_table);
   LOCK_VARIABLE(standard_key_ascii_table);
   LOCK_VARIABLE(standard_key_capslock_table);
   LOCK_VARIABLE(standard_key_shift_table);
   LOCK_VARIABLE(standard_key_control_table);
   LOCK_FUNCTION(_key_mac_interrupt);
   LOCK_FUNCTION(_handle_mac_key_press);
   LOCK_FUNCTION(_handle_mac_key_release);
   
   BlockMove(KeyNow, KeyOld, sizeof(KeyMap));
   if (!tm_running)
      _tm_sys_init();
   _mac_keyboard_installed=1;
   return 0;
}
Exemple #7
0
void ReadControllerCommand (int Control, BYTE * Command) {
	switch (Command[2]) {
	case 0x01: // read controller
		if (Controllers[Control].Present == TRUE) {
#ifndef EXTERNAL_RELEASE
			if (Command[0] != 1) { DisplayError("What am I meant to do with this Controller Command"); }
			if (Command[1] != 4) { DisplayError("What am I meant to do with this Controller Command"); }
#endif
			if (GetKeys) {
				BUTTONS Keys;
				
				GetKeys(Control,&Keys);
				*(DWORD *)&Command[3] = Keys.Value;
			} else {
				*(DWORD *)&Command[3] = 0;
			}
		}
		break;
	case 0x02: //read from controller pack
		if (Controllers[Control].Present == TRUE) {
			switch (Controllers[Control].Plugin) {
			case PLUGIN_RAW: if (ControllerCommand) { ReadController(Control, Command); } break;
			}
		} 
		break;
	case 0x03: //write controller pak
		if (Controllers[Control].Present == TRUE) {
			switch (Controllers[Control].Plugin) {
			case PLUGIN_RAW: if (ControllerCommand) { ReadController(Control, Command); } break;
			}
		}
		break;
	}
}
Exemple #8
0
int main(int argc, char *argv[]) {
	displayWindow = SDL_CreateWindow("Jello", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREENWIDTH, SCREENHEIGHT, SDL_WINDOW_OPENGL);
	context = SDL_GL_CreateContext(displayWindow);
	glOrtho(-SCREENWIDTH / 2, SCREENWIDTH / 2, SCREENHEIGHT / 2, -SCREENHEIGHT / 2, 0, 1);

	LoadContent();

	while (isRunning) {
		RemoveInitialPress();
		leftButtonPress = false;
		while (SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT)
				isRunning = false;

			GetKeys(event);
			GetButtons(event);
		}

		if (deltaTime < 1 / 60) {
			frameStart = SDL_GetTicks();
			SDL_Delay(1);
			frameEnd = SDL_GetTicks();
			deltaTime = frameEnd - frameStart;
		}
		frameStart = SDL_GetTicks();
		Update(deltaTime);
		Render(displayWindow, context);
		frameEnd = SDL_GetTicks();
		deltaTime = frameEnd - frameStart;
	}

	return 0;
}
        IDictionary<String^, IValue^>^ CefExtensionWrapper::Manifest::get()
        {
            ThrowIfDisposed();

            auto dictionary = _extension->GetManifest();;

            if (!dictionary.get() || (int)dictionary->GetSize() == 0)
            {
                return nullptr;
            }

            auto result = gcnew Dictionary<String^, IValue^>();

            CefDictionaryValue::KeyList keys;
            dictionary->GetKeys(keys);

            for (auto i = 0; i < keys.size(); i++)
            {
                auto key = keys[i];
                auto keyValue = StringUtils::ToClr(key);
                auto valueWrapper = gcnew CefValueWrapper(dictionary->GetValue(keys[i]));

                result->Add(keyValue, valueWrapper);
            }

            return result;
        }
Exemple #10
0
static int key_adb_init(void)
{
   OSErr e;
   short adb_command;
   short adb_devices;
   char adb_key_registers[8];
   ADBAddress adb_address;
   ADBSetInfoBlock mySet;

   adb_key_cpt_upp = NewADBCompletionUPP(adb_command_callback);
   adb_key_upp = NewADBServiceRoutineUPP (key_adb_interrupt);

   adb_devices = CountADBs();
   for(adb_keyboard_id = 1 ; adb_keyboard_id <= adb_devices ; adb_keyboard_id++){
      adb_address = GetIndADB(&adb_key_save, adb_keyboard_id);
      e = GetADBInfo(&adb_key_save, adb_address);
      if(adb_key_save.origADBAddr == ADB_KEYBOARD){
         switch (adb_key_save.devType){
            case 2:case 3:case 5:
	       LOCK_VARIABLE(KeyNow);
 	       LOCK_VARIABLE(KeyOld);
 	       LOCK_VARIABLE(_mouse2nd);
 	       LOCK_VARIABLE(adb_to_allegro);
 	       LOCK_VARIABLE(modifier_table);
	       LOCK_VARIABLE(standard_key_ascii_table);
	       LOCK_VARIABLE(standard_key_capslock_table);
	       LOCK_VARIABLE(standard_key_shift_table);
 	       LOCK_VARIABLE(standard_key_control_table);
/*	       LOCK_FUNCTION(key_adb_interrupt);*/
/*	       LOCK_FUNCTION(adb_command_callback);*/

               mySet.siService = adb_key_upp;
	       mySet.siDataAreaAddr = NULL;
	       SetADBInfo (&mySet,adb_address);
               adb_key_registers[0] = 2;
               adb_command = (adb_address * 16) + ADB_TALKMASK + ADB_TYPEREGISTER;
	       if (send_adb_command_sync(adb_key_registers, adb_command) == noErr){
		  adb_key_registers[2] = 3;
                  adb_command = (adb_address * 16) + ADB_LISTENMASK + ADB_TYPEREGISTER;
                  send_adb_command_sync(adb_key_registers, adb_command);
               }
               GetKeys(KeyNow);
               _key_shifts=0;

               if(BitTst(KeyNow,k_apple_shift) || BitTst(KeyNow,k_apple_rshift))_key_shifts |= KB_SHIFT_FLAG;
               if(BitTst(KeyNow,k_apple_alt) || BitTst(KeyNow,k_apple_altgr))_key_shifts |= KB_ALT_FLAG;
               if(BitTst(KeyNow,k_apple_control) || BitTst(KeyNow,k_apple_rcontrol))_key_shifts |= KB_CTRL_FLAG;
               _mouse2nd = BitTst(KeyNow,k_2nd);
               return 0;
            default:
               break;
      	 }
      }
   }
   adb_keyboard_id=0;
   return -1;
}
static Boolean UserWantsControl()
{
	/* Mouse down¡¤or key down¡¥*/
	KeyMap km;

	GetKeys(km);
	km[1] &= ~0x02; /* exclude caps lock */
	return   Button() || km[0]|| km[1] || km[2] || km[3] || skin_state==PAUSE;
}
int FCBF(DATA_SET & data, double min_threshold, std::string class_column, std::vector<std::string> & best_features) 
{
	PROB_HASH probs;
	PROB_GIVEN_HASH given_probs;
	std::vector<std::string> feature_names;
	std::list<std::pair<std::string, double>> list;
	GetKeys(data, feature_names);
	CalculateProbabilities(data, probs, given_probs, class_column);

	for(auto it = feature_names.begin(); it != feature_names.end(); ++it)
	{
		if(*it != class_column)
		{
			std::pair<std::string, double> tuple;
			tuple.first = *it;
			tuple.second = SU(data, probs, given_probs, class_column, *it);

			if(tuple.second > min_threshold) 
			{
				list.push_back(tuple);
			}
		}
	}

	list.sort(TupleCompare);

	auto F_j = list.begin();

	while (F_j != list.end())
	{
		auto F_i = F_j;
		++F_i;

		while (F_i != list.end())
		{
			double su_ij = SU(data, probs, given_probs, F_j->first, F_i->first);
			if(su_ij >= F_i->second)
			{
				F_i = list.erase(F_i);
			}
			else
			{
				++F_i;
			}
		}
		++F_j;
	}

	best_features.clear();
	best_features.reserve(list.size());
	for(auto it = list.begin(); it != list.end(); ++it)
	{
		best_features.push_back(it->first);
	}

	return 0;
}
void KEYBED_Process(void)
{
	timerTick++;
	
	upperSwitches = GetKeys();
	SetLine(0);
	ReadKeysFromOddLine(0);
	SetLine(3);
	Delay(22);

	upperSwitches = GetKeys();
	SetLine(2);
	ReadKeysFromOddLine(8);
	SetLine(5);
	Delay(22);

	upperSwitches = GetKeys();
	SetLine(4);
	ReadKeysFromOddLine(16);
	SetLine(7);
	Delay(22);

	upperSwitches = GetKeys();
	SetLine(6);
	ReadKeysFromOddLine(24);
	SetLine(9);
	Delay(22);

	upperSwitches = GetKeys();
	SetLine(8);
	ReadKeysFromOddLine(32);
	SetLine(11);
	Delay(22);

	upperSwitches = GetKeys();
	SetLine(10);
	ReadKeysFromOddLine(40);
	SetLine(13);
	Delay(22);

	upperSwitches = GetKeys();
	SetLine(12);
	ReadKeysFromOddLine(48);
	SetLine(15);
	Delay(22);

	upperSwitches = GetKeys();
	SetLine(14);
	ReadKeysFromOddLine(56);
	SetLine(1);
	Delay(22);
}
void* gstate_update_func(void* arg)
{
    KeyboardUGenGlobalState* gstate = &gKeyStateGlobals;
    for (;;) {
        Point p;
        GetKeys(gstate->keys);
        usleep(17000);
    }

    return 0;
}
bool CAccount::EncryptKeys(const CKeyingMaterial& vMasterKeyIn)
{
    if (!externalKeyStore.EncryptKeys(vMasterKeyIn))
        return false;
    if (!internalKeyStore.EncryptKeys(vMasterKeyIn))
        return false;

    if (pactiveWallet)
    {
        {
            std::set<CKeyID> setAddress;
            GetKeys(setAddress);

            LOCK(pactiveWallet->cs_wallet);
            for (const auto& keyID : setAddress)
            {
                CPubKey pubKey;
                if (!GetPubKey(keyID, pubKey))
                {
                    LogPrintf("CAccount::EncryptKeys(): Failed to get pubkey\n");
                    return false;
                }
                if (pactiveWallet->pwalletdbEncryption)
                    pactiveWallet->pwalletdbEncryption->EraseKey(pubKey);
                else
                    CWalletDB(*pactiveWallet->dbw).EraseKey(pubKey);

                std::vector<unsigned char> secret;
                if (!GetKey(keyID, secret))
                { 
                    LogPrintf("CAccount::EncryptKeys(): Failed to get crypted key\n");
                    return false;
                }
                if (pactiveWallet->pwalletdbEncryption)
                {
                    if (!pactiveWallet->pwalletdbEncryption->WriteCryptedKey(pubKey, secret, pactiveWallet->mapKeyMetadata[keyID], getUUIDAsString(getUUID()), KEYCHAIN_EXTERNAL))
                    {
                        LogPrintf("CAccount::EncryptKeys(): Failed to write key\n");
                        return false;
                    }
                }
                else
                {
                    if (!CWalletDB(*pactiveWallet->dbw).WriteCryptedKey(pubKey, secret, pactiveWallet->mapKeyMetadata[keyID], getUUIDAsString(getUUID()), KEYCHAIN_EXTERNAL))
                    {
                        LogPrintf("CAccount::EncryptKeys(): Failed to write key\n");
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Exemple #16
0
void sentinelTest() {
	HashTablePTR table = (HashTablePTR) junkdatasentinel;
	VER(InsertEntry(table, NULL, NULL, NULL), "Insert");
	VER(DeleteEntry(table, NULL, NULL), "Delete");
	VER(FindEntry(table, NULL, NULL), "Find");
	VER(GetKeys(table, NULL, NULL), "Get");
	VER(GetLoadFactor(table, NULL), "Load");
	VER(GetHashTableInfo(table, NULL), "Info");
	VER(SetResizeBehaviour(table, 0, 0, 0), "Resize factor");
	VER(DestroyHashTable(&table), "Destroy");
}
Exemple #17
0
  explicit LMDBShuffleCursor(MDB_txn* mdb_txn, MDB_cursor* mdb_cursor)
    : LMDBCursor(mdb_txn, mdb_cursor) {
    srand (time(NULL));
    GetKeys(&keys_);

    keys_permutation_.resize(keys_.size());
    for (int i = 0; i < keys_.size(); ++i) {
      keys_permutation_[i] = i;
    }

    SeekToFirst();
  }
Exemple #18
0
static void do_frame() {
  uint32_t keys[4];
  int i, d;

  GetKeys(&keys[0]);

  for (i = 0; i < n_players; i++) {
    player_t *p = &players[i];
    if (p->is_dead) {
      continue;
    }

    for (d = 0; d < 4; d++) {
      if (keys[p->keydefs[d].index] & p->keydefs[d].mask) {
	p->direction = d;
	break;
      }
    }

    switch (p->direction) {
      case DIR_R: p->x++; break;
      case DIR_U: p->y--; break;
      case DIR_L: p->x--; break;
      case DIR_D: p->y++; break;
      default:
	fprintf(stderr, "Bad direction %d\n", p->direction);
	abort();
    }

    p->x = (p->x + screen.width) % screen.width;
    p->y = (p->y + screen.height) % screen.height;
  }

  alive_count = 0;

  for (i = 0; i < n_players; i++) {
    player_t *p = &players[i];
    if (p->is_dead) {
      continue;
    }

    if (getpixel(p->x, p->y) != 0) {
      /* crash! */
      printf("Crash for player %d at %d, %d\n", i, p->x, p->y);
      p->is_dead = 1;
      continue;
    }

    alive_count++;

    putpixel(p->x, p->y, p->color);
  }
}
Exemple #19
0
void freeHashTableContents(HashTablePTR table) {
	char** keys;
	unsigned int keyCount;
	GetKeys(table, &keys, &keyCount);
	for (unsigned int i = 0; i < keyCount; i++) {
		char* dat;
		char* key = keys[i];
		FindEntry(table, key, (void**) &dat);
		free(dat);
		free(key);
	}
	free(keys);
}
void ReadKeysFromOddLine(uint8_t key)
{
	uint8_t lowerSwitches = GetKeys();

	uint8_t state = ((!(lowerSwitches & 128)) << 1) | (!(upperSwitches & 128));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);

	key++;
	state = ((!(lowerSwitches & 64)) << 1) | (!(upperSwitches & 64));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);

	key++;
	state = ((!(lowerSwitches & 32)) << 1) | (!(upperSwitches & 32));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);

	key++;
	state = ((!(lowerSwitches & 16)) << 1) | (!(upperSwitches & 16));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);

	key++;
	state = ((!(lowerSwitches & 8)) << 1) | (!(upperSwitches & 8));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);

	key++;
	state = ((!(lowerSwitches & 4)) << 1) | (!(upperSwitches & 4));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);

	key++;
	state = ((!(lowerSwitches & 2)) << 1) | (!(upperSwitches & 2));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);

	key++;
	state = ((!(lowerSwitches & 1)) << 1) | (!(upperSwitches & 1));

	if (state != (keyState[key] & 3))
	  DetectNotes(key, state);
}
Exemple #21
0
static PyObject *Evt_GetKeys(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    KeyMap theKeys__out__;
#ifndef GetKeys
    PyMac_PRECHECK(GetKeys);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    GetKeys(theKeys__out__);
    _res = Py_BuildValue("s#",
                         (char *)&theKeys__out__, (int)sizeof(KeyMap));
    return _res;
}
Exemple #22
0
void
OSXKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const
{
	::KeyMap km;
	GetKeys(km);
	const UInt8* m = reinterpret_cast<const UInt8*>(km);
	for (UInt32 i = 0; i < 16; ++i) {
		for (UInt32 j = 0; j < 8; ++j) {
			if ((m[i] & (1u << j)) != 0) {
				pressedKeys.insert(mapVirtualKeyToKeyButton(8 * i + j));
			}
		}
	}
}
Exemple #23
0
bool ezIReflectedTypeAccessor::GetValues(const char* szProperty, ezHybridArray<ezVariant, 16>& out_values) const
{
  ezHybridArray<ezVariant, 16> keys;
  if (!GetKeys(szProperty, keys))
    return false;

  out_values.Clear();
  out_values.Reserve(keys.GetCount());
  for (ezVariant key : keys)
  {
    out_values.PushBack(GetValue(szProperty, key));
  }
  return true;
}
Exemple #24
0
/* void KeyDownUp (in long keysym); */
NS_IMETHODIMP MainComponent::KeyDownUp(PRInt32 keysym)
{
    KeyCode keycode;
    long is_shift;
    GetKeys(keycode, is_shift, keysym);
    
    if(is_shift) XTestFakeKeyEvent(display, KEY_SHIFT, True, 0);
    XTestFakeKeyEvent(display, keycode, True, 0);
    XTestFakeKeyEvent(display, keycode, False, 0);
    if(is_shift) XTestFakeKeyEvent(display, KEY_SHIFT, False, 0);
    
    XSync(display,0);
    return NS_OK;
}
Exemple #25
0
void UserInput::Listen(void)
{
    while(!this->quit_)
    {
        size_t num_hdls = this->key_handlers_.size();
        if (num_hdls > 0)
        {
            SDL_Event ev;
            SDLKey key;
            uint8_t type;
            bool need_emit = false;
            while(SDL_PollEvent(&ev))
            {
                if (ev.type == SDL_KEYDOWN)
                {
                    key = ev.key.keysym.sym;
                    type = ev.type;
                    need_emit = true;
                    break;
                }
                else if (ev.type == SDL_KEYUP)
                {
                    need_emit = true;
                    type = ev.type;
                    break;
                }
            }

            if (need_emit)
            {
                for(size_t i = 0; i < num_hdls; ++i)
                {
                    auto handler = this->key_handlers_[i];
                    auto keys = handler->GetKeys();
                    size_t keys_size = keys.size();
                    for(size_t j = 0; j < keys_size; ++j)
                    {
                        if (keys[j] == key)
                        {
                            handler->OnMessage(key, type);
                        }
                    }
                }
            }
        }

        phi_sleep(30);
    }
}
Exemple #26
0
int CheckKeyDown() {
	KeyMap theKeys;
	unsigned char *keybytes;
	int i;
	
	GetKeys(theKeys);
	keybytes = (unsigned char *) theKeys;
	
	for (i = 0; i < 128; i++) {
		if (i == kVK_CapsLock) continue; // Ignore capslock
		
		if (keybytes[i >> 3] & (1 << (i & 7)))
			return i + 1;
	}
	
	return 0;
}
Exemple #27
0
void printHashTable(HashTablePTR table) {
	if (table == NULL) return;
	char** keys;
	unsigned int keyCount;
	int status = GetKeys(table, &keys, &keyCount);
	if (status == NOT_A_HASH_TABLE || status == OUT_OF_RAM) return;
	/* sort the keys */
	qsort(keys, keyCount, sizeof(char*), mycompare);
	for (unsigned int i = 0; i < keyCount; i++) {
		char* dat;
		char* key = keys[i];
		FindEntry(table, key, (void**) &dat);
		printf("%s:%s\n", key, dat);
		free(key);
	}
	free(keys);
}
Exemple #28
0
  bool LRSPublicKey::operator==(const AsymmetricKey &key) const
  {
    const LRSPublicKey *other = dynamic_cast<const LRSPublicKey *>(&key);
    if(!other) {
      return false;
    }

    if(this == other) {
      return true;
    }

    return (other->GetGenerator() == GetGenerator()) &&
      (other->GetKeys() == GetKeys()) &&
      (other->GetModulus() == GetModulus()) &&
      (other->GetSubgroup() == GetSubgroup()) &&
      (other->GetLinkageContext() == GetLinkageContext()) &&
      (other->IsValid() == IsValid());
  }
Exemple #29
0
int main(void)
{ 
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, (u32)&_vectors);
  __USB_Init();
  //__Clear_Screen(0x0000);
  // display 400x240

  for (int x=0; x<400; x++)
    for (int y=0; y<240-16; y++)
    {
      u32 dx = (x-200);
      u32 dy = (y-120);
      dx *= dx;
      dy *= dy;
      u32 dl = dx+dy;

      __Point_SCR(x, y);
      __LCD_SetPixl((uc16)(dl>>3) & 0x001f);
    }

  __Display_Str(20, 200, 0xffff, 0, "Hello DS203 Test... ");

  int x[3] = {20, 380, 220};
  int y[3] = {20, 40, 220};

  int curx = x[0];
  int cury = y[0];
  while ( !(GetKeys() & KEY2_STATUS) ) 
  {
    int c = PRNG();
    int r = c%3;
    curx = (curx+x[r]) >> 1;
    cury = (cury+y[r]) >> 1;

    __Point_SCR(curx, cury);
    __LCD_SetPixl(c<<1); // len do 32k
  }
	Reboot();
  return 0;
}
Exemple #30
0
//============================================================================
//		NCFDictionary::GetObject : Get the object.
//----------------------------------------------------------------------------
NCFObject NCFDictionary::GetObject(void) const
{	NCFObject						theObject, keyObject, theValue;
	CFTypeRef						cfKey, cfValue;
	NStringList						theKeys;
	NStringListConstIterator		theIter;
	NCFString						theKey;



	// Get the state we need
	theKeys = GetKeys();
	
	if (!theObject.SetObject(CFDictionaryCreateMutable(
										kCFAllocatorNano,
										(CFIndex) theKeys.size(),
										&kCFTypeDictionaryKeyCallBacks,
										&kCFTypeDictionaryValueCallBacks)))
		return(theObject);



	// Get the object
	for (theIter = theKeys.begin(); theIter != theKeys.end(); theIter++)
		{
		theKey   = *theIter;
		theValue = NMacTarget::ConvertObjectToCF(GetValue(theKey));
		if (theValue.IsValid())
			{
			keyObject = theKey.GetObject();
			cfKey     = (CFTypeRef) keyObject;
			cfValue   = (CFTypeRef) theValue;
			
			CFDictionarySetValue(theObject, cfKey, cfValue);
			}
		}

	return(theObject);
}