Пример #1
0
void matrix_init(void)
{
    // disable JTAG
    MCUCR = (1<<JTD);
    MCUCR = (1<<JTD);

#ifdef PS2_MOUSE_ENABLE
    // ps2 mouse detect
    DDRF &= ~(1<<PF5 | 1<<PF4);
    PORTF |= (1<<PF5 | 1<<PF4);
    if (PINF & (1<<PF5 | 1 <<PF4)) {
        ps2_mouse_detected = 0;
    }
    else {
        ps2_mouse_detected = 1;
    }
    DDRF |= (1<<PF5 | 1<<PF4);
#endif

    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #2
0
void matrix_init(void)
{
    debug_enable = true;
    debug_matrix = true;
    debug_mouse = true;
    // initialize row and col
    unselect_rows();
    init_cols();

#ifdef USE_I2C
    i2c_master_init();
#else
    serial_master_init();
#endif

    /* int x = USB_IsInitialized; */
    /* if (x) { */
    /*     DDRD  |= 1<<5; */
    /*     PORTD &= ~(1<<5); */
    /* } else { */

    // use the pro micro TX led as an indicator
    // pull D5 low to turn on
    //DDRD  |= 1<<5;
    //PORTD |= (1<<5);
    /* } */

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }

}
Пример #3
0
uint8_t matrix_scan(void)
{
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
        select_row(i);
#ifdef HYBRID_MATRIX
        init_cols();
#endif
        _delay_us(30);  // without this wait read unstable value.
        matrix_row_t cols = read_cols();
        if (matrix_debouncing[i] != cols) {
            matrix_debouncing[i] = cols;
            if (debouncing) {
                debug("bounce!: "); debug_hex(debouncing); debug("\n");
            }
            debouncing = DEBOUNCE;
        }
        unselect_rows();
    }

    if (debouncing) {
        if (--debouncing) {
            _delay_ms(1);
        } else {
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
                matrix[i] = matrix_debouncing[i];
            }
        }
    }

    return 1;
}
Пример #4
0
int main(void) {
	CPU_PRESCALE(CPU_16MHz);
	usb_init();
	while (!usb_configured()) /* wait */
		_delay_ms(1000);

	init_cols();
	//  TCCR0A = 0x00;
	//	TCCR0B =(1<<CS00);
	//	TIMSK0 = (1<<TOIE0);
	////////////////////////////////////////////////
			DDRD |= (1 << 5);
			PORTD &= ~(1 << 5);
			for(r=0;r<10;r++){
			keyboard_keys[0] = KEY_CAPS_LOCK;
			usb_keyboard_send();
			_delay_ms(100);
			keyboard_keys[0] = 0;
			usb_keyboard_send();
			_delay_ms(500);
			}
			if (PIND & (1 << 6)){
					unselect_rows();
					_delay_ms(500);
					pokerMode();
			}else{
				unselect_rows();
				_delay_ms(500);
				osuMode();
			}
}
Пример #5
0
// common/keyboard.c invokes this when the keyboard is initialized.
// This is our entry point.
void matrix_init() {

    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);

    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for ( uint8_t i=0; i < MATRIX_ROWS; i++ ) {
        matrix[ i ] = (matrix_row_t) 0;
        matrix_debouncing[ i ] = (matrix_row_t) 0;
    }

    // Initialize LED control logic:
    led_init();

    // Initialize the OLED display:
#ifdef DISPLAY_ENABLE
    display_init();
#endif

}
Пример #6
0
static t_ll *find_cols_rec(t_ll *files, int c, int width)
{
  t_ll *cols;
  t_ll *more_cols;
  t_ll *file;
  int i;
  int max;
  int len;

  cols = init_cols(c);
  for (i = 0, file = files; file != NULL; i++, file = file->next)
  {
    max = COLSIZE_AT(i);
    len = my_strlen(FINFO_LL_FILENAME(file)) + g_opts->filetypesymb;
    if (len > max)
    {
      COLSIZE_AT(i) = len;
    }
  }
  
  if (columns_too_large(cols, width))
  {
    ll_free(cols);
    return (NULL);
  }
  more_cols = find_cols_rec(files, c + 1, width);
  return (more_cols != NULL) ? more_cols : cols;
}
Пример #7
0
void matrix_init(void)
{
    // initialize row and col
    debug_enable = true;
    debug_matrix = true;
    debug_keyboard = true;
    debug_mouse = true;

    mcp23018_status = init_mcp23018();


    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }

#ifdef DEBUG_MATRIX_SCAN_RATE
    matrix_timer = timer_read32();
    matrix_scan_count = 0;
