Exemplo n.º 1
0
static void kb_handle_interrupt(uint8_t irq, struct irq_regs* regs)
{
    uint8_t scan_code = INB(0x60);

    if(scan_code == 0xFA && !g_initial_ack_received) {

        // Currently, we seem to be getting an interrupt
        // right after enabling the keyboard and interrupts.
        // The scan code is 0xFA, and the current set is 1.
        // This is not a valid scan code, and we currently do not
        // know why this is being sent. We have only ever seen it
        // get "sent" once, in this instance. So we simply ignore it.
        g_initial_ack_received = true;
        pic_send_eoi(pic_irq_keyboard);
        return;
    }

    //terminal_write_string("KB IRQ Scan code: ");
    //terminal_write_hex(scan_code);
    //terminal_write_string("\n");

    // Translate scancode
    int sc_index = sc_get_entry_index(g_current_map, scan_code);

    if (sc_index < 0) {

        // Unknown scan-code
        terminal_write_string("Unknown scan code value: ");
        terminal_write_uint32_x(scan_code);
        terminal_write_string("\n");
        // Reset to the first map in the set
        reset_map();
    }
    else {
        struct sc_map_entry* sc_entry = &g_current_map->entries[sc_index];

        switch (sc_entry->type) {
            case sc_map_entry_type_press:
                reset_map();
                if(g_current_subscriber->down != NULL) {
                    g_current_subscriber->down(sc_entry->data);
                }
                break;

            case sc_map_entry_type_release:
                reset_map();
                if(g_current_subscriber->up != NULL) {
                    g_current_subscriber->up(sc_entry->data);
                }
                break;

            case sc_map_entry_type_map:
                g_current_map = &g_current_set->maps[sc_entry->data];
                break;
        }
    }

    pic_send_eoi(pic_irq_keyboard);
}
Exemplo n.º 2
0
void node_data::set_type(NodeType::value type) {
  if (type == NodeType::Undefined) {
    m_type = type;
    m_isDefined = false;
    return;
  }

  m_isDefined = true;
  if (type == m_type)
    return;

  m_type = type;

  switch (m_type) {
    case NodeType::Null:
      break;
    case NodeType::Scalar:
      m_scalar.clear();
      break;
    case NodeType::Sequence:
      reset_sequence();
      break;
    case NodeType::Map:
      reset_map();
      break;
    case NodeType::Undefined:
      assert(false);
      break;
  }
}
Exemplo n.º 3
0
int main()
{
    int all,maxx,maxy,i,j;
#ifndef __GNUC__
    freopen("D:\\std.txt","r",stdin);
#endif
    scanf("%d",&all);
    for(;all>0;all--)
    {
        scanf("%d %d%*c",&maxx,&maxy);
        reset_map(maxx,maxy);
        for(i=0;i<maxx;i++)
        {
            memset(buff,0,128);
            gets(buff);
            for(j=0;j<maxy;j++)
            {
                if(buff[j]=='0')
                {
                    map[i+1][j+1]=0;
                }
                else
                {
                    map[i+1][j+1]=1;
                }
            }
        }
        deal(maxx,maxy);
    }
    return 0;
}
Exemplo n.º 4
0
void kb_init()
{
    g_initial_ack_received = false;

    // Get scan-code info
    g_current_set = sc_get_set_1();
    reset_map();

    // Enable the keyboard
    pic_enable_irq(pic_irq_keyboard);
    OUTB(0x60, 0xF4); // Enable on the encoder
    OUTB(0x64, 0xAE); // Enable on the controller

    interrupt_receive(IRQ_1, kb_handle_interrupt);
}
Exemplo n.º 5
0
void node_data::convert_sequence_to_map(shared_memory_holder pMemory) {
  assert(m_type == NodeType::Sequence);

  reset_map();
  for (std::size_t i = 0; i < m_sequence.size(); i++) {
    std::stringstream stream;
    stream << i;

    node& key = pMemory->create_node();
    key.set_scalar(stream.str());
    insert_map_pair(key, *m_sequence[i]);
  }

  reset_sequence();
  m_type = NodeType::Map;
}
Exemplo n.º 6
0
void node_data::convert_to_map(shared_memory_holder pMemory) {
  switch (m_type) {
    case NodeType::Undefined:
    case NodeType::Null:
      reset_map();
      m_type = NodeType::Map;
      break;
    case NodeType::Sequence:
      convert_sequence_to_map(pMemory);
      break;
    case NodeType::Map:
      break;
    case NodeType::Scalar:
      assert(false);
      break;
  }
}
Exemplo n.º 7
0
int main(void)
{

	uint move_index = 0;
	uint frame_index = 0;
	uint last_ant_id = 0;
	uint arrived_count = 0;
	t_map *map = create_map();
	Scaler scaler(map);
	std::vector<std::vector<Move> > moves;
	create_moves(moves);
	sf::RenderWindow window(sf::VideoMode(WIN_SZ, WIN_SZ), "lem_in Visualizer");
	sf::Font font;

	if (!font.loadFromFile("font.otf"))
		std::cout << "failed to load font!" << std::endl;

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color::Black);
        draw_tubes(map, window, scaler);
        for (uint i = 0; i < map->rooms->size; i++)
        	draw_room((t_room*)array_get(map->rooms, i), window, font, map, arrived_count, last_ant_id, scaler);
        draw_move_list(moves[move_index], frame_index, map, window, last_ant_id, font, scaler);
        if (frame_index < FRAME_COUNT)
        	frame_index++;
        else
        {
        	arrived_count += apply_move_list(moves[move_index], map, last_ant_id);
        	move_index++;
        	frame_index = 0;
        	if (move_index >= moves.size())
        	{
        		window.clear(sf::Color::Black);
        		draw_tubes(map, window, scaler);
		        for (uint i = 0; i < map->rooms->size; i++)
		        	draw_room((t_room*)array_get(map->rooms, i), window, font, map, arrived_count, last_ant_id, scaler);
		        window.display();
        		sf::sleep(sf::milliseconds(2000));
        		//
        		arrived_count = 0;
        		last_ant_id = 0;
        		reset_map(map);
        		move_index = 0;
        		//
        		window.clear(sf::Color::Black);
        		draw_tubes(map, window, scaler);
		        for (uint i = 0; i < map->rooms->size; i++)
		        	draw_room((t_room*)array_get(map->rooms, i), window, font, map, arrived_count, last_ant_id, scaler);
		        window.display();
        		sf::sleep(sf::milliseconds(2000));
        	}
        }
        window.display();
        sf::sleep(sf::milliseconds(10));
    }
	return (0);
}