Пример #1
0
void		add_stars(t_cmds **cmd, char *dir, t_shell *shell)
{
	int				i;
	int				len;
	char			**tmp;
	char			*tm;

	if (dir[0] == '\0')
		dir = ft_strdup(shell->get_pwd);
	if (!is_directory(dir))
		return ;
	process_key(*cmd, DELETE, "del", shell);
	if (!(i = 0) && ft_strcmp(shell->get_pwd, dir) != 0)
		while (dir[i++])
			process_key(*cmd, DELETE, "del", shell);
	tmp = get_in_dir(dir, shell);
	i = -1;
	while (tmp[++i])
	{
		len = 0;
		while (tmp[i][len] && ft_isprint(tmp[i][len]) && (tm = ft_strnew(2)))
		{
			tm[0] = tmp[i][len];
			process_key(*cmd, tmp[i][len++], tm, shell);
		}
		process_key(*cmd, ' ', " ", shell);
	}
}
Пример #2
0
// seg000:148D
int __pascal far do_paused() {
	word key;
	key = 0;
	next_room = 0;
	control_shift = 0;
	control_y = 0;
	control_x = 0;
	if (is_joyst_mode) {
		read_joyst_control();
	} else {
		read_keyb_control();
	}
	key = process_key();
	if (is_paused) {
		is_paused = 0;
		display_text_bottom("GAME PAUSED");
		// busy waiting?
		do {
			idle();
			//request_screen_update();
		} while (! process_key());
		erase_bottom_text(1);
	}
	return key || control_shift;
}
Пример #3
0
int
crypt_select (int selection)
{
    if (selection == ENCRYPTION_SELECT)
    {
        if (encrypt_or_decrypt == DECRYPTION_SELECT)
        {
            encrypt_or_decrypt = ENCRYPTION_SELECT;
            if (key_defined)                     /* if we have a key, recalculate */
                process_key (key_string, actual_key);
        }
    }

    if (selection == DECRYPTION_SELECT)
    {
        if (encrypt_or_decrypt == ENCRYPTION_SELECT)
        {
            encrypt_or_decrypt = DECRYPTION_SELECT;
            if (key_defined)                     /* if we have a key, recalculate */
                process_key (key_string, actual_key);
        }
    }

    return encrypt_or_decrypt;
}
Пример #4
0
int do_ui_key(unsigned int key)
{
    // mask keys
    key &= PSP_CTRL_UP | PSP_CTRL_DOWN | PSP_CTRL_LEFT | PSP_CTRL_RIGHT | PSP_CTRL_CIRCLE | PSP_CTRL_CROSS;
    static int prvkey = 0;
    static int repeat = 0;
    static int repeat_time = 0;

    if (key != prvkey) {
        int def = key ^ prvkey;
        repeat = 0;
        repeat_time = 0;
        process_key( def, def & key, 0 );
        if (def & key) {
            // auto repeat up / down only
            repeat = def & (PSP_CTRL_UP | PSP_CTRL_DOWN);
        } else repeat = 0;
        prvkey = key;
    } else {
        if ( repeat ) {
            repeat_time++;
            if ((repeat_time >= 32) && ((repeat_time & 0x3) == 0))
                process_key( repeat, repeat, repeat_time );
        }
    }
    return 0;
}
bool WindowContextBase::im_filter_keypress(GdkEventKey* event) {
    static size_t buf_len = 12;
    static char *buffer = NULL;

    if (buffer == NULL) {
        buffer = (char*)malloc(buf_len * sizeof (char));
    }

    KeySym keysym;
    Status status;
    XKeyPressedEvent xevent = convert_event(event);
    if (XFilterEvent((XEvent*) & xevent, GDK_WINDOW_XID(gdk_window))) {
        return TRUE;
    }

    if (event->type == GDK_KEY_RELEASE) {
        process_key(event);
        return TRUE;
    }

    int len = Xutf8LookupString(xim.ic, &xevent, buffer, buf_len - 1, &keysym, &status);
    if (status == XBufferOverflow) {
        buf_len = len + 1;
        buffer = (char*)realloc(buffer, buf_len * sizeof (char));
        len = Xutf8LookupString(xim.ic, &xevent, buffer, buf_len - 1,
                &keysym, &status);
    }
    switch (status) {
        case XLookupKeySym:
        case XLookupBoth:
            if (xevent.keycode) {
                //process it as a normal key
                process_key(event);
                break;
            }
            // fall-through
        case XLookupChars:
            buffer[len] = 0;
            jstring str = mainEnv->NewStringUTF(buffer);
            EXCEPTION_OCCURED(mainEnv);
            jsize slen = mainEnv->GetStringLength(str);
            mainEnv->CallVoidMethod(jview,
                    jViewNotifyInputMethod,
                    str,
                    NULL, NULL, NULL,
                    slen,
                    slen,
                    0);
            LOG_EXCEPTION(mainEnv)

            break;
    }

    return TRUE;
}
Пример #6
0
// Translate data from KeyToScanCode[] to calls to process_key().
static void
prockeys(u16 scancode, u8 key_release, u8 mods)
{
    if (scancode > 0xff) {
        if (scancode == 0xe145) {
            // XXX - a real AT keyboard would immediately send the key release
            if (mods & ((1<<0) | (1<<4))) {
                // Cntr+Break key
                process_key(0xe0);
                process_key(0x46 | key_release);
            } else {
                // Pause key
                process_key(0xe1);
                process_key(0x1d | key_release);
                process_key(0x45 | key_release);
            }
            return;
        } else if (scancode == 0xe037 && mods & ((1<<2) | (1<<6))) {
            // Alt+SysReq key
            process_key(0x54 | key_release);
            return;
        }
        process_key(0xe0);
    }
    process_key(scancode | key_release);
}
Пример #7
0
/*
 * This does the UNIx style ^xx^yy replace search. Only affects last
 * command and display "Modified failed." on a no match.
 */
