Exemplo n.º 1
0
void
ggi_visual_get_event (void *         vis,
		      Visual_Event * visual_event) {
  gii_event event_buffer;
  int       err;

  err = ggiEventRead(VISUAL_T(vis),
                     &event_buffer,
                     emKey | emPointer);

  switch(event_buffer.any.type)
  {
  case evPtrAbsolute:
    visual_event->type = Visual_Mouse_Move_Event;
    visual_event->mouse_move.x = event_buffer.pmove.x;
    visual_event->mouse_move.y = event_buffer.pmove.y;
    break;

  case evPtrRelative:
    fprintf(stderr, "evPtrRelative\n");
    break;

  case evPtrButtonPress:
    old_buttons |= (1 << (event_buffer.pbutton.button - 1));
    visual_event->type = Visual_Mouse_Button_Event;
    visual_event->mouse_button.buttons = old_buttons;
    visual_event->mouse_button.state = 0;
    break;

  case evPtrButtonRelease:
    old_buttons &= ~(1 << (event_buffer.pbutton.button - 1));
    visual_event->type = Visual_Mouse_Button_Event;
    visual_event->mouse_button.buttons = old_buttons;
    visual_event->mouse_button.state = 0;
    break;

  case evKeyPress:
    visual_event->type = Visual_Key_Press_Event;
    map_key(&event_buffer.key,
            &visual_event->key);
    break;

  case evKeyRelease:
    visual_event->type = Visual_Key_Release_Event;
    map_key(&event_buffer.key,
            &visual_event->key);
    break;

  case evKeyRepeat:
    visual_event->type = Visual_Key_Repeat_Event;
    map_key(&event_buffer.key,
            &visual_event->key);
    break;

  default:
    fprintf(stderr, "Unknown GII type %d in ggi_visual_get_event\n",
            event_buffer.any.type);
  }
}
Exemplo n.º 2
0
 void keyReleaseEvent(QKeyEvent* qevent) override
 {
     if (keyprocs)
     {
         keyprocs->released(keydata, map_key(qevent));
     }
 }
Exemplo n.º 3
0
 void keyPressEvent(QKeyEvent* qevent) override
 {
     if (keyprocs)
     {
         keyprocs->pressed(keydata, map_key(qevent));
     }
 }
