mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
refactoring
This commit is contained in:
@@ -19,43 +19,41 @@
|
||||
# #
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#include "usb/hid.h"
|
||||
#include "ps2/hid.h"
|
||||
#include "factory.h"
|
||||
|
||||
namespace DRIVERS
|
||||
{
|
||||
|
||||
namespace DRIVERS {
|
||||
Keyboard *Factory::makeKeyboard(type _type) {
|
||||
switch (_type) {
|
||||
|
||||
# ifdef HID_WITH_USB
|
||||
# ifdef HID_WITH_USB
|
||||
case USB_KEYBOARD:
|
||||
return new UsbKeyboard();
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef HID_WITH_PS2
|
||||
# ifdef HID_WITH_PS2
|
||||
case PS2_KEYBOARD:
|
||||
return new Ps2Keyboard();
|
||||
# endif
|
||||
# endif
|
||||
|
||||
default:
|
||||
return new Keyboard(DUMMY);
|
||||
}
|
||||
}
|
||||
|
||||
Mouse *Factory::makeMouse(type _type) {
|
||||
switch(_type)
|
||||
{
|
||||
# ifdef HID_WITH_USB
|
||||
switch (_type) {
|
||||
# ifdef HID_WITH_USB
|
||||
case USB_MOUSE_ABSOLUTE:
|
||||
case USB_MOUSE_ABSOLUTE_WIN98:
|
||||
return new UsbMouseAbsolute(_type);
|
||||
case USB_MOUSE_RELATIVE:
|
||||
return new UsbMouseRelative();
|
||||
# endif
|
||||
# endif
|
||||
default:
|
||||
return new Mouse(DRIVERS::DUMMY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include "spi.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
|
||||
|
||||
static volatile uint8_t _spi_in[8] = {0};
|
||||
static volatile uint8_t _spi_in_index = 0;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
|
||||
|
||||
void spiBegin();
|
||||
|
||||
@@ -69,6 +69,7 @@ using namespace DRIVERS;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class UsbKeyboard : public DRIVERS::Keyboard {
|
||||
public:
|
||||
UsbKeyboard() : DRIVERS::Keyboard(DRIVERS::USB_KEYBOARD) {}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "keyboard.h"
|
||||
#include "mouse.h"
|
||||
|
||||
namespace DRIVERS {
|
||||
|
||||
namespace DRIVERS {
|
||||
struct Factory {
|
||||
static Keyboard *makeKeyboard(type _type);
|
||||
static Mouse *makeMouse(type _type);
|
||||
|
||||
@@ -64,6 +64,5 @@ namespace DRIVERS {
|
||||
KeyboardLedsState result = {0};
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
# #
|
||||
*****************************************************************************/
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
|
||||
bool is_micros_timed_out(unsigned long start_ts, unsigned long timeout) {
|
||||
unsigned long now = micros();
|
||||
|
||||
@@ -22,5 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
bool is_micros_timed_out(unsigned long start_ts, unsigned long timeout);
|
||||
|
||||
Reference in New Issue
Block a user