Git Product home page Git Product logo

felk / dolphin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dolphin-emu/dolphin

54.0 54.0 10.0 434.36 MB

Dolphin is a GameCube / Wii emulator, allowing you to play games for these two platforms on PC with improvements.

Home Page: https://dolphin-emu.org/

License: Other

CMake 1.21% GLSL 0.42% Roff 0.02% Makefile 0.04% C 2.54% C++ 88.06% Shell 0.08% Perl 0.02% Assembly 0.04% Objective-C 0.03% Objective-C++ 1.02% NSIS 0.05% Java 0.88% JavaScript 0.02% Smarty 0.01% Python 0.47% Kotlin 5.09%

dolphin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dolphin's Issues

Add Support for get_frame()

I would very much appreciate the extra functionality to be able to call a method and have it return a numpy array of the RGB values of the current dolphin frame. I am a Deep Reinforcement Learning researcher, and this would help me very much as I want to allow an AI to use the raw pixel data to learn from. Thanks

Support for Accelerometer and Gyroscope

Hey, could you add support for Accelerometer and Gyroscope? I think it would be best to have x, y and z axis for the accelerometer and the pitch, yaw and roll for the gyroscope. And maybe the motion data timestamp for the accelerometer.

Regular breakpoints

Would it be much trouble to add regular code breakpoints as an event? MemoryBreakpoints can horribly lag some games (not due to your commits), but regular breakpoints seem to always work fine.

Build Issue on Windows

Unfortunately, I encountered a build error while attempting to compile it on my Windows machine using Visual Studio.

Here's the error message I received:

Severity Code Description Project File Line Suppression State
Error LNK1181 cannot open input file 'C:\Users\User\source\repos\dolphin\Build\x64\Debug\Scripting\bin\Scripting.lib' Dolphin C:\Users\User\source\repos\dolphin\Source\Core\DolphinQt\LINK 1

I'm new to C++ and was really looking forward to trying out this project. I'm not entirely sure what I might be doing wrong, and any guidance would be greatly appreciated.

Thank you so much for your time and for creating this project.

Copyright status of user python scripts.

Python scripts would import the dolphin library, which is under GPL. Does this mean that anyone who makes a script for Dolphin has to release the script under a GPL compatible license? According to the FSF faq, if the library is GPL, then any program that, but I presume this has to do with libraries which are compiled into the program, and I'm not sure how this applies for a python source file.

Importing external module (numpy) hangs up dolphin

I'm not sure if I identified the exact problem so I will write down what I try to achieve.

I would like to use some modules that aren't in the embedded python of this project. For this I modify the sys.path and add the folder where I store the external modules and import numpy like this:

import sys
sys.path.append("path\\to\\Python\\Python38\\Lib\\site-packages")

import numpy as np

Loading this script the emulator hangs up, if I load the script directly in the command-line the Dolphin window doesn't even come up. I tried numpy versions 1.19.5 and then upgraded it and used 1.21.3, in both cases I had the same hang up.

Maybe that's just a problem on my end. Would be interested how you would import external modules that aren't included in the embedded python package.

Python Scripts Desyncing/"Freezing"

Currently, Python scripts have the possibility of desyncing/freezing for a frame, which is especially noticeable with scripts that require frame perfect inputs. Games played without these scripts are able to sync with other Dolphin versions, so it is believed to be an issue to the way Python and Dolphin communicate. The reason behind these desyncs appears to be related to the frame count stopping at random intervals for a frame and resuming updates the frame after.

add support for pointers

disclaimer: I am not really a programmer so this might be already doable and I'm just dumb lol. I also might use bad terminology, but I tried to be as clear as I could 😓

I want to do stuff with certain game variables, but those variables are not always at the same place in memory. However, you can find these variables using pointers. Unfortunately, as far as I can tell there is no good way to ask dolphin to traverse these pointers atm.

