• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 30213925900

26 Jul 2026 06:03PM UTC coverage: 15.298% (-0.01%) from 15.311%
30213925900

push

github

jcelerier
3rdparty: bump libossia for the network-context poll fix

Brings in ossia/libossia#913: SDL joystick init no longer requires haptic
support (which the Emscripten SDL2 port does not have), and
network_context::poll() restarts the io_context, without which the
WebAssembly polling path stops after its first tick.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019oPj1zRcxSQX7FNni7EHM6

30400 of 198713 relevant lines covered (15.3%)

997.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

19.39
/src/plugins/score-plugin-protocols/Protocols/Joystick/JoystickProtocolFactory.cpp
1

2
#include "JoystickProtocolFactory.hpp"
3

4
#include "JoystickDevice.hpp"
5
#include "JoystickProtocolSettingsWidget.hpp"
6
#include "JoystickSpecificSettings.hpp"
7

8
#include <Explorer/DocumentPlugin/DeviceDocumentPlugin.hpp>
9

10
#include <ossia/detail/algorithms.hpp>
11
#include <ossia/protocols/joystick/joystick_protocol.hpp>
12

13
#include <QObject>
14
#include <QTimer>
15
#include <QUrl>
16
namespace Protocols
17
{
18
class DefaultJoystickEnumerator : public Device::DeviceEnumerator
19
{
20
public:
21
  void enumerate(std::function<void(const QString&, const Device::DeviceSettings&)> f)
×
22
      const override
23
  {
24
    Device::DeviceSettings s;
×
25
    s.name = "Gamepad";
×
26
    s.protocol = JoystickProtocolFactory::static_concreteKey();
×
27
    JoystickSpecificSettings specif;
×
28
    specif.gamepad = true;
×
29
    specif.id = {};
×
30
    specif.spec = specif.unassigned;
×
31

32
    s.deviceSpecificSettings = QVariant::fromValue(specif);
×
33
    f("Default Gamepad", s);
×
34
  }
×
35
};
36

37
class JoystickEnumerator : public Device::DeviceEnumerator
38
{
39
public:
40
  JoystickEnumerator()
×
41
  {
×
42
    m_timer.setInterval(1000);
×
43
    QObject::connect(&m_timer, &QTimer::timeout, this, [this] { rescan(); });
×
44
    m_timer.start();
×
45
  }
×
46

47
  void enumerate(std::function<void(const QString&, const Device::DeviceSettings&)> f)
×
48
      const override
49
  {
50
    m_current = scan();
×
51
    for(auto& [name, set] : m_current)
×
52
      f(name, set);
×
53
  }
×
54

55
private:
56
  using device_list = std::vector<std::pair<QString, Device::DeviceSettings>>;
57

58
  static device_list scan()
×
59
  {
60
    using info = ossia::net::joystick_info;
61
    device_list res;
×
62
    const unsigned int joystick_count = info::get_joystick_count();
×
63

64
    for(unsigned int i = 0; i < joystick_count; ++i)
×
65
    {
66
      const char* s = info::get_joystick_name(i);
×
67
      if(s)
×
68
      {
69
        Device::DeviceSettings set;
×
70
        set.name = s;
×
71
        set.protocol = JoystickProtocolFactory::static_concreteKey();
×
72
        JoystickSpecificSettings specif;
×
73
        info::write_joystick_uuid(i, specif.id.data);
×
74
        specif.spec = {info::get_joystick_id(i), i};
×
75
        specif.gamepad = info::get_joystick_is_gamepad(i);
×
76

77
        set.deviceSpecificSettings = QVariant::fromValue(specif);
×
78
        res.emplace_back(set.name, set);
×
79
      }
×
80
    }
×
81
    return res;
×
82
  }
×
83

84
  void rescan()
×
85
  {
86
    auto next = scan();
×
87
    auto has = [](const device_list& l, const QString& n) {
×
88
      return ossia::any_of(l, [&n](const auto& p) { return p.first == n; });
×
89
    };
90

91
    for(auto& [name, set] : m_current)
×
92
      if(!has(next, name))
×
93
        deviceRemoved(name);
×
94

95
    bool added = false;
×
96
    for(auto& [name, set] : next)
×
97
    {
98
      if(!has(m_current, name))
×
99
      {
100
        deviceAdded(name, set);
×
101
        added = true;
×
102
      }
×
103
    }
104

105
    m_current = std::move(next);
×
106
    if(added)
×
107
      sort();
×
108
  }
×
109

110
  QTimer m_timer;
111
  mutable device_list m_current;
112
};
113

114
QString JoystickProtocolFactory::prettyName() const noexcept
1✔
115
{
116
  return QObject::tr("Joystick");
1✔
117
}
118

119
QString JoystickProtocolFactory::category() const noexcept
×
120
{
121
  return StandardCategories::hardware;
×
122
}
123

124
QUrl JoystickProtocolFactory::manual() const noexcept
×
125
{
126
  return QUrl("https://ossia.io/score-docs/devices/joystick-device.html");
×
127
}
128

129
Device::DeviceEnumerators
130
JoystickProtocolFactory::getEnumerators(const score::DocumentContext& ctx) const
×
131
{
132
  return {
×
133
      {"Default", new DefaultJoystickEnumerator}, {"Devices", new JoystickEnumerator}};
×
134
}
×
135

136
Device::DeviceInterface* JoystickProtocolFactory::makeDevice(
×
137
    const Device::DeviceSettings& settings, const Explorer::DeviceDocumentPlugin& plugin,
138
    const score::DocumentContext& ctx)
139
{
140
  return new JoystickDevice{settings, plugin.networkContext()};
×
141
}
×
142

143
const Device::DeviceSettings& JoystickProtocolFactory::defaultSettings() const noexcept
1✔
144
{
145
  static const Device::DeviceSettings& settings = [&]() {
2✔
146
    Device::DeviceSettings s;
1✔
147
    s.protocol = concreteKey();
1✔
148
    s.name = "Joystick";
1✔
149

150
    JoystickSpecificSettings settings;
1✔
151
    settings.id = {};
1✔
152
    settings.spec = {-1, -1};
1✔
153
    s.deviceSpecificSettings = QVariant::fromValue(settings);
1✔
154
    return s;
1✔
155
  }();
1✔
156

157
  return settings;
1✔
158
}
159

160
Device::ProtocolSettingsWidget* JoystickProtocolFactory::makeSettingsWidget()
×
161
{
162
  return new JoystickProtocolSettingsWidget;
×
163
}
×
164

165
QVariant JoystickProtocolFactory::makeProtocolSpecificSettings(
2✔
166
    const VisitorVariant& visitor) const
167
{
168
  return makeProtocolSpecificSettings_T<JoystickSpecificSettings>(visitor);
2✔
169
}
170

171
void JoystickProtocolFactory::serializeProtocolSpecificSettings(
4✔
172
    const QVariant& data, const VisitorVariant& visitor) const
173
{
174
  serializeProtocolSpecificSettings_T<JoystickSpecificSettings>(data, visitor);
4✔
175
}
4✔
176

177
bool JoystickProtocolFactory::checkCompatibility(
×
178
    const Device::DeviceSettings& a, const Device::DeviceSettings& b) const noexcept
179
{
180
  auto a_ = a.deviceSpecificSettings.value<JoystickSpecificSettings>();
×
181
  if(a.protocol != b.protocol)
×
182
  {
183
    // FIXME check that the joystick is not already open
184
    return true;
×
185
  }
186

187
  auto b_ = b.deviceSpecificSettings.value<JoystickSpecificSettings>();
×
188
  return a_.id != b_.id || a_.spec != b_.spec;
×
189
}
×
190
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc