kodi
PeripheralMouse.h
1 /*
2  * Copyright (C) 2017-2024 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "Peripheral.h"
12 #include "XBDateTime.h"
13 #include "input/mouse/interfaces/IMouseDriverHandler.h"
14 #include "threads/CriticalSection.h"
15 
16 #include <vector>
17 
18 namespace PERIPHERALS
19 {
24 {
25 public:
27  const PeripheralScanResult& scanResult,
28  CPeripheralBus* bus);
29 
30  ~CPeripheralMouse(void) override;
31 
32  // implementation of CPeripheral
33  bool InitialiseFeature(const PeripheralFeature feature) override;
34  void RegisterMouseDriverHandler(KODI::MOUSE::IMouseDriverHandler* handler,
35  bool bPromiscuous) override;
36  void UnregisterMouseDriverHandler(KODI::MOUSE::IMouseDriverHandler* handler) override;
37  CDateTime LastActive() const override { return m_lastActive; }
39 
40  // implementation of IMouseDriverHandler
41  bool OnPosition(int x, int y) override;
42  bool OnButtonPress(KODI::MOUSE::BUTTON_ID button) override;
43  void OnButtonRelease(KODI::MOUSE::BUTTON_ID button) override;
44 
45 private:
46  struct MouseHandle
47  {
49  bool bPromiscuous;
50  };
51 
52  std::vector<MouseHandle> m_mouseHandlers;
53  CCriticalSection m_mutex;
54  CDateTime m_lastActive;
55 };
56 } // namespace PERIPHERALS
bool InitialiseFeature(const PeripheralFeature feature) override
Initialise one of the features of this peripheral.
Definition: PeripheralMouse.cpp:37
Definition: PeripheralTypes.h:326
BUTTON_ID
Buttons on a mouse.
Definition: MouseTypes.h:26
bool OnButtonPress(KODI::MOUSE::BUTTON_ID button) override
A mouse button has been pressed.
Definition: PeripheralMouse.cpp:113
Definition: RetroPlayerInput.h:15
KODI::GAME::ControllerPtr ControllerProfile() const override
Get the controller profile that best represents this peripheral.
Definition: PeripheralMouse.cpp:75
Definition: PeripheralMouse.h:23
std::shared_ptr< CController > ControllerPtr
Smart pointer to a game controller (CController)
Definition: ControllerTypes.h:25
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63
bool OnPosition(int x, int y) override
Handle mouse position updates.
Definition: PeripheralMouse.cpp:83
Definition: PeripheralBus.h:36
Interface for handling mouse driver events.
Definition: IMouseDriverHandler.h:22
void OnButtonRelease(KODI::MOUSE::BUTTON_ID button) override
A mouse button has been released.
Definition: PeripheralMouse.cpp:142
Definition: Peripheral.h:71
CDateTime LastActive() const override
Return the last time this peripheral was active.
Definition: PeripheralMouse.h:37
Definition: Peripherals.h:56