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;
|
||||
retro_input_state_t _getInputState = nullptr;
|
||||
retro_input_poll_t _pollInput = nullptr;
|
||||
bool _mouseButtons[3] = { false, false, false };
|
||||
bool _wasPushed[16] = { };
|
||||
bool _mouseButtons[3] = {false, false, false};
|
||||
bool _wasPushed[16] = {};
|
||||
|
||||
bool ProcessAction(uint32_t button)
|
||||
{
|
||||
if(_getInputState(0, RETRO_DEVICE_JOYPAD, 0, button)) {
|
||||
if(!_wasPushed[button]) {
|
||||
if (_getInputState(0, RETRO_DEVICE_JOYPAD, 0, button))
|
||||
{
|
||||
if (!_wasPushed[button])
|
||||
{
|
||||
//Newly pressed, process action
|
||||
_wasPushed[button] = true;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_wasPushed[button] = false;
|
||||
}
|
||||
return false;
|
||||
|
@ -52,11 +56,13 @@ public:
|
|||
// Inherited via IKeyManager
|
||||
virtual void RefreshState() override
|
||||
{
|
||||
if(_pollInput) {
|
||||
if (_pollInput)
|
||||
{
|
||||
_pollInput();
|
||||
}
|
||||
|
||||
if(_getInputState) {
|
||||
if (_getInputState)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -69,17 +75,23 @@ public:
|
|||
int16_t dy = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
||||
KeyManager::SetMouseMovement(dx, dy);
|
||||
|
||||
_mouseButtons[(int)MouseButton::LeftButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT) != 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;
|
||||
_mouseButtons[(int)MouseButton::LeftButton] = _getInputState(0, RETRO_DEVICE_MOUSE, 0,
|
||||
RETRO_DEVICE_ID_MOUSE_LEFT) != 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
|
||||
{
|
||||
if(keyCode > 0 && _getInputState) {
|
||||
if (keyCode > 0 && _getInputState)
|
||||
{
|
||||
return _getInputState(keyCode >> 8, RETRO_DEVICE_JOYPAD, 0, (keyCode - 1) & 0xFF) != 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,17 @@ public:
|
|||
// Inherited via IMessageManager
|
||||
virtual void DisplayMessage(string title, string message) override
|
||||
{
|
||||
if(title.empty()) {
|
||||
if(_log) {
|
||||
if (title.empty())
|
||||
{
|
||||
if (_log)
|
||||
{
|
||||
_log(RETRO_LOG_INFO, message.c_str());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
string osdMessage = "[" + title + "] " + message;
|
||||
retro_message msg = { osdMessage.c_str(), 180 };
|
||||
retro_message msg = {osdMessage.c_str(), 180};
|
||||
_retroEnv(RETRO_ENVIRONMENT_SET_MESSAGE, &msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,13 +30,15 @@ public:
|
|||
}
|
||||
|
||||
// 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
|
||||
int32_t newWidth = std::max<int32_t>(width, SNES_NTSC_OUT_WIDTH(256));
|
||||
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
|
||||
retro_system_av_info avInfo = {};
|
||||
GetSystemAudioVideoInfo(avInfo, newWidth, newHeight);
|
||||
|
@ -50,11 +52,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
OverscanDimensions overscan = _console->GetSettings()->GetOverscan();
|
||||
|
@ -62,15 +66,22 @@ public:
|
|||
int height = (239 - overscan.Top - overscan.Bottom);
|
||||
|
||||
double aspectRatio = _console->GetSettings()->GetAspectRatio(_console->GetRegion());
|
||||
if(aspectRatio != 0.0) {
|
||||
if (aspectRatio != 0.0)
|
||||
{
|
||||
VideoAspectRatio aspect = _console->GetSettings()->GetVideoConfig().AspectRatio;
|
||||
bool usePar = aspect == VideoAspectRatio::NTSC || aspect == VideoAspectRatio::PAL || aspect == VideoAspectRatio::Auto;
|
||||
if(usePar) {
|
||||
bool usePar = aspect == VideoAspectRatio::NTSC || aspect == VideoAspectRatio::PAL || aspect ==
|
||||
VideoAspectRatio::Auto;
|
||||
if (usePar)
|
||||
{
|
||||
info.geometry.aspect_ratio = (float)(width * aspectRatio / height);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
info.geometry.aspect_ratio = (float)aspectRatio;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
info.geometry.aspect_ratio = (float)width / height;
|
||||
}
|
||||
|
||||
|
@ -80,7 +91,8 @@ public:
|
|||
info.geometry.max_width = maxWidth;
|
||||
info.geometry.max_height = maxHeight;
|
||||
|
||||
if(maxHeight > 0 && maxWidth > 0) {
|
||||
if (maxHeight > 0 && maxWidth > 0)
|
||||
{
|
||||
_previousWidth = maxWidth;
|
||||
_previousHeight = maxHeight;
|
||||
}
|
||||
|
@ -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
|
||||
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) {
|
||||
for(uint32_t total = 0; total < sampleCount; ) {
|
||||
total += (uint32_t)_sendAudioSample(soundBuffer + total*2, (size_t)(sampleCount - total));
|
||||
if (!_skipMode && _sendAudioSample)
|
||||
{
|
||||
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