mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 21:39:57 +00:00
gamepad icons (mid)
This commit is contained in:
parent
5f0d83410b
commit
d0f2f211c3
4 changed files with 169 additions and 26 deletions
|
|
@ -159,8 +159,26 @@ RB_METHOD(mriRgssMain);
|
|||
RB_METHOD(mriRgssStop);
|
||||
RB_METHOD(_kernelCaller);
|
||||
|
||||
|
||||
// TODO: find the reason why Symbol doesn't have some methods
|
||||
VALUE rb_symbol_to_s(VALUE self)
|
||||
{
|
||||
ID id = SYM2ID(self);
|
||||
const char *name = rb_id2name(id);
|
||||
|
||||
if (!name)
|
||||
return rb_str_new("", 0);
|
||||
|
||||
return rb_utf8_str_new_cstr(name);
|
||||
}
|
||||
|
||||
static void mriBindingInit(){
|
||||
printf("[mriBindingInit] Loading bindings...\n");
|
||||
|
||||
rb_define_method(rb_cSymbol, "to_s", RUBY_METHOD_FUNC(rb_symbol_to_s), 0);
|
||||
rb_define_method(rb_cSymbol, "name", RUBY_METHOD_FUNC(rb_symbol_to_s), 0);
|
||||
rb_define_method(rb_cSymbol, "id2name", RUBY_METHOD_FUNC(rb_symbol_to_s), 0);
|
||||
|
||||
tableBindingInit();
|
||||
etcBindingInit();
|
||||
fontBindingInit();
|
||||
|
|
@ -565,7 +583,7 @@ static void mriBindingExecute(){
|
|||
* but not doing it will lead to crashes due to closed
|
||||
* stdio streams on some platforms (eg. Windows) */
|
||||
int argc = 0;
|
||||
char **argv = 0;
|
||||
char **argv = nullptr;
|
||||
//options_argv3[] = "--jit"
|
||||
char options_argv1[] = "oneshot", options_argv2[] = "-ev";
|
||||
char* options_argv[] = {options_argv1, options_argv2, NULL};
|
||||
|
|
|
|||
|
|
@ -25,3 +25,4 @@ fixed segfault while to fast window size changing
|
|||
updated cg_blue picture
|
||||
Deleted useless hooks
|
||||
fix crash on game exit
|
||||
added gamepad button icons in settings
|
||||
|
|
|
|||
|
|
@ -275,9 +275,9 @@ module GamepadIcons
|
|||
},
|
||||
:axes => {
|
||||
Input::GamepadAxis::INVALID => [[9, 16], [9, 16]],
|
||||
Input::GamepadAxis::LEFTX => [[5, 1], [6, 1]],
|
||||
Input::GamepadAxis::LEFTX => [[6, 1], [5, 1]],
|
||||
Input::GamepadAxis::LEFTY => [[4, 1], [7, 1]],
|
||||
Input::GamepadAxis::RIGHTX => [[5, 2], [6, 2]],
|
||||
Input::GamepadAxis::RIGHTX => [[6, 2], [5, 2]],
|
||||
Input::GamepadAxis::RIGHTY => [[4, 2], [7, 2]],
|
||||
Input::GamepadAxis::LEFT_TRIGGER => [[6, 4], [9, 16]],
|
||||
Input::GamepadAxis::RIGHT_TRIGGER => [[7, 4], [9, 16]],
|
||||
|
|
@ -405,9 +405,9 @@ module GamepadIcons
|
|||
:axes => {
|
||||
Input::GamepadAxis::LEFT_TRIGGER => [[6, 15], [9, 16]],
|
||||
Input::GamepadAxis::RIGHT_TRIGGER => [[0, 17], [9, 16]],
|
||||
Input::GamepadAxis::LEFTX => [[9, 9], [10, 9]],
|
||||
Input::GamepadAxis::LEFTX => [[10, 9], [9, 9]],
|
||||
Input::GamepadAxis::LEFTY => [[8, 9], [11, 9]],
|
||||
Input::GamepadAxis::RIGHTX => [[9, 8], [10, 8]],
|
||||
Input::GamepadAxis::RIGHTX => [[10, 8], [9, 8]],
|
||||
Input::GamepadAxis::RIGHTY => [[8, 8], [11, 8]],
|
||||
}
|
||||
},
|
||||
|
|
@ -455,7 +455,7 @@ module GamepadIcons
|
|||
Input::GamepadButton::RIGHT_STICK => [3, 17],
|
||||
},
|
||||
:axes => {
|
||||
Input::GamepadAxis::RIGHTX => [[5, 16], [6, 16]],
|
||||
Input::GamepadAxis::RIGHTX => [[6, 16], [5, 16]],
|
||||
Input::GamepadAxis::RIGHTY => [[4, 16], [7, 16]],
|
||||
}
|
||||
},
|
||||
|
|
@ -477,7 +477,7 @@ module GamepadIcons
|
|||
},
|
||||
:stadia => {
|
||||
:extends => Input::GamepadType::XBOXONE,
|
||||
:icon => [8, 17],
|
||||
:icon => [10, 13],
|
||||
:buttons => {
|
||||
Input::GamepadButton::BACK => [5, 8],
|
||||
Input::GamepadButton::GUIDE => [8, 17],
|
||||
|
|
@ -492,26 +492,131 @@ module GamepadIcons
|
|||
}
|
||||
|
||||
GUIDS = {
|
||||
|
||||
"030000006f0e00001301000000000000" => :series_x,
|
||||
"030000006f0e00001304000000000000" => :series_x,
|
||||
"030000006f0e00001302000000000000" => :series_x,
|
||||
"030000006f0e00003901000000000000" => :series_x,
|
||||
"030000006f0e00001413000000000000" => :series_x,
|
||||
"03000000ab1200000103000000000000" => :series_x,
|
||||
"03000000ad1b000000f9000000000000" => :series_x,
|
||||
"030000005e040000130b000000000000" => :series_x,
|
||||
"03000000373500000411000023000000" => :series_x,
|
||||
"030000005e040000050b000003090000" => :series_x,
|
||||
"030000005e040000130b000001050000" => :series_x,
|
||||
"030000005e040000130b000013050000" => :series_x,
|
||||
"030000005e040000130b000015050000" => :series_x,
|
||||
"030000005e040000130b000007050000" => :series_x,
|
||||
"030000005e040000130b000017050000" => :series_x,
|
||||
"030000005e040000130b000022050000" => :series_x,
|
||||
"030000005e040000220b000017050000" => :series_x,
|
||||
"030000005e040000220b000021050000" => :series_x,
|
||||
"03000000c82d00000a20000000020000" => :series_x,
|
||||
"03000000c82d00000020000000000000" => :series_x,
|
||||
"06000000c82d00000020000006010000" => :series_x,
|
||||
"030000005e040000120b00000b050000" => :series_x,
|
||||
"030000005e040000120b000016050000" => :series_x,
|
||||
"030000005e040000120b000017050000" => :series_x,
|
||||
"060000005e040000120b000001050000" => :series_x,
|
||||
"030000006f0e0000d702000006640000" => :series_x,
|
||||
"030000006f0e0000d802000006640000" => :series_x,
|
||||
"030000006f0e0000ef02000007640000" => :series_x,
|
||||
"03000000d62000000540000001010000" => :series_x,
|
||||
"03000000d62000000520000050010000" => :series_x,
|
||||
"03000000d62000000b20000001010000" => :series_x,
|
||||
"03000000d62000000f20000001010000" => :series_x,
|
||||
"03000000d62000006520000002010000" => :series_x,
|
||||
"030000004b2900000430000011000000" => :series_x,
|
||||
"030000005e040000120b000001050000" => :series_x,
|
||||
"030000005e040000120b000005050000" => :series_x,
|
||||
"030000005e040000120b000007050000" => :series_x,
|
||||
"030000005e040000120b000009050000" => :series_x,
|
||||
"030000005e040000120b00000d050000" => :series_x,
|
||||
"030000005e040000120b00000f050000" => :series_x,
|
||||
"030000005e040000120b000011050000" => :series_x,
|
||||
"030000005e040000120b000014050000" => :series_x,
|
||||
"030000005e040000120b000015050000" => :series_x,
|
||||
"030000005e040000130b000005050000" => :series_x,
|
||||
"050000005e040000130b000001050000" => :series_x,
|
||||
"050000005e040000130b000005050000" => :series_x,
|
||||
"050000005e040000130b000007050000" => :series_x,
|
||||
"050000005e040000130b000009050000" => :series_x,
|
||||
"050000005e040000130b000011050000" => :series_x,
|
||||
"050000005e040000130b000013050000" => :series_x,
|
||||
"050000005e040000130b000015050000" => :series_x,
|
||||
"050000005e040000130b000017050000" => :series_x,
|
||||
"060000005e040000120b000007050000" => :series_x,
|
||||
"060000005e040000120b00000b050000" => :series_x,
|
||||
"060000005e040000120b00000d050000" => :series_x,
|
||||
"060000005e040000120b00000f050000" => :series_x,
|
||||
"050000005e040000130b000022050000" => :series_x,
|
||||
"060000005e040000120b000011050000" => :series_x,
|
||||
"32386235353630393033393135613831" => :series_x,
|
||||
"050000005e040000120b000000783f00" => :series_x,
|
||||
"050000005e040000120b000000783f80" => :series_x,
|
||||
"050000005e040000130b0000ffff3f00" => :series_x,
|
||||
"65633038363832353634653836396239" => :series_x,
|
||||
"050000005e040000130b0000df870001" => :series_x,
|
||||
"050000005e040000130b0000ff870001" => :series_x,
|
||||
"0300fa675e040000ff02000000007801" => :series_x, # this is my gamepad, but for some reason it is not in the gamecontrollerdb.txt
|
||||
"03000000491900001904000000000000" => :luna,
|
||||
"03000000710100001904000000000000" => :luna,
|
||||
"03000000491900001904000001010000" => :luna,
|
||||
"03000000710100001904000000010000" => :luna,
|
||||
"03000000491900001904000011010000" => :luna,
|
||||
"05000000710100001904000000010000" => :luna,
|
||||
"32333634613735616163326165323731" => :luna,
|
||||
"416d617a6f6e2047616d6520436f6e74" => :luna,
|
||||
"4c756e612047616d6570616400000000" => :luna,
|
||||
"03000000362800000100000000000000" => :ouya,
|
||||
"05000000362800000100000002010000" => :ouya,
|
||||
"05000000362800000100000003010000" => :ouya,
|
||||
"05000000362800000100000004010000" => :ouya,
|
||||
"39383335313438623439373538343266" => :ouya,
|
||||
"4f5559412047616d6520436f6e74726f" => :ouya,
|
||||
"03000000de2800000112000001000000" => :steam_controller,
|
||||
"03000000de2800000112000011010000" => :steam_controller,
|
||||
"03000000de2800000211000001000000" => :steam_controller,
|
||||
"03000000de2800000211000011010000" => :steam_controller,
|
||||
"03000000de2800004211000001000000" => :steam_controller,
|
||||
"03000000de2800004211000011010000" => :steam_controller,
|
||||
"03000000de280000fc11000001000000" => :steam_controller,
|
||||
"05000000de2800000212000001000000" => :steam_controller,
|
||||
"05000000de2800000511000001000000" => :steam_controller,
|
||||
"05000000de2800000611000001000000" => :steam_controller,
|
||||
"30623739343039643830333266346439" => :steam_controller,
|
||||
"31643365666432386133346639383937" => :steam_controller,
|
||||
"03000000de2800000512000010010000" => :steam_deck,
|
||||
"03000000de2800000512000011010000" => :steam_deck,
|
||||
"03000000d11800000094000000000000" => :stadia,
|
||||
"03000000d11800000094000000010000" => :stadia,
|
||||
"03000000d11800000094000011010000" => :stadia,
|
||||
"05000000d11800000094000000010000" => :stadia,
|
||||
"35383633353935396534393230616564" => :stadia,
|
||||
"476f6f676c65204c4c43205374616469" => :stadia,
|
||||
"5374616469614e3848532d6532633400" => :stadia,
|
||||
}
|
||||
|
||||
class << self
|
||||
def button(id, skinned = true, gamepad_type = nil)
|
||||
current_gamepad = gamepad_type
|
||||
if !ICONS.has_key?(gamepad_type)
|
||||
current_gamepad = Input::GamepadType.current_type
|
||||
if !ICONS.has_key?(current_gamepad)
|
||||
current_gamepad = Input::GamepadType::UNKNOWN
|
||||
end
|
||||
end
|
||||
current_gamepad = get_gamepad_type(gamepad_type)
|
||||
|
||||
debug_string = ""
|
||||
iterations = 0
|
||||
|
||||
result = nil
|
||||
while !result
|
||||
if !ICONS[current_gamepad].has_key?(:buttons)
|
||||
current_gamepad = ICONS[current_gamepad][:extends]
|
||||
debug_string << current_gamepad << "\n"
|
||||
iterations += 1
|
||||
if iterations > 10
|
||||
puts debug_string
|
||||
result = [8, 16]
|
||||
end
|
||||
next
|
||||
end
|
||||
result = ICONS[current_gamepad][:buttons][id].clone
|
||||
current_gamepad = ICONS[current_gamepad][:extends]
|
||||
end
|
||||
if skinned
|
||||
if id == Input::GamepadButton::SOUTH ||
|
||||
|
|
@ -525,23 +630,41 @@ module GamepadIcons
|
|||
end
|
||||
|
||||
def axis(id, dir, gamepad_type = nil)
|
||||
current_gamepad = gamepad_type
|
||||
if !ICONS.has_key?(gamepad_type)
|
||||
current_gamepad = Input::GamepadType.current_type
|
||||
if !ICONS.has_key?(current_gamepad)
|
||||
current_gamepad = Input::GamepadType::UNKNOWN
|
||||
end
|
||||
end
|
||||
current_gamepad = get_gamepad_type(gamepad_type)
|
||||
|
||||
debug_string = ""
|
||||
iterations = 0
|
||||
|
||||
result = nil
|
||||
while !result
|
||||
if !ICONS[current_gamepad].has_key?(:axes)
|
||||
current_gamepad = ICONS[current_gamepad][:extends]
|
||||
debug_string << "gamepad " << current_gamepad << "\n"
|
||||
iterations += 1
|
||||
if iterations > 10
|
||||
puts debug_string
|
||||
result = [8, 16]
|
||||
end
|
||||
next
|
||||
end
|
||||
result = ICONS[current_gamepad][:axes][id][1 - dir].clone
|
||||
current_gamepad = ICONS[current_gamepad][:extends]
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def get_gamepad_type(gamepad_override = nil)
|
||||
current_gamepad = gamepad_override
|
||||
if !ICONS.has_key?(current_gamepad)
|
||||
current_gamepad = GUIDS[Input::GamepadType.current_guid]
|
||||
if !ICONS.has_key?(current_gamepad)
|
||||
current_gamepad = Input::GamepadType.current_type
|
||||
if !ICONS.has_key?(current_gamepad)
|
||||
current_gamepad = Input::GamepadType::UNKNOWN
|
||||
end
|
||||
end
|
||||
end
|
||||
current_gamepad
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -730,8 +730,9 @@ class Window_Settings
|
|||
def redraw()
|
||||
redraw_icon
|
||||
offset = !!@icon_position ? ICON_SIZE * 2 + 8 : 0
|
||||
if (@parameter)
|
||||
if @parameter && @key_binds != Settings[@parameter]
|
||||
@key_binds = Settings[@parameter]
|
||||
apply
|
||||
end
|
||||
|
||||
@sprite.bitmap.clear
|
||||
|
|
@ -747,7 +748,7 @@ class Window_Settings
|
|||
offset = (@selected && i == @selection ? SELECTED_KEYS_MARGIN : 4)
|
||||
parameter_x = @sprite.bitmap.width - PARAMETER_KEY_WIDTH * (4 - i)
|
||||
key_bind = @key_binds[i]
|
||||
if key_bind && key_bind.type > KeyBind::Type::Key && key_bind.type < KeyBind::Type::JButton
|
||||
if !(@waiting_for_key && i == @selection) && key_bind && key_bind.type > KeyBind::Type::Key && key_bind.type < KeyBind::Type::JButton
|
||||
icon_x, icon_y = case key_bind.type
|
||||
when KeyBind::Type::CButton
|
||||
GamepadIcons.button(key_bind.button)
|
||||
|
|
@ -821,12 +822,12 @@ class Window_Settings
|
|||
@waiting_for_key = @settings_content.waiting_for_key = false
|
||||
apply
|
||||
redraw
|
||||
elsif c_button
|
||||
elsif c_button && (!Input.press?(Input::ACTION) || @accept_action)
|
||||
Settings[@parameter][@selection] = KeyBind.cbutton(c_button)
|
||||
@waiting_for_key = @settings_content.waiting_for_key = false
|
||||
apply
|
||||
redraw
|
||||
elsif c_axis
|
||||
elsif c_axis && (!Input.press?(Input::ACTION) || @accept_action)
|
||||
Settings[@parameter][@selection] = KeyBind.caxis(c_axis, Input::c_axis_pressure(c_axis) > 0 ? KeyBind::Positive : KeyBind::Negative)
|
||||
@waiting_for_key = @settings_content.waiting_for_key = false
|
||||
apply
|
||||
|
|
|
|||
Loading…
Reference in a new issue