static int execute (CalcHandle* handle, VarEntry *ve, const char* args) { unsigned int i; // Go back to homescreen PAUSE(200); TRYF(send_key(handle, (KEY92P_CTRL + KEY92P_Q))); TRYF(send_key(handle, KEY92P_CLEAR)); TRYF(send_key(handle, KEY92P_CLEAR)); // Launch program by remote control for(i = 0; i < strlen(ve->folder); i++) TRYF(send_key(handle, (ve->folder)[i])); if(strcmp(ve->folder, "")) TRYF(send_key(handle, '\\')); for(i = 0; i < strlen(ve->name); i++) TRYF(send_key(handle, (ve->name)[i])); TRYF(send_key(handle, KEY92P_LP)); if(args) { for(i = 0; i < strlen(args); i++) TRYF(send_key(handle, args[i])); } TRYF(send_key(handle, KEY92P_RP)); TRYF(send_key(handle, KEY92P_ENTER)); PAUSE(200); return 0; }
void qx10_keyboard_device::write(UINT8 data) { switch(data & 0xe0) { default: break; case 0x00: // set repeat start break; case 0x20: // set repeat interval break; case 0x40: // set LED break; case 0x60: // get LED send_key(0); break; case 0x80: // get SW break; case 0xa0: // set repeat break; case 0xc0: // enable keyboard break; case 0xe0: if(!(data & 1)) send_key(0); break; } return; }
static int flush_queue(ACTIONS action, __u16 code) { int i; switch (action) { case ACTION_FUNCTION: action_function(code); break; case ACTION_CAPITALIZE: action_capitalize(code); break; case ACTION_DEFAULT: send_key(code, KEYDOWN); break; default: break; } // Now zero out the queue for (i=0; i<KEYQ_SIZE; i++) { if (key_queue[i].code) { if (action == ACTION_NONE) send_key(key_queue[i].code, key_queue[i].value); key_queue[i].code = 0; key_queue[i].value = 0; } } }
static void action_function(__u16 code) { send_key(KEY_RIGHTALT, 1); //send_key(KEY_RIGHTALT, 2); send_key(code, 1); //send_key(code, 0); send_key(KEY_RIGHTALT, 0); }
static void action_capitalize(__u16 code) { send_key(KEY_LEFTSHIFT, 1); //send_key(KEY_LEFTSHIFT, 2); send_key(code, 1); //send_key(code, 0); send_key(KEY_LEFTSHIFT, 0); }
static int dump_rom_2 (CalcHandle* handle, CalcDumpSize size, const char *filename) { int ret = 0; unsigned int i; if (handle->model == CALC_TI83) { static const uint16_t keys[] = { 0x40, 0x09, 0x09, /* Quit, Clear, Clear, */ 0xFE63, 0x97, 0xDA, /* Send(, 9, prgm */ 0xAB, 0xA8, 0xA6, 0x9D, /* R, O, M, D */ 0xAE, 0xA6, 0xA9, 0x05 /* U, M, P, Enter */ }; // Launch program by remote control for (i = 0; !ret && i < sizeof(keys) / sizeof(keys[0]); i++) { ret = send_key(handle, (uint32_t)(keys[i])); PAUSE(100); } } else if (handle->model == CALC_TI86) { static const uint16_t keys[] = { 0x76, 0x08, 0x08, /* Quit, Clear, Clear, */ 0x28, 0x3A, 0x34, 0x11, /* A, S, M, (, */ 0x39, 0x36, 0x34, 0x2B, /* R, O, M, D, */ 0x56, 0x4E, 0x51, 0x12, /* u, m, p, ), */ 0x06 /* Enter */ }; uint16_t dummy; // Launch program by remote control for (i = 0; !ret && i < (sizeof(keys) / sizeof(keys[0])) - 1; i++) { ret = send_key(handle, (uint32_t)(keys[i])); } if (!ret) { ret = SEND_KEY(handle, keys[i]); if (!ret) { ret = RECV_ACK(handle, &dummy); } PAUSE(200); } } if (!ret) { // Get dump ret = rd_dump(handle, filename); // TI-86: normally there would be another ACK after the program exits, but the ROM dumper disables that behaviour. } return ret; }
static size_t handle_panel_passthrough(struct avctp *session, uint8_t transaction, uint8_t *code, uint8_t *subunit, uint8_t *operands, size_t operand_count, void *user_data) { const char *status; int pressed, i; if (*code != AVC_CTYPE_CONTROL || *subunit != AVC_SUBUNIT_PANEL) { *code = AVC_CTYPE_REJECTED; return 0; } if (operand_count == 0) goto done; if (operands[0] & 0x80) { status = "released"; pressed = 0; } else { status = "pressed"; pressed = 1; } for (i = 0; key_map[i].name != NULL; i++) { uint8_t key_quirks; if ((operands[0] & 0x7F) != key_map[i].avc) continue; DBG("AV/C: %s %s", key_map[i].name, status); key_quirks = session->key_quirks[key_map[i].avc]; if (key_quirks & QUIRK_NO_RELEASE) { if (!pressed) { DBG("AV/C: Ignoring release"); break; } DBG("AV/C: treating key press as press + release"); send_key(session->uinput, key_map[i].uinput, 1); send_key(session->uinput, key_map[i].uinput, 0); break; } send_key(session->uinput, key_map[i].uinput, pressed); break; } if (key_map[i].name == NULL) DBG("AV/C: unknown button 0x%02X %s", operands[0] & 0x7F, status); done: *code = AVC_CTYPE_ACCEPTED; return operand_count; }
/* user_input: This function will get a key from the user and process it. * * Returns: -1 on error, 0 on success */ static int user_input(void) { static int key, val; /* Clear the current map sets. Give the KUI the map sets * that should be used with the current focus. */ val = kui_manager_clear_map_sets(kui_ctx); if (val == -1) { logger_write_pos(logger, __FILE__, __LINE__, "user_input error"); return -1; } if (if_get_focus() == CGDB) val = kui_manager_add_map_set(kui_ctx, kui_map); else if (if_get_focus() == GDB) val = kui_manager_add_map_set(kui_ctx, kui_imap); key = kui_manager_getkey(kui_ctx); if (key == -1) { logger_write_pos(logger, __FILE__, __LINE__, "kui_manager_getkey error"); return -1; } val = if_input(key); if (val == -1) { logger_write_pos(logger, __FILE__, __LINE__, "if_input error"); return -1; } else if (val != 1 && val != 2) return 0; if (val == 1 && completion_ptr) return handle_tab_completion_request(completion_ptr, key); /* Process the key */ if (kui_term_is_cgdb_key(key)) { char *seqbuf = kui_term_get_ascii_char_sequence_from_key(key); if (seqbuf == NULL) { logger_write_pos(logger, __FILE__, __LINE__, "kui_term_get_ascii_char_sequence_from_key error %d", key); return -1; } else { int length = strlen(seqbuf), i; for (i = 0; i < length; i++) send_key(val, seqbuf[i]); } } else send_key(val, key); return 0; }
static int execute (CalcHandle* handle, VarEntry *ve, const char* args) { unsigned int i; // Go back to homescreen PAUSE(200); TRYF(send_key(handle, KEY83_Quit)); TRYF(send_key(handle, KEY83_Clear)); TRYF(send_key(handle, KEY83_Clear)); // Launch program by remote control if(ve->type == TI83_ASM) { TRYF(send_key(handle, KEY83_SendMBL)); TRYF(send_key(handle, KEY83_9)); } TRYF(send_key(handle, KEY83_Exec)); for(i = 0; i < strlen(ve->name); i++) { const CalcKey *ck = ticalcs_keys_83((ve->name)[i]); TRYF(send_key(handle, ck->normal.value)); } TRYF(send_key(handle, KEY83_Enter)); PAUSE(200); return 0; }
static int dump_rom_1 (CalcHandle* handle) { // Go back to homescreen PAUSE(200); TRYF(send_key(handle, (KEY92P_CTRL + KEY92P_Q))); TRYF(send_key(handle, KEY92P_CLEAR)); TRYF(send_key(handle, KEY92P_CLEAR)); PAUSE(200); // Send dumping program TRYF(rd_send(handle, "romdump.92p", romDumpSize92, romDump92)); PAUSE(1000); return 0; }
static void handle_panel_passthrough(struct control *control, const unsigned char *operands, int operand_count) { const char *status; int pressed, i; if (operand_count == 0) return; if (operands[0] & 0x80) { status = "released"; pressed = 0; } else { status = "pressed"; pressed = 1; } for (i = 0; key_map[i].name != NULL; i++) { uint8_t key_quirks; if ((operands[0] & 0x7F) != key_map[i].avrcp) continue; debug("AVRCP: %s %s", key_map[i].name, status); key_quirks = control->key_quirks[key_map[i].avrcp]; if (key_quirks & QUIRK_NO_RELEASE) { if (!pressed) { debug("AVRCP: Ignoring release"); break; } debug("AVRCP: treating key press as press + release"); send_key(control->uinput, key_map[i].uinput, 1); send_key(control->uinput, key_map[i].uinput, 0); break; } send_key(control->uinput, key_map[i].uinput, pressed); break; } if (key_map[i].name == NULL) debug("AVRCP: unknown button 0x%02X %s", operands[0] & 0x7F, status); }
void Keyboard::sendKey(uint32_t key, uint32_t state) { if (m_focusResource) { uint32_t serial = m_compositor->nextSerial(); send_key(m_focusResource->handle, serial, m_compositor->time(), key, state); } }
JNIEXPORT void JNICALL Java_com_iiordanov_aSPICE_SpiceCommunicator_SpiceKeyEvent(JNIEnv * env, jobject obj, jboolean down, jint hardware_keycode) { SpiceDisplay* display = global_display; SpiceDisplayPrivate* d = SPICE_DISPLAY_GET_PRIVATE(display); SPICE_DEBUG("%s %s: keycode: %d", __FUNCTION__, "Key", hardware_keycode); if (!d->inputs) return; if (down) { send_key(display, hardware_keycode, 1); } else { send_key(display, hardware_keycode, 0); } }
static int dump_rom_2 (CalcHandle* handle, CalcDumpSize size, const char *filename) { int i, err = 0; static const uint16_t keys[] = { 0x40, 0x09, 0x09, /* Quit, Clear, Clear, */ 0xFE63, 0x97, 0xDA, /* Send(, 9, prgm */ 0xAB, 0xA8, 0xA6, 0x9D, /* R, O, M, D */ 0xAE, 0xA6, 0xA9, 0x05 /* U, M, P, Enter */ }; // Launch program by remote control for(i = 0; i < (int)(sizeof(keys) / sizeof(keys[0])); i++) { TRYF(send_key(handle, keys[i])); PAUSE(100); } do { handle->updat->refresh(); if (handle->updat->cancel) return ERR_ABORT; //send RDY request ??? PAUSE(1000); err = rd_is_ready(handle); } while (err == ERROR_READ_TIMEOUT); // Get dump TRYF(rd_dump(handle, filename)); return 0; }
static int dump_rom_2 (CalcHandle* handle, CalcDumpSize size, const char *filename) { #if 0 int i; static const uint16_t keys[] = { 0x40, 0x09, 0x09, 0xFC9C, /* Quit, Clear, Clear, Asm( */ 0xDA, 0xAB, 0xA8, 0xA6, /* prgm, R, O, M */ 0x9D, 0xAE, 0xA6, 0xA9, /* D, U, M, P */ 0x86 }; /* ) */ // Launch program by remote control PAUSE(200); for(i = 0; i < sizeof(keys) / sizeof(uint16_t); i++) { TRYF(send_key(handle, keys[i])); PAUSE(100); } // This fixes a 100% reproducible timeout: send_key normally requests a data ACK, // but when the program is running, no data ACK is sent. Therefore, hit the Enter // key without requesting a data ACK, only the initial delay ACK. TRYF(cmd_s_execute(handle, "", "", EID_KEY, NULL, 0x05)); TRYF(cmd_r_delay_ack(handle)); PAUSE(400); #endif #if 1 TRYF(cmd_s_execute(handle, NULL, "ROMDUMP", EID_PRGM, NULL, 0)); TRYF(cmd_r_data_ack(handle)); PAUSE(400); #endif // Get dump TRYF(rd_dump(handle, filename)); return 0; }
void send_word( char * str ) { int i; for (i=0;i<(int)strlen(str);i++) send_key(str[i]); }
static int dump_rom_2 (CalcHandle* handle, CalcDumpSize size, const char *filename) { static const uint16_t keys_83p[] = { 0x40, 0x09, 0x09, 0xFC9C, /* Quit, Clear, Clear, Asm( */ 0xDA, 0xAB, 0xA8, 0xA6, /* prgm, R, O, M */ 0x9D, 0xAE, 0xA6, 0xA9, /* D, U, M, P */ 0x86, 0x05 }; /* ), Enter */ static const uint16_t keys_73[] = { 0x40, 0x09, 0x09, 0xDA, /* Quit, Clear, Clear, prgm */ 0xAB, 0xA8, 0xA6, 0x9D, /* R, O, M, D, */ 0xAE, 0xA6, 0xA9, 0x05 }; /* U, M, P, Enter */ int ret = 0; const uint16_t *keys; unsigned int i, nkeys; if (handle->model == CALC_TI73) { keys = keys_73; nkeys = sizeof(keys_73) / sizeof(keys_73[0]); } else { keys = keys_83p; nkeys = sizeof(keys_83p) / sizeof(keys_83p[0]); } // Launch program by remote control PAUSE(200); for (i = 0; !ret && i < nkeys - 1; i++) { ret = send_key(handle, (uint32_t)(keys[i])); PAUSE(100); } if (!ret) { // This fixes a 100% reproducible timeout: send_key normally requests an ACK, // but when the program is running, no ACK is sent. Therefore, hit the Enter key // without requesting an ACK. ret = SEND_KEY(handle, keys[i]); if (!ret) { ret = RECV_ACK(handle, NULL); // when the key is received if (!ret) { PAUSE(1000); // Get dump // (Normally there would be another ACK after the program exits, // but the ROM dumper disables that behavior) ret = rd_dump(handle, filename); } } } return ret; }
void QWaylandKeyboardPrivate::sendKeyEvent(uint code, uint32_t state) { uint32_t time = compositor()->currentTimeMsecs(); uint32_t serial = compositor()->nextSerial(); uint key = code - 8; if (focusResource) send_key(focusResource->handle, serial, time, key, state); }
void generic_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { UINT8 new_code; new_code = keyboard_handler(m_last_code, &m_scan_line); if ((m_last_code != new_code) && (new_code)) send_key(new_code); m_last_code = new_code; }
static void handle_release(struct avctp *session, uint16_t op) { if (session->key.timer > 0) { g_source_remove(session->key.timer); session->key.timer = 0; } send_key(session->uinput, op, 0); }
static int tap_action() { struct key_modifier *tap = &keystate.tap; if (tap->num_active) { if (!tap->circular && (tap->count == tap->num_active)) return 0; send_key(KEY_BACKSPACE, KEYDOWN); send_key(KEY_BACKSPACE, KEYUP); send_key(keystate.tap.code, KEYUP); flush_queue(tap->actions[tap->count], tap->code); tap->count = (tap->count + 1) % tap->num_active; start_tap_timeout(); } else { flush_queue(ACTION_NONE, 0); } return 0; }
static int del_var (CalcHandle* handle, VarRequest* vr) { int ret = 0; static const uint16_t keys[] = { 0x40, 0x09, 0x09, /* Quit, Clear, Clear, */ 0x3e, 0x9d, 0x04, /* Catalog, D, Down */ 0x04, 0x04, 0x05 /* Down, Down, Enter */ }; unsigned int i; char *utf8; utf8 = ticonv_varname_to_utf8(handle->model, vr->name, vr->type); ticalcs_slprintf(update_->text, sizeof(update_->text), _("Deleting %s..."), utf8); ticonv_utf8_free(utf8); update_label(); // Input keys by remote control for (i = 0; !ret && i < sizeof(keys) / sizeof(keys[0]); i++) { ret = send_key(handle, (uint32_t)(keys[i])); } for (i = 0; !ret && i < strlen(vr->name); i++) { char c = toupper(vr->name[i]); if (isdigit(c)) { ret = send_key(handle, (uint32_t)(0x008e + c - '0')); } else { ret = send_key(handle, (uint32_t)(0x009a + c - 'A')); } } if (!ret) { ret = send_key(handle, 0x0005); // Enter } return ret; }
//Sends all words in the dictionary that can be formed by the given set of letters, then switches to the next //set of letters. void loop_through_dictionary( char* letters ) { int x; for( x = 0; x < NUM_WORDS; x++ ) { if( composed_of( dictionary[x], letters ) && strlen( dictionary[x]) < 6 ) { send_word( dictionary[x] ); } } sleep( 1 ); send_key( XKeysymToKeycode( display, XK_Control_L ) , 1); }
static void handle_press(struct avctp *session, uint16_t op) { if (session->key.timer > 0) { g_source_remove(session->key.timer); /* Only auto release if keys are different */ if (session->key.op == op) goto done; send_key(session->uinput, session->key.op, 0); } session->key.op = op; send_key(session->uinput, op, 1); done: session->key.timer = g_timeout_add_seconds(AVC_PRESS_TIMEOUT, auto_release, session); }
static int execute (CalcHandle* handle, VarEntry *ve, const char* args) { int ret; // Go back to homescreen PAUSE(200); ret = send_key(handle, KEY83_Quit); if (!ret) { ret = send_key(handle, KEY83_Clear); if (!ret) { ret = send_key(handle, KEY83_Clear); } } if (!ret) { // Launch program by remote control if (ve->type == TI83_ASM) { ret = send_key(handle, KEY83_SendMBL); if (!ret) { ret = send_key(handle, KEY83_9); } } if (!ret) { ret = send_key(handle, KEY83_Exec); if (!ret) { unsigned int i; for (i = 0; !ret && i < strlen(ve->name); i++) { const CalcKey *ck = ticalcs_keys_83((ve->name)[i]); ret = send_key(handle, (uint32_t)(ck->normal.value)); } if (!ret) { ret = send_key(handle, KEY83_Enter); PAUSE(200); } } } } return ret; }
static gboolean auto_release(gpointer user_data) { struct avctp *session = user_data; session->key.timer = 0; DBG("AV/C: key press timeout"); send_key(session->uinput, session->key.op, 0); return FALSE; }
/** * @brief avrcp sendkey tools * Use this to send a raw key code. * the rawkey keymap is /system/usr/keylayout/AVRCP.kl */ int main(int argc, char* argv[]) { uint16_t keycode = KEY_FASTFORWARD; uint16_t delay = 1; printf("[BT][AVRCP] Usage: avrcp_sendkey rawkey_code release_delay \n"); DBG_PRINTF("[BT][AVRCP] prepare to create\n"); g_uinput_fd = myinput_create("AVRCP"); // will use /system/usr/keylayout/AVRCP.kl key map if( argc > 1 ){ keycode = atoi(argv[1]); } if( argc > 2 ){ delay = atoi(argv[2]); } printf("[BT][AVRCP] keycode:%d(0x%x) delay:%d\n", keycode, keycode, delay ); DBG_PRINTF("[BT][AVRCP] keycode:%d(0x%x) delay:%d", keycode, keycode, delay ); if( g_uinput_fd > 0){ DBG_PRINTF("[BT][AVRCP] create ok fd:%d\n", g_uinput_fd); printf("[BT][AVRCP] send key before\n"); send_key(g_uinput_fd, keycode, 1); // send key pad 9 DBG_PRINTF("[BT][AVRCP] send key after\n"); sleep(delay); // seconds send_key(g_uinput_fd, keycode, 0); // send key pad 9 printf("[BT][AVRCP] send key after\n"); } if( g_uinput_fd > 0 ){ close(g_uinput_fd); g_uinput_fd = 0; } return 0; }
static int hold_action() { struct key_modifier *hold = &keystate.hold; if (hold->num_active) { if (hold->count == hold->num_active) { if (!hold->circular) return 0; hold->count -= hold->num_active; } send_key(KEY_BACKSPACE, KEYDOWN); send_key(KEY_BACKSPACE, KEYUP); send_key(keystate.hold.code, KEYUP); flush_queue(hold->actions[hold->count], hold->code); hold->count++; start_hold_timeout(); } else { flush_queue(ACTION_NONE, 0); } return 0; }
/* * console_widget_NT_t::process_focus_event * * MSDN says this event is used internally only and should be ignored. * But it seems to work ok, at least on XP ??? * I believe a broken focus handler is better than nothing, so here it is. */ void console_widget_NT_t::process_focus_event( FOCUS_EVENT_RECORD& fer ) { if (fer.bSetFocus) return; for (int i = 0; i < 255; ++i) { if (vkey_state[i]) { // release it send_key(vkey_state[i]); vkey_state[i] = 0; } } vkey_state[255] = 0; }
int main(int argc, char* argv[]) { char const* const dev = argc >= 3 ? argv[2] : "/dev/cu.usbmodem411"; int fd = ubw_init(dev); printf("%s", run("V\n", fd)); if (argc < 2) return 0; run_ok("O,0,255,0\n", fd); run_ok("C,0,0,0,0\n", fd); char const* code = argv[1]; printf("Code: [%s]\n", code); while (*code) { send_key(*code, fd); code += 1; } }