dingusppc/devices/adb.cpp

107 lines
2.6 KiB
C++
Raw Normal View History

2020-04-21 22:23:55 +00:00
/*
DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-20 divingkatae and maximum
(theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-04-22 21:14:49 +00:00
/** ADB bus definitions
2020-04-21 22:23:55 +00:00
2020-04-22 21:14:49 +00:00
Simulates Apple Desktop Bus (ADB) bus
2020-04-21 22:23:55 +00:00
*/
2020-04-22 21:14:49 +00:00
#include <array>
2020-04-21 22:23:55 +00:00
#include <cinttypes>
#include <cstring>
#include "adb.h"
2020-04-22 21:14:49 +00:00
#include "adbkeybd.h"
#include "adbmouse.h"
2020-04-21 22:23:55 +00:00
#include <thirdparty/SDL2/include/SDL.h>
#include <thirdparty/SDL2/include/SDL_events.h>
#include <thirdparty/SDL2/include/SDL_keycode.h>
#include <thirdparty/SDL2/include/SDL_mouse.h>
#include <thirdparty/SDL2/include/SDL_stdinc.h>
using namespace std;
2020-04-22 21:14:49 +00:00
ADB_Bus::ADB_Bus() {
//set data streams as clear
input_stream_len = 0;
output_stream_len = 0;
2020-04-21 22:23:55 +00:00
2020-04-22 21:14:49 +00:00
this->keyboard = new ADB_Keybd();
this->mouse = new ADB_Mouse();
2020-04-21 22:23:55 +00:00
}
2020-04-22 21:14:49 +00:00
ADB_Bus::~ADB_Bus() {
2020-04-21 22:23:55 +00:00
}
2020-04-22 21:14:49 +00:00
void ADB_Bus::add_adb_device(int type) {
2020-04-21 22:23:55 +00:00
}
2020-04-22 21:14:49 +00:00
bool ADB_Bus::adb_verify_listen(int device, int reg) {
switch (device) {
case 0:
if ((reg == 0) | (reg == 2)) {
output_stream_len = 2;
for (int i = 0; output_stream_len < 2; i++) {
output_data_stream[i] = this->keyboard->copy_stream_byte(i);
}
return true;
}
else {
return false;
}
case 1:
if (reg == 0) {
output_stream_len = 2;
for (int i = 0; output_stream_len < 2; i++) {
output_data_stream[i] = this->mouse->copy_stream_byte(i);
}
return true;
}
else {
return false;
}
default:
return false;
}
}
2020-04-21 22:23:55 +00:00
2020-04-22 21:14:49 +00:00
bool ADB_Bus::adb_verify_talk(int device, int reg) {
//temp code
return false;
}
2020-04-21 22:23:55 +00:00
2020-04-22 21:14:49 +00:00
uint8_t ADB_Bus::get_input_byte(int offset) {
return input_data_stream[offset];
}
2020-04-22 02:45:59 +00:00
2020-04-22 21:14:49 +00:00
uint8_t ADB_Bus::get_output_byte(int offset) {
return output_data_stream[offset];
}
2020-04-22 02:45:59 +00:00
2020-04-22 21:14:49 +00:00
int ADB_Bus::get_input_len() {
return input_stream_len;
2020-04-21 22:23:55 +00:00
}
2020-04-22 21:14:49 +00:00
int ADB_Bus::get_output_len() {
return output_stream_len;
}