Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
Citra2018
Commits
2720b015
Commit
2720b015
authored
Nov 11, 2017
by
James
Browse files
Additional cleanups for clang
parent
ba0e28ab
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/audio_core/libretro_sink.cpp
View file @
2720b015
...
...
@@ -45,8 +45,7 @@ size_t LibRetroSink::SamplesInQueue() const {
void
LibRetroSink
::
SetDevice
(
int
device_id
)
{}
void
LibRetroSink
::
SubmitAudioFrames
(
const
int16_t
*
samples
,
size_t
sample_count
)
{
void
LibRetroSink
::
SubmitAudioFrames
(
const
int16_t
*
samples
,
size_t
sample_count
)
{
// audio_batch_cb(data, frames);
queue
.
emplace_back
(
samples
,
samples
+
sample_count
*
2
);
}
...
...
@@ -83,7 +82,7 @@ void audio_set_state(bool state) {}
}
// namespace AudioCore
void
LibRetro
::
SubmitAudio
(
const
int16_t
*
data
,
size_t
frames
)
{
void
LibRetro
::
SubmitAudio
(
const
int16_t
*
data
,
size_t
frames
)
{
LibRetro
::
audio_batch_cb
(
data
,
frames
);
}
...
...
src/audio_core/libretro_sink.h
View file @
2720b015
...
...
@@ -13,7 +13,7 @@ namespace LibRetro {
static
retro_audio_sample_batch_t
audio_batch_cb
;
void
SubmitAudio
(
const
int16_t
*
data
,
size_t
frames
);
void
SubmitAudio
(
const
int16_t
*
data
,
size_t
frames
);
}
// namespace LibRetro
...
...
@@ -34,7 +34,7 @@ public:
void
SetDevice
(
int
device_id
)
override
;
/// Function provided by Retroarch dynamically to submit audio frames.
void
SubmitAudioFrames
(
const
int16_t
*
data
,
size_t
frames
);
void
SubmitAudioFrames
(
const
int16_t
*
data
,
size_t
frames
);
private:
struct
Impl
;
...
...
src/citra_libretro/citra_libretro.cpp
View file @
2720b015
...
...
@@ -3,8 +3,8 @@
// Refer to the license.txt file included.
#include <list>
#include <math.h>
#include <numeric>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -130,23 +130,22 @@ void UpdateSettings(bool init) {
// For our other settings, import them from LibRetro.
Settings
::
values
.
use_cpu_jit
=
LibRetro
::
FetchVariable
(
"citra_use_cpu_jit"
,
"enabled"
)
==
"enabled"
;
LibRetro
::
FetchVariable
(
"citra_use_cpu_jit"
,
"enabled"
)
==
"enabled"
;
Settings
::
values
.
use_hw_renderer
=
LibRetro
::
FetchVariable
(
"citra_use_hw_renderer"
,
"enabled"
)
==
"enabled"
;
LibRetro
::
FetchVariable
(
"citra_use_hw_renderer"
,
"enabled"
)
==
"enabled"
;
Settings
::
values
.
use_shader_jit
=
LibRetro
::
FetchVariable
(
"citra_use_shader_jit"
,
"enabled"
)
==
"enabled"
;
LibRetro
::
FetchVariable
(
"citra_use_shader_jit"
,
"enabled"
)
==
"enabled"
;
Settings
::
values
.
enable_audio_stretching
=
LibRetro
::
FetchVariable
(
"citra_audio_stretching"
,
"enabled"
)
==
"enabled"
;
LibRetro
::
FetchVariable
(
"citra_audio_stretching"
,
"enabled"
)
==
"enabled"
;
Settings
::
values
.
toggle_framelimit
=
LibRetro
::
FetchVariable
(
"citra_limit_framerate"
,
"enabled"
)
==
"enabled"
;
LibRetro
::
FetchVariable
(
"citra_limit_framerate"
,
"enabled"
)
==
"enabled"
;
Settings
::
values
.
use_virtual_sd
=
LibRetro
::
FetchVariable
(
"citra_use_virtual_sd"
,
"enabled"
)
==
"enabled"
;
LibRetro
::
FetchVariable
(
"citra_use_virtual_sd"
,
"enabled"
)
==
"enabled"
;
Settings
::
values
.
is_new_3ds
=
LibRetro
::
FetchVariable
(
"citra_is_new_3ds"
,
"Old 3DS"
)
==
"New 3DS"
;
Settings
::
values
.
swap_screen
=
LibRetro
::
FetchVariable
(
"citra_swap_screen"
,
"Top"
)
==
"Bottom"
;
LibRetro
::
FetchVariable
(
"citra_is_new_3ds"
,
"Old 3DS"
)
==
"New 3DS"
;
Settings
::
values
.
swap_screen
=
LibRetro
::
FetchVariable
(
"citra_swap_screen"
,
"Top"
)
==
"Bottom"
;
Settings
::
values
.
use_gdbstub
=
LibRetro
::
FetchVariable
(
"citra_use_gdbstub"
,
"disabled"
)
==
"enabled"
;
LibRetro
::
FetchVariable
(
"citra_use_gdbstub"
,
"disabled"
)
==
"enabled"
;
// These values are a bit more hard to define, unfortunately.
auto
scaling
=
LibRetro
::
FetchVariable
(
"citra_resolution_factor"
,
"1x (Native)"
);
...
...
@@ -178,7 +177,7 @@ void UpdateSettings(bool init) {
LibRetro
::
settings
.
deadzone
=
(
float
)
std
::
stoi
(
deadzone
)
/
100
;
auto
analog_function
=
LibRetro
::
FetchVariable
(
"citra_analog_function"
,
"C-Stick and Touchscreen Pointer"
);
LibRetro
::
FetchVariable
(
"citra_analog_function"
,
"C-Stick and Touchscreen Pointer"
);
if
(
analog_function
==
"C-Stick and Touchscreen Pointer"
)
{
LibRetro
::
settings
.
analog_function
=
LibRetro
::
CStickFunction
::
Both
;
...
...
@@ -255,8 +254,8 @@ void UpdateSettings(bool init) {
}
// Configure the file storage location
auto
use_libretro_saves
=
LibRetro
::
FetchVariable
(
"citra_use_libretro_save_path"
,
"Citra Default"
)
==
"LibRetro Default"
;
auto
use_libretro_saves
=
LibRetro
::
FetchVariable
(
"citra_use_libretro_save_path"
,
"Citra Default"
)
==
"LibRetro Default"
;
if
(
use_libretro_saves
)
{
auto
target_dir
=
LibRetro
::
GetSaveDir
();
...
...
@@ -270,10 +269,11 @@ void UpdateSettings(bool init) {
// Ensure that this new dir exists
if
(
!
FileUtil
::
CreateDir
(
target_dir
))
{
LOG_ERROR
(
Frontend
,
"Failed to create
\"
%s
\"
. Using Citra's default paths."
,
target_dir
.
c_str
());
LOG_ERROR
(
Frontend
,
"Failed to create
\"
%s
\"
. Using Citra's default paths."
,
target_dir
.
c_str
());
}
else
{
FileUtil
::
GetUserPath
(
D_ROOT_IDX
,
target_dir
);
const
auto
&
target_dir_result
=
FileUtil
::
GetUserPath
(
D_USER_IDX
,
target_dir
);
const
auto
&
target_dir_result
=
FileUtil
::
GetUserPath
(
D_USER_IDX
,
target_dir
);
LOG_INFO
(
Frontend
,
"User dir set to
\"
%s
\"
."
,
target_dir_result
.
c_str
());
}
}
...
...
@@ -353,7 +353,7 @@ void retro_reset() {
/**
* libretro callback; Called when a game is to be loaded.
*/
bool
retro_load_game
(
const
struct
retro_game_info
*
info
)
{
bool
retro_load_game
(
const
struct
retro_game_info
*
info
)
{
LOG_INFO
(
Frontend
,
"Starting Citra RetroArch game..."
);
LibRetro
::
settings
.
file_path
=
info
->
path
;
...
...
@@ -391,11 +391,12 @@ bool retro_load_game(const struct retro_game_info *info) {
UpdateSettings
(
true
);
const
Core
::
System
::
ResultStatus
load_result
{
system_core
.
Load
(
emu_window
.
get
(),
LibRetro
::
settings
.
file_path
)};
system_core
.
Load
(
emu_window
.
get
(),
LibRetro
::
settings
.
file_path
)};
switch
(
load_result
)
{
case
Core
::
System
::
ResultStatus
::
ErrorGetLoader
:
LOG_CRITICAL
(
Frontend
,
"Failed to obtain loader for %s!"
,
LibRetro
::
settings
.
file_path
.
c_str
());
LOG_CRITICAL
(
Frontend
,
"Failed to obtain loader for %s!"
,
LibRetro
::
settings
.
file_path
.
c_str
());
LibRetro
::
DisplayMessage
(
"Failed to obtain loader for specified ROM!"
);
return
false
;
case
Core
::
System
::
ResultStatus
::
ErrorLoader
:
...
...
@@ -448,7 +449,7 @@ unsigned retro_get_region() {
return
RETRO_REGION_NTSC
;
}
bool
retro_load_game_special
(
unsigned
game_type
,
const
struct
retro_game_info
*
info
,
bool
retro_load_game_special
(
unsigned
game_type
,
const
struct
retro_game_info
*
info
,
size_t
num_info
)
{
return
retro_load_game
(
info
);
}
...
...
src/citra_libretro/emu_window/libretro_window.cpp
View file @
2720b015
...
...
@@ -110,7 +110,7 @@ void EmuWindow_LibRetro::DoneCurrent() {
}
void
EmuWindow_LibRetro
::
OnMinimalClientAreaChangeRequest
(
const
std
::
pair
<
unsigned
,
unsigned
>
&
minimal_size
)
{
const
std
::
pair
<
unsigned
,
unsigned
>&
minimal_size
)
{
width
=
minimal_size
.
first
;
height
=
minimal_size
.
second
;
}
...
...
@@ -126,12 +126,12 @@ void EmuWindow_LibRetro::Prepare(bool hasOGL) {
enableEmulatedPointer
=
true
;
switch
(
Settings
::
values
.
layout_option
)
{
switch
(
Settings
::
values
.
layout_option
)
{
case
Settings
::
LayoutOption
::
SingleScreen
:
if
(
swapped
)
{
// Bottom screen visible
baseX
=
Core
::
kScreenBottomWidth
;
baseY
=
Core
::
kScreenBottomHeight
;
}
else
{
// Top screen visible
}
else
{
// Top screen visible
baseX
=
Core
::
kScreenTopWidth
;
baseY
=
Core
::
kScreenTopHeight
;
enableEmulatedPointer
=
false
;
...
...
@@ -178,7 +178,7 @@ void EmuWindow_LibRetro::Prepare(bool hasOGL) {
}
// Update Libretro with our status
struct
retro_system_av_info
info
{};
struct
retro_system_av_info
info
{};
info
.
timing
.
fps
=
60.0
;
info
.
timing
.
sample_rate
=
41000
;
info
.
geometry
.
aspect_ratio
=
(
float
)
baseX
/
(
float
)
baseY
;
...
...
src/citra_libretro/environment.cpp
View file @
2720b015
...
...
@@ -142,7 +142,7 @@ void retro_set_input_state(retro_input_state_t cb) {
input_state_cb
=
cb
;
}
void
retro_get_system_av_info
(
struct
retro_system_av_info
*
info
)
{
void
retro_get_system_av_info
(
struct
retro_system_av_info
*
info
)
{
// These are placeholders until we get control.
info
->
timing
.
fps
=
60.0
;
info
->
timing
.
sample_rate
=
41000
;
...
...
src/citra_libretro/environment.h
View file @
2720b015
...
...
@@ -62,7 +62,7 @@ void OnConfigureEnvironment();
/// Submits audio frames to LibRetro.
/// @see retro_audio_sample_batch_t
void
SubmitAudio
(
const
int16_t
*
data
,
size_t
frames
);
void
SubmitAudio
(
const
int16_t
*
data
,
size_t
frames
);
/// Checks to see if the frontend configuration has been updated.
bool
HasUpdatedConfig
();
...
...
src/citra_libretro/input/input_factory.cpp
View file @
2720b015
...
...
@@ -57,9 +57,9 @@ public:
std
::
tuple
<
float
,
float
>
GetStatus
()
const
override
{
auto
axis_x
=
(
float
)
CheckInput
((
unsigned
int
)
joystick
,
RETRO_DEVICE_ANALOG
,
(
unsigned
int
)
button
,
0
);
(
float
)
CheckInput
((
unsigned
int
)
joystick
,
RETRO_DEVICE_ANALOG
,
(
unsigned
int
)
button
,
0
);
auto
axis_y
=
(
float
)
CheckInput
((
unsigned
int
)
joystick
,
RETRO_DEVICE_ANALOG
,
(
unsigned
int
)
button
,
1
);
(
float
)
CheckInput
((
unsigned
int
)
joystick
,
RETRO_DEVICE_ANALOG
,
(
unsigned
int
)
button
,
1
);
return
std
::
make_tuple
(
axis_x
/
INT16_MAX
,
-
axis_y
/
INT16_MAX
);
}
...
...
src/citra_libretro/input/mouse_tracker.cpp
View file @
2720b015
...
...
@@ -85,20 +85,22 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
lastMouseX
=
newX
;
lastMouseY
=
newY
;
x
=
std
::
max
(
static_cast
<
int
>
(
bottomScreen
.
left
),
std
::
min
(
newX
,
static_cast
<
int
>
(
bottomScreen
.
right
)))
-
bottomScreen
.
left
;
y
=
std
::
max
(
static_cast
<
int
>
(
bottomScreen
.
top
),
std
::
min
(
newY
,
static_cast
<
int
>
(
bottomScreen
.
bottom
)))
-
bottomScreen
.
top
;
x
=
std
::
max
(
static_cast
<
int
>
(
bottomScreen
.
left
),
std
::
min
(
newX
,
static_cast
<
int
>
(
bottomScreen
.
right
)))
-
bottomScreen
.
left
;
y
=
std
::
max
(
static_cast
<
int
>
(
bottomScreen
.
top
),
std
::
min
(
newY
,
static_cast
<
int
>
(
bottomScreen
.
bottom
)))
-
bottomScreen
.
top
;
}
else
if
(
LibRetro
::
settings
.
analog_function
!=
LibRetro
::
CStickFunction
::
CStick
)
{
// Use controller movement
float
controllerX
=
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
RETRO_DEVICE_ID_ANALOG_X
)
/
INT16_MAX
);
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
RETRO_DEVICE_ID_ANALOG_X
)
/
INT16_MAX
);
float
controllerY
=
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
RETRO_DEVICE_ID_ANALOG_Y
)
/
INT16_MAX
);
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
RETRO_DEVICE_ID_ANALOG_Y
)
/
INT16_MAX
);
// Deadzone the controller inputs
if
(
std
::
abs
(
controllerX
)
<
LibRetro
::
settings
.
deadzone
)
{
...
...
@@ -115,8 +117,8 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
Restrict
(
0
,
0
,
bottomScreen
.
GetWidth
(),
bottomScreen
.
GetHeight
());
// Make the coordinates 0 -> 1
projectedX
=
(
float
)
x
/
bottomScreen
.
GetWidth
();
projectedY
=
(
float
)
y
/
bottomScreen
.
GetHeight
();
projectedX
=
(
float
)
x
/
bottomScreen
.
GetWidth
();
projectedY
=
(
float
)
y
/
bottomScreen
.
GetHeight
();
// Ensure that the projected position doesn't overlap outside the bottom screen framebuffer.
// TODO: Provide config option
...
...
@@ -125,12 +127,11 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
float
renderHeight
=
(
float
)
bottomScreen
.
GetWidth
()
/
30
/
2
;
// Map the mouse coord to the bottom screen's position (with a little margin)
projectedX
=
bottomScreen
.
left
+
renderWidth
+
projectedX
*
(
bottomScreen
.
GetWidth
()
-
renderWidth
*
2
);
projectedX
=
bottomScreen
.
left
+
renderWidth
+
projectedX
*
(
bottomScreen
.
GetWidth
()
-
renderWidth
*
2
);
projectedY
=
bottomScreen
.
top
+
renderHeight
+
projectedY
*
(
bottomScreen
.
GetHeight
()
-
renderHeight
*
2
);
isPressed
=
state
;
}
...
...
@@ -144,7 +145,7 @@ void MouseTracker::Render(int bufferWidth, int bufferHeight) {
float
projectedLeft
=
centerX
-
renderWidth
;
float
projectedTop
=
centerY
-
renderHeight
;
float
projectedRight
=
centerX
+
renderWidth
;
float
projectedRight
=
centerX
+
renderWidth
;
float
projectedBottom
=
centerY
+
renderHeight
;
glUseProgram
(
shader
);
...
...
src/citra_libretro/input/mouse_tracker.h
View file @
2720b015
...
...
@@ -36,7 +36,8 @@ public:
/// Get the pressed position, relative to the framebuffer.
std
::
pair
<
unsigned
,
unsigned
>
GetPressedPosition
()
{
return
{
static_cast
<
const
unsigned
int
&>
(
projectedX
),
static_cast
<
const
unsigned
int
&>
(
projectedY
)};
return
{
static_cast
<
const
unsigned
int
&>
(
projectedX
),
static_cast
<
const
unsigned
int
&>
(
projectedY
)};
}
private:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment