Merge branch 'master' of ssh://femoz.anipic.ru:222/Sunshine/mkxp-sunshine

This commit is contained in:
niggacum@488 2026-06-28 14:32:10 +04:00
commit 9d1caef720
18 changed files with 47 additions and 1340 deletions

View file

@ -54,7 +54,6 @@ set(MAIN_HEADERS
src/gl-util.h
src/util.h
src/config.h
src/settingsmenu.h
src/keybindings.h
src/tileatlas.h
src/sharedstate.h
@ -103,7 +102,6 @@ set(MAIN_SOURCE
src/gl-debug.cpp
src/etc.cpp
src/config.cpp
src/settingsmenu.cpp
src/security.cpp
src/keybindings.cpp
src/tileatlas.cpp
@ -153,6 +151,7 @@ elseif(BSD)
set(MODLOADER OFF)
elseif(EMSCRIPTEN)
set(STEAM OFF)
set(MODLOADER OFF)
set(CMAKE_EXECUTABLE_SUFFIX ".html" CACHE INTERNAL "")
elseif(APPLE)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND cmake -P "${CMAKE_SOURCE_DIR}/patches/mac/CompleteBundle.cmake" VERBATIM)
@ -322,7 +321,7 @@ source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS})
set(CMAKE_CXX_STANDARD 23)
if(ANDROID)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32
add_library(main SHARED
${MAIN_HEADERS}
${MAIN_SOURCE}
${BINDING_HEADERS}
@ -330,7 +329,7 @@ if(ANDROID)
${EMBEDDED_SOURCE}
)
else()
add_library(main SHARED
add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32
${MAIN_HEADERS}
${MAIN_SOURCE}
${BINDING_HEADERS}

View file

@ -25,7 +25,6 @@
#include <ruby.h>
//костыль ебаный сука
#undef snprintf
#undef inline
#include "exception.h"

View file

@ -277,7 +277,26 @@ static VALUE setBinding(VALUE self, VALUE rb_arr, VALUE rb_target){
return Qnil;
}
static VALUE setLED(VALUE self, VALUE r, VALUE g, VALUE b) {
if (gc != nullptr) {
SDL_SetGamepadLED(gc, NUM2INT(r), NUM2INT(g), NUM2INT(b));
} else if (js != nullptr) {
SDL_SetJoystickLED(js, NUM2INT(r), NUM2INT(g), NUM2INT(b));
}
return Qnil;
}
static VALUE rumble(VALUE self, VALUE low_frequency_rumble, VALUE high_frequency_rumble, VALUE duration_ms) {
Uint16 low_freq = NUM2DBL(low_frequency_rumble) * 65535;
Uint16 high_freq = NUM2DBL(high_frequency_rumble) * 65535;
if (gc != nullptr) {
SDL_RumbleGamepad(gc, low_freq, high_freq, NUM2INT(duration_ms));
} else if (js != nullptr) {
SDL_RumbleJoystick(js, low_freq, high_freq, NUM2INT(duration_ms));
}
return Qnil;
}
struct{
const char *str;
@ -349,7 +368,11 @@ void inputBindingInit(){
_rb_define_module_function(module, "c_axis_from_name", getGamepadAxisFromName);
rb_const_set(module, rb_intern("GAMEPAD_AXIS_COUNT"), SDL_GamepadAxis::SDL_GAMEPAD_AXIS_COUNT - 1);
rb_define_module_function(module, "set_binding", RUBY_METHOD_FUNC(setBinding), 2);
rb_define_module_function(module, "set_binding", setBinding, 2);
// haptic
rb_define_singleton_method(module, "set_led", setLED, 3);
rb_define_singleton_method(module, "vibrate", rumble, 3);
// mouse
_rb_define_module_function(module, "mouse_x", inputMouseX);

View file

@ -1,4 +1,3 @@
#include <SDL3/SDL_log.h>
#include <ruby.h>
#include <SDL3/SDL_version.h>
#include <SDL3/SDL_gamepad.h>
@ -39,27 +38,6 @@ static VALUE int_times(VALUE self) {
return self;
}
static VALUE SetLED(VALUE self, VALUE r, VALUE g, VALUE b) {
if (gc != nullptr) {
SDL_SetGamepadLED(gc, NUM2INT(r), NUM2INT(g), NUM2INT(b));
} else if (js != nullptr) {
SDL_SetJoystickLED(js, NUM2INT(r), NUM2INT(g), NUM2INT(b));
}
return Qnil;
}
static VALUE Rumble(VALUE self, VALUE low_frequency_rumble, VALUE high_frequency_rumble, VALUE duration_ms) {
Uint16 low_freq = NUM2DBL(low_frequency_rumble) * 65535;
Uint16 high_freq = NUM2DBL(high_frequency_rumble) * 65535;
if (gc != nullptr) {
SDL_RumbleGamepad(gc, low_freq, high_freq, NUM2INT(duration_ms));
} else if (js != nullptr) {
SDL_RumbleJoystick(js, low_freq, high_freq, NUM2INT(duration_ms));
}
return Qnil;
}
void SunshineBindingInit(){
printf("[SunshineBindingInit] Initializing Sunshine binding\n");
VALUE module = rb_define_module("Sunshine");
@ -68,8 +46,6 @@ void SunshineBindingInit(){
rb_const_set(module, rb_intern("SDLVersion_minor"), INT2NUM(SDL_MINOR_VERSION));
rb_const_set(module, rb_intern("SDLVersion_micro"), INT2NUM(SDL_MICRO_VERSION));
rb_const_set(module, rb_intern("SECURITYSTATE"), rb_str_new_cstr(securitystate));
rb_define_singleton_method(module, "SetLED", SetLED, 3);
rb_define_singleton_method(module, "Vibrate", Rumble, 3);
//если методы доступны то просто не перезаписываем их
if (!rb_respond_to(rb_cObject, rb_intern("class"))) {
rb_define_method(rb_cObject, "class", rb_obj_class, 0);

View file

@ -6,6 +6,7 @@
#include <boost/algorithm/string/replace.hpp>
#include "sunshine.h"
#include "etc.h"
#include "sharedstate.h"
#include "binding-util.h"
@ -25,7 +26,7 @@
static bool setStyle = false;
static bool setTile = false;
static bool isCached = false;
#else
#elif unix_like
#ifdef __APPLE__
#include "mac-desktop.h"
static bool isCached = false;
@ -53,9 +54,6 @@
static std::map<std::string, bool> defBlurs;
// Fallback settings
static std::string fallbackPath;
//For Standalone Window managwrs desktops
bool IsNitrogen = false;
bool IsFeh = false;
#endif
#endif
@ -67,27 +65,7 @@
desktop = shState->oneshot().desktopEnv;
if (desktop != "nope") {
#ifdef DEBUG
printf("[desktopEnvironmentInit] Running on standalone Window Manager?Trying identify configuration...\n");
#endif
// If Nitrogen wallpaper manager and feh is aviable we can just use nitrogen --restore command and feh --bg-scale:P
if (FILE *file = fopen("/usr/bin/nitrogen", "r")){
IsNitrogen = true;
#ifdef DEBUG
printf("[desktopEnvironmentInit] Nitrogen wallpaper manager detected!I will try to use it...\n");
#endif
fclose(file);
}else{ fclose(file); }
if (FILE *file = fopen("/usr/bin/feh", "r")) {
IsFeh = true;
#ifdef DEBUG
printf("[desktopEnvironmentInit] Feh detected!I will try to use it...\n");
#endif
fclose(file);
} else{ fclose(file); }
if(!IsNitrogen && !IsFeh){
return;
}
}
if (desktop == "cinnamon" || desktop == "gnome" || desktop == "mate" || desktop == "deepin") {
if (desktop == "cinnamon" || desktop == "gnome" || desktop == "deepin") {
@ -380,11 +358,6 @@ end:
Debug() << "[wallpaperSet] Wallpaper command:" << command.str();
Debug() << "[wallpaperSet ] Result:" << result;
#endif
} else if (IsFeh == true) {
//path
printf("[wallpaperSet] Trying set wallpapers via feh\n");
std::string cmd = std::string("feh --bg-scale '") + path + "'";
std::system(cmd.c_str());
} else {
std::ifstream srcHint(gameDirStr + path);
std::ofstream dstHint(fallbackPath);
@ -511,8 +484,6 @@ RB_METHOD(wallpaperReset){
Debug() << "[wallpaperReset] Reset wallpaper command:" << command.str();
Debug() << "[wallpaperReset] Reset result:" << result;
#endif
} else if (IsNitrogen == true){
system("nitrogen --restore");
} else {
if (remove(fallbackPath.c_str()) != 0) {
#ifdef DEBUG

View file

@ -1,6 +0,0 @@
MRuby::Gem::Specification.new('core') do |spec|
spec.license = 'GPLv2'
spec.summary = "Bindings for MKXP engine itself"
spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
end

View file

@ -1 +0,0 @@
nothing here for now

View file

@ -1,6 +0,0 @@
MRuby::Gem::Specification.new('oneshot') do |spec|
spec.license = 'GPLv2'
spec.summary = "Bindings for OneShot"
spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
end

View file

@ -1 +0,0 @@
nothing here for now

View file

@ -1,6 +0,0 @@
MRuby::Gem::Specification.new('sunshine') do |spec|
spec.license = 'GPLv2'
spec.summary = "Bindings for Oneshot: Sunshine"
spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
end

View file

@ -1 +0,0 @@
nothing here for now

View file

@ -15,7 +15,7 @@ begin
$console = Graphics.fullscreen
Graphics.frame_rate = 60
Font.default_size = 20
Sunshine.SetLED(0, 255, 0)
Input.set_led(0, 255, 0)
if defined?(RubyVM::YJIT)
RubyVM::YJIT.enable

View file

@ -103,6 +103,13 @@ class Window_Settings
end
def update
if Input.key_press?(Input.key_from_name("F1"))
if Oneshot.msgbox(Oneshot::Msg::YESNO, tr("Are you sure you want to reset the control settings?"))
Settings.reset_controls!
@content.redraw_all
end
end
if self.visible
@content.update
end

View file

@ -32,7 +32,6 @@
#include "sharedstate.h"
#include "graphics.h"
#include "settingsmenu.h"
#include "al-util.h"
#include "debugwriter.h"
@ -174,25 +173,12 @@ void EventThread::process(RGSSThreadData &rtData){
SDL_GetWindowSize(win, &winW, &winH); // SDL_GL_GetDrawableSize(win, &winW, &winH);
SettingsMenu *sMenu = 0;
while (true){
if (!SDL_WaitEvent(&event)){
Debug() << "[EventThread::process] EventThread: Event error";
break;
}
if (sMenu && sMenu->onEvent(event, joysticks)){
if (sMenu->destroyReq()){
delete sMenu;
sMenu = 0;
updateCursorState(cursorInWindow && windowFocused, gameScreen);
}
continue;
}
/* Preselect and discard unwanted events here */
switch (event.type){
case SDL_EVENT_MOUSE_BUTTON_DOWN :
@ -227,14 +213,14 @@ void EventThread::process(RGSSThreadData &rtData){
case SDL_EVENT_WINDOW_MOUSE_ENTER :
cursorInWindow = true;
mouseState.inWindow = true;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused, gameScreen);
break;
case SDL_EVENT_WINDOW_MOUSE_LEAVE :
cursorInWindow = false;
mouseState.inWindow = false;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused, gameScreen);
break;
@ -249,13 +235,13 @@ void EventThread::process(RGSSThreadData &rtData){
case SDL_EVENT_WINDOW_FOCUS_GAINED :
windowFocused = true;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused, gameScreen);
break;
case SDL_EVENT_WINDOW_FOCUS_LOST :
windowFocused = false;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused, gameScreen);
resetInputStates();
break;
@ -285,15 +271,6 @@ void EventThread::process(RGSSThreadData &rtData){
break;
case SDL_EVENT_KEY_DOWN :
if (event.key.scancode == SDL_SCANCODE_F1){
if (!sMenu){
sMenu = new SettingsMenu(rtData);
updateCursorState(false, gameScreen);
}
sMenu->raise();
}
if (event.key.scancode == SDL_SCANCODE_F2){
if (!displayingFPS){
fps.immInitFlag.set();
@ -518,8 +495,6 @@ void EventThread::process(RGSSThreadData &rtData){
SDL_CloseGamepad(gcit->second);
for (jsit = joysticks.begin(); jsit != joysticks.end(); ++jsit)
SDL_CloseJoystick(jsit->second);
delete sMenu;
}
bool EventThread::eventFilter(void *data, SDL_Event *event){

View file

@ -481,7 +481,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title){
// Messagebox data
SDL_MessageBoxData data;
data.window = NULL; //p->window;
data.window = p->window;
data.colorScheme = 0;
data.title = title;
data.message = body;

File diff suppressed because it is too large Load diff

View file

@ -1,49 +0,0 @@
/*
** settingsmenu.h
**
** This file is part of mkxp.
**
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SETTINGSMENU_H
#define SETTINGSMENU_H
#include <stdint.h>
#include <map>
#include <SDL3/SDL_joystick.h>
struct SettingsMenuPrivate;
struct RGSSThreadData;
union SDL_Event;
class SettingsMenu{
public:
SettingsMenu(RGSSThreadData &rtData);
~SettingsMenu();
/* Returns true if the event was consumed */
bool onEvent(const SDL_Event &event,
const std::map<int, SDL_Joystick*> &joysticks);
void raise();
bool destroyReq() const;
private:
SettingsMenuPrivate *p;
};
#endif // SETTINGSMENU_H

View file

@ -4,10 +4,13 @@
//помойка ебаная
inline boost::chrono::high_resolution_clock::time_point startTime;
#if defined(__linux__) || defined(BSD) || defined(__sun) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__GNU__) || defined(__hurd__) || defined(__DragonFly__)
#define unix_like
#if defined(__linux__) || defined(BSD) || defined(__sun) || defined(__APPLE__) || \
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__GNU__) || defined(__hurd__) || defined(__DragonFly__)
#define unix_like 1
#endif
class Sunshine{
public:
Sunshine();