mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-08-07 17:25:08 +00:00
Started work on keyboard input
This commit is contained in:
@@ -38,6 +38,8 @@ public:
|
|||||||
enum : uint32_t {
|
enum : uint32_t {
|
||||||
MOUSE_EVENT_MOTION = 1 << 0,
|
MOUSE_EVENT_MOTION = 1 << 0,
|
||||||
MOUSE_EVENT_BUTTON = 1 << 1,
|
MOUSE_EVENT_BUTTON = 1 << 1,
|
||||||
|
KEYBOARD_EVENT_DOWN = 1 << 0,
|
||||||
|
KEYBOARD_EVENT_UP = 1 << 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
class MouseEvent {
|
class MouseEvent {
|
||||||
@@ -51,6 +53,16 @@ public:
|
|||||||
uint8_t buttons_state;
|
uint8_t buttons_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class KeyboardEvent {
|
||||||
|
public:
|
||||||
|
KeyboardEvent() = default;
|
||||||
|
~KeyboardEvent() = default;
|
||||||
|
|
||||||
|
uint32_t flags;
|
||||||
|
uint32_t key;
|
||||||
|
uint16_t keys_state;
|
||||||
|
};
|
||||||
|
|
||||||
class EventManager {
|
class EventManager {
|
||||||
public:
|
public:
|
||||||
static EventManager* get_instance() {
|
static EventManager* get_instance() {
|
||||||
@@ -72,6 +84,11 @@ public:
|
|||||||
_mouse_signal.connect_method(inst, func);
|
_mouse_signal.connect_method(inst, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void add_keyboard_handler(T* inst, void (T::*func)(const KeyboardEvent&)) {
|
||||||
|
_keyboard_signal.connect_method(inst, func);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void add_post_handler(T *inst, void (T::*func)()) {
|
void add_post_handler(T *inst, void (T::*func)()) {
|
||||||
_post_signal.connect_method(inst, func);
|
_post_signal.connect_method(inst, func);
|
||||||
@@ -81,9 +98,10 @@ private:
|
|||||||
static EventManager* event_manager;
|
static EventManager* event_manager;
|
||||||
EventManager() {}; // private constructor to implement a singleton
|
EventManager() {}; // private constructor to implement a singleton
|
||||||
|
|
||||||
CoreSignal<const WindowEvent&> _window_signal;
|
CoreSignal<const WindowEvent&> _window_signal;
|
||||||
CoreSignal<const MouseEvent&> _mouse_signal;
|
CoreSignal<const MouseEvent&> _mouse_signal;
|
||||||
CoreSignal<> _post_signal;
|
CoreSignal<const KeyboardEvent&> _keyboard_signal;
|
||||||
|
CoreSignal<> _post_signal;
|
||||||
|
|
||||||
uint64_t events_captured = 0;
|
uint64_t events_captured = 0;
|
||||||
uint64_t unhandled_events = 0;
|
uint64_t unhandled_events = 0;
|
||||||
|
84
devices/common/adb/adbkeyboard.cpp
Normal file
84
devices/common/adb/adbkeyboard.cpp
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||||
|
Copyright (C) 2018-23 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Apple Desktop Bus Keyboard emulation. */
|
||||||
|
|
||||||
|
#include <devices/common/adb/adbkeyboard.h>
|
||||||
|
#include <devices/deviceregistry.h>
|
||||||
|
|
||||||
|
AdbKeyboard::AdbKeyboard(std::string name) : AdbDevice(name) {
|
||||||
|
EventManager::get_instance()->add_keyboard_handler(this, &AdbKeyboard::event_handler);
|
||||||
|
|
||||||
|
this->reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdbKeyboard::event_handler(const KeyboardEvent& event) {
|
||||||
|
if (event.flags & KEYBOARD_EVENT_DOWN) {
|
||||||
|
}
|
||||||
|
else if (event.flags & KEYBOARD_EVENT_UP) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdbKeyboard::reset() {
|
||||||
|
this->my_addr = ADB_ADDR_KBD;
|
||||||
|
this->dev_handler_id = 2; // Extended ADB keyboard
|
||||||
|
this->exc_event_flag = 2;
|
||||||
|
this->srq_flag = 1; // enable service requests
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AdbKeyboard::get_register_0() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdbKeyboard::set_register_2() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdbKeyboard::set_register_3() {
|
||||||
|
if (this->host_obj->get_input_count() < 2) // ensure we got enough data
|
||||||
|
return;
|
||||||
|
|
||||||
|
const uint8_t* in_data = this->host_obj->get_input_buf();
|
||||||
|
|
||||||
|
switch (in_data[1]) {
|
||||||
|
case 0:
|
||||||
|
this->my_addr = in_data[0] & 0xF;
|
||||||
|
this->srq_flag = !!(in_data[0] & 0x20);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
this->dev_handler_id = in_data[1];
|
||||||
|
break;
|
||||||
|
case 3: // extended keyboard protocol isn't supported yet
|
||||||
|
break;
|
||||||
|
case 0xFE: // move to a new address if there was no collision
|
||||||
|
if (!this->got_collision) {
|
||||||
|
this->my_addr = in_data[0] & 0xF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG_F(WARNING, "%s: unknown handler ID = 0x%X", this->name.c_str(), in_data[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const DeviceDescription AdbKeyboard_Descriptor = {
|
||||||
|
AdbKeyboard::create, {}, {}
|
||||||
|
};
|
||||||
|
|
||||||
|
REGISTER_DEVICE(AdbKeyboard, AdbKeyboard_Descriptor);
|
58
devices/common/adb/adbkeyboard.h
Normal file
58
devices/common/adb/adbkeyboard.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||||
|
Copyright (C) 2018-23 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file Apple Desktop Bus Keyboard definitions. */
|
||||||
|
|
||||||
|
#ifndef ADB_KEYBOARD_H
|
||||||
|
#define ADB_KEYBOARD_H
|
||||||
|
|
||||||
|
#include <core/hostevents.h>
|
||||||
|
#include <devices/common/adb/adbdevice.h>
|
||||||
|
#include <devices/common/hwcomponent.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class AdbKeyboard : public AdbDevice {
|
||||||
|
public:
|
||||||
|
AdbKeyboard(std::string name);
|
||||||
|
~AdbKeyboard() = default;
|
||||||
|
|
||||||
|
static std::unique_ptr<HWComponent> create() {
|
||||||
|
return std::unique_ptr<AdbKeyboard>(new AdbKeyboard("ADB-KEYBOARD"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() override;
|
||||||
|
void event_handler(const KeyboardEvent& event);
|
||||||
|
|
||||||
|
bool get_register_0() override;
|
||||||
|
void set_register_2() override;
|
||||||
|
void set_register_3() override;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t x_rel = 0;
|
||||||
|
int32_t y_rel = 0;
|
||||||
|
uint8_t buttons_state = 0;
|
||||||
|
bool changed = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ADB_KEYBOARD_H
|
@@ -731,7 +731,7 @@ void ViaCuda::i2c_comb_transaction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const vector<string> Cuda_Subdevices = {
|
static const vector<string> Cuda_Subdevices = {
|
||||||
"AdbBus", "AdbMouse"
|
"AdbBus", "AdbMouse", "AdbKeyboard"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const DeviceDescription ViaCuda_Descriptor = {
|
static const DeviceDescription ViaCuda_Descriptor = {
|
||||||
|
Reference in New Issue
Block a user