void special_keyboard(int key, int x, int y)
{
	if(key == GLUT_KEY_PAGE_DOWN)
		keyboard('n', 0,0);
	if(key == GLUT_KEY_PAGE_UP)
		keyboard('p', 0,0);
}
Beispiel #2
0
 static string encode(uint16_t code) {
   for(unsigned i = 0; i < Keyboard::Count; i++) {
     if(keyboard(i).belongsTo(code)) return keyboard(i).encode(code);
   }
   for(unsigned i = 0; i < Mouse::Count; i++) {
     if(mouse(i).belongsTo(code)) return mouse(i).encode(code);
   }
   for(unsigned i = 0; i < Joypad::Count; i++) {
     if(joypad(i).belongsTo(code)) return joypad(i).encode(code);
   }
   return "None";
 }
Beispiel #3
0
/* Called when a menu option has been selected. Translates the menu item
   identifier into a keystroke, then call's the keyboard function. */
void 
menu(int val)
{
  unsigned char key;

  switch (val) {
  case 1:
    key = 's';
    break;
  case 2:
    key = ' ';
    break;
  case 3:
    key = 't';
    break;
  case 4:
    key = 'o';
    break;
  case 5:
    key = '0';
    break;
  case 6:
    key = '1';
    break;
  case 7:
    key = '+';
    break;
  case 8:
    key = '-';
    break;
  default:
    return;
  }
  keyboard(key, 0, 0);
}
Beispiel #4
0
static void run_demo (void)
{
	set_color_depth (16);
	if (set_gfx_mode(GFX_OPENGL, width, height, 0, 0) < 0) {
		allegro_message ("Error setting OpenGL graphics mode:\n%s\nAllegro GL error : %s\n", allegro_error, allegro_gl_error);
		return;
	}

	install_keyboard();

	LOCK_FUNCTION(secs_timer);
	LOCK_VARIABLE(secs);

	glClearColor (0, 0, 0, 0);
	glShadeModel (GL_FLAT);
	glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
	glPolygonMode (GL_BACK, GL_POINTS);
	glEnable (GL_DEPTH_TEST);
	glCullFace (GL_BACK);
	glEnable (GL_CULL_FACE);

	install_int (secs_timer, 1000);

	do {
		keyboard();
		rest(2);
	} while (!key[KEY_ESC]);

	remove_int (secs_timer);

	remove_keyboard();
}
Beispiel #5
0
LRESULT WINAPI msgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg) {
    case WM_DESTROY:
        cleanup();
        PostQuitMessage(0);
        return 0;

    case WM_PAINT:
        render();
        //ValidateRect(hWnd, NULL);
        return 0;

    case WM_SIZE:
        RECT rect;
        GetClientRect(hWnd, &rect);
        resize(rect.right - rect.left, rect.bottom - rect.top);
        break;

    case WM_KEYDOWN:
        keyboard(hWnd, wParam);
        break;
    }
    return DefWindowProc(hWnd, msg, wParam, lParam);
}
Beispiel #6
0
hotkey_ptr create_hotkey(const std::string &id, SDL_Event &event)
{
	hotkey_ptr base = hotkey_ptr(new hotkey_void);

	switch (event.type) {
	case SDL_KEYDOWN:
	case SDL_KEYUP: {
		hotkey_keyboard_ptr keyboard(new hotkey_keyboard());
		base = std::dynamic_pointer_cast<hotkey_base>(keyboard);
		SDL_Scancode code;
		code = event.key.keysym.scancode;
		keyboard->set_scancode(code);
		break;
	}
	case SDL_MOUSEBUTTONDOWN:
	case SDL_MOUSEBUTTONUP: {
		hotkey_mouse_ptr mouse(new hotkey_mouse());
		base = std::dynamic_pointer_cast<hotkey_base>(mouse);
		mouse->set_button(event.button.button);
		break;
	}
	default:
		ERR_G<< "Trying to bind an unknown event type:" << event.type << "\n";
		break;
	}

	base->set_mods(sdl_get_mods());
	base->set_command(id);
	base->unset_default();

	return base;
}
Beispiel #7
0
void verify(){
  int guess[100];
  int key = 0;
  int pin = 0;
  int i = 0;
  while(i<counter){
    key = keyboard();
    key = convert(key);
    pin = switchh();
    pin = translate(pin);
     if(key != 0){
       guess[i] = key;
     }
     if(pin != 0){
       guess[i] = pin;
     }
    i++;
  }
  int j = 0;
  while(j<counter){
    if(newGame[j] == guess[j]){
      j++;
      printf("correct\n");
    }else{
      printf("wrong\n");
      startOver();
      repeatColors();
      verify();
   }
  }
  printf("go again\n");
   repeatColors();
   verify();
}
Beispiel #8
0
void move() {
	int width, height = 0;
	glfwGetCursorPos(window, &xpos, &ypos);
	glfwGetWindowSize (window, &width, &height);
	
	glfwSetCursorPos(window, width/2, height/2);
	
	// Compute new orientation
	horizontalAngle += mouseSpeed * float( width/2 - xpos );
	verticalAngle   += mouseSpeed * float( height/2 - ypos );
	  
	// Direction : Spherical coordinates to Cartesian coordinates conversion
	direction = glm::vec3(
		cos(verticalAngle) * sin(horizontalAngle), 
		sin(verticalAngle),
		cos(verticalAngle) * cos(horizontalAngle)
	);
	
	// Right vector
	right = glm::vec3(
		sin(horizontalAngle - 3.14f/2.0f), 
		tan(depthAngle),
		cos(horizontalAngle - 3.14f/2.0f)
	);

	// Up vector
	up = glm::cross( right, direction );
	  
	keyboard();
	mouse();
}
Beispiel #9
0
void* feedback_listener(void* args)
{
	for (;;)
	{
		FeedbackConfig config;
	
		// Listen to the feedback from clients.
		server->feedback(config);
		
		if (config.reset)
		{
			memset(particles, 0, sizeof(cData) * DS);
			keyboard('r', 0, 0);
		}

		if (config.click)
		{
			lastx = config.lastx * wstep;
			lasty = config.lasty * hstep;
			clicked = config.clicked;
		}
		
		if (config.motion)
		{
			pthread_mutex_lock(&display_mutex);
			lastx = config.lastx * wstep;
			lasty = config.lasty * hstep;
			motion(config.lastx * wstep, config.lasty * hstep, config.nx, config.ny,
				config.fx, config.fy, config.spy, config.spx);
			pthread_mutex_unlock(&display_mutex);
		}
	}
}
Beispiel #10
0
int main() {
    // Initialize keyboard
    keyboard = new Keyboard(&pc);
    // Initialize the clocks to some reasonable time
    cA.reset();
    cA.start();
    int startup = rand() % 70 + 30;
    Thread::wait(startup);
    cV.reset();
    cV.start();
    // Assign interrupts
    as_interrupt.rise(&a_sense);
    vs_interrupt.rise(&v_sense);
    // Initialize the threads
    Thread leds(led_thread);
    led_addr = &leds;
    Thread display(display_thread);
    display_addr = &display;
    Thread alarm(alarm_thread);
    alarm_addr = &alarm;
    Thread keyboard(input_thread);
    Thread mode_switch(mode_switch_thread);
    Thread pace(pace_thread);
    pace_addr = &pace;
    
    while (true) { }
}
Beispiel #11
0
/**
 * Menú contextual
 */
static void menu(int item){
	switch(item){
		case glPOINT:
			modoRender = glPOINT;
			real_renderMode = GL_POINT;
			break;
		case glFLAT:
			modoRender = glFLAT;
			real_renderMode = GL_FILL;
			glShadeModel(GL_FLAT);
			break;
		case glSMOOTH:
			modoRender = glSMOOTH;
			real_renderMode = GL_FILL;
			glShadeModel(GL_SMOOTH);
			break;
		case glLINE:
			modoRender = glLINE;
			real_renderMode = GL_LINE;
			break;
		case ANDAR_FLOTAR:
			keyboard('p',0,0);
			break;
		case ANIMAR_CAMARA:
			animarCamara = !animarCamara;
			break;
			
		default: break; 
	}
}
Beispiel #12
0
int main()
{
    mouse();
    keyboard();

    getch();
    return 0;
}
Beispiel #13
0
 void ToolbarChanged(IControlToolbar *pWin, int selecteditem, int prev) 
 {
     int states;
     size_t tag;
     int ddsidx;
     pWin->GetItemInfos(selecteditem, states, tag, NULL, 0, NULL, 0, ddsidx);
     keyboard((unsigned char)tag, 0,0);
 }
Beispiel #14
0
/*F***********************************************************
 * 
 * 
 * PURPOSE : 
 *
 * RETURN :  
 *
 * NOTES :   
 *F*/
