Reformat Libretro (Resharper)
This commit is contained in:
parent
f3f15a32fe
commit
a6e89dd132
6 changed files with 2244 additions and 2076 deletions
|
@ -10,18 +10,22 @@ private:
|
||||||
shared_ptr<Console> _console;
|
shared_ptr<Console> _console;
|
||||||
retro_input_state_t _getInputState = nullptr;
|
retro_input_state_t _getInputState = nullptr;
|
||||||
retro_input_poll_t _pollInput = nullptr;
|
retro_input_poll_t _pollInput = nullptr;
|
||||||
bool _mouseButtons[3] = { false, false, false };
|
bool _mouseButtons[3] = {false, false, false};
|
||||||
bool _wasPushed[16] = { };
|
bool _wasPushed[16] = {};
|
||||||
|
|
||||||
bool ProcessAction(uint32_t button)
|
bool ProcessAction(uint32_t button)
|
||||||
{
|
{
|
||||||
if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, button)) {
|
if (_getInputState(0, RETRO_DEVICE_JOYPAD, 0, button))
|
||||||
if(!_wasPushed[button]) {
|
{
|
||||||
|
if (!_wasPushed[button])
|
||||||
|
{
|
||||||
//Newly pressed, process action
|
//Newly pressed, process action
|
||||||
_wasPushed[button] = true;
|
_wasPushed[button] = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_wasPushed[button] = false;
|
_wasPushed[button] = false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,11 +56,13 @@ public:
|
||||||
// Inherited via IKeyManager
|
// Inherited via IKeyManager
|
||||||
virtual void RefreshState() override
|
virtual void RefreshState() override
|
||||||
{
|
{
|
||||||
if(_pollInput) {
|
if (_pollInput)
|
||||||
|
{
|
||||||
_pollInput();
|
_pollInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_getInputState) {
|
if (_getInputState)
|
||||||
|
{
|
||||||
int32_t x = _getInputState(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
|
int32_t x = _getInputState(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
|
||||||
int32_t y = _getInputState(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
|
int32_t y = _getInputState(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
|
||||||
|
|
||||||
|
@ -68,18 +74,24 @@ public:
|
||||||
int16_t dx = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
int16_t dx = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||||
int16_t dy = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
int16_t dy = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
||||||
KeyManager::SetMouseMovement(dx, dy);
|
KeyManager::SetMouseMovement(dx, dy);
|
||||||
|
|
||||||
_mouseButtons[(int)MouseButton::LeftButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT) != 0;
|
_mouseButtons[(int)MouseButton::LeftButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0,
|
||||||
_mouseButtons[(int)MouseButton::RightButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT) != 0;
|
RETRO_DEVICE_ID_MOUSE_LEFT) != 0;
|
||||||
_mouseButtons[(int)MouseButton::MiddleButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE) != 0;
|
_mouseButtons[(int)MouseButton::RightButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0,
|
||||||
|
RETRO_DEVICE_ID_MOUSE_RIGHT) != 0;
|
||||||
|
_mouseButtons[(int)MouseButton::MiddleButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0,
|
||||||
|
RETRO_DEVICE_ID_MOUSE_MIDDLE) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool IsKeyPressed(uint32_t keyCode) override
|
virtual bool IsKeyPressed(uint32_t keyCode) override
|
||||||
{
|
{
|
||||||
if(keyCode > 0 && _getInputState) {
|
if (keyCode > 0 && _getInputState)
|
||||||
|
{
|
||||||
return _getInputState(keyCode >> 8, RETRO_DEVICE_JOYPAD, 0, (keyCode - 1) & 0xFF) != 0;
|
return _getInputState(keyCode >> 8, RETRO_DEVICE_JOYPAD, 0, (keyCode - 1) & 0xFF) != 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +109,7 @@ public:
|
||||||
{
|
{
|
||||||
return vector<uint32_t>();
|
return vector<uint32_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual string GetKeyName(uint32_t keyCode) override
|
virtual string GetKeyName(uint32_t keyCode) override
|
||||||
{
|
{
|
||||||
return string();
|
return string();
|
||||||
|
@ -119,4 +131,4 @@ public:
|
||||||
virtual void SetDisabled(bool disabled) override
|
virtual void SetDisabled(bool disabled) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,14 +25,18 @@ public:
|
||||||
// Inherited via IMessageManager
|
// Inherited via IMessageManager
|
||||||
virtual void DisplayMessage(string title, string message) override
|
virtual void DisplayMessage(string title, string message) override
|
||||||
{
|
{
|
||||||
if(title.empty()) {
|
if (title.empty())
|
||||||
if(_log) {
|
{
|
||||||
|
if (_log)
|
||||||
|
{
|
||||||
_log(RETRO_LOG_INFO, message.c_str());
|
_log(RETRO_LOG_INFO, message.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
string osdMessage = "[" + title + "] " + message;
|
string osdMessage = "[" + title + "] " + message;
|
||||||
retro_message msg = { osdMessage.c_str(), 180 };
|
retro_message msg = {osdMessage.c_str(), 180};
|
||||||
_retroEnv(RETRO_ENVIRONMENT_SET_MESSAGE, &msg);
|
_retroEnv(RETRO_ENVIRONMENT_SET_MESSAGE, &msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,18 +30,20 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inherited via IRenderingDevice
|
// Inherited via IRenderingDevice
|
||||||
virtual void UpdateFrame(void *frameBuffer, uint32_t width, uint32_t height) override
|
virtual void UpdateFrame(void* frameBuffer, uint32_t width, uint32_t height) override
|
||||||
{
|
{
|
||||||
if(!_skipMode && _sendFrame) {
|
if (!_skipMode && _sendFrame)
|
||||||
|
{
|
||||||
//Use Blargg's NTSC filter's max size as a minimum resolution, to prevent changing resolution too often
|
//Use Blargg's NTSC filter's max size as a minimum resolution, to prevent changing resolution too often
|
||||||
int32_t newWidth = std::max<int32_t>(width, SNES_NTSC_OUT_WIDTH(256));
|
int32_t newWidth = std::max<int32_t>(width, SNES_NTSC_OUT_WIDTH(256));
|
||||||
int32_t newHeight = std::max<int32_t>(height, 239 * 2);
|
int32_t newHeight = std::max<int32_t>(height, 239 * 2);
|
||||||
if(_retroEnv != nullptr && (_previousWidth != newWidth || _previousHeight != newHeight)) {
|
if (_retroEnv != nullptr && (_previousWidth != newWidth || _previousHeight != newHeight))
|
||||||
|
{
|
||||||
//Resolution change is needed
|
//Resolution change is needed
|
||||||
retro_system_av_info avInfo = {};
|
retro_system_av_info avInfo = {};
|
||||||
GetSystemAudioVideoInfo(avInfo, newWidth, newHeight);
|
GetSystemAudioVideoInfo(avInfo, newWidth, newHeight);
|
||||||
_retroEnv(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &avInfo);
|
_retroEnv(RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, &avInfo);
|
||||||
|
|
||||||
_previousWidth = newWidth;
|
_previousWidth = newWidth;
|
||||||
_previousHeight = newHeight;
|
_previousHeight = newHeight;
|
||||||
}
|
}
|
||||||
|
@ -49,12 +51,14 @@ public:
|
||||||
_sendFrame(frameBuffer, width, height, sizeof(uint32_t) * width);
|
_sendFrame(frameBuffer, width, height, sizeof(uint32_t) * width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetSystemAudioVideoInfo(retro_system_av_info &info, int32_t maxWidth = 0, int32_t maxHeight = 0)
|
void GetSystemAudioVideoInfo(retro_system_av_info& info, int32_t maxWidth = 0, int32_t maxHeight = 0)
|
||||||
{
|
{
|
||||||
AudioConfig audio = _console->GetSettings()->GetAudioConfig();
|
AudioConfig audio = _console->GetSettings()->GetAudioConfig();
|
||||||
|
|
||||||
info.timing.fps = _console->GetRegion() == ConsoleRegion::Ntsc ? 60.098811862348404716732985230828 : 50.006977968268290848936010226333;
|
info.timing.fps = _console->GetRegion() == ConsoleRegion::Ntsc
|
||||||
|
? 60.098811862348404716732985230828
|
||||||
|
: 50.006977968268290848936010226333;
|
||||||
info.timing.sample_rate = audio.SampleRate;
|
info.timing.sample_rate = audio.SampleRate;
|
||||||
|
|
||||||
OverscanDimensions overscan = _console->GetSettings()->GetOverscan();
|
OverscanDimensions overscan = _console->GetSettings()->GetOverscan();
|
||||||
|
@ -62,15 +66,22 @@ public:
|
||||||
int height = (239 - overscan.Top - overscan.Bottom);
|
int height = (239 - overscan.Top - overscan.Bottom);
|
||||||
|
|
||||||
double aspectRatio = _console->GetSettings()->GetAspectRatio(_console->GetRegion());
|
double aspectRatio = _console->GetSettings()->GetAspectRatio(_console->GetRegion());
|
||||||
if(aspectRatio != 0.0) {
|
if (aspectRatio != 0.0)
|
||||||
|
{
|
||||||
VideoAspectRatio aspect = _console->GetSettings()->GetVideoConfig().AspectRatio;
|
VideoAspectRatio aspect = _console->GetSettings()->GetVideoConfig().AspectRatio;
|
||||||
bool usePar = aspect == VideoAspectRatio::NTSC || aspect == VideoAspectRatio::PAL || aspect == VideoAspectRatio::Auto;
|
bool usePar = aspect == VideoAspectRatio::NTSC || aspect == VideoAspectRatio::PAL || aspect ==
|
||||||
if(usePar) {
|
VideoAspectRatio::Auto;
|
||||||
|
if (usePar)
|
||||||
|
{
|
||||||
info.geometry.aspect_ratio = (float)(width * aspectRatio / height);
|
info.geometry.aspect_ratio = (float)(width * aspectRatio / height);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
info.geometry.aspect_ratio = (float)aspectRatio;
|
info.geometry.aspect_ratio = (float)aspectRatio;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
info.geometry.aspect_ratio = (float)width / height;
|
info.geometry.aspect_ratio = (float)width / height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +91,8 @@ public:
|
||||||
info.geometry.max_width = maxWidth;
|
info.geometry.max_width = maxWidth;
|
||||||
info.geometry.max_height = maxHeight;
|
info.geometry.max_height = maxHeight;
|
||||||
|
|
||||||
if(maxHeight > 0 && maxWidth > 0) {
|
if (maxHeight > 0 && maxWidth > 0)
|
||||||
|
{
|
||||||
_previousWidth = maxWidth;
|
_previousWidth = maxWidth;
|
||||||
_previousHeight = maxHeight;
|
_previousHeight = maxHeight;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +107,7 @@ public:
|
||||||
{
|
{
|
||||||
_skipMode = skip;
|
_skipMode = skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Render() override
|
virtual void Render() override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -104,7 +116,8 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetFullscreenMode(bool fullscreen, void *windowHandle, uint32_t monitorWidth, uint32_t monitorHeight) override
|
virtual void SetFullscreenMode(bool fullscreen, void* windowHandle, uint32_t monitorWidth,
|
||||||
|
uint32_t monitorHeight) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,11 +23,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inherited via IAudioDevice
|
// Inherited via IAudioDevice
|
||||||
virtual void PlayBuffer(int16_t *soundBuffer, uint32_t sampleCount, uint32_t sampleRate, bool isStereo) override
|
virtual void PlayBuffer(int16_t* soundBuffer, uint32_t sampleCount, uint32_t sampleRate, bool isStereo) override
|
||||||
{
|
{
|
||||||
if(!_skipMode && _sendAudioSample) {
|
if (!_skipMode && _sendAudioSample)
|
||||||
for(uint32_t total = 0; total < sampleCount; ) {
|
{
|
||||||
total += (uint32_t)_sendAudioSample(soundBuffer + total*2, (size_t)(sampleCount - total));
|
for (uint32_t total = 0; total < sampleCount;)
|
||||||
|
{
|
||||||
|
total += (uint32_t)_sendAudioSample(soundBuffer + total * 2, (size_t)(sampleCount - total));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
2843
Libretro/libretro.h
2843
Libretro/libretro.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue