Exemplo n.º 1
0
void init()
{
    WDTCTL = WDTPW + WDTHOLD; // disable WDT
    BCSCTL1 = CALBC1_1MHZ; // 1MHz clock
    DCOCTL = CALDCO_1MHZ;

    P1OUT = 0;
    P2OUT = 0;
    P1DIR = 0;
    P2DIR = 0;

    WDTCTL = WDT_ADLY_1000;                   // WDT 1s interval timer
    IE1 = WDTIE;                             // Enable WDT interrupt

    P1DIR |= LCD5110_SCE_PIN + LCD5110_DC_PIN + BACKLIGHT;
    P1OUT |= LCD5110_SCE_PIN + LCD5110_DC_PIN;

    SPI_init();
    __delay_cycles(50000);
    initLCD();
    clearLCD();

    defaultRX = 0;
    NRF_init(86);
    NRF_down();

    initKeyboard();
    // end init
};
Exemplo n.º 2
0
bool MouseKeyboardInput::initalise(HINSTANCE hInstance,HWND hWnd)
{
	winHandle = hWnd;

	HRESULT hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION,
    IID_IDirectInput8, (void**)&m_diObject, NULL);

	if(FAILED(m_diObject->CreateDevice(GUID_SysKeyboard, &m_diKeyboardDevice, NULL)))
	{
		GAMEERROR("Unable to create input device object.",winHandle);
		return false;
	}

	if( FAILED( initMouse() ) )
	{
		GAMEERROR("Unable to create mouse initalise mouse.",winHandle);
		return false;
	}

	if( FAILED( initKeyboard() ) )
	{
		GAMEERROR("Unable to create mouse initalise keyboard.",winHandle);
		return false;
	}

	return true;

}
Exemplo n.º 3
0
bool init( HINSTANCE hInstance, HWND hWnd )
{
    // create the DirectInput interface
    HRESULT result = DirectInput8Create( hInstance,    // the handle to the application
                                         DIRECTINPUT_VERSION,    // the compatible version
                                         IID_IDirectInput8,    // the DirectInput interface version
                                         (void**)&din,    // the pointer to the interface
                                         NULL    // COM stuff, so we'll set it to NULL
                                       );
    
    if ( FAILED( result ) )
    {
        logg( "    ERROR: Unable to init DirectInput" );
        return ( false );
    }
    
    if ( !initKeyboard( hWnd ) )
    {
        logg( "    ERROR: Keyboard not initialized." );
        return ( false );
    }
    
    if ( !initJoysticks( hWnd ) )
    {
        logg( "    ERROR: Joystick(s) not initialized." );
        return ( false );
    }
    
    return ( true );
}
Exemplo n.º 4
0
void Input::init( Window& window )
{
	deleteKeyboard();
	deleteMouse();
	deleteInput();

	initInput();
	initKeyboard( window );
	initMouse( window );
};
Exemplo n.º 5
0
int runTimingTests()
{
	time_t start, startsec;
	int i, j;
	Keyboard tester;
	Keyboard array[1024];
	
	long initAverage = 0;
	long copyAverage = 0;
	long fitnessAverage = 0;
	long locAverage = 0;
	
	struct timeval tv;
		
	/* Use a longer loop to get more accurate data. */
	for (j = 0; j < 50; j++) {
		// How long does it take to initialize a keyboard?
		gettimeofday(&tv, NULL);
		start = tv.tv_usec;
		startsec = tv.tv_sec;
		for (i = 0; i < 100000; ++i) initKeyboard(&tester);
		gettimeofday(&tv, NULL);
		initAverage = ((initAverage * j) + tv.tv_usec - start + 1000000*(tv.tv_sec - startsec)) / (j + 1);
		
		// How long does it take to copy a keyboard?
		gettimeofday(&tv, NULL);
		start = tv.tv_usec;
		startsec = tv.tv_sec;
		for (i = 0; i < 100000; ++i) copyKeyboard(&tester, &array[0]);
		gettimeofday(&tv, NULL);
		copyAverage = ((copyAverage * j) + tv.tv_usec - start + 1000000*(tv.tv_sec - startsec)) / (j + 1);

		// How long does it take to score a keyboard?
		gettimeofday(&tv, NULL);
		start = tv.tv_usec;
		startsec = tv.tv_sec;
		for (i = 0; i < 100000; ++i) calcFitness(&tester);
		gettimeofday(&tv, NULL);
		fitnessAverage = ((fitnessAverage * j) + tv.tv_usec - start + 1000000*(tv.tv_sec - startsec)) / (j + 1);

		// How long does it take to find a key on a keyboard?
		gettimeofday(&tv, NULL);
		start = tv.tv_usec;
		startsec = tv.tv_sec;
		for (i = 0; i < 100000; ++i) locIgnoreShifted(&tester, 'a');
		gettimeofday(&tv, NULL);
		locAverage = ((locAverage * j) + tv.tv_usec - start + 1000000*(tv.tv_sec - startsec)) / (j + 1);
	}
	printf(" *  Time to initialize 100,000 keyboards:     %ld microseconds.\n", initAverage);
	printf(" *  Time to copy 100,000 keyboards:           %ld microseconds.\n", copyAverage);
	printf(" *  Time to score 100,000 keyboards:          %ld microseconds.\n", fitnessAverage);
	printf(" *  Time to do locW/OShifted() 100,000 times: %ld microseconds.\n", locAverage);
	
	return 0;
}
Exemplo n.º 6
0
int init() {
    initMillis () ;
    initKeyboard();

    pthread_t k_t;
    pthread_create(&k_t, NULL, &keyboard_thread, NULL);

    printf("init ");
    sprintf(pt.density, " .',-+:;=o&%%/$*W@#");

    pt.C_stroke_r = 255;
    pt.C_stroke_g = 255;
    pt.C_stroke_b = 255;

    pt.C_color = 0;
    pt.C_pixel = '.';
    pt.running = 1;
    pt.PT_paused = 0;
    pt.PT_keyblocked = 0;

 

    pt.PT_bitmap_width  = 120;
    pt.PT_bitmap_height = 80;

    ellipseMode(CENTER);
    pt.cv = caca_create_canvas(0, 0);
    if (!pt.cv) {
        fprintf(stderr, "unable to initialise libcaca\n");
        return 1;
    }

    pt.dp = caca_create_display_with_driver(pt.cv, "ncurses"); // x11, raw..
    if (pt.dp == NULL ) {
        printf("Failed to create display\n");
        return 1;
    }
    if (!pt.PT_USE_DITHERING) {
        width = caca_get_canvas_width(pt.cv) / X_SCALE;
        height = caca_get_canvas_height(pt.cv);
    } else {
        width = pt.PT_bitmap_width;
        height = pt.PT_bitmap_height;

    }
   // caca_set_display_time(pt.dp,40000);
    useDithering();
    stroke(255);
    setDitherResolution(caca_get_canvas_width(pt.cv), caca_get_canvas_height(pt.cv));
    background(0);
    printf("done ");

    return 0;
}
Exemplo n.º 7
0
void init( HINSTANCE hInstance, HWND hWnd )
{
    // create the DirectInput interface
    DirectInput8Create( hInstance,    // the handle to the application
                        DIRECTINPUT_VERSION,    // the compatible version
                        IID_IDirectInput8,    // the DirectInput interface version
                        (void**)&din,    // the pointer to the interface
                        NULL    // COM stuff, so we'll set it to NULL
                      );
    
    initKeyboard( hWnd );
    initJoysticks( hWnd );
}
/// <summary>
/// Initializes a new instance of the <see cref="KeyboardEventHandler"/> class.
/// </summary>
/// <param name="argHwnd">HWND</param>
/// <param name="input">LPDIRECTINPUT8.</param>
KeyboardEventHandler::KeyboardEventHandler( HWND argHwnd, LPDIRECTINPUT8 input )
{
	dInput				= input; 
	dDevice				= NULL; 
	hwnd				= argHwnd;

	if (initKeyboard())
	{
		Logger::getInstance()->log(LogLevel::INFO, "Keyboard initiated.");
	}
	else
	{
		Logger::getInstance()->log(LogLevel::WARNING, "Failed to initiate keyboard.");
	}
}
void SwitchLayout::loadSwitchLayout()
{
    if (m_KeyboardList.length() > 1) {
        // give out the value of m_MaxTextWidth and m_KeyboradLayoutHeight, to help resize this app
        calculateKeyboardSize();

        resizeParent();

        initKeyboard();
    } else {
        qDebug() << "hide parent";
        // if user's keyboard layout(s) just contain(s) 1 kind, quit the app immediately
        hide();
        deleteOsd();
    }
}
Exemplo n.º 10
0
/*
 *  Ubiquitous main function, argv and all
 *
 */
