2013-12-21 10:45:58 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/poll.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <libudev.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
#include "keyboard/xlib.cpp"
|
|
|
|
#include "mouse/xlib.cpp"
|
|
|
|
#include "joypad/udev.cpp"
|
|
|
|
|
Update to v094r29 release.
byuu says:
Note: for Windows users, please go to nall/intrinsics.hpp line 60 and
correct the typo from "DISPLAY_WINDOW" to "DISPLAY_WINDOWS" before
compiling, otherwise things won't work at all.
This will be a really major WIP for the core SNES emulation, so please
test as thoroughly as possible.
I rewrote the 65816 CPU core's dispatcher from a jump table to a switch
table. This was so that I could pass class variables as parameters to
opcodes without crazy theatrics.
With that, I killed the regs.r[N] stuff, the flag_t operator|=, &=, ^=
stuff, and all of the template versions of opcodes.
I also removed some stupid pointless flag tests in xcn and pflag that
would always be true.
I sure hope that AWJ is happy with this; because this change was so that
my flag assignments and branch tests won't need to build regs.P into
a full 8-bit variable anymore.
It does of course incur a slight performance hit when you pass in
variables by-value to functions, but it should help with binary size
(and thus cache) by reducing a lot of extra functions. (I know I could
have used template parameters for some things even with a switch table,
but chose not to for the aforementioned reasons.)
Overall, it's about a ~1% speedup from the previous build. The CPU core
instructions were never a bottleneck, but I did want to fix the P flag
building stuff because that really was a dumb mistake v_v'
2015-06-22 13:31:49 +00:00
|
|
|
struct InputUdev : Input {
|
2013-12-21 10:45:58 +00:00
|
|
|
InputKeyboardXlib xlibKeyboard;
|
|
|
|
InputMouseXlib xlibMouse;
|
|
|
|
InputJoypadUdev udev;
|
Update to v094r29 release.
byuu says:
Note: for Windows users, please go to nall/intrinsics.hpp line 60 and
correct the typo from "DISPLAY_WINDOW" to "DISPLAY_WINDOWS" before
compiling, otherwise things won't work at all.
This will be a really major WIP for the core SNES emulation, so please
test as thoroughly as possible.
I rewrote the 65816 CPU core's dispatcher from a jump table to a switch
table. This was so that I could pass class variables as parameters to
opcodes without crazy theatrics.
With that, I killed the regs.r[N] stuff, the flag_t operator|=, &=, ^=
stuff, and all of the template versions of opcodes.
I also removed some stupid pointless flag tests in xcn and pflag that
would always be true.
I sure hope that AWJ is happy with this; because this change was so that
my flag assignments and branch tests won't need to build regs.P into
a full 8-bit variable anymore.
It does of course incur a slight performance hit when you pass in
variables by-value to functions, but it should help with binary size
(and thus cache) by reducing a lot of extra functions. (I know I could
have used template parameters for some things even with a switch table,
but chose not to for the aforementioned reasons.)
Overall, it's about a ~1% speedup from the previous build. The CPU core
instructions were never a bottleneck, but I did want to fix the P flag
building stuff because that really was a dumb mistake v_v'
2015-06-22 13:31:49 +00:00
|
|
|
InputUdev() : xlibKeyboard(*this), xlibMouse(*this), udev(*this) {}
|
|
|
|
~InputUdev() { term(); }
|
2013-12-21 10:45:58 +00:00
|
|
|
|
|
|
|
struct Settings {
|
|
|
|
uintptr_t handle = 0;
|
|
|
|
} settings;
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto cap(const string& name) -> bool {
|
2013-12-21 10:45:58 +00:00
|
|
|
if(name == Input::Handle) return true;
|
|
|
|
if(name == Input::KeyboardSupport) return true;
|
|
|
|
if(name == Input::MouseSupport) return true;
|
|
|
|
if(name == Input::JoypadSupport) return true;
|
|
|
|
if(name == Input::JoypadRumbleSupport) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto get(const string& name) -> any {
|
|
|
|
if(name == Input::Handle) return settings.handle;
|
|
|
|
return {};
|
2013-12-21 10:45:58 +00:00
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto set(const string& name, const any& value) -> bool {
|
|
|
|
if(name == Input::Handle && value.is<uintptr_t>()) {
|
|
|
|
settings.handle = value.get<uintptr_t>();
|
2013-12-21 10:45:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto acquire() -> bool {
|
2013-12-21 10:45:58 +00:00
|
|
|
return xlibMouse.acquire();
|
|
|
|
}
|
|
|
|
|
2015-06-20 05:44:05 +00:00
|
|
|
auto release() -> bool {
|
|
|
|
return xlibMouse.release();
|
2013-12-21 10:45:58 +00:00
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto acquired() -> bool {
|
2013-12-21 10:45:58 +00:00
|
|
|
return xlibMouse.acquired();
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto poll() -> vector<shared_pointer<HID::Device>> {
|
|
|
|
vector<shared_pointer<HID::Device>> devices;
|
Update to v093r12 release.
byuu says:
I've completely redone the ethos InputManager and ruby to work on
HID::Device objects instead of one giant scancode pool.
Currently only the udev driver supports the changes to ruby, so only
Linux users will be able to compile and run this WIP build.
The nice thing about the new system is that it's now possible to
uniquely identify controllers, so if you swap out gamepads, you won't
end up with it working but with all the mappings all screwed up. Since
higan lets you map multiple physical inputs to one emulated input, you
can now configure your keyboard and multiple gamepads to the same
emulated input, and then just use whatever controller you want.
Because USB gamepad makers failed to provide unique serial#s with each
controller, we have to limit the mapping to specific USB ports.
Otherwise, we couldn't distinguish two otherwise identical gamepads. So
basically your computer USB ports act like real game console input port
numbers. Which is kind of neat, I guess.
And the really nice thing about the new system is that we now have the
capability to support hotplugging input devices. I haven't yet added
this to any drivers, but I'm definitely going to add it to udev for v094
official.
Finally, with the device ID (vendor ID + product ID) exposed, we gain
one last really cool feature that we may be able to develop more in the
future. Say we created a joypad.bml file to include with higan. In it,
we'd store the Xbox 360 controller, and pre-defined button mappings for
each emulated system. So if higan detects you have an Xbox 360
controller, you can just plug it in and use it. Even better, we can
clearly specify the difference between triggers and analog axes, and
name each individual input. So you'd see "Xbox 360 Gamepad #1: Left
Trigger" instead of higan v093's "JP0::Axis2.Hi"
Note: for right now, ethos' input manager isn't filtering the device IDs
to look pretty. So you're going to see a 64-bit hex value for a device
ID right now instead of something like Joypad#N for now.
2013-12-23 11:43:51 +00:00
|
|
|
xlibKeyboard.poll(devices);
|
|
|
|
xlibMouse.poll(devices);
|
|
|
|
udev.poll(devices);
|
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto rumble(uint64_t id, bool enable) -> bool {
|
2014-01-05 09:59:17 +00:00
|
|
|
return udev.rumble(id, enable);
|
2013-12-21 10:45:58 +00:00
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto init() -> bool {
|
2013-12-21 10:45:58 +00:00
|
|
|
if(xlibKeyboard.init() == false) return false;
|
|
|
|
if(xlibMouse.init(settings.handle) == false) return false;
|
|
|
|
if(udev.init() == false) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:16:43 +00:00
|
|
|
auto term() -> void {
|
2013-12-21 10:45:58 +00:00
|
|
|
xlibKeyboard.term();
|
|
|
|
xlibMouse.term();
|
|
|
|
udev.term();
|
|
|
|
}
|
|
|
|
};
|