void MoonGame::run(void) {

  SDL_Event event;
  Uint32 start;
  const int FPS = 60;

  while(isRunning) {
    start = SDL_GetTicks();
    if(glGetError() != GL_NO_ERROR) {
      exit(1);
    }

    while(SDL_PollEvent(&event) != 0) {

      switch(event.type){

      case SDL_KEYDOWN:
	keyboard(event, true);
	break;

      case SDL_KEYUP:
	keyboard(event, false);
	break;

      case SDL_QUIT:
	isRunning = false;
	break;
      }
    }

    if(!paused) {
      while(moon->update(controls)) {
	while(true) {
	  //we won
	  moon->draw(controls);
	  keyboard(event, true);
	}
      }
    }
    moon->draw(controls);
    SDL_RenderPresent(displayRenderer);
    if(1000/FPS > SDL_GetTicks() - start) {
      SDL_Delay(1000/FPS - (SDL_GetTicks() - start));
    }
  }
}
Beispiel #15
0
GFXDECODE_END


void mbc200_state::mbc200(machine_config &config)
{
	/* basic machine hardware */
	Z80(config, m_maincpu, 8_MHz_XTAL / 2); // NEC D780C-1
	m_maincpu->set_addrmap(AS_PROGRAM, &mbc200_state::mbc200_mem);
	m_maincpu->set_addrmap(AS_IO, &mbc200_state::mbc200_io);

	z80_device &subcpu(Z80(config, "subcpu", 8_MHz_XTAL / 2)); // NEC D780C-1
	subcpu.set_addrmap(AS_PROGRAM, &mbc200_state::mbc200_sub_mem);
	subcpu.set_addrmap(AS_IO, &mbc200_state::mbc200_sub_io);

	/* video hardware */
	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
	screen.set_refresh_hz(50);
	screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
	screen.set_size(640, 400);
	screen.set_visarea(0, 640-1, 0, 400-1);
	screen.set_screen_update("crtc", FUNC(hd6845s_device::screen_update));
	GFXDECODE(config, "gfxdecode", m_palette, gfx_mbc200);
	PALETTE(config, m_palette, palette_device::MONOCHROME);

	HD6845S(config, m_crtc, 8_MHz_XTAL / 4); // HD46505SP
	m_crtc->set_screen("screen");
	m_crtc->set_show_border_area(false);
	m_crtc->set_char_width(8);
	m_crtc->set_update_row_callback(FUNC(mbc200_state::update_row), this);

	// sound
	SPEAKER(config, "mono").front_center();
	BEEP(config, m_beep, 1000).add_route(ALL_OUTPUTS, "mono", 0.50); // frequency unknown
	SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 0.50);

	I8255(config, "ppi_1").out_pc_callback().set(FUNC(mbc200_state::p1_portc_w));
	I8255(config, "ppi_2").in_pa_callback().set(FUNC(mbc200_state::p2_porta_r));

	I8255(config, m_ppi_m);
	m_ppi_m->out_pa_callback().set(FUNC(mbc200_state::pm_porta_w));
	m_ppi_m->out_pb_callback().set(FUNC(mbc200_state::pm_portb_w));

	I8251(config, "uart1", 0); // INS8251N

	I8251(config, "uart2", 0); // INS8251A

	MB8876(config, m_fdc, 8_MHz_XTAL / 8); // guess
	FLOPPY_CONNECTOR(config, "fdc:0", mbc200_floppies, "qd", floppy_image_device::default_floppy_formats).enable_sound(true);
	FLOPPY_CONNECTOR(config, "fdc:1", mbc200_floppies, "qd", floppy_image_device::default_floppy_formats).enable_sound(true);

	/* Keyboard */
	generic_keyboard_device &keyboard(GENERIC_KEYBOARD(config, "keyboard", 0));
	keyboard.set_keyboard_callback(FUNC(mbc200_state::kbd_put));

	/* software lists */
	SOFTWARE_LIST(config, "flop_list").set_original("mbc200");
}
Beispiel #16
0
void keyboard_Aux(GLFWwindow* pWindow, int key, int codes, int action, int mods)
{
#ifdef USE_ANTTWEAKBAR
    int ant = TwEventKeyGLFW(key, action);
    if (ant != 0)
        return;
#endif
    keyboard(pWindow, key, codes, action, mods);
}
Beispiel #17
0
void keyboardchar(int key) { 
   if (isdigit((char)key)) {
      octave = key - '0';   
      return;
   }
   switch (key) {
      case 'q':
         chordType = DIMINISHED_TRIAD;
         break;
      case 'w':
         chordType = MINOR_TRIAD;
         break;
      case 'e':
         chordType = MAJOR_TRIAD;
         break;
      case 'r':
         chordType = AUGMENTED_TRIAD;
         break;
      case 't':
         chordType = FULLY_DIM_7TH;
         break;
      case 'y':
         chordType = HALF_DIM_7TH;
         break;
      case 'u':
         chordType = mm_7TH;
         break;
      case 'i':
         chordType = mM_7TH;
         break;
      case 'o':
         chordType = Mm_7TH;
         break;
      case 'p':
         chordType = MM_7TH;
         break;
      case '[':
         offset--;
         break;
      case ']':
         offset++; 
         break;
      case '\\':
         recordRhythms();
         break;
      case '=':
         cout << "Onsets:    \t" << onset[0] << "\t" << onset[1]
              << "\t" << onset[2] << "\t" << onset[3] << endl;
         cout << "durations: \t" << duration[0] << "\t" << duration[1]
              << "\t" << duration[2] << "\t" << duration[3] << endl;
         cout << "Offset: " << offset << endl;
         break;
      default:
         keyboard(key);
   }
}
Beispiel #18
0
int WrapDemo()
{


    init ();
    reshape(WINDOW_WIDTH, WINDOW_HEIGHT);
    keyboard();
    
   return 1;
}
Beispiel #19
0
void special(int key, int x, int y) {
  switch (key) {
    case GLUT_KEY_F4:
      if(glutGetModifiers() == GLUT_ACTIVE_ALT) {
        glutLeaveMainLoop();
      }
      break;
  }
  keyboard(key+128, x, y);
}
void NameEntryScreen::activate(){

	Coordinate keyboard_origin(90,100);
	OnScreenKeyboard keyboard(keyboard_origin);
	NameEntryBox nameBox(keyboard_origin,3,20);

	stroke(65,65,65);
	fill(196,207,161);
	drawrect(0,0, 320,240);

	text("Congratulations!", 90, 30);
	text("HI SCORE: ", 90,45);
	text(player_score_, 160, 45);
	text("Enter your name:", 90, 60);

	keyboard.draw();
	nameBox.draw();

	long curr_time = millis();
	bool enter_pressed = false;

	//read in the user's name
	while (!nameBox.isNameComplete()) {

		input_shield_->readInputShield(&input_state_);

		if(millis() - curr_time > (1000/10)){
			keyboard.updateCursorPosition(input_state_);

			if(input_state_.ButtonA){
				if(!enter_pressed){
					nameBox.enterChar(keyboard.click());
					nameBox.draw();
					enter_pressed = true;
				}
			}else{
				enter_pressed = false;
			}

			keyboard.draw();
			curr_time = millis();
		}
	}

	char* player_name = nameBox.getName();

	hi_score_->setNewHiScore(player_name, player_score_);

	stroke(65,65,65);
	fill(196,207,161);
	drawrect(55,80,240,60);
	text("(Press A to start a new game)",80,110);

	pressAToContinue();
}
Beispiel #21
0
void OVR_SDL2_app::dispatch(SDL_Event& e)
{
    switch (e.type)
    {
        case SDL_KEYDOWN:
            keyboard(e.key.keysym.scancode, true,  (e.key.repeat != 0));
            break;
        case SDL_KEYUP:
            keyboard(e.key.keysym.scancode, false, (e.key.repeat != 0));
            break;
        case SDL_MOUSEBUTTONDOWN:
            mouse_button(e.button.button, true);
            break;
        case SDL_MOUSEBUTTONUP:
            mouse_button(e.button.button, false);
            break;
        case SDL_MOUSEMOTION:
            mouse_motion(e.motion.xrel, e.motion.yrel);
            break;
        case SDL_MOUSEWHEEL:
            mouse_wheel(e.wheel.x, e.wheel.y);
            break;
        case SDL_CONTROLLERAXISMOTION:
            game_axis(e.caxis.which, e.caxis.axis, e.caxis.value / 32768.f);
            break;
        case SDL_CONTROLLERBUTTONDOWN:
            game_button(e.caxis.which, e.cbutton.button, true);
            break;
        case SDL_CONTROLLERBUTTONUP:
            game_button(e.caxis.which, e.cbutton.button, false);
            break;
        case SDL_CONTROLLERDEVICEADDED:
            game_connect(e.cdevice.which, true);
            break;
        case SDL_CONTROLLERDEVICEREMOVED:
            game_connect(e.cdevice.which, false);
            break;
        case SDL_QUIT:
            running = false;
            break;
    }
}
void RenderWidget::keyReleaseEvent(QKeyEvent* event)
{
    he::io::IKeyboard* keyboard(CONTROLS->getKeyboard(getHandle()));
    if (event->isAutoRepeat() == false)
    {
        he::io::Key key(ConvertKey(event->key()));
        if (key != he::io::Key_Unknown)
            keyboard->KeyReleased(key);
    }
    QWidget::keyReleaseEvent(event);
}
Beispiel #23
0
/*
 * We've got the hangup or term signal.
 */
static void hangsig(int sig)
{
  if (stdwin)
    werror(_("Killed by signal %d !\n"), sig);
  if (capfp)
    fclose(capfp);

  keyboard(KUNINSTALL, 0);
  hangup();
  modemreset();
  leave("\n");
}
Beispiel #24
0
void update(int value) {

   // input handling
   keyboard();

// update ball
   updateBall();

   // Call update() again in 'interval' milliseconds
   glutTimerFunc(interval, update, 0);

   // Redisplay frame
   glutPostRedisplay();
}
Beispiel #25
0
void control(gamedata &g, Uint8 *keys, int &jx, int &jy, bool &jb){

  switch(g.p().control){
    case 1: // Player 1
      if(demo)
	computer_ai(g, g.p(), jx, jy, jb);
      else
      	keyboard(keys, jx, jy, jb, SDLK_UP, SDLK_LALT,
               SDLK_LEFT, SDLK_RIGHT, SDLK_LCTRL);
      break;
    case 2: // Player 2
      if(demo)
	computer_ai(g, g.p(), jx, jy, jb);
      else
      	keyboard(keys, jx, jy, jb, SDLK_s, SDLK_x,
               SDLK_z, SDLK_c, SDLK_LCTRL);
      break;
    default: // Computer controlled
      computer_ai(g, g.p(), jx, jy, jb);
      break;
  }

}
Beispiel #26
0
/*!
 * First kernel function (after boot loader loads it to memory)
 */
void k_startup ()
{
    extern void *k_stdout; /* console for kernel messages */

    /* set initial stdout */
    kdevice_set_initial_stdout ();

    /* initialize memory subsystem (needed for boot) */
    k_memory_init ();

    /*! start with regular initialization */

    /* interrupts */
    arch_init_interrupts ();

    /* detect memory faults (qemu do not detect segment violations!) */
    arch_register_interrupt_handler ( INT_MEM_FAULT, k_memory_fault, NULL );
    arch_register_interrupt_handler ( INT_UNDEF_FAULT, k_memory_fault, NULL );

    /* timer subsystem */
    k_time_init ();

    /* devices */
    k_devices_init ();

    /* switch to default 'stdout' for kernel */
    k_stdout = k_device_open ( K_STDOUT, O_WRONLY );

    kprintf ( "%s\n", system_info );

    /* enable interrupts */
    enable_interrupts ();

    stdio_init (); /* initialize standard input & output devices */

    /* start desired program(s) */
    hello_world ();
    keyboard ();
    timer ();
    /* segm_fault (); */

#if ( TURN_OFF == 0 )
    kprintf ( "\nSystem halted!\n" );
    halt ();
#else
    /* power off (if supported, or just stop if not) */
    kprintf ( "Powering off\n\n" );
    power_off ();
#endif
}
Beispiel #27
0
int main(){
    int pointCommand = 0;
    char null = NULL;
    int lll = 0, i;
    struct playLists arrPlaylist[20];
    struct playLists * pointPlaylist = (struct playLists *)malloc(sizeof(struct playLists));
    pointPlaylist = &arrPlaylist;
    readfromFile(pointPlaylist);
    while(lll != 1){
        lll = choice(pointCommand);
        switch(lll){
        case 2: keyboard(0);
            break;
        case 3: choicePlaylists(arrPlaylist);
            break;
        case 4: keyboard(1);
            break;
        }
    }
    saveToFile(pointPlaylist);
    free(pointPlaylist);
    goodbye();
    return 0;
}
Beispiel #28
0
void InputMapper::poll() {
  activeState = !activeState;
  input.poll(stateTable[activeState]);

  modifier = 0;
  for(unsigned i = 0; i < Keyboard::Count; i++) {
    if(state(keyboard(i)[Keyboard::Shift])) modifier |= InputModifier::Shift;
    if(state(keyboard(i)[Keyboard::Control])) modifier |= InputModifier::Control;
    if(state(keyboard(i)[Keyboard::Alt])) modifier |= InputModifier::Alt;
    if(state(keyboard(i)[Keyboard::Super])) modifier |= InputModifier::Super;
  }

  for(unsigned i = 0; i < size(); i++) {
    (*this)[i]->poll();
  }

  for(unsigned i = 0; i < Scancode::Limit; i++) {
    if(state(i) != previousState(i)) {
      utility.inputEvent(i);
      diskBrowser->inputEvent(i);
      inputSettingsWindow->inputEvent(i);
    }
  }
}
Beispiel #29
0
void z_read( zmachine *zm ) {
  zbyte max = read_byte( zm, zm->zargs[0] );
  zbyte size = read_byte( zm, zm->zargs[0] + 1 );

  VALUE line;

  int i;

  if( h_version(zm) < 5 ) {
    max -= 1;
    size = 0;
  }

  line = rb_funcall( keyboard(zm), id_read_line, 1, UINT2NUM(max - size) );

  for( i = 0; i < RSTRING_LEN(line); i++ ) {
    zchar c = *(RSTRING_PTR(line) + i);

    write_byte( zm, zm->zargs[0] + text_buffer_offset(zm) + size + i, 
      translate_to_zscii( zm->m, c ) );
  }

  if( h_version(zm) < 5 ) {
    write_byte( zm, zm->zargs[0] + text_buffer_offset(zm) + size + i, 0 );
  }

  if( h_version(zm) > 4 ) {
    write_byte( zm, zm->zargs[0] + 1, i );
  }

  /* write the parse table */

  if( zm->zargs[1] != 0 ) {
    write_parse_table( zm, line, zm->zargs[1], h_dictionary(zm), 0 );
  }

  /* echo the input back to the output */

  print_cstr( zm, "> " );
  print_rstr( zm, line );
  print_cstr( zm, "\n" );

  /* store the terminating character (if required) */

  if( h_version(zm) > 4 ) {
    p_store( zm, translate_to_zscii( zm->m, 10 ) );
  }
}
void RenderWidget::keyPressEvent(QKeyEvent* event)
{
    he::io::IKeyboard* keyboard(CONTROLS->getKeyboard(getHandle()));
    if (event->isAutoRepeat() == false)
    {
        he::io::Key key(ConvertKey(event->key()));
        if (key != he::io::Key_Unknown)
            keyboard->KeyPressed(key);
    }
    if (event->text().size() > 0)
    {
        keyboard->TextEntered(event->text().toUtf8().data());
    }

    QWidget::keyPressEvent(event);
}