Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeralChild64 <unknown>2022-10-07 08:29:11 +0300
committerkcgen <1557255+kcgen@users.noreply.github.com>2022-10-22 21:15:34 +0300
commitb2e3cef0eb5b297eed194c92e6fd16254bd50910 (patch)
treee9298418e2a39c4c70820323f3b1fadda64a31ea /include
parent1d8a5cfa903398d82513f86a155b22abec6901eb (diff)
Add mouse mapper, config tool and config section
Diffstat (limited to 'include')
-rw-r--r--include/mouse.h175
-rw-r--r--include/sdlmain.h2
2 files changed, 158 insertions, 19 deletions
diff --git a/include/mouse.h b/include/mouse.h
index 44c528f08..3a704546b 100644
--- a/include/mouse.h
+++ b/include/mouse.h
@@ -22,39 +22,79 @@
#include "dosbox.h"
+#include <regex>
+#include <string>
+#include <vector>
+
+// ***************************************************************************
+// Initialization, configuration
+// ***************************************************************************
+
+void MOUSE_Init(Section * );
+void MOUSE_AddConfigSection(const config_ptr_t &);
+
+// ***************************************************************************
+// Data types
+// ***************************************************************************
+
+enum class MouseInterfaceId : uint8_t {
+ DOS, // emulated DOS mouse driver
+ PS2, // PS/2 mouse (this includes VMware mouse protocol)
+ COM1, // serial mouse
+ COM2,
+ COM3,
+ COM4,
+
+ First = DOS,
+ Last = COM4,
+ None = UINT8_MAX
+};
+
+constexpr uint8_t num_mouse_interfaces_com = 4;
+constexpr uint8_t num_mouse_interfaces = static_cast<uint8_t>(MouseInterfaceId::Last) + 1;
+
+
+enum class MouseMapStatus : uint8_t {
+ HostPointer,
+ Mapped, // single physical mouse mapped to emulated port
+ Disconnected, // physical mouse used to be mapped, but got unplugged
+ Disabled
+};
+
// ***************************************************************************
// Notifications from external subsystems - all should go via these methods
// ***************************************************************************
-void MOUSE_EventMoved(const float x_rel, const float y_rel,
+void MOUSE_EventMoved(const float x_rel, const float y_rel,
const uint16_t x_abs, const uint16_t y_abs);
-void MOUSE_EventPressed(const uint8_t idx);
-void MOUSE_EventReleased(const uint8_t idx);
+void MOUSE_EventMoved(const float x_rel, const float y_rel,
+ const MouseInterfaceId device_id);
+
+void MOUSE_EventButton(const uint8_t idx, const bool pressed);
+void MOUSE_EventButton(const uint8_t idx, const bool pressed,
+ const MouseInterfaceId device_id);
+
void MOUSE_EventWheel(const int16_t w_rel);
+void MOUSE_EventWheel(const int16_t w_rel,
+ const MouseInterfaceId device_id);
-void MOUSE_SetConfig(const bool raw_input);
+void MOUSE_NotifyBooting();
+
+void MOUSE_SetConfig(const bool raw_input,
+ const float sensitivity_x,
+ const float sensitivity_y);
+void MOUSE_SetNoMouse();
void MOUSE_NewScreenParams(const uint16_t clip_x, const uint16_t clip_y,
const uint16_t res_x, const uint16_t res_y,
const bool fullscreen, const uint16_t x_abs,
const uint16_t y_abs);
// ***************************************************************************
-// Common structures and variables
+// Variables shared with external modules
// ***************************************************************************
// If driver with seamless pointer support is running
extern bool mouse_seamless_driver;
-// Suggestion to GUI to show host pointer despite other conditions
-extern bool mouse_suggest_show; // TODO: use this information
-
-// ***************************************************************************
-// Serial mouse
-// ***************************************************************************
-
-class CSerialMouse;
-
-void MOUSESERIAL_RegisterListener(CSerialMouse &listener);
-void MOUSESERIAL_UnRegisterListener(CSerialMouse &listener);
// ***************************************************************************
// BIOS mouse interface for PS/2 mouse
@@ -67,7 +107,7 @@ bool MOUSEBIOS_SetPacketSize(const uint8_t packet_size);
bool MOUSEBIOS_SetSampleRate(const uint8_t rate_id);
void MOUSEBIOS_SetScaling21(const bool enable);
bool MOUSEBIOS_SetResolution(const uint8_t res_id);
-uint8_t MOUSEBIOS_GetType();
+uint8_t MOUSEBIOS_GetProtocol();
uint8_t MOUSEBIOS_GetStatus();
uint8_t MOUSEBIOS_GetResolution();
uint8_t MOUSEBIOS_GetSampleRate();
@@ -79,4 +119,105 @@ uint8_t MOUSEBIOS_GetSampleRate();
void MOUSEDOS_BeforeNewVideoMode();
void MOUSEDOS_AfterNewVideoMode(const bool setmode);
+// ***************************************************************************
+// MOUSECTL.COM / GUI configurator interface
+// ***************************************************************************
+
+class MouseInterface;
+class MousePhysical;
+
+class MouseInterfaceInfoEntry final {
+public:
+
+ bool IsEmulated() const;
+ bool IsMapped() const;
+ bool IsMapped(const uint8_t device_idx) const;
+ bool IsMappedDeviceDisconnected() const;
+
+ MouseInterfaceId GetInterfaceId() const;
+ MouseMapStatus GetMapStatus() const;
+ const std::string &GetMappedDeviceName() const;
+ uint8_t GetSensitivityX() const; // 1-99
+ uint8_t GetSensitivityY() const; // 1-99
+ uint16_t GetMinRate() const; // 10-500, 0 for none
+ uint16_t GetRate() const; // current rate, 10-500, 0 for N/A
+
+private:
+
+ friend class MouseInterface;
+ MouseInterfaceInfoEntry(const MouseInterfaceId interface_id);
+
+ const uint8_t idx;
+ const MouseInterface &Interface() const;
+ const MousePhysical &MappedPhysical() const;
+};
+
+class MousePhysicalInfoEntry final {
+public:
+
+ bool IsMapped() const;
+ bool IsDeviceDisconnected() const;
+ const std::string &GetDeviceName() const;
+
+private:
+
+ friend class ManyMouseGlue;
+ MousePhysicalInfoEntry(const uint8_t idx);
+
+ const uint8_t idx;
+ const MousePhysical &Physical() const;
+};
+
+class MouseConfigAPI final {
+public:
+
+ // Always destroy the object once it is not needed anymore
+ // (configuration tool finishes it's job) and we are returning
+ // to normal code excution!
+
+ MouseConfigAPI();
+ ~MouseConfigAPI();
+
+ // Empty list = performs operation on all emulated interfaces
+ typedef std::vector<MouseInterfaceId> ListIDs;
+
+ // Do not use the references after object gets destroyed
+ const std::vector<MouseInterfaceInfoEntry> &GetInfoInterfaces() const;
+ const std::vector<MousePhysicalInfoEntry> &GetInfoPhysical();
+
+ static bool CheckInterfaces(const ListIDs &list_ids);
+ static bool PatternToRegex(const std::string &pattern, std::regex &regex);
+ bool ProbeForMapping(uint8_t &device_id); // for MOUSECTL.COM only!
+
+ bool Map(const MouseInterfaceId interface_id, const uint8_t device_idx);
+ bool Map(const MouseInterfaceId interface_id, const std::regex &regex);
+ bool UnMap(const ListIDs &list_ids);
+
+ bool OnOff(const ListIDs &list_ids, const bool enable);
+ bool Reset(const ListIDs &list_ids);
+
+ // Valid sensitivity values are 1-99
+ bool SetSensitivity(const ListIDs &list_ids,
+ const uint8_t sensitivity_x,
+ const uint8_t sensitivity_y);
+ bool SetSensitivityX(const ListIDs &list_ids,
+ const uint8_t sensitivity_x);
+ bool SetSensitivityY(const ListIDs &list_ids,
+ const uint8_t sensitivity_y);
+
+ bool ResetSensitivity(const ListIDs &list_ids);
+ bool ResetSensitivityX(const ListIDs &list_ids);
+ bool ResetSensitivityY(const ListIDs &list_ids);
+
+ static const std::vector<uint16_t> &GetValidMinRateList();
+ static const std::string &GetValidMinRateStr();
+ bool SetMinRate(const MouseConfigAPI::ListIDs &list_ids,
+ const uint16_t value_hz);
+ bool ResetMinRate(const MouseConfigAPI::ListIDs &list_ids);
+
+private:
+ MouseConfigAPI(const MouseConfigAPI &) = delete;
+ MouseConfigAPI &operator=(const MouseConfigAPI &) = delete;
+};
+
#endif // DOSBOX_MOUSE_H
diff --git a/include/sdlmain.h b/include/sdlmain.h
index 03f978fba..cbf17c200 100644
--- a/include/sdlmain.h
+++ b/include/sdlmain.h
@@ -233,8 +233,6 @@ struct SDL_Block {
int period_us_late = 0;
} frame = {};
struct {
- float xsensitivity = 0.3f;
- float ysensitivity = 0.3f;
MouseControlType control_choice = Seamless;
bool middle_will_release = true;
bool has_focus = false;