Fix crash on app exit
This commit is contained in:
parent
446ffda6fe
commit
41ccfa39df
5 changed files with 44 additions and 6 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import sets, strutils
|
||||
import libnx/graphics
|
||||
import libnx/wrapper/hid
|
||||
import libnx/wrapper/console
|
||||
import libnx/wrapper/con
|
||||
import libnx/ext/integer128
|
||||
import libnx/account
|
||||
import libnx/input
|
||||
|
|
@ -38,7 +37,6 @@ proc main() =
|
|||
echo msg
|
||||
|
||||
|
||||
|
||||
mainLoop:
|
||||
let keysDown = keysDown(Controller.P1_AUTO)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import sets
|
||||
import libnx/graphics
|
||||
import libnx/wrapper/console
|
||||
import libnx/wrapper/con
|
||||
import libnx/wrapper/hid
|
||||
import libnx/app
|
||||
import libnx/input
|
||||
|
||||
|
||||
proc main() =
|
||||
initDefault()
|
||||
discard consoleInit(nil)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
author = "Joey Payne"
|
||||
description = "Nintendo Switch library libnx for Nim."
|
||||
license = "The Unlicense"
|
||||
|
|
|
|||
33
libnxGen.cfg
33
libnxGen.cfg
|
|
@ -22,6 +22,10 @@ filter=lock
|
|||
"${output}/nim.cfg"
|
||||
"${output}/config.nims"
|
||||
|
||||
[n.wildcard]
|
||||
wildcard = "console.h"
|
||||
rename = "$replace(console=con)"
|
||||
|
||||
[n.prepare]
|
||||
git = "https://github.com/switchbrew/libnx"
|
||||
execute = """
|
||||
|
|
@ -323,3 +327,32 @@ search.o = "import libnx"
|
|||
prepend.o = """
|
||||
import libnx/ext/integer128
|
||||
"""
|
||||
|
||||
[con.nim]
|
||||
search.o = "type\n"
|
||||
prepend.o = """
|
||||
|
||||
template CONSOLE_ESC*(x: string): string = "\x1b[" & $x
|
||||
# Colors
|
||||
template CONSOLE_RESET*: string = CONSOLE_ESC("0m")
|
||||
template CONSOLE_BLACK*: string = CONSOLE_ESC("30m")
|
||||
template CONSOLE_RED*: string = CONSOLE_ESC("31;1m")
|
||||
template CONSOLE_GREEN*: string = CONSOLE_ESC("32;1m")
|
||||
template CONSOLE_YELLOW*: string = CONSOLE_ESC("33;1m")
|
||||
template CONSOLE_BLUE*: string = CONSOLE_ESC("34;1m")
|
||||
template CONSOLE_MAGENTA*: string = CONSOLE_ESC("35;1m")
|
||||
template CONSOLE_CYAN*: string = CONSOLE_ESC("36;1m")
|
||||
template CONSOLE_WHITE*: string = CONSOLE_ESC("37;1m")
|
||||
|
||||
# Styles
|
||||
template CONSOLE_COLOR_BOLD*: int = (1 shl 0)
|
||||
template CONSOLE_COLOR_FAINT*: int = (1 shl 1)
|
||||
template CONSOLE_ITALIC*: int = (1 shl 2)
|
||||
template CONSOLE_UNDERLINE*: int = (1 shl 3)
|
||||
template CONSOLE_BLINK_SLOW*: int =(1 shl 4)
|
||||
template CONSOLE_BLINK_FAST*: int = (1 shl 5)
|
||||
template CONSOLE_COLOR_REVERSE*: int = (1 shl 6)
|
||||
template CONSOLE_CONCEAL*: int = (1 shl 7)
|
||||
template CONSOLE_CROSSED_OUT*: int = (1 shl 8)
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -54,14 +54,20 @@ var enabled = false
|
|||
proc initDefault*() =
|
||||
if not enabled:
|
||||
gfxInitDefault()
|
||||
enabled = true
|
||||
enabled = true
|
||||
|
||||
## *
|
||||
## @brief Uninitializes the graphics subsystem.
|
||||
## @warning Do not use \ref viExit when using this function.
|
||||
##
|
||||
proc exit*() =
|
||||
# XXX Important!!! This deallocHeap call must be here
|
||||
# in order for the switch not to crash. It must be run right
|
||||
# before gfxExit() to leave a clean slate in the OS. This call
|
||||
# will disable any further allocations and free all consumed
|
||||
# memory on the heap.
|
||||
if enabled:
|
||||
deallocHeap(runFinalizers = true, allowGcAfterwards = false)
|
||||
gfxExit()
|
||||
enabled = false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue