move keyrepeathandler to apple2
This commit is contained in:
parent
29165a5685
commit
077425c108
|
@ -33,6 +33,7 @@
|
||||||
#include "diskcontroller.h"
|
#include "diskcontroller.h"
|
||||||
#include "languagecard.h"
|
#include "languagecard.h"
|
||||||
#include "screenimage.h"
|
#include "screenimage.h"
|
||||||
|
#include "KeyRepeatHandler.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
@ -41,6 +42,7 @@
|
||||||
Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates, AnalogTV& tv, KeyboardBufferMode& buffered, ScreenImage& gui) :
|
Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates, AnalogTV& tv, KeyboardBufferMode& buffered, ScreenImage& gui) :
|
||||||
slts(gui),
|
slts(gui),
|
||||||
kbd(keypresses, buffered),
|
kbd(keypresses, buffered),
|
||||||
|
keyrepeater(keypresses),
|
||||||
rom(AddressBus::MOTHERBOARD_ROM_SIZ),
|
rom(AddressBus::MOTHERBOARD_ROM_SIZ),
|
||||||
ram(revision),
|
ram(revision),
|
||||||
cassetteIn(gui),
|
cassetteIn(gui),
|
||||||
|
@ -83,6 +85,7 @@ void Apple2::tick() {
|
||||||
this->speaker.tick();
|
this->speaker.tick();
|
||||||
this->cassetteIn.tick();
|
this->cassetteIn.tick();
|
||||||
this->cassetteOut.tick();
|
this->cassetteOut.tick();
|
||||||
|
this->keyrepeater.tick();
|
||||||
|
|
||||||
if (this->revision > 0) {
|
if (this->revision > 0) {
|
||||||
this->powerUpReset.tick();
|
this->powerUpReset.tick();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "slots.h"
|
#include "slots.h"
|
||||||
#include "videomode.h"
|
#include "videomode.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
#include "KeyRepeatHandler.h"
|
||||||
#include "addressbus.h"
|
#include "addressbus.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "memoryrandomaccess.h"
|
#include "memoryrandomaccess.h"
|
||||||
|
@ -49,6 +50,7 @@ class Apple2 : public Timable
|
||||||
Slots slts;
|
Slots slts;
|
||||||
VideoMode videoMode;
|
VideoMode videoMode;
|
||||||
Keyboard kbd;
|
Keyboard kbd;
|
||||||
|
KeyRepeatHandler keyrepeater;
|
||||||
Paddles paddles;
|
Paddles paddles;
|
||||||
SpeakerClicker speaker;
|
SpeakerClicker speaker;
|
||||||
Memory rom;
|
Memory rom;
|
||||||
|
@ -77,6 +79,8 @@ public:
|
||||||
|
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
|
KeyRepeatHandler &rept() { return this->keyrepeater; }
|
||||||
|
|
||||||
friend class Emulator;
|
friend class Emulator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ Emulator::Emulator() :
|
||||||
videoStatic(display),
|
videoStatic(display),
|
||||||
apple2(keypresses, paddleButtonStates, display, buffered, screenImage),
|
apple2(keypresses, paddleButtonStates, display, buffered, screenImage),
|
||||||
timable(nullptr), // No ticked object (NULL pointer)
|
timable(nullptr), // No ticked object (NULL pointer)
|
||||||
keyrepeater(keypresses),
|
|
||||||
keysDown(0),
|
keysDown(0),
|
||||||
prev_ms(SDL_GetTicks()) {
|
prev_ms(SDL_GetTicks()) {
|
||||||
}
|
}
|
||||||
|
@ -110,7 +109,6 @@ void Emulator::tick50ms() {
|
||||||
if (this->timable) {
|
if (this->timable) {
|
||||||
for (int i = 0; i < CHECK_EVERY_CYCLE; ++i) {
|
for (int i = 0; i < CHECK_EVERY_CYCLE; ++i) {
|
||||||
this->timable->tick(); // this runs the emulator!
|
this->timable->tick(); // this runs the emulator!
|
||||||
this->keyrepeater.tick(); // TODO move into Apple2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +206,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_Keycode sym = keyEvent.keysym.sym;
|
const SDL_Keycode sym = keyEvent.keysym.sym;
|
||||||
const SDL_Keymod mod = (SDL_Keymod) keyEvent.keysym.mod;
|
const SDL_Keymod mod = (SDL_Keymod)keyEvent.keysym.mod;
|
||||||
|
|
||||||
//printf("keydown: mod: %04X sym: %08X scan:%04X name:%s\n", mod, sym, scan, SDL_GetKeyName(sym));
|
//printf("keydown: mod: %04X sym: %08X scan:%04X name:%s\n", mod, sym, scan, SDL_GetKeyName(sym));
|
||||||
|
|
||||||
|
@ -217,7 +215,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sym == SDLK_F10) {
|
if (sym == SDLK_F10) {
|
||||||
this->keyrepeater.press();
|
this->apple2.rept().press();
|
||||||
// } else if (SDLK_F1 <= sym && sym <= SDLK_F12) {
|
// } else if (SDLK_F1 <= sym && sym <= SDLK_F12) {
|
||||||
// wxGetApp().OnFnKeyPressed(sym);
|
// wxGetApp().OnFnKeyPressed(sym);
|
||||||
} else {
|
} else {
|
||||||
|
@ -226,7 +224,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) {
|
||||||
if (sendKey) {
|
if (sendKey) {
|
||||||
//printf(" sending to apple as ASCII ------------------------------> %02X (%02X) (%d)\n", key, key | 0x80, key | 0x80);
|
//printf(" sending to apple as ASCII ------------------------------> %02X (%02X) (%d)\n", key, key | 0x80, key | 0x80);
|
||||||
this->keypresses.push(key);
|
this->keypresses.push(key);
|
||||||
this->keyrepeater.setKey(key);
|
this->apple2.rept().setKey(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,12 +236,12 @@ void Emulator::dispatchKeyUp(const SDL_KeyboardEvent& keyEvent) {
|
||||||
if (isKeyDown(sym, mod)) {
|
if (isKeyDown(sym, mod)) {
|
||||||
--this->keysDown;
|
--this->keysDown;
|
||||||
if (this->keysDown <= 0) {
|
if (this->keysDown <= 0) {
|
||||||
this->keyrepeater.clearKey();
|
this->apple2.rept().clearKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sym == SDLK_F10) {
|
if (sym == SDLK_F10) {
|
||||||
this->keyrepeater.release();
|
this->apple2.rept().release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ class E2Config;
|
||||||
class Emulator {
|
class Emulator {
|
||||||
PaddleButtonStates paddleButtonStates;
|
PaddleButtonStates paddleButtonStates;
|
||||||
KeypressQueue keypresses;
|
KeypressQueue keypresses;
|
||||||
KeyRepeatHandler keyrepeater;
|
|
||||||
|
|
||||||
KeyboardBufferMode buffered;
|
KeyboardBufferMode buffered;
|
||||||
ScreenImage screenImage;
|
ScreenImage screenImage;
|
||||||
|
|
Loading…
Reference in New Issue