mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Adds type recipient as a dynamic type, and accepts paste and fullscreen toggle in SDL.
This commit is contained in:
parent
89c3e2ba5a
commit
3365ff0200
@ -41,6 +41,10 @@ template<typename T> class TypedDynamicMachine: public ::Machine::DynamicMachine
|
|||||||
return get<Configurable::Device>();
|
return get<Configurable::Device>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utility::TypeRecipient *type_recipient() override {
|
||||||
|
return get<Utility::TypeRecipient>();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename Class> Class *get() {
|
template <typename Class> Class *get() {
|
||||||
return dynamic_cast<Class *>(machine_.get());
|
return dynamic_cast<Class *>(machine_.get());
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "../CRTMachine.hpp"
|
#include "../CRTMachine.hpp"
|
||||||
#include "../JoystickMachine.hpp"
|
#include "../JoystickMachine.hpp"
|
||||||
#include "../KeyboardMachine.hpp"
|
#include "../KeyboardMachine.hpp"
|
||||||
|
#include "Typer.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -32,6 +33,7 @@ struct DynamicMachine {
|
|||||||
virtual JoystickMachine::Machine *joystick_machine() = 0;
|
virtual JoystickMachine::Machine *joystick_machine() = 0;
|
||||||
virtual KeyboardMachine::Machine *keyboard_machine() = 0;
|
virtual KeyboardMachine::Machine *keyboard_machine() = 0;
|
||||||
virtual Configurable::Device *configurable_device() = 0;
|
virtual Configurable::Device *configurable_device() = 0;
|
||||||
|
virtual Utility::TypeRecipient *type_recipient() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -382,6 +382,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// Run the main event loop until the OS tells us to quit.
|
// Run the main event loop until the OS tells us to quit.
|
||||||
bool should_quit = false;
|
bool should_quit = false;
|
||||||
|
Uint32 fullscreen_mode = 0;
|
||||||
while(!should_quit) {
|
while(!should_quit) {
|
||||||
// Process all pending events.
|
// Process all pending events.
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
@ -408,6 +409,23 @@ int main(int argc, char *argv[]) {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
// Syphon off the key-press if it's control+shift+V (paste).
|
||||||
|
if(event.key.keysym.sym == SDLK_v && (SDL_GetModState()&KMOD_CTRL) && (SDL_GetModState()&KMOD_SHIFT)) {
|
||||||
|
Utility::TypeRecipient *type_recipient = machine->type_recipient();
|
||||||
|
if(type_recipient) {
|
||||||
|
type_recipient->set_typer_for_string(SDL_GetClipboardText());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also syphon off alt+enter (toggle full-screen).
|
||||||
|
if(event.key.keysym.sym == SDLK_RETURN && (SDL_GetModState()&KMOD_ALT)) {
|
||||||
|
fullscreen_mode ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
|
SDL_SetWindowFullscreen(window, fullscreen_mode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// deliberate fallthrough...
|
||||||
case SDL_KEYUP: {
|
case SDL_KEYUP: {
|
||||||
KeyboardMachine::Machine *keyboard_machine = machine->keyboard_machine();
|
KeyboardMachine::Machine *keyboard_machine = machine->keyboard_machine();
|
||||||
if(!keyboard_machine) break;
|
if(!keyboard_machine) break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user