#endif

    matrix_init_quantum();

}
Пример #8
0
void matrix_init(void)
{
    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);


    // initialize row and col
    unselect_rows();
    init_cols();



    /* int x = USB_IsInitialized; */
    /* if (x) { */
    /*     DDRD  |= 1<<5; */
    /*     PORTD &= ~(1<<5); */
    /* } else { */

    // use the pro micro TX led as an indicator
    // pull D5 low to turn on
    DDRD  |= 1<<5;
    PORTD |= (1<<5);
    /* } */

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }

    matrix_init_kb();
}
Пример #9
0
void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #10
0
void matrix_clear(void)
{
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i = 0; i < MATRIX_ROWS; i++)
    {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
        debouncing_times[i] = 0;
        debouncing[i] = false;
    }
}
Пример #11
0
void matrix_init(void)
{
    // initialize row and col
    init_ergodox();
    uint8_t mcp23018_status;
    mcp23018_status = init_mcp23018();
    unselect_rows(mcp23018_status);
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #12
0
void
Keyboard__init()
{
  stdio_init();
  init_cols();

  kb.default_keymap  = (KeyMap) pgm_read_word(&default_keymap);
  kb.selected_keymap = kb.default_keymap;
  kb.active_keymap   = NULL;
  kb.prev_keymap     = kb.default_keymap;

  BlockedKeys__init();
  ReportQueue__init();
  reset();
}
Пример #13
0
void matrix_init(void)
{
    // JTAG disable for PORT F. write JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);

    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #14
0
void matrix_init(void)
{
    // disable JTAG
    MCUCR = _BV(JTD);
    MCUCR = _BV(JTD);

    // initialize row and col
    init_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #15
0
void matrix_init(void)
{
    debug_enable = true;
    debug_matrix = true;
    debug_mouse = true;
    // initialize row and col
    unselect_rows();
    init_cols();

    TX_RX_LED_INIT;

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #16
0
void matrix_init(void)
{
    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }

    //debug
    debug_matrix = true;
    LED_ON();
    wait_ms(500);
    LED_OFF();
}
Пример #17
0
void matrix_power_up(void) {
    mcp23018_status = init_mcp23018();

    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }

#ifdef DEBUG_MATRIX_SCAN_RATE
    matrix_timer = timer_read32();
    matrix_scan_count = 0;
#endif

}
Пример #18
0
void matrix_init(void)
{
    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);

    backlight_init_ports();

    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
    rgblight_init();
}
Пример #19
0
void matrix_init(void) {

    // initialize row and col
#if (DIODE_DIRECTION == COL2ROW)
    unselect_rows();
    init_cols();
#elif (DIODE_DIRECTION == ROW2COL)
    unselect_cols();
    init_rows();
#endif

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }

    matrix_init_quantum();
}
Пример #20
0
void matrix_init(void)
{
    // initialize row and col
    init_ergodox();
    mcp23018_status = init_mcp23018();
    ergodox_blink_all_leds();
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }

#ifdef DEBUG_MATRIX_FREQ
    matrix_timer = timer_read32();
    matrix_scan_count = 0;
#endif
}
Пример #21
0
void matrix_init(void)
{
    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);

    #if BACKLIGHT_ENABLE == 'yes'
    backlight_init_ports();
    #endif

    // Turn status LED on
    DDRE |= (1<<6);
    PORTE |= (1<<6);

    // initialize row and col
    unselect_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #22
0
void matrix_init(void)
{

#ifdef UART_RGB_ENABLE
uart_rgb_init();
#endif
    // disable JTAG
    MCUCR = _BV(JTD);
    MCUCR = _BV(JTD);

    // 85 REST
    DDRD |= _BV(PD7);
    PORTD |= _BV(PD7);

    // initialize row and col
    init_rows();
    init_cols();

    // initialize matrix state: all keys off
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
        matrix[i] = 0;
        matrix_debouncing[i] = 0;
    }
}
Пример #23
0
int main( int argc, char *argv[] )
{
	glob_t globdata;
	int i, j, l, file_arg_start, new_empty = TRUE, get_screenshot = FALSE;

	if (argc > 1)
	{
		if ( strcmp(argv[1], "--version") == 0 )
		{
			printf("%s\n\n", MT_VERSION);
			exit(0);
		}
		if ( strcmp(argv[1], "--help") == 0 )
		{
			printf("%s\n\n"
				"Usage: mtpaint [option] [imagefile ... ]\n\n"
				"Options:\n"
				"  --help          Output this help\n"
				"  --version       Output version information\n"
				"  -s              Grab screenshot\n"
				"  -v              Start in viewer mode\n\n"
			, MT_VERSION);
			exit(0);
		}
	}

	putenv( "G_BROKEN_FILENAMES=1" );	// Needed to read non ASCII filenames in GTK+2

#if GTK2VERSION >= 4
	/* Tablet handling in GTK+ 2.18+ is broken beyond repair if this mode
	 * is set; so unset it, if g_unsetenv() is present */
	g_unsetenv("GDK_NATIVE_WINDOWS");
#endif

#ifdef U_THREADS
	/* Enable threading for GLib, but NOT for GTK+ (at least, not yet) */
	g_thread_init(NULL);
#endif
	inifile_init("/etc/mtpaint/mtpaintrc", "~/.mtpaint");

#ifdef U_NLS
#if GTK_MAJOR_VERSION == 1
	/* !!! GTK+1 needs locale set up before gtk_init(); GTK+2, *QUITE*
	 * the opposite - WJ */
	setup_language();
#endif
#endif

#ifdef U_THREADS
	/* !!! Uncomment to allow GTK+ calls from other threads */
	/* gdk_threads_init(); */
#endif
	gtk_init( &argc, &argv );
	gtk_init_bugfixes();
#if GTK_MAJOR_VERSION == 2
	{
		char *theme = inifile_get(DEFAULT_THEME_INI, "");
		if (theme[0]) gtk_rc_parse(theme);
	}
#endif

#ifdef U_NLS
#if GTK_MAJOR_VERSION == 2
	/* !!! GTK+2 starts acting up if this is before gtk_init() - WJ */
	setup_language();
#endif
	bindtextdomain("mtpaint", MT_LANG_DEST);
	textdomain("mtpaint");
#if GTK_MAJOR_VERSION == 2
	bind_textdomain_codeset("mtpaint", "UTF-8");
#endif
#endif

	file_arg_start = 1;
	if (argc > 1)		// Argument received, so assume user is trying to load a file
	{
		if ( strcmp(argv[1], "-g") == 0 )	// Loading GIF animation frames
		{
			file_arg_start+=2;
			sscanf(argv[2], "%i", &preserved_gif_delay);
		}
		if ( strcmp(argv[1], "-v") == 0 )	// Viewer mode
		{
			file_arg_start++;
			viewer_mode = TRUE;
		}
		if ( strcmp(argv[1], "-s") == 0 )	// Screenshot
		{
			file_arg_start++;
			get_screenshot = TRUE;
		}
		if ( strstr(argv[0], "mtv") != NULL ) viewer_mode = TRUE;
	}

	/* Something else got passed in */
	l = argc - file_arg_start;
	while (l)
	{
		/* First, process wildcarded args */
		memset(&globdata, 0, sizeof(globdata));
/* !!! I avoid GLOB_DOOFFS here, because glibc before version 2.2 mishandled it,
 * and quite a few copycats had cloned those buggy versions, some libc
 * implementors among them. So it is possible to encounter a broken function
 * in the wild, and playing it safe doesn't cost all that much - WJ */
		for (i = file_arg_start , j = 0; i < argc; i++)
		{
			if (strcmp(argv[i], "-w")) continue; j++;
			if (++i >= argc) break; j++;
			// Ignore errors - be glad for whatever gets returned
			glob(argv[i], (j > 2 ? GLOB_APPEND : 0), NULL, &globdata);
		}
		files_passed = l - j + globdata.gl_pathc;

		/* If no wildcarded args */
		file_args = argv + file_arg_start;
		if (!j) break;
		/* If no normal args */
		file_args = globdata.gl_pathv;
		if (l <= j) break;

		/* Allocate space for both kinds of args together */
		file_args = calloc(files_passed + 1, sizeof(char *));
		// !!! Die by SIGSEGV if this allocation fails

		/* Copy normal args if any */
		for (i = file_arg_start , j = 0; i < argc; i++)
		{
			if (!strcmp(argv[i], "-w")) i++; // Skip the pair
			else file_args[j++] = argv[i];
		}

		/* Copy globbed args after them */
		if (globdata.gl_pathc) memcpy(file_args + j, globdata.gl_pathv,
			globdata.gl_pathc * sizeof(char *));
		break;
	}

	string_init();				// Translate static strings
	var_init();				// Load INI variables
	mem_init();				// Set up memory & back end
	layers_init();
	init_cols();

	if ( get_screenshot )
	{
		if (load_image(NULL, FS_PNG_LOAD, FT_PIXMAP) == 1)
			new_empty = FALSE;	// Successfully grabbed so no new empty
		else get_screenshot = FALSE;	// Screenshot failed
	}
	main_init();					// Create main window

	if ( get_screenshot )
	{
		do_new_chores(FALSE);
		notify_changed();
	}
	else
	{
		if ((files_passed > 0) && !do_a_load(file_args[0], FALSE))
			new_empty = FALSE;
	}

	if ( new_empty )		// If no file was loaded, start with a blank canvas
	{
		create_default_image();
	}

	update_menus();

	THREADS_ENTER();
	gtk_main();
	THREADS_LEAVE();

	spawn_quit();
	inifile_quit();

	return 0;
}