2010-08-09 13:28:56 +00:00
|
|
|
#include <ruby/ruby.hpp>
|
|
|
|
|
2010-10-23 05:08:05 +00:00
|
|
|
#undef mkdir
|
|
|
|
#undef usleep
|
2013-04-14 08:52:47 +00:00
|
|
|
#include <ruby/implementation.cpp>
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
namespace ruby {
|
|
|
|
|
|
|
|
VideoInterface video;
|
|
|
|
AudioInterface audio;
|
|
|
|
InputInterface input;
|
|
|
|
|
|
|
|
/* VideoInterface */
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
const char* Video::Handle = "Handle";
|
|
|
|
const char* Video::Synchronize = "Synchronize";
|
|
|
|
const char* Video::Depth = "Depth";
|
|
|
|
const char* Video::Filter = "Filter";
|
|
|
|
const char* Video::Shader = "Shader";
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2013-04-14 08:52:47 +00:00
|
|
|
const unsigned Video::FilterNearest = 0;
|
|
|
|
const unsigned Video::FilterLinear = 1;
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void VideoInterface::driver(const char* driver) {
|
2010-08-09 13:28:56 +00:00
|
|
|
if(p) term();
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
if(!driver || !*driver) driver = optimalDriver();
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
if(0);
|
|
|
|
|
2013-03-19 08:48:50 +00:00
|
|
|
#ifdef VIDEO_CGL
|
|
|
|
else if(!strcmp(driver, "OpenGL")) p = new VideoCGL();
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#ifdef VIDEO_DIRECT3D
|
|
|
|
else if(!strcmp(driver, "Direct3D")) p = new VideoD3D();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIDEO_DIRECTDRAW
|
|
|
|
else if(!strcmp(driver, "DirectDraw")) p = new VideoDD();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIDEO_GDI
|
|
|
|
else if(!strcmp(driver, "GDI")) p = new VideoGDI();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIDEO_GLX
|
|
|
|
else if(!strcmp(driver, "OpenGL")) p = new VideoGLX();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIDEO_QTOPENGL
|
|
|
|
else if(!strcmp(driver, "Qt-OpenGL")) p = new VideoQtOpenGL();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIDEO_QTRASTER
|
|
|
|
else if(!strcmp(driver, "Qt-Raster")) p = new VideoQtRaster();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIDEO_SDL
|
|
|
|
else if(!strcmp(driver, "SDL")) p = new VideoSDL();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VIDEO_WGL
|
|
|
|
else if(!strcmp(driver, "OpenGL")) p = new VideoWGL();
|
|
|
|
#endif
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
#ifdef VIDEO_XSHM
|
|
|
|
else if(!strcmp(driver, "XShm")) p = new VideoXShm();
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#ifdef VIDEO_XV
|
|
|
|
else if(!strcmp(driver, "X-Video")) p = new VideoXv();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
else p = new Video();
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
const char* VideoInterface::optimalDriver() {
|
|
|
|
#if defined(VIDEO_WGL)
|
|
|
|
return "OpenGL";
|
|
|
|
#elif defined(VIDEO_DIRECT3D)
|
|
|
|
return "Direct3D";
|
|
|
|
#elif defined(VIDEO_DIRECTDRAW)
|
|
|
|
return "DirectDraw";
|
|
|
|
#elif defined(VIDEO_GDI)
|
|
|
|
return "GDI";
|
|
|
|
|
|
|
|
#elif defined(VIDEO_CGL)
|
|
|
|
return "OpenGL";
|
|
|
|
|
|
|
|
#elif defined(VIDEO_GLX)
|
|
|
|
return "OpenGL";
|
|
|
|
#elif defined(VIDEO_XV)
|
|
|
|
return "X-Video";
|
|
|
|
#elif defined(VIDEO_XSHM)
|
|
|
|
return "XShm";
|
|
|
|
#elif defined(VIDEO_SDL)
|
|
|
|
return "SDL";
|
|
|
|
|
|
|
|
#else
|
|
|
|
return "None";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* VideoInterface::safestDriver() {
|
2010-08-09 13:28:56 +00:00
|
|
|
#if defined(VIDEO_DIRECT3D)
|
|
|
|
return "Direct3D";
|
|
|
|
#elif defined(VIDEO_WGL)
|
|
|
|
return "OpenGL";
|
|
|
|
#elif defined(VIDEO_DIRECTDRAW)
|
|
|
|
return "DirectDraw";
|
|
|
|
#elif defined(VIDEO_GDI)
|
|
|
|
return "GDI";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
2013-03-19 08:48:50 +00:00
|
|
|
#elif defined(VIDEO_CGL)
|
|
|
|
return "OpenGL";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
#elif defined(VIDEO_XSHM)
|
|
|
|
return "XShm";
|
2010-08-09 13:28:56 +00:00
|
|
|
#elif defined(VIDEO_SDL)
|
|
|
|
return "SDL";
|
|
|
|
#elif defined(VIDEO_XV)
|
|
|
|
return "X-Video";
|
|
|
|
#elif defined(VIDEO_GLX)
|
|
|
|
return "OpenGL";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#else
|
|
|
|
return "None";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
const char* VideoInterface::availableDrivers() {
|
2010-08-09 13:28:56 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
//Windows
|
|
|
|
|
|
|
|
#if defined(VIDEO_WGL)
|
|
|
|
"OpenGL;"
|
|
|
|
#endif
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
#if defined(VIDEO_DIRECT3D)
|
|
|
|
"Direct3D;"
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#if defined(VIDEO_DIRECTDRAW)
|
|
|
|
"DirectDraw;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(VIDEO_GDI)
|
|
|
|
"GDI;"
|
|
|
|
#endif
|
|
|
|
|
2013-03-19 08:48:50 +00:00
|
|
|
//OS X
|
|
|
|
|
|
|
|
#if defined(VIDEO_CGL)
|
|
|
|
"OpenGL;"
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
//Linux
|
|
|
|
|
|
|
|
#if defined(VIDEO_GLX)
|
|
|
|
"OpenGL;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(VIDEO_XV)
|
|
|
|
"X-Video;"
|
|
|
|
#endif
|
|
|
|
|
Update to v084r03 release.
(r02 was not posted to the WIP thread)
byuu says:
Internally, all color is processed with 30-bit precision. The filters
also operate at 30-bit depth.
There's a new config file setting, video.depth, which defaults to 24.
This causes the final output to downsample to 24-bit, as most will
require.
If you set it to 30-bit, the downsampling will not occur, and bsnes will
ask ruby for a 30-bit surface. If you don't have one available, you're
going to get bad colors. Or maybe even a crash with OpenGL.
I don't yet have detection code to make sure you have an appropriate
visual in place.
30-bit mode will really only work if you are running Linux, running Xorg
at Depth 30, use the OpenGL or XShm driver, have an nVidia Quadro or AMD
FireGL card with the official drivers, and have a 30-bit capable
monitor.
Lots of planning and work for very little gain here, but it's nice that
it's finally finished.
Oh, I had to change the contrast/brightness formulas a tiny bit, but
they still work and look nice.
2011-12-03 03:22:54 +00:00
|
|
|
#if defined(VIDEO_XSHM)
|
|
|
|
"XShm;"
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#if defined(VIDEO_SDL)
|
|
|
|
"SDL;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
"None";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VideoInterface::init() {
|
|
|
|
if(!p) driver();
|
|
|
|
return p->init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VideoInterface::term() {
|
|
|
|
if(p) {
|
2013-08-18 03:21:14 +00:00
|
|
|
p->term();
|
2010-08-09 13:28:56 +00:00
|
|
|
delete p;
|
2011-09-27 11:55:02 +00:00
|
|
|
p = nullptr;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VideoInterface::cap(const string& name) { return p ? p->cap(name) : false; }
|
|
|
|
any VideoInterface::get(const string& name) { return p ? p->get(name) : false; }
|
|
|
|
bool VideoInterface::set(const string& name, const any& value) { return p ? p->set(name, value) : false; }
|
2013-05-02 11:25:45 +00:00
|
|
|
bool VideoInterface::lock(uint32_t*& data, unsigned& pitch, unsigned width, unsigned height) { return p ? p->lock(data, pitch, width, height) : false; }
|
2010-08-09 13:28:56 +00:00
|
|
|
void VideoInterface::unlock() { if(p) p->unlock(); }
|
|
|
|
void VideoInterface::clear() { if(p) p->clear(); }
|
|
|
|
void VideoInterface::refresh() { if(p) p->refresh(); }
|
2011-09-27 11:55:02 +00:00
|
|
|
VideoInterface::VideoInterface() : p(nullptr) {}
|
2010-08-09 13:28:56 +00:00
|
|
|
VideoInterface::~VideoInterface() { term(); }
|
|
|
|
|
|
|
|
/* AudioInterface */
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
const char* Audio::Handle = "Handle";
|
|
|
|
const char* Audio::Synchronize = "Synchronize";
|
|
|
|
const char* Audio::Frequency = "Frequency";
|
|
|
|
const char* Audio::Latency = "Latency";
|
2011-08-14 10:34:11 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void AudioInterface::driver(const char* driver) {
|
2010-08-09 13:28:56 +00:00
|
|
|
if(p) term();
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
if(!driver || !*driver) driver = optimalDriver();
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
if(0);
|
|
|
|
|
|
|
|
#ifdef AUDIO_ALSA
|
|
|
|
else if(!strcmp(driver, "ALSA")) p = new AudioALSA();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIO_AO
|
|
|
|
else if(!strcmp(driver, "libao")) p = new AudioAO();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIO_DIRECTSOUND
|
|
|
|
else if(!strcmp(driver, "DirectSound")) p = new AudioDS();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIO_OPENAL
|
|
|
|
else if(!strcmp(driver, "OpenAL")) p = new AudioOpenAL();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIO_OSS
|
|
|
|
else if(!strcmp(driver, "OSS")) p = new AudioOSS();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIO_PULSEAUDIO
|
|
|
|
else if(!strcmp(driver, "PulseAudio")) p = new AudioPulseAudio();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIO_PULSEAUDIOSIMPLE
|
|
|
|
else if(!strcmp(driver, "PulseAudioSimple")) p = new AudioPulseAudioSimple();
|
|
|
|
#endif
|
|
|
|
|
2010-08-16 04:10:50 +00:00
|
|
|
#ifdef AUDIO_XAUDIO2
|
|
|
|
else if(!strcmp(driver, "XAudio2")) p = new AudioXAudio2();
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
else p = new Audio();
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
const char* AudioInterface::optimalDriver() {
|
|
|
|
#if defined(AUDIO_XAUDIO2)
|
|
|
|
return "XAudio2";
|
|
|
|
#elif defined(AUDIO_DIRECTSOUND)
|
|
|
|
return "DirectSound";
|
|
|
|
|
|
|
|
#elif defined(AUDIO_ALSA)
|
|
|
|
return "ALSA";
|
|
|
|
#elif defined(AUDIO_OPENAL)
|
|
|
|
return "OpenAL";
|
|
|
|
#elif defined(AUDIO_OSS)
|
|
|
|
return "OSS";
|
|
|
|
#elif defined(AUDIO_PULSEAUDIO)
|
|
|
|
return "PulseAudio";
|
|
|
|
#elif defined(AUDIO_PULSEAUDIOSIMPLE)
|
|
|
|
return "PulseAudioSimple";
|
|
|
|
#elif defined(AUDIO_AO)
|
|
|
|
return "libao";
|
|
|
|
|
|
|
|
#else
|
|
|
|
return "None";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* AudioInterface::safestDriver() {
|
2010-08-09 13:28:56 +00:00
|
|
|
#if defined(AUDIO_DIRECTSOUND)
|
|
|
|
return "DirectSound";
|
2010-08-16 04:10:50 +00:00
|
|
|
#elif defined(AUDIO_XAUDIO2)
|
|
|
|
return "XAudio2";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#elif defined(AUDIO_ALSA)
|
|
|
|
return "ALSA";
|
|
|
|
#elif defined(AUDIO_OPENAL)
|
|
|
|
return "OpenAL";
|
|
|
|
#elif defined(AUDIO_PULSEAUDIO)
|
|
|
|
return "PulseAudio";
|
|
|
|
#elif defined(AUDIO_PULSEAUDIOSIMPLE)
|
|
|
|
return "PulseAudioSimple";
|
|
|
|
#elif defined(AUDIO_AO)
|
|
|
|
return "libao";
|
|
|
|
#elif defined(AUDIO_OSS)
|
|
|
|
return "OSS";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#else
|
|
|
|
return "None";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
const char* AudioInterface::availableDrivers() {
|
2010-08-09 13:28:56 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
//Windows
|
|
|
|
|
2010-08-16 04:10:50 +00:00
|
|
|
#if defined(AUDIO_XAUDIO2)
|
|
|
|
"XAudio2;"
|
|
|
|
#endif
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
#if defined(AUDIO_DIRECTSOUND)
|
|
|
|
"DirectSound;"
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
//Linux
|
|
|
|
|
|
|
|
#if defined(AUDIO_ALSA)
|
|
|
|
"ALSA;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AUDIO_OPENAL)
|
|
|
|
"OpenAL;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AUDIO_OSS)
|
|
|
|
"OSS;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AUDIO_PULSEAUDIO)
|
|
|
|
"PulseAudio;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AUDIO_PULSEAUDIOSIMPLE)
|
|
|
|
"PulseAudioSimple;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AUDIO_AO)
|
|
|
|
"libao;"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
"None";
|
|
|
|
}
|
|
|
|
|
2011-08-14 10:34:11 +00:00
|
|
|
bool AudioInterface::init() {
|
|
|
|
if(!p) driver();
|
|
|
|
return p->init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioInterface::term() {
|
|
|
|
if(p) {
|
2013-08-18 03:21:14 +00:00
|
|
|
p->term();
|
2011-08-14 10:34:11 +00:00
|
|
|
delete p;
|
2011-09-27 11:55:02 +00:00
|
|
|
p = nullptr;
|
2011-08-14 10:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AudioInterface::cap(const string& name) { return p ? p->cap(name) : false; }
|
|
|
|
any AudioInterface::get(const string& name) { return p ? p->get(name) : false; }
|
|
|
|
bool AudioInterface::set(const string& name, const any& value) { return p ? p->set(name, value) : false; }
|
|
|
|
void AudioInterface::sample(uint16_t left, uint16_t right) { if(p) p->sample(left, right); }
|
|
|
|
void AudioInterface::clear() { if(p) p->clear(); }
|
2011-09-27 11:55:02 +00:00
|
|
|
AudioInterface::AudioInterface() : p(nullptr) {}
|
2011-08-14 10:34:11 +00:00
|
|
|
AudioInterface::~AudioInterface() { term(); }
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
/* InputInterface */
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
const char* Input::Handle = "Handle";
|
|
|
|
const char* Input::KeyboardSupport = "KeyboardSupport";
|
|
|
|
const char* Input::MouseSupport = "MouseSupport";
|
|
|
|
const char* Input::JoypadSupport = "JoypadSupport";
|
2013-12-21 10:45:58 +00:00
|
|
|
const char* Input::JoypadRumbleSupport = "JoypadRumbleSupport";
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void InputInterface::driver(const char* driver) {
|
2010-08-09 13:28:56 +00:00
|
|
|
if(p) term();
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
if(!driver || !*driver) driver = optimalDriver();
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
if(0);
|
|
|
|
|
2014-01-05 09:59:17 +00:00
|
|
|
#ifdef INPUT_WINDOWS
|
|
|
|
else if(!strcmp(driver, "Windows")) p = new InputWindows();
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-19 08:48:50 +00:00
|
|
|
#ifdef INPUT_CARBON
|
|
|
|
else if(!strcmp(driver, "Carbon")) p = new InputCarbon();
|
|
|
|
#endif
|
|
|
|
|
2013-12-21 10:45:58 +00:00
|
|
|
#ifdef INPUT_UDEV
|
|
|
|
else if(!strcmp(driver, "udev")) p = new InputUdev();
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#ifdef INPUT_SDL
|
|
|
|
else if(!strcmp(driver, "SDL")) p = new InputSDL();
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
#ifdef INPUT_XLIB
|
|
|
|
else if(!strcmp(driver, "Xlib")) p = new InputXlib();
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
else p = new Input();
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
const char* InputInterface::optimalDriver() {
|
2014-01-05 09:59:17 +00:00
|
|
|
#if defined(INPUT_WINDOWS)
|
|
|
|
return "Windows";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
2013-03-19 08:48:50 +00:00
|
|
|
#elif defined(INPUT_CARBON)
|
|
|
|
return "Carbon";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
2013-12-21 10:45:58 +00:00
|
|
|
#elif defined(INPUT_UDEV)
|
|
|
|
return "udev";
|
2010-08-09 13:28:56 +00:00
|
|
|
#elif defined(INPUT_SDL)
|
|
|
|
return "SDL";
|
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
|
|
|
#elif defined(INPUT_XLIB)
|
|
|
|
return "Xlib";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
return "None";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* InputInterface::safestDriver() {
|
2014-01-05 09:59:17 +00:00
|
|
|
#if defined(INPUT_WINDOWS)
|
|
|
|
return "Windows";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
|
|
|
#elif defined(INPUT_CARBON)
|
|
|
|
return "Carbon";
|
|
|
|
|
2013-12-21 10:45:58 +00:00
|
|
|
#elif defined(INPUT_UDEV)
|
|
|
|
return "udev";
|
2013-07-29 09:42:45 +00:00
|
|
|
#elif defined(INPUT_SDL)
|
|
|
|
return "SDL";
|
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
|
|
|
#elif defined(INPUT_XLIB)
|
|
|
|
return "Xlib";
|
2013-07-29 09:42:45 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#else
|
|
|
|
return "none";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
const char* InputInterface::availableDrivers() {
|
2010-08-09 13:28:56 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
//Windows
|
|
|
|
|
2014-01-05 09:59:17 +00:00
|
|
|
#if defined(INPUT_WINDOWS)
|
|
|
|
"Windows;"
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-19 08:48:50 +00:00
|
|
|
//OS X
|
|
|
|
|
|
|
|
#if defined(INPUT_CARBON)
|
|
|
|
"Carbon;"
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
//Linux
|
|
|
|
|
2013-12-21 10:45:58 +00:00
|
|
|
#if defined(INPUT_UDEV)
|
|
|
|
"udev;"
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#if defined(INPUT_SDL)
|
|
|
|
"SDL;"
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
#if defined(INPUT_XLIB)
|
|
|
|
"Xlib;"
|
2010-08-09 13:28:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
"None";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InputInterface::init() {
|
|
|
|
if(!p) driver();
|
|
|
|
return p->init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputInterface::term() {
|
|
|
|
if(p) {
|
2013-08-18 03:21:14 +00:00
|
|
|
p->term();
|
2010-08-09 13:28:56 +00:00
|
|
|
delete p;
|
2011-09-27 11:55:02 +00:00
|
|
|
p = nullptr;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InputInterface::cap(const string& name) { return p ? p->cap(name) : false; }
|
|
|
|
any InputInterface::get(const string& name) { return p ? p->get(name) : false; }
|
|
|
|
bool InputInterface::set(const string& name, const any& value) { return p ? p->set(name, value) : false; }
|
|
|
|
bool InputInterface::acquire() { return p ? p->acquire() : false; }
|
|
|
|
bool InputInterface::unacquire() { return p ? p->unacquire() : false; }
|
|
|
|
bool InputInterface::acquired() { return p ? p->acquired() : false; }
|
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
|
|
|
vector<HID::Device*> InputInterface::poll() { return p ? p->poll() : vector<HID::Device*>(); }
|
2014-01-05 09:59:17 +00:00
|
|
|
bool InputInterface::rumble(uint64_t id, bool enable) { return p ? p->rumble(id, enable) : false; }
|
2011-09-27 11:55:02 +00:00
|
|
|
InputInterface::InputInterface() : p(nullptr) {}
|
2010-08-09 13:28:56 +00:00
|
|
|
InputInterface::~InputInterface() { term(); }
|
|
|
|
|
|
|
|
};
|