void history_sub(char *args)
{
    char *p;
    char buf[MAXSIZ];
    char pat[MAXSIZ];

    p = strchr(args, '^');

    if (!p) {
        msg("-- No specified modifier.");

        return;
    }

    *p = '\0';
    sprintf(pat, "*%s*", args);

    if (!pattern_match(hist_cur->prev->line, pat, pattern)) {
        msg("-- Modifier failed.");

        return;
    } else {
        sprintf(buf, "%s%s%s", pattern1, p + 1, pattern2);
        msg("%s", buf);
        process_key(buf, false);
        add_history(buf);
    }
}
Пример #8
0
/* processor:
 *  Processes the first packet in the buffer, if any, returning the number
 *  of bytes eaten.
 */
static int processor (unsigned char *buf, int buf_size)
{
   struct input_event *event;

   if (buf_size < (int)sizeof(struct input_event))
      return 0; /* not enough data */

   event = (struct input_event*)buf;
   switch (event->type) {
      case EV_KEY:
         process_key(event);
         break;
      case EV_REL:
         process_rel(event);
         break;
      case EV_ABS:
         process_abs(event);
         break;
   }

   if (current_tool!=no_tool) {
      x_axis.out_abs = CLAMP(x_axis.out_min, x_axis.out_abs, x_axis.out_max);
      y_axis.out_abs = CLAMP(y_axis.out_min, y_axis.out_abs, y_axis.out_max);
      /* There's no range for z */

      _mouse_x = x_axis.out_abs;
      _mouse_y = y_axis.out_abs;
      _mouse_z = z_axis.out_abs;
      _mouse_b = button_left + (button_right<<1) + (button_middle<<2);
      _handle_mouse_input();
   }
   /* Returns the size of the data used */
   return sizeof(struct input_event);
}
Пример #9
0
int main(void)
{
	int i;

	srand((unsigned)time(NULL));
	setcursortype(NOCURSOR);
	draw_title(); 
	reset();

	while (1)
	{
		for (i = 0; i<5; i++) //블록이 한칸떨어지는동안 5번 키입력받을 수 있음 
		{ 
			process_key(); //키입력확인 
			draw_game();
			Sleep(speed);
			if (crush_on&&check_crush(bx, by + 1, b_rotation) == false) 
				Sleep(100); //블록이 충돌중인경우 추가로 이동및 회전할 시간을 갖음
			if (space_key_on == 1) //스페이스바를 누른경우(hard drop) 추가로 이동및 회전할수 없음 break; 
			{ 
				space_key_on = 0;
				break;
			}
		}
		move_down();  
		check_level_up(); 
		check_game_over(); 
		if (new_block_on == 1)
			new_block(); // 뉴 블럭 flag가 있는 경우 새로운 블럭 생성 
	}
}
Пример #10
0
int main(int argc, char **args)
{
	RAND = ((int)time(NULL))%10;
	init_console();
	init_buffer();
	init_clipboard();
	if (argc > 1)
	{
		FILENAME = (unsigned char *)malloc(256*sizeof(char));
		strcpy((char *)FILENAME, args[1]);
		file_to_buffer();
	}
	else 
	{
		MAX_VPOS = 1;
	}
	while (RUN)
	{
		redraw_screen();
#ifdef DEBUG_MODE
		printf("%d", INPUT_KEY);
#endif
		INPUT_KEY = _getch();
		process_key();
	}
	DestroyAndExit("Exiting...");
	return 0;
}
Пример #11
0
void kos_Main()
{
	kos_InitHeap();
	load_edit_box();
	init();
	
	for (;;)
	{
		switch (kos_WaitForEvent())
		{
		case 6:
			process_mouse();
			break;
		case 1:
			window_drawall=true;
			draw_window();
			break;
		case 2:
			process_key();
			break;
		case 3:
			process_button();
			break;
		}
	}
}
Пример #12
0
// INT09h : Keyboard Hardware Service Entry Point
void VISIBLE16
handle_09(void)
{
    if (! CONFIG_PS2PORT)
        return;

    debug_isr(DEBUG_ISR_09);

    // read key from keyboard controller
    u8 v = inb(PORT_PS2_STATUS);
    if (v & I8042_STR_AUXDATA) {
        dprintf(1, "ps2 keyboard irq but found mouse data?!\n");
        goto done;
    }
    v = inb(PORT_PS2_DATA);

    if (!(GET_EBDA(ps2ctr) & I8042_CTR_KBDINT))
        // Interrupts not enabled.
        goto done;

    process_key(v);

done:
    eoi_pic1();
}
Пример #13
0
/* synthesize a BUFFER_SIZE_SAMPLES's of audio-data */
static void synth_fragment (void *synth, const size_t n_samples, float *left, float *right) {
  RSSynthesizer* rs = (RSSynthesizer*)synth;
  memset (left, 0, n_samples * sizeof(float));
  memset (right, 0, n_samples * sizeof(float));
  uint8_t keycomp = 0;
  int c,k;
  size_t i;

  for (c=0; c < 16; ++c) {
    for (k=0; k < 128; ++k) {
      if (rs->sc[c].miditable[k] == 0) continue;
      process_key(synth, c, k, n_samples, left, right);
    }
    keycomp += rs->sc[c].keycomp;
  }

#if 1 // key-compression
  float kctgt = 8.0 / (float)(keycomp + 7.0);
  if (kctgt < .5) kctgt = .5;
  if (kctgt > 1.0) kctgt = 1.0;
  const float _w = rs->kcfilt;
  for (i=0; i < n_samples; ++i) {
    rs->kcgain += _w * (kctgt - rs->kcgain);
    left[i]  *= rs->kcgain;
    right[i] *= rs->kcgain;
  }
  rs->kcgain += 1e-12;
#endif
}
Пример #14
0
void Application::run()
{
    if( plane == NULL )
        throw NoPlaneError();
    if( light_source == NULL )
        throw NoLightSourceModelError();
    if( target_plane == NULL )
        throw NoTargetPlaneError();

    window.show();
    window.update();

    // Enter the message loop
    MSG msg;
    ZeroMemory( &msg, sizeof( msg ) );
    while( msg.message != WM_QUIT )
    {
        if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
        {
            if( msg.message == WM_KEYDOWN )
            {
                process_key( static_cast<unsigned>( msg.wParam ) );
            }

            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        else
            render();
    }
}
Пример #15
0
int main( int argc, char *argv[] )
{
	struct map_data *map;
	if ( init(&map, argc, argv) ) {
		exit( 0 );
	}
	
	int cur = '\0';
	
	point_t start = get_start_point( map );
	

	
	 do {
		clear();
		print_map( map );
		
		process_key( cur );
		switch ( cur ) {
			default: {
				point_t target = get_cursor();
				//mvprintw( 0, 0, "Cursor was at : (%d, %d)", target.x, target.y);
				path_t *path_to_target = search_path( start, target, map );
				print_path( path_to_target );
				refresh();
			}
		}
		
		refresh();
	 } while ( (cur = getch()) != 'q' );
	
	
	cleanup_all();
	return 0;
}
Пример #16
0
static int	parse_key_four(int i, size_t key, t_cmds **cmd, t_shell *shell)
{
	if (key == 19)
	{
		if ((*cmd)->cp == -1)
		{
			(*cmd)->cp = 0;
			(*cmd)->txt_cp = ft_strnew(1);
			(*cmd)->txt_cp[0] = (*cmd)->cmd[(*cmd)->pointer];
		}
		else
		{
			(*cmd)->cp = -1;
			edit_cmd_cp(*cmd);
		}
	}
	else if (key == 24)
	{
		if (!(*cmd)->txt_cp && (*cmd)->up && (*cmd)->up->txt_cp)
			(*cmd)->txt_cp = (*cmd)->up->txt_cp;
		while ((*cmd)->txt_cp && (*cmd)->txt_cp[++i])
			process_key(*cmd, (*cmd)->txt_cp[i],\
			ft_strndup((*cmd)->txt_cp + i, 1), shell);
	}
	else
		return (parse_key_five(key, cmd, shell));
	return (1);
}
Пример #17
0
void
EvdevDevice::update(float delta)
{
  struct input_event ev[128];
  // FIXME: turn this into a while loop so all events get processed
  int rd = read(fd, ev, sizeof(struct input_event) * 128);
  //std::cout << rd / sizeof(struct input_event) << std::endl;
  if (rd >= (int) sizeof(struct input_event))
    {
      for (int i = 0; i < rd / (int)sizeof(struct input_event); ++i)
        {
          //std::cout << ev[i].type << " " << ev[i].code << " " << ev[i].value << std::endl;

          switch (ev[i].type)
            {
              case EV_ABS:
                process_absolute(ev[i]);
                break;

              case EV_REL:
                process_relative(ev[i]);
                break;

              case EV_KEY:
                process_key(ev[i]);
                break;

              default:
#if 0
                if (ev[i].type == EV_SYN) 
                  {
                    printf("Event: time %ld.%06ld, -------------- %s ------------\n",
                           ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].code ? "Config Sync" : "Report Sync" );
                  }
                else if (ev[i].type == EV_MSC && (ev[i].code == MSC_RAW || ev[i].code == MSC_SCAN)) 
                  {
                    printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %02x\n",
                           ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type,
                           events[ev[i].type] ? events[ev[i].type] : "?",
                           ev[i].code,
                           names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?",
                           ev[i].value);
                  } 
                else 
                  {
                    printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %d\n",
                           ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type,
                           events[ev[i].type] ? events[ev[i].type] : "?",
                           ev[i].code,
                           names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?",
                           ev[i].value);
                  }	
#endif                  
                break;
            }
        }
    }
}
Пример #18
0
void GUI::process_keys() {

  if(new_keys_start != new_keys_end) {
    process_key(new_keys_key[new_keys_start],new_keys_type[new_keys_start]);

    new_keys_start++;
    if(new_keys_start >= NEW_KEYS_MAX_SIZE) new_keys_start=0;
  }

}
Пример #19
0
u1_t handler_dev_display_read(u2_t addr)
{
	u1_t data;

	assert (addr == RREG_KEY_SCAN);

	// For reasons that are not understood, when the -O3 optimized version of the app are run in
	// auto-start mode the reset key push is not detected most of the time unless this delay is added.
	// Oddly, this bug doesn't appear if the optimized version is run from the command line, which makes no sense.
	// It doesn't appear to be code getting optimized away or a missing volatile declaration but rather timing related.
#ifndef DEBUG
	delay(1);
#endif

	data = bus_read(addr);

	if (data != KEY_IDLE) {
		process_key(data);
	} else

	if (sim_key) {
		data = sim_key;
		
		// simulate reset key down for an extended period
		if (reset_key_down) {
			if ((time_diff(timer_ms(), reset_key_down) > 1250)) reset_key_down = 0;
		} else {
			if (sim_running) {
				if (!sim_key_intr) sim_key = 0;		// allow it to be read twice, but generate interrupt only once
			} else {
				sim_key = 0;	// only once for non-simulator uses
			}
		}
		
		sim_key_intr = 0;
		process_key(data);
	}

	return data;
}
Пример #20
0
static void
process_ps2byte(u8 status, u8 data)
{
    if (!MODE16) {
        // Don't pull in all of keyboard/mouse code into 32bit code -
        // just discard the data.
        dprintf(1, "Discarding ps2 data %x (status=%x)\n", data, status);
        return;
    }
    if (status & I8042_STR_AUXDATA)
        process_mouse(data);
    else
        process_key(data);
}
Пример #21
0
void HaiQTextEdit::keyPressEvent ( QKeyEvent * event ) {
	if (isReadOnly()) return;
	last_keypress.start();
	if (emit_key_only_mode) {
		emit key_pressed(*event);
		event->accept();
		return;
	}
	else {
		process_key(*event);
		emit key_pressed(*event);
		event->accept();
		return;
	}
}
Пример #22
0
bool CCustomAnimKey::ProcessKey( Obj::CObject* pObject )
{
	if ( !m_active )
	{
		Dbg_Message( "Key at %d was not active...  ignored!", m_frame );

		return false;
	}

	// once it's run, don't run it again...
	// (this is in case you pause a movie camera
	// on the same frame that it's running a key)
	this->SetActive( false );

	return process_key( pObject );
}
Пример #23
0
int
do_ui(void)
{
  char key = '\0';
  int ret = DOUI_ERR;

  /* init TUI and UI Elements (input field, status bar, etc) */
  if (init_ui(on_update_cb, on_postupdate_cb))
    init_ui_elements(ui_get_maxx(), ui_get_maxy());
  else
    return DOUI_ERR;

  /* some color definitions */
  init_pair(1, COLOR_RED, COLOR_WHITE);
  init_pair(2, COLOR_WHITE, COLOR_BLACK);
  init_pair(3, COLOR_BLACK, COLOR_WHITE);
  /* TXTwindow */
  init_pair(4, COLOR_YELLOW, COLOR_RED);
  init_pair(5, COLOR_WHITE, COLOR_CYAN);

  ui_thrd_suspend();
  if (run_ui_thrd() != 0) {
    ui_thrd_resume();
    return ret;
  }
  timeout(0);
  ui_thrd_resume();

  while ( ui_ipc_getvalue(SEM_UI) > 0 ) {
    if ( (key = ui_wgetch(10000)) == ERR )
      continue;

    if ( process_key(key) != true ) {
      ui_ipc_semtrywait(SEM_UI);
    }

    ui_thrd_force_update(true,false);
  }
  stop_ui_thrd();
  free_ui_elements();

  return DOUI_OK;
}
//Handle SFML events
void handle_event(sf::Event e)
{
	switch (e.type) {
	case sf::Event::Closed:
		fprintf(stderr,
		        "OpenGL Version String: %s\n",
		        glGetString(GL_VERSION));
		g_run = false;
		break;
	case sf::Event::Resized:
		win_resized(e.size.width, e.size.height);
		break;
	case sf::Event::KeyPressed:
		process_key(e.key);
		break;
	default:
		break;
	}
}
Пример #25
0
//-------- Begin of function Sys::detect --------//
//
void Sys::detect()
{
	//--- only detect at the even frames when in report mode ---//

	if( view_mode != MODE_NORMAL &&
		// ###### begin Gilbert 5/11 ######//
		 !report_disp_frame_no )
		// ###### end Gilbert 5/11 ######//
	{
		return;
	}

	//--------------------------------------//

	mouse.get_event();

	if( option_menu.is_active() )
	{
		option_menu.detect();
		return;
	}

	if( in_game_menu.is_active() )
	{
		in_game_menu.detect();
		return;
	}

	if( VBrowse::press_record )		// if the user is pulling the records of the browser up and down, calling detect() routines of other controls will confuse it
	{
		VBrowse::press_vbrowse_ptr->detect();
	}

	if( mouse.is_key_event() )
	{
		process_key(mouse.scan_code, mouse.event_skey_state);
	}

	detect_button();		// detect main buttons on the screen

	detect_view();
}
Пример #26
0
static void
touchpad_process(struct evdev_dispatch *dispatch,
		 struct evdev_device *device,
		 struct input_event *e,
		 uint32_t time)
{
	struct touchpad_dispatch *touchpad =
		(struct touchpad_dispatch *) dispatch;

	switch (e->type) {
	case EV_SYN:
		if (e->code == SYN_REPORT)
			touchpad->event_mask |= TOUCHPAD_EVENT_REPORT;
		break;
	case EV_ABS:
		process_absolute(touchpad, device, e);
		break;
	case EV_KEY:
		process_key(touchpad, device, e, time);
		break;
	}

	touchpad_update_state(touchpad, time);
}
Пример #27
0
void handle_loop(void)
{
    long cur_time;
    Loop *p = loop_info.head;
    char temp[MAXSIZ];

    cur_time = time(0);

    if ((loop_info.last_time + (long)loop_info.low_time) > cur_time) {
        return;
    }

    loop_info.last_time = cur_time;

    while (p) {
        if ((p->last_time + (long)p->time) < cur_time) {
            strcpy(temp, p->cmd);
            process_key(temp, 0);
            p->last_time = cur_time;
        }

        p = p->next;
    }
}
Пример #28
0
/**
 * Handles window messages sent to the main window.
 */
LRESULT CALLBACK winceapp_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
    PAINTSTRUCT ps;
    HDC hdc;
    int cmd;
    DWORD err;
    static int ignoreCancelMode = 0;

    switch (msg) {
    case WM_CREATE:
        {
            SHMENUBARINFO mbi;

            /* Create the menu bar with two simple soft buttons */
            ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
            mbi.cbSize = sizeof(SHMENUBARINFO);
            mbi.hwndParent = hwnd;
            mbi.nToolBarId = ID_MENU_SIMPLE;
            mbi.hInstRes = instanceMain;

            if (SHCreateMenuBar(&mbi) == FALSE) {
                /* Couldn't create the menu bar.  Fail creation of the window. */
                return -1;
            } else {
                hwndMenuBarSimple = mbi.hwndMB;

                /* In order to make the Back button work properly,
                 * it's necessary to override it and then call the
                 * appropriate SH API
                 */
                SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK,
                            MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
                                       SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
            }

            /* Create the menu bar with a popup menu. This is used if
             * the current MIDP screen has more than 2 Commands.
             */
            ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
            mbi.cbSize = sizeof(SHMENUBARINFO);
            mbi.hwndParent = hwnd;
            mbi.nToolBarId = ID_MENU_POPUP;
            mbi.hInstRes = instanceMain;

            if (SHCreateMenuBar(&mbi) == FALSE) {
                /* Couldn't create the menu bar.  Fail creation of the window. */
                return -1;
            } else {
              hwndMenuBarPopup = mbi.hwndMB;

                /* Get a handle to the popup menu, which will host the
                 * Commands of the current MIDP screen.
                 */
                TBBUTTONINFO tbbi = {0};
                tbbi.cbSize = sizeof(tbbi);
                tbbi.dwMask = TBIF_LPARAM;


                if (!SendMessage(hwndMenuBarPopup, TB_GETBUTTONINFO, IDM_SOFTBTN_0, (LPARAM)&tbbi)) {
                  err = GetLastError();
                }

                hmenuPopup = (HMENU)tbbi.lParam;

                /* In order to make the Back button work properly,
                 * it's necessary to override it and then call the
                 * appropriate SH API
                 */
                SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK,
                            MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
                                       SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
            }

            hwndMenuBar = hwndMenuBarSimple;
            ShowWindow(hwndMenuBarSimple, SW_SHOW);
            ShowWindow(hwndMenuBarPopup, SW_HIDE);
        }
        return 0;

    case WM_HOTKEY:
        /* If back key is overriden, back button messages are sent in
         * a WM_HOTKEY to the menu bar with the id VK_TBACK in the
         * LPARAM.
         */
        if (HIWORD(lp) == VK_TBACK && (LOWORD(lp) & MOD_KEYUP)) {
            if (editBoxShown) {
                SendMessage(hwndTextActive, WM_CHAR, VK_BACK, 0);
            } else {
#if ENABLE_MULTIPLE_ISOLATES
                if (gForegroundIsolateId == midpGetAmsIsolateId()) {
                    SHNavigateBack();
                } else {
                    pMidpEventResult->type = SELECT_FOREGROUND_EVENT;
                    pSignalResult->waitingFor = AMS_SIGNAL;
                }
#else
                SHNavigateBack();
#endif
            }
        }
        return 1;

    case WM_SETTINGCHANGE: {
        updateVisibleDesktop();
        updateEditorForRotation();
        lastWmSettingChangeTick = GetTickCount();
        /* Handle Virtual Keyboard change */
        RECT virtualKeyboardRect = {0, 0};
        HWND hWndInputPanel = FindWindow(TEXT("SipWndClass"), NULL);
        if (hWndInputPanel != NULL) {
            if (IsWindowVisible(hWndInputPanel)) {
                GetWindowRect(hWndInputPanel, &virtualKeyboardRect);
            }
        }
        virtualKeyboardHeight = virtualKeyboardRect.bottom - virtualKeyboardRect.top;
    }
        return DefWindowProc(hwnd, msg, wp, lp);

    case WM_TIMER:
        if (wp == EVENT_TIMER_ID+1) {
            KillTimer(hwndMain, EVENT_TIMER_ID+1);
            process_skipped_refresh();
        }
        return 0;

    case WM_COMMAND:
        switch ((cmd = GET_WM_COMMAND_ID(wp, lp))) {
        case IDOK:
#if ENABLE_MULTIPLE_ISOLATES
            /* On PocketPC devices that don't have a lot of hardware
             * buttons, this is a good way for implementing
             * the 'task switch' event - click on the OK button on
             * the window title
             */
            if (gForegroundIsolateId == midpGetAmsIsolateId()) {
                SetForegroundWindow(GetDesktopWindow());
                /* SHNavigateBack(); */
            } else {
                pMidpEventResult->type = SELECT_FOREGROUND_EVENT;
                pSignalResult->waitingFor = AMS_SIGNAL;
            }
#else
            /* IMPL_NOTE: we ask the user if the current Midlet should be
             * terminated.
             */
            SendMessage(hwnd, WM_CLOSE, 0, 0);
#endif
            /* for some reason windows has already sent us a CANCELMODE message
             * before we come to here. Let's re-enable painting.
             */
            if (!midpPaintAllowed) {
                enablePaint();
            }
            return 0;
        case IDM_SOFTBTN_0:
        case IDM_SOFTBTN_1:
            pMidpEventResult->type = MIDP_KEY_EVENT;
            pMidpEventResult->CHR = (cmd==IDM_SOFTBTN_0) ? 
                KEYMAP_KEY_SOFT1:KEYMAP_KEY_SOFT2;
            pMidpEventResult->ACTION = KEYMAP_STATE_RELEASED;
            pSignalResult->waitingFor = UI_SIGNAL;             
            pMidpEventResult->DISPLAY = gForegroundDisplayId;
            sendMidpKeyEvent(pMidpEventResult, sizeof(*pMidpEventResult));

            /* for some reason windows will send us a CANCELMODE message
             * afterwards
             */
            ignoreCancelMode ++;
            return 0;
        default:
            /* IMPL_NOTE The events from the menu are not transfer up to 
             *  java without displaying and addition menu.  
             * Only a MIDP_COMMAND_EVENT should be used.  Disabling this feature for now.
             */
            if (cmd >= ID_DYNAMIC_MENU) {
                pMidpEventResult->type = MIDP_KEY_EVENT;
                pMidpEventResult->CHR = ((cmd - ID_DYNAMIC_MENU)==IDM_SOFTBTN_0)
                                           ? KEYMAP_KEY_SOFT1:KEYMAP_KEY_SOFT2;
                pMidpEventResult->ACTION = KEYMAP_STATE_RELEASED;
                pSignalResult->waitingFor = UI_SIGNAL;
                pMidpEventResult->DISPLAY = gForegroundDisplayId;
                sendMidpKeyEvent(pMidpEventResult, sizeof(*pMidpEventResult));
                /* This command comes from a menu item dynamically
                 * created in the native method
                 */
                /* Disabled
                 SoftButtonLayer.setNativePopupMenu()
                 pMidpEventResult->type = MIDP_COMMAND_EVENT;
                 pMidpEventResult->COMMAND = (cmd - ID_DYNAMIC_MENU);
                 pSignalResult->waitingFor = UI_SIGNAL;
                 pMidpEventResult->DISPLAY = gForegroundDisplayId;
                 sendMidpKeyEvent(pMidpEventResult, sizeof(*pMidpEventResult));
                */  
                /* for some reason windows will send us a CANCELMODE message
                 * afterwards
                 */
                ignoreCancelMode ++;
                return 0;
            } else {
                return DefWindowProc(hwnd, msg, wp, lp);
            }
        }
        break;

    case WM_ACTIVATE:
        if (LOWORD(wp)) { /* active */
            enablePaint();
            if (editBoxShown) {
                SetFocus(hwndTextActive);
            }
        } else { /* inactive */
#if ENABLE_MULTIPLE_ISOLATES
            pMidpEventResult->type = SELECT_FOREGROUND_EVENT;
            pSignalResult->waitingFor = AMS_SIGNAL;
#endif
            disablePaint();
        }
        return DefWindowProc(hwnd, msg, wp, lp);

    case WM_EXITMENULOOP:
        enablePaint();
        return DefWindowProc(hwnd, msg, wp, lp);

    case WM_CANCELMODE:
        if (!ignoreCancelMode) {
            disablePaint();
        } else {
            ignoreCancelMode --;
        }
        /* We have to do this, or else windows is unhappy. */
        return DefWindowProc(hwnd, msg, wp, lp);

    case WM_PAINT:
        hdc = BeginPaint(hwnd, &ps);
        EndPaint(hwnd, &ps);
        enablePaint();
        if (editBoxShown) {
            SetFocus(hwndTextActive);
        }
        return 0;

    case WM_CLOSE:
        return DefWindowProc(hwnd, msg, wp, lp);

    case WM_DESTROY:
        PostQuitMessage(0);
        exit(0);
        return 0;

    case WM_MOUSEMOVE:
    case WM_LBUTTONDOWN:
    case WM_LBUTTONUP:
        {
            lastUserInputTick = GetTickCount();

            POINT pen_position ={LOWORD(lp), HIWORD(lp)};
            if (msg == WM_MOUSEMOVE) {
                pMidpEventResult->ACTION = KEYMAP_STATE_DRAGGED;
            } else if (msg == WM_LBUTTONUP) {
                pMidpEventResult->ACTION = KEYMAP_STATE_RELEASED;
            } else {
                pMidpEventResult->ACTION = KEYMAP_STATE_PRESSED;
            }
            pMidpEventResult->type = MIDP_PEN_EVENT;
            pMidpEventResult->X_POS = pen_position.x;
            pMidpEventResult->Y_POS = pen_position.y;

            pSignalResult->waitingFor = UI_SIGNAL;
            pMidpEventResult->DISPLAY = gForegroundDisplayId;
            sendMidpKeyEvent(pMidpEventResult, sizeof(*pMidpEventResult));
        }
        return 0;

    case WM_KEYDOWN: /* fall through */
    case WM_KEYUP:
        return process_key(hwnd, msg, wp, lp);
    default:
        return DefWindowProc(hwnd, msg, wp, lp);
    }
    return DefWindowProc(hwnd, msg, wp, lp);
}
Пример #29
0
    virtual BOOL on_key(HELEMENT he, HELEMENT target, UINT event_type, UINT code, UINT keyboardStates ) 
    { 
        const char* keyname = 0;
        if( event_type == (KEY_DOWN | SINKING) && (keyboardStates & ALT_KEY_PRESSED) == 0  )
        {
          keyname = get_key_name( code, keyboardStates);
          if( !keyname )
            return FALSE;
        }
        else if( (event_type == (KEY_CHAR | SINKING)) && (keyboardStates == ALT_KEY_PRESSED) ) 
        {
          if( code != '\'' && code != '\"' )
          {
            static char name[2];
            name[0] = (char) code;
            name[1] = 0;
            keyname = name;
          }
          else
            return false;
        }
        else 
          return false;

        dom::element container = he;

        HWND thisHWnd = container.get_element_hwnd(false);
        
        // handling IFrame in focus situation
        if( ::GetFocus() == thisHWnd) 
        {
          dom::element super_container = dom::element::root_element( ::GetParent(thisHWnd)  );
          if( super_container.is_valid() ) // yes, we have outer frame
          {
            if(process_key(super_container, keyname))
                return TRUE;
          }
        }

        // normal handling

        if(process_key(container, keyname))
            return TRUE;

        // child iframes handling (if any)
        struct CB:public htmlayout::dom::callback 
        {
          const char* keyname;
          bool done;
          virtual bool on_element(HELEMENT he) 
          {
            htmlayout::dom::element iframe = he; 
            if( iframe.enabled() && iframe.visible() ) // only if it is visible and enabled
            {
              HWND hwndIFrame = iframe.get_element_hwnd(false);
              htmlayout::dom::element iframeRoot = htmlayout::dom::element::root_element(hwndIFrame);
              if(accesskeys::process_key( iframeRoot, keyname ))
              {
                done = true;
                return true; // stop enumeration
              }
            }
            return false;
          }
        };
        CB cb;
        cb.done = false;        
        cb.keyname = keyname;
        container.find_all(&cb, "iframe");
        return cb.done;
       
    }