Exemplo n.º 4
0
int find_keyword(const char* inbytes, size_t* length, const language_zh_map *m, int begin, int end, const int whence)
{
	int location, offset;
	size_t wwidth, nwidth;

	if((offset = binary_find(inbytes, length, m, begin, end)) == -1)
		return -1;

	/* match the most accurate value */
	wwidth = *length;
	do{
		location = offset;
		*length  = wwidth;
		nwidth   = utf8_char_width(const_bin_c_str(inbytes+wwidth));
		wwidth  += nwidth;
	}
	while(nwidth != 0 && (offset = binary_find(inbytes, &wwidth, m, offset, end)) != -1);

	/* extention word fix */
	if(!match_cond(cond_ptr(m, location), inbytes, strlen(map_key(m, location)), whence))
	{
		*length = utf8_char_width(const_bin_c_str(inbytes));
		return -1;
	}

	return location;
}
Exemplo n.º 5
0
static void _json_write_object(FILE * file, map_t map, unsigned int depth)
{
    if (map_size(map) == 0) {
        fputs("{}", file);
    } else {
        bool first = true;

        fputs("{\n", file);

        for_each_map(it, map) {
            if (first) first = false;
            else fputs(",\n");

            for (int i = 0; i < depth + 1; i++)
                fputs("    ", file);
            _json_write_string(file, map_key(it));
            fputs(": ");
            _json_write(file, map_value(it), depth + 1);
        }

        fputs("\n", file);
        for (int i = 0; i < depth; i++)
            fputs("    ", file);
        fputs("}", file);
    }
}
Exemplo n.º 6
0
csKeyMap* find_mapping (const char* keyname)
{
  csKeyMap map;
  map_key (keyname, &map);

  csKeyMap* m = mapping;
  while (m)
  {
    if (map.key == m->key && map.shift == m->shift && map.ctrl == m->ctrl && map.alt == m->alt
    	&& map.need_status == m->need_status)
      return m;
    m = m->next;
  }
  return 0;
}
Exemplo n.º 7
0
/* If a real keyboard is plugged in (via usb) */
void *Keyboard_eventThread(void *arg) 
{
	const char *dev = "/dev/input/by-path/platform-20980000.usb-usb-0:1.2.1:1.0-event-kbd";
    ssize_t n;

    keyboard_fd = open(dev, O_RDONLY);
    if (keyboard_fd == -1) {
        fprintf(stderr, "Cannot open %s: %s.\n", dev, strerror(errno));
        return EXIT_FAILURE;
    }
    printf("Opened /dev/input/by-path/KEYBOARD\n");
    
    char ch;
	while (1) {

		n = read(keyboard_fd, &keyboard_ev, sizeof(struct input_event));
		if (n == (ssize_t)-1) {		// incase of buggy kernel/driver partial event.
            if (errno == EINTR)  continue;
            else  break;
        } else if (n != sizeof keyboard_ev) {
            errno = EIO;
            break;
        }
        
		// Read Linux Event for the key        
		if (keyboard_ev.type==EV_KEY)
		{
			
			if ((keyboard_ev.code == KEY_LEFTSHIFT) || (keyboard_ev.code == KEY_RIGHTSHIFT))
			{	if (keyboard_ev.value==0)
					shift_down = false;
				else shift_down = true;
			} else if (keyboard_ev.value>=1  && keyboard_ev.value<=2)
			{
					if (shift_down)  Dprintf("shift down");
					
					ch = map_key(keyboard_ev.code);
					MainDisplay.relay_key( ch );					
					if (Debug) printf("%c\n", ch);	
					//printf("%s 0x%04x (%d) %c\n", evval[keyboard_ev.value], (int)keyboard_ev.code, 
					//							(int)keyboard_ev.code, key_map[keyboard_ev.code]);		
			}
		}
	}
 	fflush (stdout);
    fprintf(stderr, "%s.\n", strerror(errno));
    return EXIT_FAILURE;
}
Exemplo n.º 8
0
void bind_key (const char* _arg)
{
  if (!_arg)
  {
    csKeyMap* map = mapping;
    while (map)
    {
      Sys->Report (CS_REPORTER_SEVERITY_NOTIFY,
      	"Key %s bound to %s.", CS::Quote::Single (keyname (map)),
	CS::Quote::Single (map->cmd));
      map = map->next;
    }
    return;
  }
  char* arg = new char[strlen(_arg) + 1];
  strcpy (arg, _arg);
  char* space = strchr (arg, ' ');
  if (space)
  {
    *space = 0;
    csKeyMap* map = find_mapping (arg);
    if (map)
    {
      delete [] map->cmd;
    }
    else
    {
      map = new csKeyMap ();
      map->next = mapping;
      map->prev = 0;
      if (mapping) mapping->prev = map;
      mapping = map;
      map_key (arg, map);
    }
    map->cmd = new char [strlen (space+1)+1];
    strcpy (map->cmd, space+1);
    *space = ' ';
  }
  else
  {
    csKeyMap* map = find_mapping (arg);
    if (map) Sys->Report (CS_REPORTER_SEVERITY_NOTIFY,
    	"Key bound to %s!", CS::Quote::Single (map->cmd));
    else Sys->Report (CS_REPORTER_SEVERITY_NOTIFY, "Key not bound!");
  }
  delete[] arg;
}
Exemplo n.º 9
0
inline void map_print( container *C, value a )
{
    int		i=0;
    iterator	it = map_begin(a.C);

    printf("(");
    for (; it.valid; it=map_next(it))
    {
        if (i==0) i++;
        else printf(" ");

        printv(((map_container_priv*)C->priv)->Key, map_key(it));
        printf(":");
        printv(((map_container_priv*)C->priv)->Data, map_val(it));
    }
    printf(")");
}
Exemplo n.º 10
0
void
WRATHAttributeStoreAllocator::
unregister(WRATHAttributeStore *q)
{
    map_type::iterator iter;

    WRATHAutoLockMutex(m_mutex);

    iter=m_attribute_stores.find( map_key(q->m_key) );
    if(iter!=m_attribute_stores.end())
    {
        iter->second.erase(q);
        if(iter->second.empty())
        {
            m_attribute_stores.erase(iter);
        }
    }

}
Exemplo n.º 11
0
static int quirk_btc_8193(struct hid_usage *usage, struct input_dev *input,
			      unsigned long **bit, int *max)
{
	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
		return 0;

	switch (usage->hid & HID_USAGE) {
		case 0x230: map_key(BTN_MOUSE);			break;
		case 0x231: map_rel(REL_WHEEL);			break;
		/* 
		 * this keyboard has a scrollwheel implemented in
		 * totally broken way. We map this usage temporarily
		 * to HWHEEL and handle it in the event quirk handler
		 */
		case 0x232: map_rel(REL_HWHEEL);		break;

		default:
			return 0;
	}
	return 1;
}
Exemplo n.º 12
0
void attribute_count_print( container *attributes, int attrib_count, int indent )
{
    iterator		it = map_begin(attributes);

    for (; it.valid; it=map_next(it))
	{
	    int		i;

	    for (i=0; i<indent; i++) printf(" ");
	    printf("%s\n", (char*)map_key(it).ptr);
	    /*
	    for (i=0; i<attrib_count; i++)
		{
		    if (i>0) printf(", ");
		    printf("%i", ((int*)pair(map_val(it)).second.ptr)[i]);
		}
	    printf(")\n");
	    */

	    attribute_count_print(pair(map_val(it)).first.C, attrib_count, indent+2);
	}
}
Exemplo n.º 13
0
int _attribute_count_hits_(container *count, int filter, int group_filter_id)
{
    if (count==NULL) return 0;

    int		i;
    int		len = group_filter_id+1;
    int		alle = 0;

    for (i=0; i<len; i++) alle+= 1<<i;

    int		inverse = alle - filter;
    //printf("filter:");
    //for (i=0; i<len; i++) printf("%c", (inverse & (1<<i) ? '1':'0'));
    //printf("\n");

    int		hits = 0;
    int		__total__ = 0;
    iterator	it;

    it = map_begin(count);
    for (; it.valid; it=map_next(it))
	{
	    //printf("       ");
	    //for (i=0; i<len; i++) printf("%c", ((alle - map_key(it).i) & (1<<i) ? '1':'0'));

	    __total__++;
	    if (((alle - map_key(it).i) & inverse) == 0)
		{
		    hits+= map_val(it).i;
		    //printf("  <count>\n");
		}
	    //else printf("  <----->\n");
	}
    //printf("       match:%i/%i\n", hits, __total__);

    return hits;
}
Exemplo n.º 14
0
Arquivo: win32.c Projeto: B-Rich/simh
static void
keydown(int k)
{
    display_keydown(map_key(k));
}
Exemplo n.º 15
0
struct quote_map*
qsvr_init(const char *path)
{
	uint32_t hash_key[512] = {0};
	struct quote_map* init_val;
	init_val = (struct quote_map *)malloc(sizeof(struct quote_map));
	memset(init_val,0,sizeof(struct quote_map));
	
	int index = 0 ; 
    uint32_t input_data_len = sizeof(struct qsvr )*History_len;
    uint32_t malloc_sec_hash_len = Second_hash_index * sizeof(uint32_t *);
	
	struct qsvr * origin_array ;
	origin_array = (struct qsvr *) malloc(input_data_len); 
	
	uint32_t ***index_array ;
	index_array     = (uint32_t ***)malloc(sizeof(uint32_t *) *Days);
    
	for(int i = 0 ; i < Days  ; i++) 
        index_array[i]  = (uint32_t **)malloc(malloc_sec_hash_len);
	
	for(int i = 0 ; i < Days  ; i++) 
		for(int j = 0 ; j < Second_hash_index ; j++)
			index_array[i][j] = NULL;

	init_val->hash 			= hash_key 		;
	init_val->origin_array 	= origin_array  ;
	init_val->index_array 	= index_array   ;



	FILE *stream ;
  	char buf[128]={0} ,*tmp_array[Type_size] ;
	stream = fopen(path,"r+");
 	if (stream == NULL)
  	{
      printf("can't open input_data.txt \n,%s",strerror(errno));
      return NULL ;
  	}
	while(fgets(buf,128,stream))
  	{
      char *cur = buf ,*front =buf ;
      int outer = 0;
      while(*cur != '\n' )
      {   
        if( ' ' == *cur )
        {
              *cur = '\0';
              tmp_array[outer] = front ;
              cur++;
              front = cur ;
              outer++;
          }
          else
              cur++;
      }
      tmp_array[outer] = front;
      origin_array[index].date = atoi(tmp_array[0]);
      sprintf(origin_array[index].item,"%s",tmp_array[1]);
      sprintf(origin_array[index].contract,"%s",tmp_array[2]);
      origin_array[index].rank = atoi(tmp_array[3]);
      sprintf(origin_array[index].quote_record,"%s",tmp_array[4]);
      sprintf(origin_array[index].address,"%s",tmp_array[5]);
	  origin_array[index].next = NULL ;
      index++;
   	};
	fclose(stream);
//map item to dictionary
	stream  = fopen("../uniq.txt","r+"); //reuse stream 
    if (stream == NULL)
    {
         printf("can't open uniq.txt \n,%s",strerror(errno));
         return NULL;
    }
	index = 0 ; //reuse  index 
    while(fgets(buf,128,stream)) //reuse buf
    {
          uint32_t middle_key ;
          char tmp_buf[5];
          int i ;
          for(i = 0 ;buf[i] != '\n' ; i++)
          tmp_buf[i] = buf[i];
          tmp_buf[i] = '\0';
  
          middle_key  = calculate_item_key(tmp_buf);
          hash_key[middle_key]= index ;
          index++;
     }
     fclose(stream);
     map_key(init_val , History_len);
     printf("map success \n");
return init_val ;
}
Exemplo n.º 16
0
struct _attr_ret_ _attribute_add_children_(container *attributes, container *attr_query, container *hide, container *A, int container_id)
{
    int		i, j;
    container	*list_items = vector_container( ptr_container() );
    iterator	it_m1 = map_begin(attributes);
    int		has_selected_child = 0;

