libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
ControlDeck.h
Go to the documentation of this file.
1#pragma once
2
3#include "ControlPort.h"
4#include <vector>
10#include "ship/controller/controldevice/controller/mapping/ControllerDefaultMappings.h"
11#include "ship/core/Component.h"
12#include "ship/window/Window.h"
13
14namespace Ship {
15class WheelHandler;
16
38class ControlDeck : public Component {
39 public:
48 ControlDeck(std::vector<CONTROLLERBUTTONS_T> additionalBitmasks,
49 std::shared_ptr<ControllerDefaultMappings> controllerDefaultMappings,
50 std::unordered_map<CONTROLLERBUTTONS_T, std::string> buttonNames,
51 std::shared_ptr<Window> window = nullptr, std::shared_ptr<ConsoleVariable> consoleVariable = nullptr);
53
58 void Init(uint8_t* controllerBits);
67 virtual void WriteToPad(void* pads) = 0;
76 std::shared_ptr<Controller> GetControllerByPort(uint8_t port);
85 void BlockGameInput(int32_t blockId);
90 void UnblockGameInput(int32_t blockId);
103 bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode);
110 bool ProcessMouseButtonEvent(bool isPressed, MouseBtn button);
111
113 std::shared_ptr<ConnectedPhysicalDeviceManager> GetConnectedPhysicalDeviceManager();
115 std::shared_ptr<GlobalSDLDeviceSettings> GetGlobalSDLDeviceSettings();
117 std::shared_ptr<ControllerDefaultMappings> GetControllerDefaultMappings();
119 std::shared_ptr<WheelHandler> GetWheelHandler() const;
123 const std::unordered_map<CONTROLLERBUTTONS_T, std::string>& GetAllButtonNames() const;
130
131 protected:
139 std::vector<std::shared_ptr<ControlPort>> mPorts = {};
140
141 private:
142 uint8_t* mControllerBits = nullptr;
143 std::unordered_map<int32_t, bool> mGameInputBlockers;
144 std::shared_ptr<ConnectedPhysicalDeviceManager> mConnectedPhysicalDeviceManager;
145 std::shared_ptr<GlobalSDLDeviceSettings> mGlobalSDLDeviceSettings;
146 std::shared_ptr<ControllerDefaultMappings> mControllerDefaultMappings;
147 std::unordered_map<CONTROLLERBUTTONS_T, std::string> mButtonNames;
148 std::shared_ptr<Window> mWindow;
149 std::shared_ptr<ConsoleVariable> mConsoleVariables;
150 std::shared_ptr<WheelHandler> mWheelHandler;
151
153 std::shared_ptr<Window> GetWindow() const;
155 std::shared_ptr<ConsoleVariable> GetConsoleVariables() const;
156};
157} // namespace Ship
#define CONTROLLERBUTTONS_T
Definition ControllerButtonMapping.h:13
A named Part with a parent/child hierarchy and optional thread safety.
Definition Component.h:34
Manages all controller ports and routes input/blocking requests.
Definition ControlDeck.h:38
bool AllGameInputBlocked()
Returns true if all registered blockers have blocked game input.
ControlDeck(std::vector< CONTROLLERBUTTONS_T > additionalBitmasks, std::shared_ptr< ControllerDefaultMappings > controllerDefaultMappings, std::unordered_map< CONTROLLERBUTTONS_T, std::string > buttonNames, std::shared_ptr< Window > window=nullptr, std::shared_ptr< ConsoleVariable > consoleVariable=nullptr)
Constructs the ControlDeck and sets up the port list.
void BlockGameInput(int32_t blockId)
Blocks all game input for the caller identified by blockId.
void Init(uint8_t *controllerBits)
Initialises the controller deck and loads saved mappings from Config.
const std::unordered_map< CONTROLLERBUTTONS_T, std::string > & GetAllButtonNames() const
Returns the full bitmask→name map for all registered buttons.
std::vector< std::shared_ptr< ControlPort > > mPorts
One entry per controller port.
Definition ControlDeck.h:139
uint8_t * GetControllerBits()
Returns the pointer passed to Init() that tracks which ports have controllers.
std::shared_ptr< GlobalSDLDeviceSettings > GetGlobalSDLDeviceSettings()
Returns the global SDL device settings (dead-zone, axis scale, etc.).
bool MouseGameInputBlocked()
Returns true if any blocker has blocked mouse game input.
std::shared_ptr< ControllerDefaultMappings > GetControllerDefaultMappings()
Returns the default mapping configuration applied to new controllers.
void UnblockGameInput(int32_t blockId)
Removes the block associated with blockId.
bool KeyboardGameInputBlocked()
Returns true if any blocker has blocked keyboard game input.
std::shared_ptr< ConnectedPhysicalDeviceManager > GetConnectedPhysicalDeviceManager()
Returns the manager that tracks currently connected SDL/HID devices.
std::string GetButtonNameForBitmask(CONTROLLERBUTTONS_T bitmask)
Returns the human-readable name for the given button bitmask.
std::shared_ptr< Controller > GetControllerByPort(uint8_t port)
Returns the Controller connected to the given port, or nullptr.
virtual void WriteToPad(void *pads)=0
Reads controller state and writes it to the game-specific pad structure(s).
bool ProcessKeyboardEvent(KbEventType eventType, KbScancode scancode)
Forwards a keyboard event to all controllers that have keyboard bindings.
bool GamepadGameInputBlocked()
Returns true if any blocker has blocked gamepad game input.
std::shared_ptr< WheelHandler > GetWheelHandler() const
Returns the cached wheel handler.
bool ProcessMouseButtonEvent(bool isPressed, MouseBtn button)
Forwards a mouse-button event to all controllers that have mouse bindings.
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
KbScancode
Platform-independent keyboard scan codes used by the input mapping system.
Definition KeyboardScancodes.h:26
KbEventType
Identifies the type of a keyboard event delivered to the input mapping system.
Definition KeyboardScancodes.h:12
MouseBtn
Identifies a mouse button delivered to the input mapping system.
Definition KeyboardScancodes.h:136