Slightly clean-up and expansion for future uses

This commit is contained in:
dingusdev 2020-04-23 18:22:47 -07:00
parent c0d0187190
commit f2ab933884
3 changed files with 30 additions and 7 deletions

View File

@ -28,12 +28,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cinttypes>
#include <cstring>
#include "devices/adb.h"
#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>
#include <thirdparty/loguru/loguru.hpp>
using namespace std;
ADB_Bus::ADB_Bus() {
@ -54,7 +57,7 @@ ADB_Bus::~ADB_Bus() {
}
bool ADB_Bus::adb_verify_listen(int device, int reg) {
bool ADB_Bus::listen(int device, int reg) {
if (device == keyboard_access_no) {
if (adb_keybd_listen(reg)) {
return true;
@ -71,11 +74,28 @@ bool ADB_Bus::adb_verify_listen(int device, int reg) {
return false;
}
}
else {
return false;
}
}
bool ADB_Bus::talk(int device, int reg, uint16_t value) {
//temp code
return false;
}
bool ADB_Bus::adb_verify_talk(int device, int reg) {
bool ADB_Bus::bus_reset() {
//temp code
return true;
}
bool ADB_Bus::set_addr(int dev_addr, int new_addr) {
//temp code
return false;
}
bool ADB_Bus::flush(int dev_addr) {
//temp code
return false;
}

View File

@ -39,8 +39,11 @@ public:
ADB_Bus();
~ADB_Bus();
bool adb_verify_listen(int device, int reg);
bool adb_verify_talk(int device, int reg);
bool listen(int device, int reg);
bool talk(int device, int reg, uint16_t value);
bool bus_reset();
bool set_addr(int dev_addr, int new_addr);
bool flush(int dev_addr);
bool adb_keybd_listen(int reg);
bool adb_mouse_listen(int reg);

View File

@ -307,7 +307,7 @@ void ViaCuda::process_adb_command(uint8_t cmd_byte, int data_count)
else if ((cmd & 0xC) == 8) {
LOG_F(9, "Cuda: ADB Listen command requested\n");
int adb_reg = cmd_byte & 0x3;
if (adb_obj->adb_verify_listen(adb_dev, adb_reg)){
if (adb_obj->listen(adb_dev, adb_reg)){
response_header(CUDA_PKT_ADB, 0);
for (int data_ptr = 0; data_ptr < adb_obj->get_output_len(); data_ptr++) {
this->in_buf[(2 + data_ptr)] = adb_obj->get_output_byte(data_ptr);
@ -321,7 +321,7 @@ void ViaCuda::process_adb_command(uint8_t cmd_byte, int data_count)
LOG_F(9, "Cuda: ADB Talk command requested\n");
response_header(CUDA_PKT_ADB, 0);
int adb_reg = cmd_byte & 0x3;
if (adb_obj->adb_verify_talk(adb_dev, adb_reg)) {
if (adb_obj->talk(adb_dev, adb_reg, this->in_buf[2])) {
response_header(CUDA_PKT_ADB, 0);
}
else {