    for (; it_m1.valid; it_m1=map_next(it_m1))
	{
	    vector_pushback(attr_query, (char*)map_key(it_m1).ptr);

	    int		is_hidden = 0;
	    for (i=0; i<vector_size(hide) && !is_hidden; i++)
		{
		    container	*hide_elem = vector_get(hide, i).C;

		    for (j=0; j<vector_size(hide_elem); j++)
			{
			    if (strcasecmp(vector_get(attr_query,j).ptr, vector_get(hide_elem,j).ptr)) break;
			}

		    if (j>=vector_size(hide_elem)) is_hidden = 1;
		}

	    if (is_hidden)
		{
		    vector_remove_last(attr_query);
		    continue;
		}

	    struct _attr_tree_	*this_item = _attribute_tree_malloc_();
	    int val = _attribute_is_selected_(A, attr_query, container_id);
	    if (val>=0) this_item->selected = val;

	    if (map_size(pair(map_val(it_m1)).first.ptr) > 0)
		{
		    struct _attr_ret_ ret = _attribute_add_children_(pair(map_val(it_m1)).first.ptr, attr_query, hide, A, container_id);
		    if (ret.selected_descendant)
			{
			    this_item->selected_descendant = 1;
			    has_selected_child = 1;
			}
		    this_item->children = ret.C;
		    this_item->query_param = vector_container( string_container() );
		    for (j=0; j<vector_size(attr_query); j++)
			vector_pushback(this_item->query_param, vector_get(attr_query, j).ptr);
		    //this_item->name = ;
		    this_item->count = pair(map_val(it_m1)).second.ptr;
		}
	    else
		{
		    this_item->query_param = vector_container( string_container() );
		    for (j=0; j<vector_size(attr_query); j++)
			vector_pushback(this_item->query_param, vector_get(attr_query, j).ptr);
		    //this_item->name = ;
		    this_item->count = pair(map_val(it_m1)).second.ptr;
		}

	    vector_remove_last(attr_query);

	    if (this_item->name == NULL && this_item->query_param == NULL && this_item->count == NULL && this_item->children == NULL)
		{
		    free(this_item);
		}
	    else
		{
		    vector_pushback(list_items, this_item);
		    if (this_item->selected >= 0) has_selected_child = 1;
		}
	}

    struct _attr_ret_	ret;
    ret.C = list_items;
    ret.selected_descendant = has_selected_child;
    return ret;
}
Exemplo n.º 17
0
      void assemble(PDESystemType const & pde_system,
                    std::size_t           pde_index,
                    SegmentT      const & segment,
                    StorageType & storage,
                    MatrixT             & system_matrix,
                    VectorT             & load_vector)
      {
        typedef typename SegmentT::config_type                config_type;
        typedef viennamath::equation                          equ_type;
        typedef viennamath::expr                              expr_type;
        typedef typename expr_type::interface_type            interface_type;
        typedef typename expr_type::numeric_type              numeric_type;

        typedef typename viennagrid::result_of::cell_tag<SegmentT>::type CellTag;
        typedef typename viennagrid::result_of::facet_tag<CellTag>::type FacetTag;

        typedef typename viennagrid::result_of::element<SegmentT, FacetTag>::type                FacetType;
        typedef typename viennagrid::result_of::element<SegmentT, CellTag  >::type                CellType;

        typedef typename viennagrid::result_of::const_element_range<SegmentT, CellTag>::type    CellContainer;
        typedef typename viennagrid::result_of::iterator<CellContainer>::type                      CellIterator;

        typedef typename viennagrid::result_of::const_element_range<CellType, FacetTag>::type  FacetOnCellContainer;
        typedef typename viennagrid::result_of::iterator<FacetOnCellContainer>::type               FacetOnCellIterator;

        viennamath::equation          const & pde         = pde_system.pde(pde_index);
        viennamath::function_symbol   const & u           = pde_system.unknown(pde_index)[0];
        viennafvm::linear_pde_options const & pde_options = pde_system.option(pde_index);

        viennafvm::mapping_key   map_key(u.id());
        viennafvm::boundary_key  bnd_key(u.id());


#ifdef VIENNAFVM_DEBUG
        std::cout << " - Strong form: " << pde << std::endl;
#endif

        equ_type integral_form = viennafvm::make_integral_form( pde );

#ifdef VIENNAFVM_DEBUG
        std::cout << " - Integral form: " << integral_form << std::endl;
#endif

        //
        // Preprocess symbolic representation:
        //

        //Note: Assuming that LHS holds all matrix terms, while RHS holds all load vector terms
        expr_type  partial_omega_integrand = extract_surface_integrand<FacetType>(storage, integral_form.lhs(), u);
        expr_type   matrix_omega_integrand = extract_volume_integrand<CellType>(storage, integral_form.lhs(), u);
        expr_type      rhs_omega_integrand = extract_volume_integrand<CellType>(storage, integral_form.rhs(), u);
        expr_type  stabilization_integrand = prepare_for_evaluation<CellType>(storage, pde_options.damping_term(), u);

#ifdef VIENNAFVM_DEBUG
        std::cout << " - Surface integrand for matrix: " << partial_omega_integrand << std::endl;
        std::cout << " - Volume integrand for matrix:  " <<  matrix_omega_integrand << std::endl;
        std::cout << " - Stabilization for matrix:     " << stabilization_integrand << std::endl;
        std::cout << " - Volume integrand for rhs:     " <<     rhs_omega_integrand << std::endl;
#endif

        viennafvm::flux_handler<StorageType, CellType, FacetType, interface_type>  flux(storage, partial_omega_integrand, u);

        expr_type substituted_matrix_omega_integrand  = viennamath::diff(matrix_omega_integrand, u);

        std::vector<double> p(3); //dummy vector for evaluation

        //
        // Preprocess domain
        //
        setup(segment, storage);


        typename viennadata::result_of::accessor<StorageType, viennafvm::mapping_key, long, CellType>::type cell_mapping_accessor =
            viennadata::make_accessor(storage, map_key);

        typename viennadata::result_of::accessor<StorageType, viennafvm::facet_area_key, double, FacetType>::type facet_area_accessor =
            viennadata::make_accessor(storage, viennafvm::facet_area_key());

        typename viennadata::result_of::accessor<StorageType, viennafvm::boundary_key, double, CellType>::type boundary_accessor =
            viennadata::make_accessor(storage, bnd_key);

        typename viennadata::result_of::accessor<StorageType, viennafvm::current_iterate_key, double, CellType>::type current_iterate_accessor =
            viennadata::make_accessor(storage, viennafvm::current_iterate_key(u.id()));

        //
        // Actual assembly:
        //
        CellContainer cells(segment);
        for (CellIterator cit = cells.begin(); cit != cells.end(); ++cit)
        {
          long row_index = cell_mapping_accessor(*cit);

          if (row_index < 0)
            continue;

          // update ncell quantities in expressions for current cell:
          viennamath::rt_traversal_wrapper<interface_type> cell_updater( new detail::ncell_updater<CellType, interface_type>(*cit) );

          substituted_matrix_omega_integrand.get()->recursive_traversal(cell_updater);
          stabilization_integrand.get()->recursive_traversal(cell_updater);
          rhs_omega_integrand.get()->recursive_traversal(cell_updater);



          typename viennadata::result_of::accessor<StorageType, facet_distance_key, double, FacetType>::type facet_distance_accessor =
              viennadata::make_accessor(storage, facet_distance_key());

          //
          // Boundary integral terms:
          //
          FacetOnCellContainer facets_on_cell(*cit);
          for (FacetOnCellIterator focit  = facets_on_cell.begin();
                                   focit != facets_on_cell.end();
                                 ++focit)
          {
            CellType const * other_cell = util::other_cell_of_facet(*focit, *cit, segment);

            if (other_cell)
            {
              long col_index = cell_mapping_accessor(*other_cell);
              double effective_facet_area = facet_area_accessor(*focit);

              for (std::size_t i=0; i<pde_system.size(); ++i)
                compute_gradients_for_cell(*cit, *focit, *other_cell,
                                           viennadata::make_accessor<current_iterate_key, double, CellType>(storage, current_iterate_key(pde_system.unknown(i)[0].id())),
                                           viennadata::make_accessor<current_iterate_key, double, FacetType>(storage, current_iterate_key(pde_system.unknown(i)[0].id())),
                                           facet_distance_accessor);

              if (col_index == viennafvm::DIRICHLET_BOUNDARY)
              {
                double boundary_value = boundary_accessor(*other_cell);
                double current_value  = current_iterate_accessor(*cit);

                // updates are homogeneous, hence no direct contribution to RHS here. Might change later when boundary values are slowly increased.
                load_vector(row_index)              -= flux.out(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area * (boundary_value - current_value);
                system_matrix(row_index, row_index) -= flux.in(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area;

                load_vector(row_index) -= flux.out(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area * current_value;
                load_vector(row_index) += flux.in(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area * current_iterate_accessor(*cit);
              }
              else if (col_index >= 0)
              {
                system_matrix(row_index, col_index) += flux.out(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area;
                system_matrix(row_index, row_index) -= flux.in(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area;

                load_vector(row_index) -= flux.out(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area * current_iterate_accessor(*other_cell);
                load_vector(row_index) += flux.in(*cit, *focit, *other_cell, facet_distance_accessor) * effective_facet_area * current_iterate_accessor(*cit);
              }
              // else: nothing to do because other cell is not considered for this quantity

            }
          }

          //
          // Volume terms
          //
          double cell_volume      = viennagrid::volume(*cit);

          // Matrix (including residual contributions)
          system_matrix(row_index, row_index) += viennamath::eval(substituted_matrix_omega_integrand, p) * cell_volume;
          load_vector(row_index) -= viennamath::eval(substituted_matrix_omega_integrand, p) * cell_volume * current_iterate_accessor(*cit);

          system_matrix(row_index, row_index) += viennamath::eval(stabilization_integrand, p) * cell_volume;

          // RHS
          load_vector(row_index) += viennamath::eval(rhs_omega_integrand, p) * cell_volume;
          //std::cout << "Writing " << viennamath::eval(omega_integrand, p) << " * " << cell_volume << " to rhs at " << row_index << std::endl;

        } // for cells

      } // assemble
Exemplo n.º 18
0
Arquivo: main.cpp Projeto: CCJY/coliru
	kv_pair_iterator& operator++()
	{
	    ++pair.first ;
	    pair = map_key( pair.first ) ;
	    return *this ;
    }
Exemplo n.º 19
0
static unsigned
make_break(unsigned scode)
{
    /* This routine can handle keyboards that interrupt only on key depression,
     * as well as keyboards that interrupt on key depression and key release.
     * For efficiency, the interrupt routine filters out most key releases.
     */

    unsigned ch;
    bool make, escape;

    /* High-order bit set on key release. */
    make = (scode & KEY_RELEASE) == 0;	/* true if pressed */

    ch = map_key(scode &= ASCII_MASK);	/* map to ASCII */

    escape = esc;				/* Key is escaped?  (true if added since the XT) */
    esc = false;

    switch (ch)
    {
        case CTRL:				/* Left or right control key */
            *(escape ? &ctrl_r : &ctrl_l) = make;
            ctrl = ctrl_l | ctrl_r;
            break;
        case SHIFT:			/* Left or right shift key */
            *(scode == RSHIFT_SCAN ? &shift_r : &shift_l) = make;
            shift = shift_l | shift_r;
            break;
        case ALT:				/* Left or right alt key */
            *(escape ? &alt_r : &alt_l) = make;
            alt = alt_l | alt_r;
            break;
        case CALOCK:			/* Caps lock - toggle on 0 -> 1 transition */
            if (!caps_down && make)
            {
                locks ^= CAPS_LOCK;
                set_leds();
            }
            caps_down = make;
            break;
        case NLOCK:			/* Num lock */
            if (!num_down && make)
            {
                locks ^= NUM_LOCK;
                set_leds();
            }
            num_down = make;
            break;
        case SLOCK:			/* Scroll lock */
            if (!scroll_down && make)
            {
                locks ^= SCROLL_LOCK;
                set_leds();
            }
            scroll_down = make;
            break;
        case EXTKEY:			/* Escape keycode */
            esc = true;			/* Next key is escaped */
            return NONE;
        default:				/* A normal key */
            return make ? ch : NONE;
    }

    return NONE;
}
Exemplo n.º 20
0
int			keyboard(int keycode, t_env *map)
{
	map_key(keycode, map);
	return (0);
}
Exemplo n.º 21
0
Arquivo: win32.c Projeto: B-Rich/simh
static void
keyup(int k)
{
    display_keyup(map_key(k));
}