New keyboard code tested. New non-event-driven framework started.
This commit is contained in:
parent
b81eeb3324
commit
4b68c49ce6
4 changed files with 159 additions and 4 deletions
|
@ -22,6 +22,9 @@ New Features
|
||||||
which default audio track you want (-o or --audio). For games with multiple
|
which default audio track you want (-o or --audio). For games with multiple
|
||||||
languages, you can specify AUDIO_TRACK in the games.dat as well.
|
languages, you can specify AUDIO_TRACK in the games.dat as well.
|
||||||
|
|
||||||
|
- New keyboard methods to make handling input easier, especially multiple
|
||||||
|
keypresses for diagonal movement.
|
||||||
|
|
||||||
- SINGE_DEAD_ZONE global variable now available based on the DEAD_ZONE
|
- SINGE_DEAD_ZONE global variable now available based on the DEAD_ZONE
|
||||||
controller configuration option.
|
controller configuration option.
|
||||||
|
|
||||||
|
|
|
@ -326,6 +326,27 @@ SCANCODE = {
|
||||||
SCANCODE_MIN = 4 -- Lowest value
|
SCANCODE_MIN = 4 -- Lowest value
|
||||||
SCANCODE_MAX = 286 -- Highest value, not the number of items in the table.
|
SCANCODE_MAX = 286 -- Highest value, not the number of items in the table.
|
||||||
|
|
||||||
|
MODIFIER = {
|
||||||
|
NONE = { name = "NONE", value = 0x0000 },
|
||||||
|
LSHIFT = { name = "LSHIFT", value = 0x0001 },
|
||||||
|
RSHIFT = { name = "RSHIFT", value = 0x0002 },
|
||||||
|
LCTRL = { name = "LCTRL", value = 0x0040 },
|
||||||
|
RCTRL = { name = "RCTRL", value = 0x0080 },
|
||||||
|
LALT = { name = "LALT", value = 0x0100 },
|
||||||
|
RALT = { name = "RALT", value = 0x0200 },
|
||||||
|
LGUI = { name = "LGUI", value = 0x0400 },
|
||||||
|
RGUI = { name = "RGUI", value = 0x0800 },
|
||||||
|
NUM = { name = "NUM", value = 0x1000 },
|
||||||
|
CAPS = { name = "CAPS", value = 0x2000 },
|
||||||
|
MODE = { name = "MODE", value = 0x4000 },
|
||||||
|
SCROLL = { name = "SCROLL", value = 0x8000 },
|
||||||
|
|
||||||
|
SHIFT = { name = "SHIFT", value = 0x0001 + 0x0002 },
|
||||||
|
CTRL = { name = "CTRL", value = 0x0040 + 0x0080 },
|
||||||
|
ALT = { name = "ALT", value = 0x0100 + 0x0200 },
|
||||||
|
GUI = { name = "GUI", value = 0x0400 + 0x0800 }
|
||||||
|
}
|
||||||
|
|
||||||
GAMEPAD_0 = {
|
GAMEPAD_0 = {
|
||||||
AXIS_LEFT_X = { name = "AXIS_LEFT_X", value = 500 },
|
AXIS_LEFT_X = { name = "AXIS_LEFT_X", value = 500 },
|
||||||
AXIS_LEFT_X_L = { name = "AXIS_LEFT_X_L", value = 501 },
|
AXIS_LEFT_X_L = { name = "AXIS_LEFT_X_L", value = 501 },
|
||||||
|
@ -497,3 +518,18 @@ if singeGetHeight ~= nil then
|
||||||
daphneGetWidth = singeGetWidth
|
daphneGetWidth = singeGetWidth
|
||||||
daphneScreenshot = singeScreenshot
|
daphneScreenshot = singeScreenshot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Singe 2.10 Threaded Application Support ------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
if singeMain ~= nil then
|
||||||
|
onOverlayUpdate = function()
|
||||||
|
coroutine.resume(SINGE_SELF)
|
||||||
|
return(OVERLAY_UPDATED)
|
||||||
|
end
|
||||||
|
singeYield = coroutine.yield
|
||||||
|
SINGE_SELF = coroutine.create(singeMain)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
117
assets/Service.singe
Normal file
117
assets/Service.singe
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
--[[
|
||||||
|
*
|
||||||
|
* Singe 2
|
||||||
|
* Copyright (C) 2006-2024 Scott Duensing <scott@kangaroopunch.com>
|
||||||
|
*
|
||||||
|
* This program 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 3
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
local socket = require("socket")
|
||||||
|
local copas = require("copas")
|
||||||
|
local https = require("copas.http").request
|
||||||
|
|
||||||
|
|
||||||
|
dofile("Singe/Framework.singe")
|
||||||
|
|
||||||
|
|
||||||
|
function get(url)
|
||||||
|
local download = {}
|
||||||
|
download.url = url
|
||||||
|
download.finished = false
|
||||||
|
copas.addthread(function(d)
|
||||||
|
d.result, d.error = https(d.url)
|
||||||
|
d.finished = true
|
||||||
|
end,
|
||||||
|
download)
|
||||||
|
return download
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function onInputPressed(what)
|
||||||
|
|
||||||
|
if what == SWITCH_LEFT then
|
||||||
|
discStepBackward()
|
||||||
|
end
|
||||||
|
|
||||||
|
if what == SWITCH_RIGHT then
|
||||||
|
discStepForward()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function onOverlayUpdate()
|
||||||
|
|
||||||
|
copas.step()
|
||||||
|
|
||||||
|
colorBackground(0, 0, 0, 127) -- this dims the background 50%
|
||||||
|
overlayClear()
|
||||||
|
|
||||||
|
overlayPrint(1, 1, dldGameList.url.." "..(dldGameList.finished and 'true' or 'false'))
|
||||||
|
if dldGameList.finished then
|
||||||
|
overlayPrint(1, 2, dldGameList.error)
|
||||||
|
overlayPrint(1, 3, dldGameList.result)
|
||||||
|
end
|
||||||
|
|
||||||
|
colorForeground(255, 0, 0)
|
||||||
|
overlayBox(0, 0, overlayGetWidth() - 1, overlayGetHeight() - 1)
|
||||||
|
|
||||||
|
spriteDraw((overlayGetWidth() - spriteGetWidth(sprServiceMenu)) / 2, 25, sprServiceMenu)
|
||||||
|
|
||||||
|
return(OVERLAY_UPDATED)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function onShutdown()
|
||||||
|
|
||||||
|
spriteUnload(sprServiceMenu)
|
||||||
|
fontUnload(fntSans18)
|
||||||
|
fontUnload(fntSans32)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
copas.running = true
|
||||||
|
|
||||||
|
dldGameList = get("https://kangaroopunch.com/api/singeSoftware")
|
||||||
|
|
||||||
|
overlaySetResolution(vldpGetWidth(), vldpGetHeight())
|
||||||
|
|
||||||
|
DISC_SINGE_LOGO = 140
|
||||||
|
|
||||||
|
discSkipToFrame(DISC_SINGE_LOGO)
|
||||||
|
discPause()
|
||||||
|
|
||||||
|
fontQuality(FONT_QUALITY_BLENDED)
|
||||||
|
fntSans18 = fontLoad("Singe/FreeSansBold.ttf", 18)
|
||||||
|
fntSans32 = fontLoad("Singe/FreeSansBold.ttf", 32)
|
||||||
|
|
||||||
|
fontSelect(fntSans32)
|
||||||
|
sprServiceMenu = fontToSprite("Singe Service Menu")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
|
|
||||||
|
Game Management
|
||||||
|
|
||||||
|
|
||||||
|
--]]
|
||||||
|
|
|
@ -5048,10 +5048,6 @@ void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) {
|
||||||
progTrace("Script is running");
|
progTrace("Script is running");
|
||||||
while (_global.running) {
|
while (_global.running) {
|
||||||
|
|
||||||
// Clear per-loop values.
|
|
||||||
_global.keyboardLastDown = SDL_SCANCODE_UNKNOWN;
|
|
||||||
_global.keyboardLastUp = SDL_SCANCODE_UNKNOWN;
|
|
||||||
|
|
||||||
// SDL Event Loop
|
// SDL Event Loop
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
@ -5296,6 +5292,9 @@ void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) {
|
||||||
_global.refreshDisplay = true;
|
_global.refreshDisplay = true;
|
||||||
}
|
}
|
||||||
frameClock = SDL_GetTicks() + 15; // Don't eat all the CPU.
|
frameClock = SDL_GetTicks() + 15; // Don't eat all the CPU.
|
||||||
|
// Clear per-frame values.
|
||||||
|
_global.keyboardLastDown = SDL_SCANCODE_UNKNOWN;
|
||||||
|
_global.keyboardLastUp = SDL_SCANCODE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update display
|
// Update display
|
||||||
|
|
Loading…
Add table
Reference in a new issue