/** * Simulate press or release of a key corresponding to given character */ void Keymap_SimulateCharacter(char asckey, bool press) { SDL_Keysym sdlkey; sdlkey.mod = KMOD_NONE; sdlkey.scancode = 0; if (isupper(asckey)) { if (press) { sdlkey.sym = SDLK_LSHIFT; Keymap_KeyDown(&sdlkey); } sdlkey.sym = tolower(asckey); sdlkey.mod = KMOD_LSHIFT; } else { sdlkey.sym = asckey; } if (press) { Keymap_KeyDown(&sdlkey); } else { Keymap_KeyUp(&sdlkey); if (isupper(asckey)) { sdlkey.sym = SDLK_LSHIFT; Keymap_KeyUp(&sdlkey); } } }
void Process_key() { int i; for(i=0; i<320; i++) Key_Sate[i]=input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,i) ? 0x80: 0; if(memcmp( Key_Sate,old_Key_Sate , sizeof(Key_Sate) ) ) for(i=0; i<320; i++) if(Key_Sate[i] && Key_Sate[i]!=old_Key_Sate[i] ) { if(i==RETROK_RALT) { //KBMOD=-KBMOD; //printf("Modifier pressed %d \n",KBMOD); continue; } Keymap_KeyDown(i); } else if ( !Key_Sate[i] && Key_Sate[i]!=old_Key_Sate[i] ) { if(i==RETROK_RALT) { //KBMOD=-KBMOD; //printf("Modifier pressed %d \n",KBMOD); continue; } Keymap_KeyUp(i); } memcpy(old_Key_Sate,Key_Sate , sizeof(Key_Sate) ); }
/** * SDL message handler. * Here we process the SDL events (keyboard, mouse, ...) and map it to * Atari IKBD events. */ void Main_EventHandler(void) { bool bContinueProcessing; SDL_Event event; int events; int remotepause; do { bContinueProcessing = false; /* check remote process control */ remotepause = Control_CheckUpdates(); if ( bEmulationActive || remotepause ) { events = SDL_PollEvent(&event); } else { ShortCut_ActKey(); /* last (shortcut) event activated emulation? */ if ( bEmulationActive ) break; events = SDL_WaitEvent(&event); } if (!events) { /* no events -> if emulation is active or * user is quitting -> return from function. */ continue; } switch (event.type) { case SDL_QUIT: Main_RequestQuit(); break; case SDL_MOUSEMOTION: /* Read/Update internal mouse position */ Main_HandleMouseMotion(&event); bContinueProcessing = false; break; case SDL_MOUSEBUTTONDOWN: if (event.button.button == SDL_BUTTON_LEFT) { if (ConfigureParams.Mouse.bEnableAutoGrab && !bGrabMouse) { bGrabMouse = true; /* Toggle flag */ /* If we are in windowed mode, toggle the mouse cursor mode now: */ if (!bInFullScreen) { SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetWindowGrab(sdlWindow, SDL_TRUE); Main_SetTitle(MOUSE_LOCK_MSG); } } Keymap_MouseDown(true); } else if (event.button.button == SDL_BUTTON_RIGHT) { Keymap_MouseDown(false); // Keyboard.bRButtonDown |= BUTTON_MOUSE; } else if (event.button.button == SDL_BUTTON_MIDDLE) { /* Start double-click sequence in emulation time */ // Keyboard.LButtonDblClk = 1; } break; case SDL_MOUSEBUTTONUP: if (event.button.button == SDL_BUTTON_LEFT) { Keymap_MouseUp(true); // Keyboard.bLButtonDown &= ~BUTTON_MOUSE; } else if (event.button.button == SDL_BUTTON_RIGHT) { Keymap_MouseUp(false); // Keyboard.bRButtonDown &= ~BUTTON_MOUSE; } break; case SDL_KEYDOWN: if (ConfigureParams.Keyboard.bDisableKeyRepeat && event.key.repeat) break; Keymap_KeyDown(&event.key.keysym); break; case SDL_KEYUP: Keymap_KeyUp(&event.key.keysym); break; default: /* don't let unknown events delay event processing */ bContinueProcessing = true; break; } } while (bContinueProcessing || !(bEmulationActive || bQuitProgram)); }