mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
Merge branch 'master' of ssh://femoz.anipic.ru:222/Sunshine/mkxp-sunshine
This commit is contained in:
commit
4092eb570d
4 changed files with 22 additions and 26 deletions
|
|
@ -1,8 +1,10 @@
|
|||
#include <ruby.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
#include <SDL3/SDL_joystick.h>
|
||||
#include <limits.h>
|
||||
#include "security.h"
|
||||
#include "config.h"
|
||||
#include "eventthread.h"
|
||||
//Просто на C реализуем методы мне в падлу ебаться со статической линковкой и прочим дерьмом.
|
||||
//Аминь.
|
||||
|
||||
|
|
@ -32,6 +34,15 @@ 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;
|
||||
}
|
||||
|
||||
void SunshineBindingInit(){
|
||||
printf("[SunshineBindingInit] Initializing Sunshine binding\n");
|
||||
VALUE module = rb_define_module("Sunshine");
|
||||
|
|
@ -40,6 +51,7 @@ 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);
|
||||
//если методы доступны то просто не перезаписываем их
|
||||
if (!rb_respond_to(rb_cObject, rb_intern("class"))) {
|
||||
rb_define_method(rb_cObject, "class", rb_obj_class, 0);
|
||||
|
|
|
|||
|
|
@ -11,30 +11,11 @@ at_exit do
|
|||
end
|
||||
|
||||
begin
|
||||
p RUBY_VERSION
|
||||
if $debug
|
||||
trace = TracePoint.new(:raise) do |tp|
|
||||
p [tp.lineno, tp.event, tp.raised_exception]
|
||||
end
|
||||
trace.enable
|
||||
|
||||
0 / 0
|
||||
#tp = TracePoint.new(:call, :return) do |t|
|
||||
# case t.event
|
||||
# when :call
|
||||
# puts "WRAP START (#{start_code}) -> #{t.defined_class}##{t.method_id}"
|
||||
# when :return
|
||||
# puts "WRAP END -> #{t.defined_class}##{t.method_id}"
|
||||
# end
|
||||
#end
|
||||
#tp.enable
|
||||
end
|
||||
|
||||
|
||||
RPG::Mod.exec_hooks("hooks/Main/start", binding)
|
||||
$console = Graphics.fullscreen
|
||||
Graphics.frame_rate = 60
|
||||
Font.default_size = 20
|
||||
Sunshine.SetLED(0, 255, 0)
|
||||
|
||||
if defined?(RubyVM::YJIT)
|
||||
RubyVM::YJIT.enable
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ enum{
|
|||
};
|
||||
|
||||
static uint32_t usrIdStart;
|
||||
SDL_Gamepad* gc = nullptr;
|
||||
SDL_Joystick* js = nullptr;
|
||||
|
||||
bool EventThread::allocUserEvents(){
|
||||
usrIdStart = SDL_RegisterEvents(EVENT_COUNT);
|
||||
|
|
@ -123,7 +125,7 @@ void EventThread::process(RGSSThreadData &rtData){
|
|||
fps.displayCounter = 0;
|
||||
fps.acc = 0;
|
||||
fps.accDiv = 0;
|
||||
|
||||
|
||||
if (rtData.config.printFPS)
|
||||
fps.sendUpdates.set();
|
||||
|
||||
|
|
@ -147,12 +149,12 @@ void EventThread::process(RGSSThreadData &rtData){
|
|||
for (int i = 0; i < tmpstupidshit; ++i) {
|
||||
if (SDL_IsGamepad(i)) {
|
||||
//Load as game controller
|
||||
SDL_Gamepad *gc = SDL_OpenGamepad(i);
|
||||
gc = SDL_OpenGamepad(i);
|
||||
int id = SDL_GetJoystickID(SDL_GetGamepadJoystick(gc));
|
||||
controllers[id] = gc;
|
||||
} else {
|
||||
//Fall back to joystick
|
||||
SDL_Joystick *js = SDL_OpenJoystick(i);
|
||||
js = SDL_OpenJoystick(i);
|
||||
joysticks[SDL_GetJoystickID(js)] = js;
|
||||
}
|
||||
}
|
||||
|
|
@ -166,8 +168,6 @@ void EventThread::process(RGSSThreadData &rtData){
|
|||
int winW, winH;
|
||||
int i;
|
||||
|
||||
SDL_Joystick *js;
|
||||
SDL_Gamepad *gc;
|
||||
int id;
|
||||
std::map<int, SDL_Joystick*>::iterator jsit;
|
||||
std::map<int, SDL_Gamepad*>::iterator gcit;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ union SDL_Event;
|
|||
|
||||
#define MAX_FINGERS 4
|
||||
|
||||
extern SDL_Gamepad* gc;
|
||||
extern SDL_Joystick* js;
|
||||
|
||||
class EventThread{
|
||||
public:
|
||||
struct ControllerState{
|
||||
|
|
|
|||
Loading…
Reference in a new issue