This is my current solution for finding my speed:
base_vel = memory.read_u32(0x809AFF38)
base_vel = memory.read_u32(base_vel + 0xC)
base_vel = memory.read_u32(base_vel + 0x10)
base_vel = memory.read_u32(base_vel + 0x0)
base_vel = memory.read_u32(base_vel + 0x10)
base_vel = memory.read_u32(base_vel + 0x10)
base_vel = memory.read_f32(base_vel + 0x20)

I'd like to do something like this:
base_vel = memory.read_f32(0x809AFF38, 0xC, 0x10, 0x0, 0x10, 0x10, 0x20)

sorry if this is already doable lol

avoid Core linking ImGui

From dolphin-emu#7064 (comment):

As well as this, the code contained for the scripting API uses ImGUI, but the code is not well separated from Core and as such ImGUI now needs to be linked to the Core section of code in order for it to build (which isn't ideal in certain build circumstances eg headless, libretro etc)

Add support for programmatic IR input

I'd like to use Dolphin as a reinforcement learning environment, and the game I'm planning on working with requires Wii IR input, which appears unsupported.

Would it be possible to support IR input? The only alternative I can find is programmatically editing the TAS Input window.

Memorybreakpoint event returns None type on FrameAdvance()

The python script is not using frameadvance at all, but still seems to be triggered by it.

while True:
        (is_write, addr, value) = await event.memorybreakpoint()
        print(f"{addr:08x} was changed to {value}")

An await event.memorybreakpoint() loop will break the script when None type is returned. The correct way to write the code currently is:

while True:
    try:
        (is_write, addr, value) = await event.memorybreakpoint()
    except:
         continue

    print(f"{addr:08x} was changed to {value}")

A callback will throw errors, but not break the script.

savestate.load_from_slot() causes Dolphin to hang from within a loop

Here's a simplified snippet from my script for Mario Kart Wii:

savestate.load_from_slot(1) # works fine

while True:
    (width, height, data) = await event.framedrawn()

    if frame_counter > 460:
        frame_counter = 0
        savestate.load_from_slot(1) # causes Dolphin to hang
        continue

For some reason, the second call to load_from_slot causes Dolphin to hang. It works fine the first time (out of the loop).

Let me know if I can provide any additional detail.

emulator occasionally crashes when reloading or removing a script

easy to reproduce: load a script like this:

from dolphin import event
while True:
    await event.frameadvance()

and then hammer on "Reload Selected Script". The emulator will eventually crash.

Judging from the stacktrace this is a concurrency issue with an event firing while the script is being removed, causing the callback to still use a python object that has since been removed.
Commenting out Py_EndInterpreter(m_interp_threadstate) in PyScriptingBackend's destructor avoids the issue. Not sure how I'm gonna fix this cleanly.

Add Support for Classic Controller

I am hoping to use this fork for Deep Reinforcement learning, and some games such as Mario Kart Wii are much easier to do using the classic controller.

Freezing upon loading savestates

I've noticed a few ways that savestate functions can cause Dolphin to freeze. The first is when you attempt to load a savestate with the scripting API that wasn't created using the API. (Edit: This actually works, but for some reason the game speed is much faster than normal upon loading.) Likewise, attempting to load a savestate with a hotkey will also cause a freeze if the savestate was created using the API. Finally, loading a savestate twice in the same program causes a freeze. This is a quick program that causes that:

from dolphin import event, savestate

await event.frameadvance()
savestate.load_from_file([path to file]) #this one works fine
for i in range(60):
    await event.frameadvance()
savestate.load_from_file([path to file]) #this one crashes

I don't know why these freezes happen, and there might be some other bugs with the savestate module.

cannot compile

arch linux

[ 46%] Building CXX object Source/Core/Scripting/CMakeFiles/scripting.dir/ScriptingEngine.cpp.o
In file included from /home/samy/dolphin/Source/Core/Scripting/Python/PyScriptingBackend.h:12,
from /home/samy/dolphin/Source/Core/Scripting/ScriptingEngine.cpp:10:
/home/samy/dolphin/Source/Core/Core/API/Controller.h: In member function ‘void API::BaseManip::NotifyFrameAdvanced()’:
/home/samy/dolphin/Source/Core/Core/API/Controller.h:37:10: error: ‘erase_if’ is not a member of ‘std’; did you mean ‘enable_if’?
37 | std::erase_if(m_overrides, [](const auto& kvp) {
| ^~~~~~~~
| enable_if
make[2]: *** [Source/Core/Scripting/CMakeFiles/scripting.dir/build.make:76: Source/Core/Scripting/CMakeFiles/scripting.dir/ScriptingEngine.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1632: Source/Core/Scripting/CMakeFiles/scripting.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Build issues with pch.h / Python.h

I have been working on trying to see if I can get the Python scripting added into project rio (dolphin fork for mario superstar baseball). After adding the changes, and trying to build, I kept getting two errors:

"cannot open include file: 'pch.h': no such file or directory" (in some cases this instead has said Python.h instead of pch.h)

And

"cannot read module dependencies file c:\Users...\build\x64\release\scripting\registersmodule.h.module.json: Expecting element 'root' from namespace ".. Encountered 'None' with name " namespace ". The build order might be incorrect"

I am admittedly much less familiar with c++ in general, but I tried to clone this repo and build just to make sure it wasn't specific to Project Rio, and it still throws the same errors. Do you have any clue what it is that I could be doing that might be causing it? It seems like something with my configuration I guess, but I'm not certain

Support for python's Buffer protocol

The save-stating and screenshotting methods should be able to read from and write to any python object that exposes a buffer.

Writing the data directly into a buffer will greatly increase performance, because you won't have to allocate memory for a bytes object, nor will you have to copy the data twice.

The buffer protocol was made an official protocol as of python 3.11, and all major array-like objects support it (including bytes, bytearray, array.array, numpy.array, etc).

Creating PyTorch Tensors hangs Dolphin

I've been playing around with the idea of having the python script that interacts with dolphin perform computation using a pytorch model. However, when doing this I found that creating a pytorch tensor hangs dolphin, but only after await event.framedrawn() or event.frameadvance() has been called. Importing Pytorch and even loading a pytorch model appears to work fine before one of the aforementioned functions are called. This is done with the --no-subinterpreters version as this uses numpy.

Here's the code for recreation:

from dolphin import event, gui, savestate, memory, controller
import sys
sys.path.append("C:\\Users\\TYLER\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\site-packages")

import torch
import numpy as np

red = 0xffff0000

x = np.array([1,2,3,4])

frame_counter = 0
while True:
    frame_counter += 1
    # this first part works fine!
    tensor = torch.tensor(x, dtype=torch.float)

    

    (width, height, data) = await event.framedrawn()
    # await event.frameadvance() # no difference with this instead!

    # This line hands Dolphin!
    tens = torch.tensor(x, dtype=torch.float)
    

    gui.draw_text((10, 10), red, f"Frame: {frame_counter}")

Gamecube controller script not working

Hello,
I found your post on stackoverflow: https://stackoverflow.com/questions/32064844/python-interact-with-dolphin-emulator
I tried to test that code, I just installed this release: https://github.com/Felk/dolphin/releases
Then I made a python script which I put on my desktop called "new.py" and put in it the code that you posted on stackoverflow.
I've opened dolphin from your release, pressed on add new script and selected the "new.py" on my desktop.
But nothing's happening, the game plays normally like in normal dolphin, the A button isn't pressed by the python script but I can press it normally on my keyboard.

Build errors on windows

My build is failing on Windows. I do not get these errors with upstream dolphin-emu/dolphin. Help would be appreciated, thank you!

Error List output:

Severity	Code	Description	Project	File	Line	Suppression State

Error	C2062	type 'unknown-type' unexpected
  explicit FMT_CONSTEXPR format_string_checker( (compiling source file UICommon\UICommon.cpp)	DolphinLib	C:\...\dolphin\Externals\fmt\include\fmt\core.h	2951	

Error	C7595	'fmt::v9::basic_format_string<char,double,int &,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::basic_format_string': call to immediate function is not a constant expression	DolphinLib	C:\...\dolphin\Source\Core\UICommon\UICommon.cpp	556	

Error	LNK1181	cannot open input file 'C:\...\dolphin\Build\x64\Release\DolphinLib\bin\DolphinLib.lib'	Dolphin	C:\...\dolphin\Source\Core\DolphinQt\LINK	1	

Error description from Output log:

...

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951): error C2062: type 'unknown-type' unexpected
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951): error C2062:   explicit FMT_CONSTEXPR format_string_checker( (compiling source file UICommon\UICommon.cpp)
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message : while compiling class template member function 'fmt::v9::detail::format_string_checker<Char,fmt::v9::detail::error_handler,double,int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::format_string_checker(fmt::v9::basic_string_view<Char>,ErrorHandler)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message :             ErrorHandler=fmt::v9::detail::error_handler
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message :   explicit FMT_CONSTEXPR format_string_checker(
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2951,3): message :   ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,54): message : see reference to class template instantiation 'fmt::v9::detail::format_string_checker<Char,fmt::v9::detail::error_handler,double,int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>' being compiled
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,54): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,54): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,54): message :             Char=char
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,54): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,54): message :       detail::parse_format_string<true>(str_, checker(s, {}));
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,54): message :                                                      ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message : see reference to function template instantiation 'fmt::v9::basic_format_string<char,double,int &,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::basic_format_string<char[12],0>(const S (&))' being compiled
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :         with
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :         [
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :             S=char [12]
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :         ]
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :   return fmt::format("{:.{}Lf} {}", bytes / unit_size, decimals,
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :                      ^
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): error C7595: 'fmt::v9::basic_format_string<char,double,int &,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::basic_format_string': call to immediate function is not a constant expression

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message : failure was caused by a read of an uninitialized symbol
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message :     if (arg_id < num_args_ && types_ && !is_integral_type(types_[arg_id]))
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message :                                                                        ^ (compiling source file UICommon\UICommon.cpp)
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message : see usage of 'fmt::v9::detail::format_string_checker<Char,fmt::v9::detail::error_handler,double,int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::types_'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message :             Char=char
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(758,72): message :         ] (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message : the call stack of the evaluation (the oldest call first) is
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :   return fmt::format("{:.{}Lf} {}", bytes / unit_size, decimals,
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :                      ^
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message : while evaluating function 'fmt::v9::basic_format_string<char,double,int &,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::basic_format_string<char[12],0>(const S (&))'
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :         with
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :         [
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :             S=char [12]
37>C:\...\dolphin\Source\Core\UICommon\UICommon.cpp(556,22): message :         ]

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,40): message : while evaluating function 'void fmt::v9::detail::parse_format_string<true,char,checker>(fmt::v9::basic_string_view<char>,Handler &&)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,40): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,40): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,40): message :             Handler=checker
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,40): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,40): message :       detail::parse_format_string<true>(str_, checker(s, {}));
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3159,40): message :                                        ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message : while evaluating function 'const Char *fmt::v9::detail::parse_replacement_field<char,Handler&>(const Char *,const Char *,fmt::v9::detail::format_string_checker<Char,fmt::v9::detail::error_handler,double,int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>&)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message :             Handler=checker
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message :         begin = p = parse_replacement_field(p - 1, end, handler);
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2688,44): message :                                            ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2663,38): message : while evaluating function 'const Char *fmt::v9::detail::format_string_checker<Char,fmt::v9::detail::error_handler,double,int,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>::on_format_specs(int,const Char *,const Char *)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2663,38): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2663,38): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2663,38): message :             Char=char
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2663,38): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2663,38): message :       begin = handler.on_format_specs(adapter.arg_id, begin + 1, end);
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2663,38): message :                                      ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message : while evaluating function 'const char *fmt::v9::detail::parse_format_specs<double,fmt::v9::detail::compile_parse_context<Char,ErrorHandler>>(ParseContext &)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :             ErrorHandler=fmt::v9::detail::error_handler,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :             ParseContext=fmt::v9::detail::compile_parse_context<char,fmt::v9::detail::error_handler>
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :     return id >= 0 && id < num_args ? parse_funcs_[id](context_) : begin;
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2984,55): message :                                                       ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2746,17): message : while evaluating function 'const char *fmt::v9::formatter<double,char,void>::parse<ParseContext>(ParseContext &)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2746,17): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2746,17): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2746,17): message :             ParseContext=fmt::v9::detail::compile_parse_context<char,fmt::v9::detail::error_handler>
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2746,17): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2746,17): message :   return f.parse(ctx);
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2746,17): message :                 ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message : while evaluating function 'const Char *fmt::v9::detail::parse_format_specs<Char,fmt::v9::detail::specs_checker<handler_type>&>(const Char *,const Char *,SpecHandler)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message :             SpecHandler=fmt::v9::detail::specs_checker<handler_type> &
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message :     auto it = detail::parse_format_specs(begin, end, checker);
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(3044,41): message :                                         ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message : while evaluating function 'const Char *fmt::v9::detail::parse_precision<Char,fmt::v9::detail::specs_checker<handler_type>&>(const Char *,const Char *,Handler)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message :             Handler=fmt::v9::detail::specs_checker<handler_type> &
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message :     begin = parse_precision(begin, end, handler);
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2614,28): message :                            ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message : while evaluating function 'const Char *fmt::v9::detail::parse_arg_id<Char,fmt::v9::detail::parse_precision::precision_adapter>(const Char *,const Char *,IDHandler &&)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message :             IDHandler=fmt::v9::detail::parse_precision::precision_adapter
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message :       begin = parse_arg_id(begin, end, precision_adapter{handler});
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2504,27): message :                           ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2438,10): message : while evaluating function 'void fmt::v9::detail::parse_precision::precision_adapter::operator ()(void)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2438,10): message :   handler();
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2438,10): message :          ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2478): message : while evaluating function 'void fmt::v9::detail::dynamic_specs_handler<ParseContext>::on_dynamic_precision<fmt::v9::detail::auto_id>(Id)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2478): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2478): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2478): message :             ParseContext=fmt::v9::detail::compile_parse_context<char,fmt::v9::detail::error_handler>,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2478): message :             Id=fmt::v9::detail::auto_id
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2478): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2478): message :                                    Handler&& handler) -> const Char* { (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message : while evaluating function 'fmt::v9::detail::arg_ref<Char> fmt::v9::detail::dynamic_specs_handler<ParseContext>::make_arg_ref(fmt::v9::detail::auto_id)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message :             ParseContext=fmt::v9::detail::compile_parse_context<char,fmt::v9::detail::error_handler>
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message :     specs_.precision_ref = make_arg_ref(arg_id);
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2252,28): message :                            ^ (compiling source file UICommon\UICommon.cpp)

37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message : while evaluating function 'void fmt::v9::detail::compile_parse_context<Char,ErrorHandler>::check_dynamic_spec(int)'
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message :         with
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message :         [
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message :             Char=char,
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message :             ErrorHandler=fmt::v9::detail::error_handler
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message :         ]
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message :     context_.check_dynamic_spec(arg_id);
37>C:\...\dolphin\Externals\fmt\include\fmt\core.h(2273,32): message :                                ^ (compiling source file UICommon\UICommon.cpp)

...

38>LINK : fatal error LNK1181: cannot open input file 'C:\...\dolphin\Build\x64\Release\DolphinLib\bin\DolphinLib.lib'
38>Done building project "DolphinQt.vcxproj" -- FAILED.
========== Rebuild All: 36 succeeded, 2 failed, 0 skipped ==========

Breakpoints

I think there should be an add/remove code breakpoints like there is for memchecks.

Also, it would be nice to specify if any breakpoint should pause on break. For memory breakpoints, specifying read and/or write would also be good.

I could try to add this. Would memory and code breakpoints both go into the same API file? Also not sure the best way to handle the extra args.

Add support for frame advance

I would like to make a script that sets an input map, advances a frame or two, and then analyzes the graphical output before any further action. Is it possible to add a function that tells Dolphin to frame advance?

Build crashing on Ubuntu 23.10

The build is crashing for me on Ubuntu Desktop 23.10. I tried following along the other open issue and built with g++12 and clang, but still get issue. The error always comes when trying to build the PyScripting namespace. For reference here is how I'm building:

mkdir build
cd build
cmake ..
make -j $(nproc)

and it fails on the last command before I can install it. Here is the error, it is the same regardless of compiler used:

/home/macio/dolphin/Source/Core/Scripting/Python/PyScriptingBackend.cpp: In constructor ‘PyScripting::PyScriptingBackend::PyScriptingBackend(std::filesystem::__cxx11::path, API::EventHub&, API::Gui&, API::BaseManip&, API::BaseManip&, API::BaseManip&, API::BaseManip&, API::BaseManip&)’:
/home/macio/dolphin/Source/Core/Scripting/Python/PyScriptingBackend.cpp:148:5: error: ‘PyInterpreterConfig’ was not declared in this scope; did you mean ‘PyInterpreterState’?
  148 |     PyInterpreterConfig config = {
      |     ^~~~~~~~~~~~~~~~~~~
      |     PyInterpreterState
/home/macio/dolphin/Source/Core/Scripting/Python/PyScriptingBackend.cpp:153:75: error: ‘config’ was not declared in this scope; did you mean ‘Config’?
  153 |     PyStatus status = Py_NewInterpreterFromConfig(&m_interp_threadstate, &config);
      |                                                                           ^~~~~~
      |                                                                           Config
/home/macio/dolphin/Source/Core/Scripting/Python/PyScriptingBackend.cpp:153:23: error: ‘Py_NewInterpreterFromConfig’ was not declared in this scope
  153 |     PyStatus status = Py_NewInterpreterFromConfig(&m_interp_threadstate, &config);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/macio/dolphin/Source/Core/Scripting/Python/PyScriptingBackend.cpp:170:59: error: ‘PyErr_GetRaisedException’ was not declared in this scope; did you mean ‘PyErr_GetHandledException’?
  170 |       const char* ex_cstr = PyUnicode_AsUTF8(PyObject_Str(PyErr_GetRaisedException()));
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                                           PyErr_GetHandledException
/home/macio/dolphin/Source/Core/Scripting/Python/PyScriptingBackend.cpp:178:59: error: ‘PyErr_GetRaisedException’ was not declared in this scope; did you mean ‘PyErr_GetHandledException’?
  178 |       const char* ex_cstr = PyUnicode_AsUTF8(PyObject_Str(PyErr_GetRaisedException()));
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                                           PyErr_GetHandledException
make[2]: *** [Source/Core/Scripting/CMakeFiles/scripting.dir/build.make:90: Source/Core/Scripting/CMakeFiles/scripting.dir/Python/PyScriptingBackend.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:2060: Source/Core/Scripting/CMakeFiles/scripting.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Is it an issue with my python? for context I have miniconda installed. Any help would be greatly appreciated.

Left clicking inside emulator window disables all inputs

Game: Serious Sam: Next Encounter (US version, ID: G3BE9G)
Issue:
When I bind mouse left click ("Click 0") to R button on first gamecube controller, pressing left click disables all inputs (including the left click (R button) itself, so I can't, for example, hold left click to do a charged cannon shot). Binding gamecube R button to a keyboard key does not produce this issue.
Observations:

  1. This issue only occurs if I click inside the emulator window, if I left click on window title bar, it works just fine, all inputs go through.
  2. If I click left mouse button once and then hold it inside the emulator window then inputs do actually go through for some reason.
  3. Issue does not occur with right mouse button. With RMB bound to B button (reload) it works just fine.

Emulator version: Can reproduce on Preview 1, 2 and 3. On regular Dolphin 5.0-21460 issue does not occur.

TAS input window breaks when running scripts and vice versa

The way input overrides via scripting are handled right now causes the TAS input window to not register any inputs anymore. Also, if a script is executed before the TAS input window is opened, opening it makes the TAS input window work, but Scripting controller inputs not work anymore.

This is due to a limitation on how the new input override system was implemented, namely that it is not designed for multiple "hijackers" to exist simultaneously. More technically, I use SetInputOverrideFunction, which replaces the TAS input window's override function, and vice versa.

This needs to be fixed eventually. There's a TODO in the code:
https://github.com/Felk/dolphin/blob/master/Source/Core/Core/API/Controller.cpp#L31

BaseManip::BaseManip(API::EventHub& event_hub,
          const std::vector<ControllerEmu::EmulatedController*> controllers)
    : m_event_hub(event_hub), m_controllers(controllers)
{
  m_frame_advanced_listener = m_event_hub.ListenEvent<API::Events::FrameAdvance>(
      [&](const API::Events::FrameAdvance&) { NotifyFrameAdvanced(); });
  for (auto i = 0; i < m_controllers.size(); i++)
  {
    // TODO felk: find a more robust way to set the input override functions.
    //   This way scripting breaks once the TAS input window is opened,
    //   and vice versa, the TAS window breaks once scripting starts.
    m_controllers[i]->SetInputOverrideFunction([=](const std::string_view group_name,
                                                   const std::string_view control_name,
                                                   ControlState orig_state) {
      const InputKey input_key = {group_name, control_name};
      std::optional<ControlState> manip = this->PerformInputManip(i, input_key, orig_state);
      m_last_seen_input[{i, input_key}] = manip.value_or(orig_state);
      return manip;
    });
  }
}

I considered this not a priority right now, as I think people are likely not TASing and Scripting at the same time. But yeah, needs to be fixed eventually...

Build error with new commits

I pulled the new commits from the last two days, and now I have a build error on Ubuntu 22.04:
/usr/bin/ld: ../Scripting/CMakeFiles/scripting.dir/Python/PyScriptingBackend.cpp.o: in function `PyScripting::PyScriptingBackend::PyScriptingBackend(std::filesystem::__cxx11::path, API::GenericEventHub<API::Events::FrameAdvance, API::Events::SetInterrupt, API::Events::ClearInterrupt, API::Events::MemoryBreakpoint, API::Events::CodeBreakpoint>&, API::Gui&, API::GCManip&, API::WiiButtonsManip&, API::WiiIRManip&)': PyScriptingBackend.cpp:(.text+0x726): undefined reference to `PyInit_registers' collect2: error: ld returned 1 exit status make[2]: *** [Source/Core/DolphinQt/CMakeFiles/dolphin-emu.dir/build.make:2771: Binaries/dolphin-emu] Error 1 make[1]: *** [CMakeFiles/Makefile2:2567: Source/Core/DolphinQt/CMakeFiles/dolphin-emu.dir/all] Error 2 make: *** [Makefile:156: all] Error 2

await event.frameadvance() tied to VPS instead of FPS

Using "await event.frameadvance()" is dependent on VPS and not FPS. For instance, if you're getting 30 FPS, but 60 VPS, then "await event.frameadvance()" will execute twice per in-game frame. I tested this with:

while True:
    await event.frameadvance()
    print(f"frame advance!?")  

The above script outputs "frame advance!?" twice per frame in Super Mario Sunshine, a 30 FPS game, but only once per frame on the title screen of Luigi's Mansion, which runs at 60 FPS. Both, however, were running at 60 VPS. Here's a video demonstrating.

This doesn't seem intentional to me considering the readme example of frameadvance(), but if it is, I apologize😅 Thank you for your time!

Emulator freezes when loading saveslot from created thread

Hey there, after using the latest scripting preview (scripting-preview-3), I've noticed that my emulator occasionally freezes when loading a saveslot from a thread created using Python's threading module.

I am using this code to test after noticing the issue in another project:

import dolphin
import threading
import time


def main():
    while True:
        time.sleep(0.25)
        print("Loading from slot 1 ...")
        dolphin.savestate.load_from_slot(1)
        print("Loaded from slot 1")


threading.Thread(target=main).start()

After running this code for only about a minute, the emulator freezes, shown in the video below

Emulator.freezing.mp4

I have not tested to see if this issue still occurs in past versions of this project. I've also noticed that this can happen when reading the memory with dolphin.memory.

Set font size

When using gui.draw_text I would like to be able to set the font size somehow. The text is pretty small on a high-dpi monitor and becomes very difficult to read! I'm a bit of a noob when it comes to programming so I apologize if this is already possible...

GameCube controller input not working as expected

I'm not sure if there is something wrong on my end or if this is a bug, but I'm having a hard time getting programmatically setting inputs to a GameCube controller.

My code:

image

Console output:

image

Dolphin Controller Settings:

image

Let me know if you need any more information about my setup. Thanks!

Question: why is tkinter module not supported?

When running a script with tkinter imported, this exception is thrown: Script stderr: ModuleNotFoundError: No module named 'tkinter'

After doing some research, I see that ext-python specifically says to not copy over tkinter for the embed. So before trying to make a build that includes tkinter myself, I figure I could perhaps save some time and ask: for what reason is tkinter not included with the embed? Does it break Python Dolphin? Or am I safe to make a build with it included? Or alternatively, am I just overlooking something obvious?

For context, I've been co-developing an online mod for Super Mario Sunshine, and we use Python Dolphin for communicating between games. I'm trying to (easily) make a pop-up GUI to change settings on the fly and run commands.

Thank you, and I hope you're having a great day/night :^)

savestates causes the emulator to hang

I tested saving and loading savestates on Ubuntu 20.04, and the emulator just hangs on some of the methods. The save_* functions sometimes work and the load_* functions seems to reliably deadlock every time.

Scene module

This might be a lot of work in the backend, but I believe it would be super helpful to be able to slightly control some aspects of 3D rendering. Here are some possible methods I was thinking of.

def draw_point(pos: Position, color: int, size: int):
    """
    Accepts X, Y, and Z, color, and point size. Draws a single point at that location in 3D. Useful for debugging.
    """
def draw_line(point1: Position, point2: Position, color: int, thickness: float = 1):
    """
    Draws a line from point 1 to point 2 in 3D.
    """
def get_display_location(pos: Position):
    """
    Returns a tuple (x,y) that has the position of the given 3D point on the 2D display. 
    """
# and more...
# maybe

I was also thinking of a billboard text and a billboard texture method. They would display 2D text in the 3D scene that is facing the camera, and a 2D image in the 3D scene that is facing the camera, respectively. I do not know how hard it is to actually mess with the 3D scenes in Dolphin's code, but this would be pretty cool to see and use.

More ergonomic script selection

Right now, selecting a script from the GUI is a bit painful, because you have to navigate to the python file each time. This should be more ergonomic. A few ideas:

  • Remember the previous location the user navigated to
  • Offer a list of recently used scripts
  • Have a fixed directory for scripts (similar to where you'd put shaders for examples) and select scripts from there

this is something THC98 requested on the tasvideos forum: http://tasvideos.org/forum/viewtopic.php?t=22105

Add support for get_render_size()

The get_display_size() method returns the size of the window, which may differ from the actual render size. It is possible to calculate the render size using aspect ratios, but it would be a lot nicer to be able to get it easily through Dolphin. With the render size, you can align text and other GUI elements to be in the actual game render instead of all over the window.

image
Here is an example. get_display_size() currently gives the size of the red outline in this image, and the proposed get_render_size() would give the size of the yellow outline in the image.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.