2018-05-24 02:14:17 +00:00
|
|
|
#pragma once
|
2014-01-05 09:59:17 +00:00
|
|
|
|
|
|
|
struct InputMouseRawInput {
|
2015-06-20 05:44:05 +00:00
|
|
|
Input& input;
|
|
|
|
InputMouseRawInput(Input& input) : input(input) {}
|
|
|
|
|
Update to v103r15 release.
byuu says:
Changelog:
- ruby: rewrote the API interfaces for Video, Audio, Input
- ruby/audio: can now select the number of output channels (not useful
to higan, sorry)
- ruby/asio: various improvements
- tomoko: audio settings panel can now select separate audio devices
(for ASIO, OSS so far)
- tomoko: audio settings panel frequency and latency lists are
dynamically populated now
Note: due to the ruby API rewrite, most drivers will not compile. Right
now, the following work:
- video: Direct3D, XShm
- audio: ASIO, OSS
- input: Windows, SDL, Xlib
It takes a really long time to rewrite these (six hours to do the
above), so it's going to be a while before we're back at 100%
functionality again.
Errata:
- ASIO needs device(), setDevice()
- need to call setDevice() at program startup to populate
frequency/latency settings properly
- changing the device and/or frequency needs to update the emulator
resampler rates
The really hard part is going to be the last one: the only way to change
the emulator frequency is to flush all the audio streams and then
recompute all the coefficients for the resamplers. If this is called
during emulation, all audio streams will be erased and thus no sound
will be output. I'll most likely be forced to simply ignore
device/frequency changes until the user loads another game. It is at
least possible to toggle the latency dynamically.
2017-07-17 05:11:18 +00:00
|
|
|
uintptr handle = 0;
|
2014-01-05 09:59:17 +00:00
|
|
|
bool mouseAcquired = false;
|
|
|
|
|
|
|
|
struct Mouse {
|
2015-06-12 13:14:38 +00:00
|
|
|
shared_pointer<HID::Mouse> hid{new HID::Mouse};
|
2014-01-05 09:59:17 +00:00
|
|
|
|
2018-05-24 02:14:17 +00:00
|
|
|
int relativeX = 0;
|
|
|
|
int relativeY = 0;
|
|
|
|
int relativeZ = 0;
|
2014-01-05 09:59:17 +00:00
|
|
|
bool buttons[5] = {0};
|
|
|
|
} ms;
|
|
|
|
|
Update to v103r15 release.
byuu says:
Changelog:
- ruby: rewrote the API interfaces for Video, Audio, Input
- ruby/audio: can now select the number of output channels (not useful
to higan, sorry)
- ruby/asio: various improvements
- tomoko: audio settings panel can now select separate audio devices
(for ASIO, OSS so far)
- tomoko: audio settings panel frequency and latency lists are
dynamically populated now
Note: due to the ruby API rewrite, most drivers will not compile. Right
now, the following work:
- video: Direct3D, XShm
- audio: ASIO, OSS
- input: Windows, SDL, Xlib
It takes a really long time to rewrite these (six hours to do the
above), so it's going to be a while before we're back at 100%
functionality again.
Errata:
- ASIO needs device(), setDevice()
- need to call setDevice() at program startup to populate
frequency/latency settings properly
- changing the device and/or frequency needs to update the emulator
resampler rates
The really hard part is going to be the last one: the only way to change
the emulator frequency is to flush all the audio streams and then
recompute all the coefficients for the resamplers. If this is called
during emulation, all audio streams will be erased and thus no sound
will be output. I'll most likely be forced to simply ignore
device/frequency changes until the user loads another game. It is at
least possible to toggle the latency dynamically.
2017-07-17 05:11:18 +00:00
|
|
|
auto acquired() -> bool {
|
|
|
|
if(mouseAcquired) {
|
|
|
|
SetFocus((HWND)handle);
|
|
|
|
SetCapture((HWND)handle);
|
|
|
|
RECT rc;
|
|
|
|
GetWindowRect((HWND)handle, &rc);
|
|
|
|
ClipCursor(&rc);
|
|
|
|
}
|
|
|
|
return GetCapture() == (HWND)handle;
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto acquire() -> bool {
|
2015-11-14 00:52:51 +00:00
|
|
|
if(!mouseAcquired) {
|
2014-01-05 09:59:17 +00:00
|
|
|
mouseAcquired = true;
|
|
|
|
ShowCursor(false);
|
|
|
|
}
|
2015-11-14 00:52:51 +00:00
|
|
|
return acquired();
|
2014-01-05 09:59:17 +00:00
|
|
|
}
|
|
|
|
|
2015-06-20 05:44:05 +00:00
|
|
|
auto release() -> bool {
|
2015-11-14 00:52:51 +00:00
|
|
|
if(mouseAcquired) {
|
2014-01-05 09:59:17 +00:00
|
|
|
mouseAcquired = false;
|
|
|
|
ReleaseCapture();
|
2015-06-12 13:14:38 +00:00
|
|
|
ClipCursor(nullptr);
|
2014-01-05 09:59:17 +00:00
|
|
|
ShowCursor(true);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto update(RAWINPUT* input) -> void {
|
2014-01-05 09:59:17 +00:00
|
|
|
if((input->data.mouse.usFlags & 1) == MOUSE_MOVE_RELATIVE) {
|
|
|
|
ms.relativeX += input->data.mouse.lLastX;
|
|
|
|
ms.relativeY += input->data.mouse.lLastY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_WHEEL) {
|
|
|
|
ms.relativeZ += (int16_t)input->data.mouse.usButtonData;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_1_DOWN) ms.buttons[0] = 1;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_1_UP ) ms.buttons[0] = 0;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_2_DOWN) ms.buttons[1] = 1;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_2_UP ) ms.buttons[1] = 0;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_3_DOWN) ms.buttons[2] = 1;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_3_UP ) ms.buttons[2] = 0;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) ms.buttons[3] = 1;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_UP ) ms.buttons[3] = 0;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) ms.buttons[4] = 1;
|
|
|
|
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_UP ) ms.buttons[4] = 0;
|
|
|
|
}
|
|
|
|
|
2018-05-24 02:14:17 +00:00
|
|
|
auto assign(uint groupID, uint inputID, int16_t value) -> void {
|
2015-06-12 13:14:38 +00:00
|
|
|
auto& group = ms.hid->group(groupID);
|
|
|
|
if(group.input(inputID).value() == value) return;
|
2015-06-20 05:44:05 +00:00
|
|
|
input.doChange(ms.hid, groupID, inputID, group.input(inputID).value(), value);
|
2015-06-12 13:14:38 +00:00
|
|
|
group.input(inputID).setValue(value);
|
2014-01-05 09:59:17 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto poll(vector<shared_pointer<HID::Device>>& devices) -> void {
|
2014-01-05 09:59:17 +00:00
|
|
|
assign(HID::Mouse::GroupID::Axis, 0, ms.relativeX);
|
|
|
|
assign(HID::Mouse::GroupID::Axis, 1, ms.relativeY);
|
|
|
|
assign(HID::Mouse::GroupID::Axis, 2, ms.relativeZ);
|
|
|
|
|
|
|
|
//keys are intentionally reordered below:
|
|
|
|
//in ruby, button order is {left, middle, right, up, down}
|
|
|
|
assign(HID::Mouse::GroupID::Button, 0, ms.buttons[0]);
|
|
|
|
assign(HID::Mouse::GroupID::Button, 2, ms.buttons[1]);
|
|
|
|
assign(HID::Mouse::GroupID::Button, 1, ms.buttons[2]);
|
|
|
|
assign(HID::Mouse::GroupID::Button, 4, ms.buttons[3]);
|
|
|
|
assign(HID::Mouse::GroupID::Button, 3, ms.buttons[4]);
|
|
|
|
|
|
|
|
ms.relativeX = 0;
|
|
|
|
ms.relativeY = 0;
|
|
|
|
ms.relativeZ = 0;
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
devices.append(ms.hid);
|
2014-01-05 09:59:17 +00:00
|
|
|
}
|
|
|
|
|
Update to v103r15 release.
byuu says:
Changelog:
- ruby: rewrote the API interfaces for Video, Audio, Input
- ruby/audio: can now select the number of output channels (not useful
to higan, sorry)
- ruby/asio: various improvements
- tomoko: audio settings panel can now select separate audio devices
(for ASIO, OSS so far)
- tomoko: audio settings panel frequency and latency lists are
dynamically populated now
Note: due to the ruby API rewrite, most drivers will not compile. Right
now, the following work:
- video: Direct3D, XShm
- audio: ASIO, OSS
- input: Windows, SDL, Xlib
It takes a really long time to rewrite these (six hours to do the
above), so it's going to be a while before we're back at 100%
functionality again.
Errata:
- ASIO needs device(), setDevice()
- need to call setDevice() at program startup to populate
frequency/latency settings properly
- changing the device and/or frequency needs to update the emulator
resampler rates
The really hard part is going to be the last one: the only way to change
the emulator frequency is to flush all the audio streams and then
recompute all the coefficients for the resamplers. If this is called
during emulation, all audio streams will be erased and thus no sound
will be output. I'll most likely be forced to simply ignore
device/frequency changes until the user loads another game. It is at
least possible to toggle the latency dynamically.
2017-07-17 05:11:18 +00:00
|
|
|
auto initialize(uintptr handle) -> bool {
|
|
|
|
if(!handle) return false;
|
2014-01-05 09:59:17 +00:00
|
|
|
this->handle = handle;
|
|
|
|
|
2018-05-24 02:14:17 +00:00
|
|
|
ms.hid->setVendorID(HID::Mouse::GenericVendorID);
|
|
|
|
ms.hid->setProductID(HID::Mouse::GenericProductID);
|
|
|
|
ms.hid->setPathID(0);
|
2014-01-05 09:59:17 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
ms.hid->axes().append("X");
|
|
|
|
ms.hid->axes().append("Y");
|
|
|
|
ms.hid->axes().append("Z");
|
2014-01-05 09:59:17 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
ms.hid->buttons().append("Left");
|
|
|
|
ms.hid->buttons().append("Middle");
|
|
|
|
ms.hid->buttons().append("Right");
|
|
|
|
ms.hid->buttons().append("Up");
|
|
|
|
ms.hid->buttons().append("Down");
|
2014-01-05 09:59:17 +00:00
|
|
|
|
|
|
|
rawinput.updateMouse = {&InputMouseRawInput::update, this};
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Update to v103r15 release.
byuu says:
Changelog:
- ruby: rewrote the API interfaces for Video, Audio, Input
- ruby/audio: can now select the number of output channels (not useful
to higan, sorry)
- ruby/asio: various improvements
- tomoko: audio settings panel can now select separate audio devices
(for ASIO, OSS so far)
- tomoko: audio settings panel frequency and latency lists are
dynamically populated now
Note: due to the ruby API rewrite, most drivers will not compile. Right
now, the following work:
- video: Direct3D, XShm
- audio: ASIO, OSS
- input: Windows, SDL, Xlib
It takes a really long time to rewrite these (six hours to do the
above), so it's going to be a while before we're back at 100%
functionality again.
Errata:
- ASIO needs device(), setDevice()
- need to call setDevice() at program startup to populate
frequency/latency settings properly
- changing the device and/or frequency needs to update the emulator
resampler rates
The really hard part is going to be the last one: the only way to change
the emulator frequency is to flush all the audio streams and then
recompute all the coefficients for the resamplers. If this is called
during emulation, all audio streams will be erased and thus no sound
will be output. I'll most likely be forced to simply ignore
device/frequency changes until the user loads another game. It is at
least possible to toggle the latency dynamically.
2017-07-17 05:11:18 +00:00
|
|
|
auto terminate() -> void {
|
2016-09-06 00:09:33 +00:00
|
|
|
rawinput.updateMouse.reset();
|
2015-06-20 05:44:05 +00:00
|
|
|
release();
|
2014-01-05 09:59:17 +00:00
|
|
|
}
|
|
|
|
};
|