int main(int argc, char* argv[])
{
	int bez[] = { 
		GLUT_KEY_F1,
		GLUT_KEY_F2,
		GLUT_KEY_F3,
		GLUT_KEY_F4,
		GLUT_KEY_F5,
		GLUT_KEY_F6,
		GLUT_KEY_F7,
		GLUT_KEY_F8,
		GLUT_KEY_F9,
		0,
	};

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);

	glutCreateWindow("University of Missouri Campus");

	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutMouseFunc(mouse_click);
	glutMotionFunc(mouse_drag);

	// real-time muliple key-presses
	initKeyboard(50);
	keyboardCallbackv("asdfhjklionm", move_camera);
	keyboardCallback(27, closeWin);
	keyboardSpecialCallback(GLUT_KEY_F12, fillMode);
	keyboardSpecialCallback(GLUT_KEY_F11, free_camera);
	keyboardSpecialCallback(GLUT_KEY_F10, circle_camera);
	keyboardSpecialCallbackv(bez, bezier_camera);

	init_lights();
	init_campus();
	init_camera();

	glutFullScreen();
	glutMainLoop();
	return 0;
}
Exemplo n.º 11
0
X11UIEngine::X11UIEngine() : 
  _display(NULL),
  _fd(-1),
  _screen(-1),
  _root(0),
  _gc(0),
  _visual(NULL),
  _colorMap(0),
  _xim(0),
  _numButtons(0),
  _xShm(false),
  _xPrivateColorMap(false),
  _xForcePixmap(true),
  _xDontLogUnsupportedBpp(false),
  _wmClientLeader(0),
  _atomNames(X11UIEngine_atomNames)
{
  _wakeUpPipe[0] = -1;
  _wakeUpPipe[1] = -1;
  
  // Make sure that there is no garbage in these arrays.
  MemOps::zero(_atomList, X11_ATOM_COUNT * sizeof(XAtom));
  MemOps::zero(&_keyMap , sizeof(_keyMap));
  MemOps::zero(&_XLib   , sizeof(_XLib));
  MemOps::zero(&_XExt   , sizeof(_XExt));
  MemOps::zero(&_XRender, sizeof(_XRender));

  if (openXlib() != ERR_OK)
    return;

  if (openDisplay() != ERR_OK)
    return;
  
  initDisplay();
  initKeyboard();
  initMouse();

  _eventLoop.adopt(fog_new X11UIEventLoopImpl(this));
  _isInitialized = true;
}
void ApplePS2Keyboard::setDevicePowerState( UInt32 whatToDo )
{
    switch ( whatToDo )
    {
        case kPS2C_DisableDevice:

            //
            // Disable keyboard.
            //
            setKeyboardEnable( false );

            // Work around for auto repeat keyboard sometimes after
            //  wakeup from sleep
            // see: http://www.mydellmini.com/forum/general-mac-os-x-discussion/3553-fixed-zero-key-stack-after-wake-up.html
            // remove interrupt handler
            setCommandByte(kCB_DisableKeyboardClock, kCB_EnableKeyboardIRQ);
            if (_interruptHandlerInstalled)
            {
                _device->uninstallInterruptAction();
                _interruptHandlerInstalled = false;
            }
            break;

        case kPS2C_EnableDevice:
            // re-install interrupt handler
            _device->installInterruptAction(this,
                /*(PS2InterruptAction)&ApplePS2Keyboard::interruptOccurred*/
                OSMemberFunctionCast(PS2InterruptAction, this, &ApplePS2Keyboard::interruptOccurred));
            _interruptHandlerInstalled = true;

            //
            // Enable keyboard and restore state.
            //
            initKeyboard();
            break;
    }
}
Exemplo n.º 13
0
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  //MX_GPIO_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* USER CODE BEGIN 3 */
  /* Infinite loop */
	//start_lcd_work();
	
	lcdStartWorking();
  lcdRepaintMenu();
	lcdMovePoint(0);
	
	//keyboard init
	initKeyboard();
	
	//read from flash
  readFromFlashMemory();	
	
	//init out devices
	initOutDevices();
	
	//init timer for work
	initTimers();
  while (1)
  {
     //HAL_Delay(100);
		if(workState == FREE)
		  {

			}
		else if(workState == START_WORK)
		  {
			  alWorkSystem();
				
			}	
    else if(workState == END_WORK)
	    {
			 lcdRepaintMenu();
	     lcdMovePoint(0);
			 workState = FREE;
			}		
  }
  /* USER CODE END */

}
Exemplo n.º 14
0
Keyboard::Keyboard(ClientSession *Client){
	initKeyboard(Client);
}
Exemplo n.º 15
0
int main(int argc, char *argv[]) {
    register char *s, *p;
    register char *pn = argv[0];

    // configure the I/O ports
    AD1PCFG = 0xFFFF; // Default all pins to digital
    mJTAGPortEnable(0); // turn off jtag

    // setup the CPU
    SYSTEMConfigPerformance(CLOCKFREQ); // System config performance
    mOSCSetPBDIV(OSC_PB_DIV_1); // fix the peripheral bus to half main clock speed
    INTEnableSystemMultiVectoredInt();

    TRISBbits.TRISB15 = 0;
 //   TRISDbits.TRISD11 = 0;
 //   ODCDbits.ODCD11 = 1;
 //   LATDbits.LATD11=0;

    TRISBbits.TRISB13 = 0;
    ODCBbits.ODCB13 = 1;
    PORTBbits.RB13=0;
#ifdef UARTConsole
    UARTInit();
#endif
    initKeyboard();

#ifdef UseVideo
    initVideo();
#endif



#ifdef CPU_SPEED
    f_flag = CPU_SPEED;
    tmax = CPU_SPEED * 10000;
#endif
    argc = 0;
    while (--argc > 0 && (*++argv)[0] == '-')
        for (s = argv[0] + 1; *s != '\0'; s++)
            switch (*s) {
                case 's': /* save core and CPU on exit */
                    s_flag = 1;
                    break;
                case 'l': /* load core and CPU from file */
                    l_flag = 1;
                    break;
#ifdef Z80_UNDOC
                case 'z': /* trap undocumented Z80 ops */
                    z_flag = 1;
                    break;
#endif
                case 'i': /* trap I/O on unused ports */
                    i_flag = 1;
                    break;
                case 'm': /* initialize Z80 memory */
                    m_flag = exatoi(s + 1);
                    s += strlen(s + 1);
                    break;
                case 'f': /* set emulation speed */
                    f_flag = atoi(s + 1);
                    s += strlen(s + 1);
                    tmax = f_flag * 10000;
                    break;
                case 'x': /* get filename with Z80 executable */
                    x_flag = 1;
                    s++;
                    p = xfn;
                    while (*s)
                        *p++ = *s++;
                    *p = '\0';
                    s--;
                    break;
                case '?':
                    goto usage;
                default:
                    printf("illegal option %c\n", *s);
#ifndef Z80_UNDOC
usage:
                    printf("usage:\t%s -s -l -i -mn -fn -xfilename\n", pn);
#else
usage:
                    printf("usage:\t%s -s -l -i -z -mn -fn -xfilename\n", pn);
#endif
                    puts("\ts = save core and cpu");
                    puts("\tl = load core and cpu");
                    puts("\ti = trap on I/O to unused ports");
#ifdef Z80_UNDOC
                    puts("\tz = trap on undocumented Z80 ops");
#endif
                    puts("\tm = init memory with n");
                    puts("\tf = CPU frequenzy n in MHz");
                    puts("\tx = load and execute filename");
                    exit(1);
            }

    putchar('\n');
    puts("#######  #####    ###            #####    ###   #     #");
    puts("     #  #     #  #   #          #     #    #    ##   ##");
    puts("    #   #     # #     #         #          #    # # # #");
    puts("   #     #####  #     #  #####   #####     #    #  #  #");
    puts("  #     #     # #     #               #    #    #     #");
    puts(" #      #     #  #   #          #     #    #    #     #");
    puts("#######  #####    ###            #####    ###   #     #");
    printf("\nRelease %s, %s\n", RELEASE, COPYR);
    printf("\nPort to PIC32 By kenseglerdesigns.com\n");
    if (f_flag > 0)
        printf("\nCPU speed is %d MHz\n", f_flag);
    else
        printf("\nCPU speed is unlimited\n");
#ifdef	USR_COM
    printf("\n%s Release %s, %s\n", USR_COM, USR_REL, USR_CPR);
#endif
    fflush(stdout);

    wrk_ram = PC = ram;
    STACK = ram +0xffff;
    memset((char *) ram, m_flag, 65536);
    if (l_flag)
        if (load_core())
            return (1);
    int_on();
    init_io();
    mon();
    if (s_flag)
        save_core();
    exit_io();
    int_off();
    return (0);
}
Exemplo n.º 16
0
void initPeripheralStatus()
{
	initTiming();
	initKeyboard();
	initMouseData();
}
Exemplo n.º 17
0
/*
 * Entry routine for the user application.
 * At this point, Initialize and start the user application.
 *
 * Entry routine is called from the initial task for Kernel,
 * so system call for stopping the task should not be issued
 * from the contexts of entry routine.
 * We recommend that:
 * (1)'usermain()' only generates the user initial task.
 * (2)initialize and start the user application by the user
 * initial task.
 */
EXPORT	INT	usermain( void )
{
	ER	err = E_OK;
	
	/* Start the device drivers */
#ifdef DRV_CONSOLE
	//err = ConsoleIO(0, NULL);
	tm_putstring(err >= E_OK ? "ConsoleIO - OK\n" : "ConsoleIO - ERR\n");
	vd_printf(err >= E_OK ? "ConsoleIO - OK\n" : "ConsoleIO - ERR\n");
#endif
#ifdef DRV_CLOCK
	err = ClockDrv(0, NULL);
	tm_putstring(err >= E_OK ? "ClockDrv - OK\n" : "ClockDrv - ERR\n");
	vd_printf(err >= E_OK ? "ClockDrv - OK\n" : "ClockDrv - ERR\n");
#endif
#ifdef DRV_SYSDISK
	err = SysDiskDrv(0, NULL);
	tm_putstring(err >= E_OK ? "SysDiskDrv - OK\n" : "SysDiskDrv - ERR\n");
	vd_printf(err >= E_OK ? "SysDiskDrv - OK\n" : "SysDiskDrv - ERR\n");
#endif
#ifdef DRV_SCREEN
	//err = ScreenDrv(0, NULL);
	tm_putstring(err >= E_OK ? "ScreenDrv - OK\n" : "ScreenDrv - ERR\n");
	vd_printf(err >= E_OK ? "ScreenDrv - OK\n" : "ScreenDrv - ERR\n");
#endif
#ifdef DRV_KBPD
	//err = KbPdDrv(0, NULL);
	tm_putstring(err >= E_OK ? "KbPdDrv - OK\n" : "KbPdDrv - ERR\n");
	vd_printf(err >= E_OK ? "KbPdDrv - OK\n" : "KbPdDrv - ERR\n");
#endif
#ifdef DRV_LOWKBPD
	//err = LowKbPdDrv(0, NULL);
	tm_putstring(err >= E_OK ? "LowKbPdDrv - OK\n" : "LowKbPdDrv - ERR\n");
	vd_printf(err >= E_OK ? "LowKbPdDrv - OK\n" : "LowKbPdDrv - ERR\n");
#endif
#ifdef DRV_NET
	err = NetDrv(0, NULL);
	tm_putstring(err >= E_OK ? "NetDrv - OK\n" : "NetDrv - ERR\n");
	vd_printf(err >= E_OK ? "NetDrv - OK\n" : "NetDrv - ERR\n");
#endif
	err = initKeyboard();
	
	if (err)vd_printf("err:initKeyborad\n");
	initVga();
	
	/* Start the T2EX extension modules */
#ifdef	USE_T2EX_DT
	err = dt_main(0, NULL);
	tm_putstring(err >= E_OK ? "dt_main(0) - OK\n":"dt_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "dt_main(0) - OK\n":"dt_main(0) - ERR\n");
#endif
#ifdef	USE_T2EX_PM
	err = pm_main(0, NULL);
	tm_putstring(err >= E_OK ? "pm_main(0) - OK\n":"pm_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "pm_main(0) - OK\n":"pm_main(0) - ERR\n");
#endif
#ifdef	USE_T2EX_FS
	err = fs_main(0, NULL);
	tm_putstring(err >= E_OK ? "fs_main(0) - OK\n":"fs_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "fs_main(0) - OK\n":"fs_main(0) - ERR\n");
#endif
#ifdef	USE_T2EX_NET
	err = so_main(0, NULL);
	tm_putstring(err >= E_OK ? "so_main(0) - OK\n":"so_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "so_main(0) - OK\n":"so_main(0) - ERR\n");
#endif
	/* Initialize stdio */
	libc_stdio_init();

	/* Start the T2EX application */
	tm_putstring("*** T2EX Application program start !!\n");

	appl_main();

	/* Shutdowm the T2EX extension modules */
#ifdef	USE_T2EX_DT
	err = dt_main(-1, NULL);
	tm_putstring(err >= E_OK ? "dt_main(-1) - OK\n":"dt_main(-1) - ERR\n");
#endif
#ifdef	USE_T2EX_PM
	err = pm_main(-1, NULL);
	tm_putstring(err >= E_OK ? "pm_main(-1) - OK\n":"pm_main(-1) - ERR\n");
#endif
#ifdef	USE_T2EX_FS
	err = fs_main(-1, NULL);
	tm_putstring(err >= E_OK ? "fs_main(-1) - OK\n":"fs_main(-1) - ERR\n");
#endif
#ifdef	USE_T2EX_NET
	err = so_main(-1, NULL);
	tm_putstring(err >= E_OK ? "so_main(-1) - OK\n":"so_main(-1) - ERR\n");
#endif

	/* Stop the device drivers */
#ifdef DRV_NET
	NetDrv(-1, NULL);
#endif
#ifdef DRV_LOWKBPD
	LowKbPdDrv(-1, NULL);
#endif
#ifdef DRV_KBPD
	KbPdDrv(-1, NULL);
#endif
#ifdef DRV_SCREEN
	ScreenDrv(-1, NULL);
#endif
#ifdef DRV_SYSDISK
	SysDiskDrv(-1, NULL);
#endif
#ifdef DRV_CLOCK
	ClockDrv(-1, NULL);
#endif
#ifdef DRV_CONSOLE
	ConsoleIO(-1, NULL);
#endif

	return 0;
}
bool ApplePS2Keyboard::start(IOService * provider)
{
    OSBoolean *xml_swap_CAPSLOCK_CTRL;
    OSBoolean *xml_swap_ALT_WIN;
    OSBoolean *xml_use_right_modifier_into_HANGUL_HANJA;
    OSBoolean *xml_make_APP_into_RWIN;
    OSBoolean *xml_swap_GRAVE_EUROPE2;
    OSBoolean *xml_make_APP_into_AppleFN;
    
    //
    // The driver has been instructed to start.   This is called after a
    // successful attach.
    //

    if (!super::start(provider))  return false;

    //
    // Maintain a pointer to and retain the provider object.
    //

    _device = (ApplePS2KeyboardDevice *)provider;
    _device->retain();


    //
    // Configure user preferences from Info.plist
    //

    xml_swap_CAPSLOCK_CTRL = OSDynamicCast( OSBoolean, getProperty("Swap capslock and left control"));
    if (xml_swap_CAPSLOCK_CTRL) {
        if ( xml_swap_CAPSLOCK_CTRL->getValue()) {
            char temp = _PS2ToADBMap[0x3a];
            _PS2ToADBMap[0x3a] = _PS2ToADBMap[0x1d];
            _PS2ToADBMap[0x1d] = temp;
        }
    }

    xml_swap_ALT_WIN = OSDynamicCast( OSBoolean, getProperty("Swap command and option"));
    if (xml_swap_ALT_WIN) {
        if ( xml_swap_ALT_WIN->getValue()) {
            char temp = _PS2ToADBMap[0x38];
            _PS2ToADBMap[0x38] = _PS2ToADBMap[0x15b];
            _PS2ToADBMap[0x15b] = temp;

            temp = _PS2ToADBMap[0x138];
            _PS2ToADBMap[0x138] = _PS2ToADBMap[0x15c];
            _PS2ToADBMap[0x15c] = temp;
        }
    }

    xml_use_right_modifier_into_HANGUL_HANJA = OSDynamicCast( \
            OSBoolean, getProperty("Make right modifier keys into Hangul and Hanja"));
    if (xml_use_right_modifier_into_HANGUL_HANJA) {
        if ( xml_use_right_modifier_into_HANGUL_HANJA->getValue()) {
            _PS2ToADBMap[0x138] = _PS2ToADBMap[0xf2];    // Right alt becomes Hangul
            _PS2ToADBMap[0x11d] = _PS2ToADBMap[0xf1];    // Right control becomes Hanja
        }
    }

    xml_make_APP_into_RWIN = OSDynamicCast( OSBoolean, getProperty("Make Application key into right windows"));
    if (xml_make_APP_into_RWIN) {
        if ( xml_make_APP_into_RWIN->getValue())
            _PS2ToADBMap[0x15d] = _PS2ToADBMap[0x15c];
    }

    // not implemented yet.
    // Apple Fn key works well, but no combined key action was made.
    xml_make_APP_into_AppleFN = OSDynamicCast( OSBoolean, getProperty("Make Application key into Apple Fn key"));
    if (xml_make_APP_into_AppleFN) {
        if ( xml_make_APP_into_AppleFN->getValue()) {
            _PS2ToADBMap[0x15d] = 0x3f;
        }
    }

    // ISO specific mapping to match ADB keyboards
    // This should really be done in the keymaps.
    xml_swap_GRAVE_EUROPE2 = OSDynamicCast( OSBoolean, getProperty("Use ISO layout keyboard"));
    if (xml_swap_GRAVE_EUROPE2) {
        if ( xml_swap_GRAVE_EUROPE2->getValue()) {
            char temp = _PS2ToADBMap[0x29];             //Grave '~'
            _PS2ToADBMap[0x29] = _PS2ToADBMap[0x56];    //Europe2 '¤º'
            _PS2ToADBMap[0x56] = temp;
        }
    }
    
    // now load PS2 -> PS2 configuration data
    
    OSArray* pArray = OSDynamicCast(OSArray, getProperty("Custom PS2 Map"));
    if (NULL != pArray)
    {
        for (int i = 0; i < pArray->getCount(); i++)
        {
            OSString* pString = OSDynamicCast(OSString, pArray->getObject(i));
            if (NULL == pString)
                continue;
            const char* psz = pString->getCStringNoCopy();
            // check for comment
            if (';' == *psz)
                continue;
            // otherwise, try to parse it
            UInt16 scanIn, scanOut;
            if (!parseRemap(psz, scanIn, scanOut))
            {
                IOLog("VoodooPS2Keyboard: invalid custom PS2 map entry: \"%s\"\n", psz);
                continue;
            }
            // must be normal scan code or extended, nothing else
            UInt8 exIn = scanIn >> 8;
            UInt8 exOut = scanOut >> 8;
            if ((exIn != 0 && exIn != 0xe0) || (exOut != 0 && exOut != 0xe0))
            {
                IOLog("VoodooPS2Keyboard: scan code invalid for PS2 map entry: \"%s\"\n", psz);
                continue;
            }
            // modify PS2 to PS2 map per remap entry
            int index = (scanIn & 0xff) + (exIn == 0xe0 ? KBV_NUM_SCANCODES : 0);
            assert(index < countof(_PS2ToPS2Map));
            _PS2ToPS2Map[index] = (scanOut & 0xff) + (exOut == 0xe0 ? KBV_NUM_SCANCODES : 0);
        }
    }
    
    // now load PS2 -> ADB configuration data
    
    pArray = OSDynamicCast(OSArray, getProperty("Custom ADB Map"));
    if (NULL != pArray)
    {
        for (int i = 0; i < pArray->getCount(); i++)
        {
            OSString* pString = OSDynamicCast(OSString, pArray->getObject(i));
            if (NULL == pString)
                continue;
            const char* psz = pString->getCStringNoCopy();
            // check for comment
            if (';' == *psz)
                continue;
            // otherwise, try to parse it
            UInt16 scanIn, adbOut;
            if (!parseRemap(psz, scanIn, adbOut))
            {
                IOLog("VoodooPS2Keyboard: invalid custom ADB map entry: \"%s\"\n", psz);
                continue;
            }
            // must be normal scan code or extended, nothing else, adbOut is only a byte
            UInt8 exIn = scanIn >> 8;
            if ((exIn != 0 && exIn != 0xe0) || adbOut > 0xFF)
            {
                IOLog("VoodooPS2Keyboard: scan code invalid for ADB map entry: \"%s\"\n", psz);
                continue;
            }
            // modify PS2 to ADB map per remap entry
            int index = (scanIn & 0xff) + (exIn == 0xe0 ? ADB_CONVERTER_EX_START : 0);
            assert(index < countof(_PS2ToADBMap));
            _PS2ToADBMap[index] = adbOut;
        }
    }
    
    // get time before sleep button takes effect
    
    OSNumber* num;
	if ((num = OSDynamicCast(OSNumber, getProperty("SleepPressTime"))))
		maxsleeppresstime = (uint64_t)num->unsigned32BitValue() * (uint64_t)1000000;

    //
    // Reset and enable the keyboard.
    //

    initKeyboard();

    //
    // Install our driver's interrupt handler, for asynchronous data delivery.
    //

    _device->installInterruptAction(this,
            OSMemberFunctionCast(PS2InterruptAction,this,&ApplePS2Keyboard::interruptOccurred));
    _interruptHandlerInstalled = true;

    //
    // Install our power control handler.
    //

    _device->installPowerControlAction( this,
            OSMemberFunctionCast(PS2PowerControlAction,this, &ApplePS2Keyboard::setDevicePowerState ));
    _powerControlHandlerInstalled = true;

    return true;
}
Exemplo n.º 19
0
int main( void )
{
	initGLFW();
	initWindow();
	initGLEW();
	initKeyboard();
	
	// Dark blue background
	glClearColor(0.0f, 0.0f, 0.4f, 0.0f);

	int size = 5;
	float* map = generateHeightMap(size);
	printf("generated map\n" );
	std::vector<glm::vec3> terrain;
	mapHeightsToPoints(terrain, map, size);
	printf("mapped to points\n");
	// GLuint* indices = generateIndices(terrain, size);

	uint terrainVertexAmount = size* size * 3;
	uint indiceAmount = 3 * (1 << size);

	for(int i = 0; i < terrain.size(); ++i){
		printf("[%f, %f, %f]\n", terrain[i].x, terrain[i].y, terrain[i].z);
	}

	printf("vertices %d\n", terrainVertexAmount);

	GLuint VertexArrayID = newVertexArray();

	// Create and compile our GLSL program from the shaders
	GLuint programID = LoadShaders( "SimpleVertexShader.vertexshader", "SimpleFragmentShader.fragmentshader" );
	printf("loaded\n");
	initMatrices(programID);

	
	GLuint vertexbuffer = newVertexBuffer(terrainVertexAmount, &terrain);
	
	double lastTime = glfwGetTime();
 	int nbFrames = 0;
 	printf("loop\n");


 	initDepth();
	do{

		// Clear the screen
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		// Use our shader
		glUseProgram(programID);
		
		// TODO
		// recalculateMatrices();

		// Send our transformation to the currently bound shader, 
		// in the "MVP" uniform
		glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);

		// 1rst attribute buffer : vertices
		bindVertexBuffer(vertexbuffer);

		// Draw the triangle !
		glDrawArrays(GL_TRIANGLE_FAN, 0, terrainVertexAmount); // 3 indices starting at 0 -> 1 triangle

		glDisableVertexAttribArray(0);

		// Swap buffers
		glfwSwapBuffers(window);
		glfwPollEvents();


		// measureTime(lastTime, &nbFrames);

	} // Check if the ESC key was pressed or the window was closed
	while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
		   glfwWindowShouldClose(window) == 0 );

	// Cleanup VBO
	glDeleteBuffers(1, &vertexbuffer);
	glDeleteVertexArrays(1, &VertexArrayID);
	glDeleteProgram(programID);

	// Close OpenGL window and terminate GLFW
	glfwTerminate();
	// normal** ns = generateNormals(map, size);
	return 0;
}
Exemplo n.º 20
0
int main(void) {
	while (1) {
		state = 0;
		int setTime = 15;
		numPlayers = 2;
		initScreen();
		clearScreen();
		initCharBuffer();
		clean_up();
		initKeyboard();
		initState0();
		initAI();


		//Bypass the menu system for testing
		if (IORD(keys,0) == 8) {
			initPlayer(pOne, MARIO, "pOne", 50, 100, HUMAN);
			initPlayer(pTwo, LUIGI, "pTwo", 50, 100, COMPUTER);
			state = 2;
		} else {
			while (state == 0) {
				decode_scancode(ps2, &decode_mode, buf, &ascii);
				state_0(decode_mode, buf[0]);
			};
			initState1(pOne);
			if(aOn)file_handle = initAudio(fname);
			if(aOn)alt_irq_register(AUDIO_0_IRQ, &ab, (alt_isr_func) write_fifo);
			if(aOn)		alt_up_audio_enable_write_interrupt(ab->audio);
			while (state == 1) {
				decode_scancode(ps2, &decode_mode, buf, &ascii);
				state_1(decode_mode, buf[0], ascii);
				if(aOn)loop_audio(file_handle, fname, ab);
			};
		}

		//clean_up();
		clearCharBuffer();
		clearScreen();

		//enable keyboard IRQ
		void* keyboard_control_register_ptr = (void*) (KEYBOARD_BASE + 4);
		alt_irq_register(KEYBOARD_IRQ, keyboard_control_register_ptr,
				keyboard_ISR);
		alt_up_ps2_enable_read_interrupt(ps2);

		//Draw field and UI to both buffers
		initField();

		updateField();
		drawName(p[pOne].name, p[pTwo].name, p[pThree].name, p[pFour].name);
		drawGas(p[pOne].gas);
		drawHealth(p[pOne].hp, p[pTwo].hp, p[pThree].hp, p[pFour].hp);
		drawBullet(p[pOne].bulletType);
		//drawWindIndicator(1);
		updateScreen();

		updateField();
		drawName(p[pOne].name, p[pTwo].name, p[pThree].name, p[pFour].name);
		drawGas(p[pOne].gas);
		drawHealth(p[pOne].hp, p[pTwo].hp, p[pThree].hp, p[pFour].hp);
		drawBullet(p[pOne].bulletType);
		//drawWindIndicator(1);

		float time;
		alt_timestamp_start();


		int start_timer_flag = 1;
		//printf("NUM PLAYERA %i\n", numPlayers);
		int i;
		while (state == 2) {
			int fallFlag = 1;

			//Checks to see if any players are falling
			while (fallFlag == 1) {
				fallFlag = 0;
				for (i = 0; i < numPlayers; i++) {
					if (p[i].alive) {
						if (p[i].y + TANK_HEIGHT >= SCREEN_HEIGHT-1) {
							p[i].hp = 0;
							p[i].alive = DEAD;
						}
						checkPlayerFalling(i);
						if (p[i].isFalling) {
							undrawPlayer(i);
							updatePlayer(i);
							fallFlag = 1;
						}
					}
				}
				if (fallFlag == 1) {
					updateScreen();
				}
			}

			if(start_timer_flag){
				start_time = (float) alt_timestamp() / (float) alt_timestamp_freq();
				start_timer_flag = 0;
			}
			time = (float) alt_timestamp() / (float) alt_timestamp_freq()-start_time;
			if (time >= setTime) {
				setPlayerTurn();
			}
			if (p[turn].type == HUMAN) {
				runGame();

			} else {
				p[turn].deg = 0;
				aiMain(turn);
				setPlayerTurn();
			}
			printTimer(setTime - time);
			int deadCount = 0;
			for (i = 0; i < numPlayers; i++) {
				if (p[i].alive == DEAD)
					deadCount++;
			}
			if (deadCount == numPlayers - 1) {
				usleep(500000);
				state = 3;
			}
		}

		alt_up_ps2_disable_read_interrupt(ps2);
		if(aOn)alt_up_audio_disable_write_interrupt(ab->audio);

		GameOverScreen();
	}
}