Update to spice2x-25-04-25 (pre-apply)

> broken commit
This commit is contained in:
[ ]
2025-05-07 00:25:31 +09:00
parent 04dee88276
commit c94de456b5
543 changed files with 78491 additions and 91698 deletions
-15
View File
@@ -1,15 +0,0 @@
# Lua Scripting
Supported version: Lua 5.4.3
No proper documentation yet. Check the example scripts if you need this!
For undocumented functions you can find the definitions in the source code (script/api/*.cpp).
They are very similar to what the network API provides.
# Automatic Execution
Create a "scripts" folder next to spice and put your scripts in there (subfolders allowed).
The prefix specifies when the script will be called:
- `boot_*`: executed on game boot
- `shutdown_*`: executed on game end
- `config_*`: executed when you start spicecfg (mostly for debugging/tests)
Example: "scripts/boot_patch.py" would be called on game boot.
-113
View File
@@ -1,113 +0,0 @@
-- example script for light effects on IIDX TT stab movement
-- create a folder called "script" next to spice and put me in there
--------------------------------------------------------------------------------
-- settings
tt_duration = 0.25
zero_duration = 0.3141592
loop_delta = 1 / 240
curve_pow = 1 / 4
col_r = 1.0
col_g = 0.0
col_b = 0.0
light_p1_r = "Side Panel Left Avg R"
light_p1_g = "Side Panel Left Avg G"
light_p1_b = "Side Panel Left Avg B"
light_p2_r = "Side Panel Right Avg R"
light_p2_g = "Side Panel Right Avg G"
light_p2_b = "Side Panel Right Avg B"
-- wait for game
while not analogs.read()["Turntable P1"] do yield() end
-- initial state
tt1_last = tonumber(analogs.read()["Turntable P1"].state)
tt2_last = tonumber(analogs.read()["Turntable P2"].state)
tt1_diff_last = 0
tt2_diff_last = 0
tt1_trigger = 0
tt2_trigger = 0
tt1_zero_elapsed = 0
tt2_zero_elapsed = 0
-- main loop
while true do
-- read state
tt1 = tonumber(analogs.read()["Turntable P1"].state)
tt2 = tonumber(analogs.read()["Turntable P2"].state)
time_cur = time()
-- calculate difference
tt1_diff = tt1 - tt1_last
tt2_diff = tt2 - tt2_last
-- fix wrap around
if math.abs(tt1_diff) > 0.5 then tt1_diff = 0 end
if math.abs(tt2_diff) > 0.5 then tt2_diff = 0 end
-- trigger on movement start and direction changes
if (tt1_diff_last == 0 and tt1_diff ~= 0)
or (tt1_diff_last > 0 and tt1_diff < 0)
or (tt1_diff_last < 0 and tt1_diff > 0) then
tt1_trigger = time_cur
end
if (tt2_diff_last == 0 and tt2_diff ~= 0)
or (tt2_diff_last > 0 and tt2_diff < 0)
or (tt2_diff_last < 0 and tt2_diff > 0) then
tt2_trigger = time_cur
end
-- light effects when last trigger is still active
if time_cur - tt1_trigger < tt_duration then
brightness = 1 - ((time_cur - tt1_trigger) / tt_duration) ^ curve_pow
lights.write({[light_p1_r]={state=brightness*col_r}})
lights.write({[light_p1_g]={state=brightness*col_g}})
lights.write({[light_p1_b]={state=brightness*col_b}})
else
lights.write_reset(light_p1_r)
lights.write_reset(light_p1_g)
lights.write_reset(light_p1_b)
end
if time_cur - tt2_trigger < tt_duration then
brightness = 1 - ((time_cur - tt2_trigger) / tt_duration) ^ curve_pow
lights.write({[light_p2_r]={state=brightness*col_r}})
lights.write({[light_p2_g]={state=brightness*col_g}})
lights.write({[light_p2_b]={state=brightness*col_b}})
else
lights.write_reset(light_p2_r)
lights.write_reset(light_p2_g)
lights.write_reset(light_p2_b)
end
-- flush HID light output
lights.update()
-- turntable movement detection
-- doesn't set the diff back to zero unless enough time has passed
if tt1_diff == 0 then
tt1_zero_elapsed = tt1_zero_elapsed + loop_delta
if tt1_zero_elapsed >= zero_duration then
tt1_diff_last = tt1_diff
end
else
tt1_zero_elapsed = 0
tt1_diff_last = tt1_diff
end
if tt2_diff == 0 then
tt2_zero_elapsed = tt2_zero_elapsed + loop_delta
if tt2_zero_elapsed >= zero_duration then
tt2_diff_last = tt2_diff
end
else
tt2_zero_elapsed = 0
tt2_diff_last = tt2_diff
end
-- remember state
tt1_last = tt1
tt2_last = tt2
-- loop end
sleep(loop_delta)
end
-57
View File
@@ -1,57 +0,0 @@
-- script examples
-- no proper documentation yet
-- create a folder called "script" next to spice and put me in there
-- then open the config and if needed select IIDX for the demo
--------------------------------------------------------------------------------
-- sleep for 0.2 seconds
sleep(0.2)
-- log functions
log_misc("example misc")
log_info("example info")
log_warning("example warning")
--log_fatal("this would terminate")
-- print time
log_info(time())
-- show message box
msgbox("You are running the example script! Select IIDX if not already done.")
-- wait until analog is available
while not analogs.read()["Turntable P1"] do yield() end
-- write button state
buttons.write({["P1 Start"]={state=1}})
-- write analog state
analogs.write({["Turntable P1"]={state=0.33}})
-- write light state
lights.write({["P2 Start"]={state=0.8}})
-- import other libraries in "script" folder
--local example = require('script.example')
-- demo
while true do
-- analog animation
analogs.write({["Turntable P2"]={state=math.abs(math.sin(time()))}})
-- button blink
if math.cos(time() * 10) > 0 then
buttons.write({["P1 1"]={state=1}})
else
buttons.write({["P1 1"]={state=0}})
end
-- flush HID light output
lights.update()
-- check for keyboard press
if GetAsyncKeyState(0x20) > 0 then
msgbox("You pressed space!")
end
end
@@ -12,3 +12,4 @@ from .keypads import *
from .lights import *
from .memory import *
from .touch import *
from .resize import *
+8 -2
View File
@@ -2,8 +2,14 @@ from .connection import Connection
from .request import Request
def lights_read(con: Connection):
res = con.request(Request("lights", "read"))
def lights_read(con: Connection, light_names=None):
req = Request("lights", "read")
if light_names:
for light_name in light_names:
req.add_param(light_name)
res = con.request(req)
return res.get_data()
+12
View File
@@ -0,0 +1,12 @@
from .connection import Connection
from .request import Request
def image_resize_enable(con: Connection, enable: bool):
req = Request("resize", "image_resize_enable")
req.add_param(enable)
con.request(req)
def image_resize_set_scene(con: Connection, scene: int):
req = Request("resize", "image_resize_set_scene")
req.add_param(scene)
con.request(req)
+62 -1
View File
@@ -179,7 +179,7 @@ class ControlTab(ttk.Frame):
self.card_lbl = ttk.Label(self.card, text="Card")
self.card_lbl.grid(row=0, columnspan=2)
self.card_entry = ttk.Entry(self.card)
self.card_entry.insert(tk.END, "E004000000000000")
self.card_entry.insert(tk.END, "E004010000000000")
self.card_entry.grid(row=1, columnspan=2, sticky=NSEW, padx=2, pady=2)
self.card_insert_p1 = ttk.Button(self.card, text="Insert P1", command=self.action_insert_p1)
self.card_insert_p1.grid(row=2, column=0, sticky=NSEW, padx=2, pady=2)
@@ -397,6 +397,65 @@ class LightsTab(ttk.Frame):
# set text
self.txt_lights.set_text(txt)
class ResizeTab(ttk.Frame):
"""Resize tab."""
def __init__(self, app, parent, **kwargs):
# init frame
ttk.Frame.__init__(self, parent, **kwargs)
self.app = app
self.parent = parent
# scale grid
self.columnconfigure(0, weight=1)
# image resize
self.resize = ttk.Frame(self, padding=(8, 8, 8, 8))
self.resize.grid(row=0, column=0, sticky=tk.E+tk.W)
self.resize.columnconfigure(0, weight=1)
self.resize.columnconfigure(1, weight=1)
self.resize_lbl = ttk.Label(self.resize, text="Image Resize")
self.resize_lbl.grid(row=0, columnspan=2)
self.resize_off = ttk.Button(self.resize, text="Disable", command=self.action_resize_false)
self.resize_off.grid(row=2, column=0, sticky=NSEW, padx=2, pady=2)
self.resize_on = ttk.Button(self.resize, text="Enable", command=self.action_resize_on)
self.resize_on.grid(row=2, column=1, sticky=NSEW, padx=2, pady=2)
self.resize_scene_1 = ttk.Button(self.resize, text="Scene 1", command=self.action_resize_scene_1)
self.resize_scene_1.grid(row=3, column=0, sticky=NSEW, padx=2, pady=2)
self.resize_scene_2 = ttk.Button(self.resize, text="Scene 2", command=self.action_resize_scene_2)
self.resize_scene_2.grid(row=3, column=1, sticky=NSEW, padx=2, pady=2)
self.resize_scene_3 = ttk.Button(self.resize, text="Scene 3", command=self.action_resize_scene_3)
self.resize_scene_3.grid(row=4, column=0, sticky=NSEW, padx=2, pady=2)
self.resize_scene_4 = ttk.Button(self.resize, text="Scene 4", command=self.action_resize_scene_4)
self.resize_scene_4.grid(row=4, column=1, sticky=NSEW, padx=2, pady=2)
@api_action
def action_resize_on(self):
spiceapi.image_resize_enable(self.app.connection, True)
@api_action
def action_resize_false(self):
spiceapi.image_resize_enable(self.app.connection, False)
@api_action
def action_resize_scene_1(self):
spiceapi.image_resize_set_scene(self.app.connection, 1)
@api_action
def action_resize_scene_2(self):
spiceapi.image_resize_set_scene(self.app.connection, 2)
@api_action
def action_resize_scene_3(self):
spiceapi.image_resize_set_scene(self.app.connection, 3)
@api_action
def action_resize_scene_4(self):
spiceapi.image_resize_set_scene(self.app.connection, 4)
class MainApp(ttk.Frame):
"""The main application frame."""
@@ -419,6 +478,8 @@ class MainApp(ttk.Frame):
self.tabs.add(self.tab_analogs, text="Analogs")
self.tab_lights = LightsTab(self, self.tabs)
self.tabs.add(self.tab_lights, text="Lights")
self.tab_resize = ResizeTab(self, self.tabs)
self.tabs.add(self.tab_resize, text="Resize")
self.tab_manual = ManualTab(self, self.tabs)
self.tabs.add(self.tab_manual, text="Manual")
self.tabs.pack(expand=True, fill=tk.BOTH)