Updated threaded model to not be dependent on framerate.
This commit is contained in:
parent
6c6a635484
commit
519ae04cc3
3 changed files with 141 additions and 6 deletions
|
@ -25,6 +25,8 @@ New Features
|
|||
- New keyboard methods to make handling input easier, especially multiple
|
||||
keypresses for diagonal movement.
|
||||
|
||||
- controllerGetButton() added.
|
||||
|
||||
- SINGE_DEAD_ZONE global variable now available based on the DEAD_ZONE
|
||||
controller configuration option.
|
||||
|
||||
|
|
|
@ -276,6 +276,10 @@ After installing Singe, you can find a sample input configuration file at
|
|||
file, read through <InstallDir> /Singe/Framework.singe.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Section
|
||||
Command Line Options
|
||||
\end_layout
|
||||
|
||||
\begin_layout Part
|
||||
Frequently Asked Questions
|
||||
\end_layout
|
||||
|
@ -356,7 +360,7 @@ Due to the way Singe accesses video files to provide frame seeking, it is
|
|||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Why does my audio stutter?
|
||||
Why does my audio stutter on Windows?
|
||||
\end_layout
|
||||
|
||||
\begin_layout Quotation
|
||||
|
@ -403,6 +407,75 @@ You should have sound again.
|
|||
Load up Singe, and your audio will be working and lag free!
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Why does my audio stutter on the Raspberry Pi?
|
||||
\end_layout
|
||||
|
||||
\begin_layout Quotation
|
||||
The Raspberry Pi OS now uses Pipewire as the default audio backend.
|
||||
Switching to PulseAudio seems to fix the issue.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Run
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
sudo raspi-config
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
from a terminal window.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Select
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
Advanced Options
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Select
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
Audio Config
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Select
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
PulseAudio
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press TAB, select
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
Ok
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
, and let it reboot.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Part
|
||||
Game Development
|
||||
\end_layout
|
||||
|
@ -1005,17 +1078,22 @@ function singeMain()
|
|||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
while(true) do
|
||||
while(true) do
|
||||
\end_layout
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
colorBackground(0, 0, 0, 255)
|
||||
if SINGE_OK_TO_DRAW then
|
||||
\end_layout
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
overlayClear()
|
||||
colorBackground(0, 0, 0, 255)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
overlayClear()
|
||||
\end_layout
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
@ -1025,12 +1103,17 @@ function singeMain()
|
|||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
colorForeground(255, 255, 255, 255)
|
||||
colorForeground(255, 255, 255, 255)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
overlayPrint(x, y, "+")
|
||||
overlayPrint(x, y, "+")
|
||||
\end_layout
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
end
|
||||
\end_layout
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
@ -1091,6 +1174,10 @@ dofile("Singe/Framework.singe")
|
|||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
Hybrid
|
||||
\end_layout
|
||||
|
||||
\begin_layout Section
|
||||
games.dat
|
||||
\end_layout
|
||||
|
@ -1839,6 +1926,10 @@ Controller
|
|||
controllerGetAxis
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsubsection
|
||||
controllerGetButton
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
Debug
|
||||
\end_layout
|
||||
|
|
42
src/singe.c
42
src/singe.c
|
@ -73,6 +73,7 @@ LSEC_API int luaopen_ssl_config(lua_State *L);
|
|||
#define MOUSE_AXIS_COUNT 2
|
||||
#define MAX_CONTROLLERS 4
|
||||
#define CONTROLLER_AXIS_COUNT 6
|
||||
#define CONTROLLER_BUTTON_COUNT 15
|
||||
#define AXIS_COUNT (MAX_CONTROLLERS * CONTROLLER_AXIS_COUNT + MAX_MICE * MOUSE_AXIS_COUNT)
|
||||
#define AXIS_KEY_DOWN 0
|
||||
#define AXIS_KEY_UP 1
|
||||
|
@ -332,6 +333,7 @@ int32_t apiColorBackground(lua_State *L);
|
|||
int32_t apiColorForeground(lua_State *L);
|
||||
|
||||
int32_t apiControllerGetAxis(lua_State *L);
|
||||
int32_t apiControllerGetButton(lua_State *L);
|
||||
|
||||
int32_t apiDebugPrint(lua_State *L);
|
||||
|
||||
|
@ -593,6 +595,45 @@ int32_t apiControllerGetAxis(lua_State *L) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
int32_t apiControllerGetButton(lua_State *L) {
|
||||
int32_t n = lua_gettop(L);
|
||||
int32_t c = 0;
|
||||
int32_t a = 0;
|
||||
int32_t v = 0;
|
||||
double d = 0;
|
||||
bool result = false;
|
||||
|
||||
if (n == 2) {
|
||||
if (lua_isnumber(L, 1)) {
|
||||
if (lua_isnumber(L, 2)) {
|
||||
d = lua_tonumber(L, 1); c = (int32_t)d;
|
||||
d = lua_tonumber(L, 2); a = (int32_t)d;
|
||||
if ((c < 0) || (c >= MAX_CONTROLLERS)) luaDie(L, "controllerGetButton", "Invalid controller index: %d", c);
|
||||
if ((a < 0) || (a >= CONTROLLER_BUTTON_COUNT)) luaDie(L, "controllerGetButton", "Invalid controller button: %d", a);
|
||||
if (_global.controllers[c] != NULL) {
|
||||
// Figure out SDL enumeration value from our framework value
|
||||
// Controller codes begin at 500 and increment in 100
|
||||
// The button values line up with the enumeration used by SDL + 18
|
||||
a = ((a - 500) - (c * 100)) - 18;
|
||||
v = SDL_GameControllerGetButton(_global.controllers[c], a);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
luaTrace(L, "controllerGetButton", "%d %d %d", c, a, v);
|
||||
lua_pushboolean(L, v);
|
||||
} else {
|
||||
luaDie(L, "controllerGetButton", "Failed!");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int32_t apiSingeGetHeight(lua_State *L) {
|
||||
int32_t y;
|
||||
SDL_GetWindowSize(_global.window, NULL, &y);
|
||||
|
@ -4718,6 +4759,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) {
|
|||
lua_register(_global.luaContext, "colorForeground", apiColorForeground); // 1.xx
|
||||
|
||||
lua_register(_global.luaContext, "controllerGetAxis", apiControllerGetAxis); // 2.00
|
||||
lua_register(_global.luaContext, "controllerGetButton", apiControllerGetButton); // 2.10
|
||||
|
||||
lua_register(_global.luaContext, "debugPrint", apiDebugPrint); // 1.xx
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue