mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-28 20:46:52 +01:00
Plugins: joysticks are read on a thread of their own, with all 8 radio channels, and a plugin picks which one
reskate.input.joystick() scanned Windows' 16 winmm slots inside the plugin's call whenever no
controller was cached; on some PCs empty slots made one scan take over 50 ms, and the FPV drone
was stopped for its tick running long after switching to a radio with none plugged in. A thread
now finds the controllers (every 2 s) and reads them (250 a second) through DirectInput, only
while a plugin has asked in the last 2 s, and a call copies its last reading.
DirectInput gives the eight axes a radio sends, where winmm gave six: axes are now X, Y, Z, Rx,
Ry, Rz and the two sliders. A plugin that saved axis numbers should let players set them again.
reskate.input.joysticks() lists every controller plugged in ({device, name}), and
reskate.input.joystick(device) reads that one, so a player with a gamepad and a radio picks which
flies; with no argument it still reads the first, a radio first. The list and the device field
follow neekgate's plugin-joystick-pick branch.
This commit is contained in:
1 parent
be7a72d816
commit
6bad0e95d2
7 files changed
+292
-98
No files matched your search
@@ -912,12 +912,18 @@ public:
|
||||
if (!pad.valid) return std::nullopt;
|
||||
return PadInput{pad.left_x, pad.left_y, pad.right_x, pad.right_y, pad.left_trigger, pad.right_trigger, pad.buttons, pad.playstation};
|
||||
}
|
||||
std::optional<StickInput> joystick() override {
|
||||
std::optional<StickInput> joystick(int device) override {
|
||||
if (!joystick::game_in_foreground()) return std::nullopt;
|
||||
const auto sample = joystick::poll();
|
||||
const auto sample = joystick::poll(device);
|
||||
if (!sample.valid) return std::nullopt;
|
||||
overlay::note_joystick(sample.buttons, sample.axes);
|
||||
return StickInput{sample.axes, sample.buttons, sample.name};
|
||||
// (Binds take a joystick's first six axes.)
|
||||
overlay::note_joystick(sample.buttons, {sample.axes[0], sample.axes[1], sample.axes[2], sample.axes[3], sample.axes[4], sample.axes[5]});
|
||||
return StickInput{sample.axes, sample.buttons, sample.name, sample.device};
|
||||
}
|
||||
std::vector<StickDevice> joysticks() override {
|
||||
std::vector<StickDevice> out;
|
||||
for (const auto& sample : joystick::list()) out.push_back({sample.device, sample.name});
|
||||
return out;
|
||||
}
|
||||
std::string capture_input(std::string_view plugin, bool on) override {
|
||||
if (!on) {
|
||||
|
||||
Reference in new issue
Block a user