mirror of
https://github.com/cmosher01/Epple-II.git
synced 2024-12-26 10:32:56 +00:00
move keyrepeathandler to apple2
This commit is contained in:
parent
29165a5685
commit
077425c108
@ -33,6 +33,7 @@
|
||||
#include "diskcontroller.h"
|
||||
#include "languagecard.h"
|
||||
#include "screenimage.h"
|
||||
#include "KeyRepeatHandler.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <istream>
|
||||
@ -41,6 +42,7 @@
|
||||
Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates, AnalogTV& tv, KeyboardBufferMode& buffered, ScreenImage& gui) :
|
||||
slts(gui),
|
||||
kbd(keypresses, buffered),
|
||||
keyrepeater(keypresses),
|
||||
rom(AddressBus::MOTHERBOARD_ROM_SIZ),
|
||||
ram(revision),
|
||||
cassetteIn(gui),
|
||||
@ -83,6 +85,7 @@ void Apple2::tick() {
|
||||
this->speaker.tick();
|
||||
this->cassetteIn.tick();
|
||||
this->cassetteOut.tick();
|
||||
this->keyrepeater.tick();
|
||||
|
||||
if (this->revision > 0) {
|
||||
this->powerUpReset.tick();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "slots.h"
|
||||
#include "videomode.h"
|
||||
#include "keyboard.h"
|
||||
#include "KeyRepeatHandler.h"
|
||||
#include "addressbus.h"
|
||||
#include "memory.h"
|
||||
#include "memoryrandomaccess.h"
|
||||
@ -49,6 +50,7 @@ class Apple2 : public Timable
|
||||
Slots slts;
|
||||
VideoMode videoMode;
|
||||
Keyboard kbd;
|
||||
KeyRepeatHandler keyrepeater;
|
||||
Paddles paddles;
|
||||
SpeakerClicker speaker;
|
||||
Memory rom;
|
||||
@ -77,6 +79,8 @@ public:
|
||||
|
||||
virtual void tick();
|
||||
|
||||
KeyRepeatHandler &rept() { return this->keyrepeater; }
|
||||
|
||||
friend class Emulator;
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,6 @@ Emulator::Emulator() :
|
||||
videoStatic(display),
|
||||
apple2(keypresses, paddleButtonStates, display, buffered, screenImage),
|
||||
timable(nullptr), // No ticked object (NULL pointer)
|
||||
keyrepeater(keypresses),
|
||||
keysDown(0),
|
||||
prev_ms(SDL_GetTicks()) {
|
||||
}
|
||||
@ -110,7 +109,6 @@ void Emulator::tick50ms() {
|
||||
if (this->timable) {
|
||||
for (int i = 0; i < CHECK_EVERY_CYCLE; ++i) {
|
||||
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_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));
|
||||
|
||||
@ -217,7 +215,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) {
|
||||
}
|
||||
|
||||
if (sym == SDLK_F10) {
|
||||
this->keyrepeater.press();
|
||||
this->apple2.rept().press();
|
||||
// } else if (SDLK_F1 <= sym && sym <= SDLK_F12) {
|
||||
// wxGetApp().OnFnKeyPressed(sym);
|
||||
} else {
|
||||
@ -226,7 +224,7 @@ void Emulator::dispatchKeyDown(const SDL_KeyboardEvent& keyEvent) {
|
||||
if (sendKey) {
|
||||
//printf(" sending to apple as ASCII ------------------------------> %02X (%02X) (%d)\n", key, key | 0x80, key | 0x80);
|
||||
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)) {
|
||||
--this->keysDown;
|
||||
if (this->keysDown <= 0) {
|
||||
this->keyrepeater.clearKey();
|
||||
this->apple2.rept().clearKey();
|
||||
}
|
||||
}
|
||||
|
||||
if (sym == SDLK_F10) {
|
||||
this->keyrepeater.release();
|
||||
this->apple2.rept().release();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@ class E2Config;
|
||||
class Emulator {
|
||||
PaddleButtonStates paddleButtonStates;
|
||||
KeypressQueue keypresses;
|
||||
KeyRepeatHandler keyrepeater;
|
||||
|
||||
KeyboardBufferMode buffered;
|
||||
ScreenImage screenImage;
|
||||
|
Loading…
Reference in New Issue
Block a user