/* void SendKeys (in nsISupports aNode, in wstring value); */
NS_IMETHODIMP nsNativeKeyboard::SendKeys(nsISupports *aNode,
    const PRUnichar *value,
    bool releaseModifiers)
{
  LOG(DEBUG) << "---------- Got to start of callback. aNode: " << aNode
    << " ----------";
  NS_LossyConvertUTF16toASCII ascii_keys(value);
  LOG(DEBUG) << "Ascii keys: " << ascii_keys.get();
  LOG(DEBUG) << "Ascii string length: " << strlen(ascii_keys.get());
  int i = 0;
  while (value[i] != '\0') {
    LOG(DEBUG) << value[i] << " ";
    i++;
  }

  AccessibleDocumentWrapper doc(aNode);

  WINDOW_HANDLE windowHandle = doc.getWindowHandle();

  if (!windowHandle) {
    LOG(WARN) << "Sorry, window handle is null.";
    return NS_ERROR_NULL_POINTER;
  }

  // Note that it's OK to send wchar_t even though wchar_t is *usually*
  // 32 bit, because this code (and any code that links with it) *MUST*
  // be compiled with -fshort-wchar, so it's actually 16 bit and,
  // incidentally, just like PRUnichar. This, of course, breaks any
  // library function that uses wchar_t.
#ifdef BUILD_ON_UNIX
  assert(sizeof(PRUnichar) == sizeof(wchar_t));
  const wchar_t* valuePtr = (const wchar_t*) value;
#else
  const PRUnichar* valuePtr = value;
#endif
  sendKeys(windowHandle, valuePtr, 0);

  if (releaseModifiers) {
    LOG(DEBUG) << "Also releasing modifiers.";
    releaseModifierKeys(windowHandle, 0);
  }

  LOG(DEBUG) << "Sent keys sucessfully.";

  return NS_OK;
}
Пример #2
0
void pokerMode(){
	while (1) {
		for (r = 0; r < ROWS; r++) {
			pullDownRows(r);
			read_cols(r);
			unselect_rows();
		}
		for (r = 0; r < ROWS; r++) {
			for (c = 0; c < COLS; c++) {
				if (keystate[r][c] > 0x08) {
					if (keytype[r][c] == 0x01) {
						if (FN == 0x00)
							presskey(hexaKeys[r][c]);
						else if (FN == 0x01)
							presskey(hexaKeys2[r][c]);
					} else if (keytype[r][c] == 0x02) {
						pressModifierKeys(hexaKeys[r][c]);
					} else if (keytype[r][c] == 0x04 && FN == 0x00) {
						FN = 0x02;
					}
				} else {
					if (keytype[r][c] == 0x01) {
						if (FN == 0x00)
							releasekey(hexaKeys[r][c]);
						else if (FN == 0x01)
							releasekey(hexaKeys2[r][c]);
					} else if (keytype[r][c] == 0x02) {
						releaseModifierKeys(hexaKeys[r][c]);
					} else if (keytype[r][c] == 0x04 && FN == 0x01) {
						FN = 0x04;
					}
				}

			}
		}
		  if(FN==0x02){FN=0x01;releaseAll();}
		  else if(FN==0x04){FN=0x00;releaseAll();}
		  usb_keyboard_send();
			///////////////////////////////////
		}
}