Пример #30
0
int main(void) {
    DDRB = 0b00011110; //Configure some of them to be input, some to output
    PORTB = 0xFF; // all of them to pull up or high

    DDRC = 0x00; // All of them to input
    PORTC = 0xFF; // with a pull up
    PORTD = 0xFF;

    _delay_ms(100);

    uart_init();
    stdout = &uart_output;
    stdin  = &uart_input;
    ps2_mouse_init();
    /* ps2_init(); */
    _delay_ms(100);
    reset_report();
    send_raw_key_report();

    DDRD &= 0b00011111; // D will be reconfigured by the uart module.

    int i,j;
    while(1) {
        reset_report();
        reset_mouse_report();
        /* keys[0] = K_A; */
        for(j=0; j<4; j++) {
            PORTB = ~(1<<(1+j));
            for(i=0; i<6; i++) {
                process_key(j*12+i, !(PINC & (1<<i)));
            }
            process_key(j*12+i, !(PINB & 1)  );
            i++;
            process_key(j*12+i, !(PIND & (1<<7)));
            i++;
            process_key(j*12+i, !(PIND & (1<<6)));
            i++;
            process_key(j*12+i, !(PIND & (1<<5)));
            i++;
            process_key(j*12+i, !(PINB & (1<<7)));
            i++;
            process_key(j*12+i, !(PINB & (1<<6)));
        }
        send_raw_key_report();

        if( mouse_delay == 0) {
            if( mouse_trackpt ) {
                ps2_mouse_task();

                if( (mouse_report.x < 10 && mouse_report.x > -10) ||
                        (mouse_report.y < 10 && mouse_report.y > -10)  )  {
                    if( (mouse_report.x < 2 && mouse_report.x > -2) ||
                            (mouse_report.y < 2 && mouse_report.y > -2)  ) {
                        mouse_report.x = 0;
                        mouse_report.y = 0;
                    } else {
                        mouse_report.x >>= 2;
                        mouse_report.y >>= 2;
                    }
                } else {
                    mouse_report.x >>= 1;
                    mouse_report.y >>= 1;
                }

                mouse_x = mouse_report.x;
                mouse_y = mouse_report.y;
            }
            mouse_delay = 2;
        } else {