Commit graph

524 commits

Author SHA1 Message Date
Solomon Peachy
a2c10f6189 unicode: Support characters beyond the first unicode plane
We used 16-bit variables to store the 'character code' everywhere but
this won't let us represent anything beyond U+FFFF.

This patch changes those variables to a custom type that can be 32 or 16
bits depending on the build, and adjusts numerous internal APIs and
datastructures to match.  This includes:

 * utf8decode() and friends
 * font manipulation, caching, rendering, and generation
 * on-screen keyboard
 * FAT filesystem (parsing and generating utf16 LFNs)
 * WIN32 simulator platform code

Note that this patch doesn't _enable_ >16bit unicode support; a followup
patch will turn that on for appropriate targets.

Appears to work on:

  * hosted linux, native, linux simulator in both 16/32-bit modes.

Needs testing on:

  * windows and macos simulator (16bit+32bit)

Change-Id: Iba111b27d2433019b6bff937cf1ebd2c4353a0e8
2025-09-12 09:24:30 -04:00
Solomon Peachy
16c9ef64b0 misc: Ensure stacks are always aligned with the native pointer size.
Change-Id: Ie7efae914dcb43be98bbb71bae9b765b2d87d817
2025-09-05 19:43:11 -04:00
Hairo R. Carela
6f107430f4 rgnano: Voltage and current measure support
Battery time estimation works now.

This commit also changes the mksquashfs path to FUNKEY_SDK_PATH.

Change-Id: Ic0aa4c40011b0716f1c36c014377eaccb486e841
2025-08-23 13:44:25 -04:00
Solomon Peachy
84504c7471 Revert "internals: Support characters beyond the first unicode plane (WIP)"
This reverts commit d05c59f35b.
2025-08-20 16:09:49 -04:00
Solomon Peachy
d05c59f35b internals: Support characters beyond the first unicode plane (WIP)
We used 16-bit variables to store the 'character code' everywhere but
this won't let us represent anything beyond U+FFFF.

This patch changes those variables to a custom type that can be 32 or 16
bits depending on the build, and adjusts numerous internal APIs and
datastructures to match.  This includes:

 * utf8decode() and friends
 * on-screen keyboard
 * font manipulation, caching, rendering, and generation
 * VFAT code parses and generates utf16 dirents
 * WIN32 simulator reads and writes utf16 filenames

Note that this patch doesn't _enable_ >16bit unicode support; a followup
patch will turn that on for appropriate targets.

Known bugs:

  * Native players in 32-bit unicode mode generate mangled filename
    entries if they include UTF16 surrogate codepoints.  Root cause
    is unclear, and may reside in core dircache code.

Needs testing on:

 * windows simulator (16bit+32bit)

Change-Id: I193a00fe2a11a4181ddc82df2d71be52bf00b6e6
2025-08-20 16:08:43 -04:00
Hairo R. Carela
c9e16e4888 rgnano: Sleep timer and idle poweroff support
Actually power off the handheld with the sleep timer and idle poweroff functions instead of closing rockbox.

This commit also moves setting system volume to max from the launch script to system-sdl.c so it works when running rockbox via instant play.

Change-Id: I174b67c6abef451faa05f4a8f52b8d9eeed98a22
2025-08-15 09:44:35 -04:00
Solomon Peachy
6265bbbd97 sdl: Explicitly disable the cursor for non-touchscreen devices
...Except for simulators, those always need the cursor

In practice this only affects the RG Nano as it is currently our
only SDL target that lacks a touchscreen.

Change-Id: I292f923848528c233da518b062d9ccd8a03515dd
2025-08-07 09:36:51 -04:00
Solomon Peachy
209f833c7a rgnano: Fix simulator build
Change-Id: I2e6dfae25a2dae18e672c5584e8bd52c7bbd279a
2025-08-06 21:25:57 -04:00
Hairo R. Carela
46d10dda33 rgnano: Instant play support and proper system brightness/volume handling
Instant play is a Funkey OS feature that allows it to relaunch at boot the last program it was running before shutting down, which means that if the handheld is powered off (holding the power button) while rockbox is running the next time it's powered on rockbox will launch at boot.

This commit also handles system brightness/volume in rockbox itself instead of the launch script, so the values are properly reset when powering off the handheld while rockbox is running.

Change-Id: Ie1adbf71069aeed5fbf6670971718a2f718716a3
2025-08-06 20:21:02 -04:00
Hairo R. Carela
7b0f408c71 rgnano: UI simulator support
Change-Id: Id488d16e01ef49a9d1b57641bc1c22ed2fef4931
2025-08-05 08:30:30 -04:00
Solomon Peachy
3dda9bd99b sdl: Turn on debugf in sdl-threads by default
Change-Id: I688732ad9bb52bd4eeb77d989e1a20e50ddd4a2c
2025-07-29 21:05:53 -04:00
Hairo R. Carela
48392bab94 New port: Anbernic RG Nano
A bit of context, this device is a clone of the FunKey-S with a different form factor, hardware is mostly identical, the relevant difference is it has audio out (via usb-c, adapter to 3.5mm is included), this is the reason why the FunKey-SDK is needed for bulding.

This port is based on the old SDL 1.2 code because the device doesn't have SDL2 support. Alongside what was supported in the SDL 1.2 builds this port supports battery level, charging status and backlight control.

Change-Id: I7fcb85be62748644b667c0efebabf59d6e9c5ade
2025-07-29 21:01:53 -04:00
Solomon Peachy
efefe143bd ibasso: Fix a build warning that got lost
Change-Id: I51287f5cdd7f07d9407ed6aac949d4e389d6df0e
2025-05-25 11:02:27 -04:00
Solomon Peachy
adb49159ce winsim: Build fixes for current mingw64 cross compiles
Change-Id: I5d523a4aa0ca9044b8f83ae6aafd4f3705ff96d6
2025-05-25 07:56:05 -04:00
Solomon Peachy
08a6f804ce ibasso: Use correct API to query power input and charging state
Instead of using the generic hosted sysfs code, which expects
a full path, the ibasso code's sysfs code uses an enumeration.
Unfortunatley the generic power input/charging code used the former
API but linked with the latter.  oops.

Correct this by placing a private copy of these functions in
the ibasso-specific port, and removing the generic version from
that build.

(A "proper" fix would be to rework all 17 of the ibasso sysfs calls
 to use the generic sysfs API)

Change-Id: Ic13adc9782d85560f0c74d77f60a629619d38668
2025-05-22 07:15:15 -04:00
Solomon Peachy
c63b82a895 debug: Report if double-buffered fb is enabled
(Only applies to hosted targets if FB_DOUBLEBUF is enabled)

Change-Id: I6ef3ead5f6ef12b26e3dd0d07ac582cff98deaed
2025-05-08 12:35:03 -04:00
Solomon Peachy
89ea2eafb5 surfansf28: Get rid of the redundant debug code.
Change-Id: Iabfea333fc8598e3b7518bd2502759864b1982e8
2025-05-08 12:27:48 -04:00
Solomon Peachy
0ebfab36ba surfansf28: More fixes:
* Use 16-bit audio output
 * More audio tweaks (mute on startup, working volume control)
 * Treat the rotary input as a scroll wheel (works now)

To-dos:

 * Better global keymap (incorporate touchscreen)
 * Turn on plugins and define the approximately eight bajillion keymaps
 * Still have some audible pops when we turn on, need to figure out why
 * Default Cabbiev2 comes off as rather crappy on this device

...I don't know how much work I will do on this thing, as the limited
number of physical controls (and a lack of a line-out) mean I'd never
want to use this thing myself.

Change-Id: I37229d92766495219ee989d9ae48b5ed79bd45f5
2025-05-06 09:56:03 -04:00
Solomon Peachy
95f970076e surfansf28: Major improvements:
* Add a crude keymap
 * Use native "hardware mute" for audiohw_mute()
 * Properly handle touchscreen inputs
 * Can now play back music, with some warts..

Broken:

 * rotary wheel still doesn't work
 * audio garbled/distorted a bit
 * no volume control

Change-Id: I040217035a7bf3983b0e269fca3408eedd972cd0
2025-05-05 20:38:18 -04:00
Solomon Peachy
3a0d490713 hosted: improvements in devinput touchscreen handling
Some screens (eg Surfans F28) only report absolute positioning
via "EV_ABS" events, and the actual "touch on, touch off" happens
via a separate "EV_KEY" event.  So handle this.

This also fixes a nasty bug introduced in 3270daf2c4.

Change-Id: If73d390679ba6ffe37541442f631c03b73774fbb
2025-05-05 20:34:28 -04:00
Solomon Peachy
859984bd8c Fix red in 82f3d0c18f, accidentaly commited it.
Change-Id: Ie801992589ea278e3c2864d9bb335aeff549debc
2025-05-04 18:57:31 -04:00
Solomon Peachy
82f3d0c18f WIP hosted port to the Surfans F28
* Only bootloader builds
 * Plugins disabled
 * No keymaps to anything else
 * No simulator
 * Touchscreen not wired up yet
 * Audio still untested

Bugs:

 * rotary encoder does nothing in bootloader
   (might be bootloader bug, might be something else)

Other stuff pulled in:

 * Unify all of the (identical!) hibyos makefiles
 * Rename the "bootloader" to more generic name

Change-Id: I6d8a3b58de726db8e89cf193c90960a070a575c2
2025-05-04 18:34:22 -04:00
Solomon Peachy
3270daf2c4 hosted: Have common /dev/input code handle touchscreens.
With this we should be able to consolidate some of the hosted
variations.

Change-Id: Ie03631b4e700e3a0adcdc1b8476237384f0ace1a
2025-05-04 18:34:22 -04:00
Solomon Peachy
6acbf74d7f Add support for double buffering to hosted framebuffer code
Requires kernel-level support to work.  No in-tree users yet

Change-Id: Iec7e22971aa24fc7a26996a3d507143955c0ab5c
2025-05-02 13:48:31 -04:00
Solomon Peachy
1f43b14127 linux-fbdev: Don't overrun the framebuffer when it's larger than expected
We expect a fixed FRAMEBUFFER_SIZE that's width*height*bitdepth, and we
mmap()ed that in.  However, when doing the initial fb clear, we
were using the hardware-provided 'finfo.smem_len' which could be
larger than FRAMEBUFFER_SIZE.  This overran our mmap and triggered
a segfault.

Correct this by mmaping (and clearing) the entire smem_len.  As a safety
measure, panic if smem_len is smaller than our expected FRAMEBUFFER_SIZE

Change-Id: I3222139c7aed6e8e8ee232b1730edd5cd70065ff
2025-05-02 11:42:31 -04:00
William Wilgus
4f3bbeaffc Remove BATTERY_TYPES
Change-Id: I4fa03a10d0032fd6f92722bbe1d4b7eec0b95cb4
2025-03-11 02:26:38 -04:00
William Wilgus
a05bd377ab [FixRed] YPR1
the YPR1 apparently can do voltage or percent measure
I'm pretty sure its missing logic for disksafe and shutdown,
perhaps the device takes care of it for you?

hopefully someone with the device notices the issue
(perhaps due to a older battery needing capacity tweaked)

Change-Id: I79d3927fa8b154ba231aa6894de7920a4e4dd4c7
2025-03-06 19:28:21 -05:00
William Wilgus
10f8312db4 FS#13538 export and import battery level tables
when battery_bench is run
exports a file in the rockbox directory called 'battery_levels.default'

if the user wants their own levels they can rename the file battery_levels.cfg
and it will be loaded at boot

some minimal error checking is performed prior to using the values

added manual entry

Change-Id: Ia0126faced0c7229fcf8385a1bcb584b5a9dc378
2025-03-06 11:54:21 -05:00
William Wilgus
95f4accf45 use lcd_drawinfo instead of separate drawmode, fg, bg calls
Change-Id: I181ff3a93f03ce1ae44a20f2b216de400320207f
2025-02-08 01:02:22 -05:00
William Wilgus
5d9b01b9ed [Fix Red] define lcd_awake for targets with lcd_sleep
Change-Id: I62f8f7908f2877d4b255075120f87e3c9a375f66
2025-01-05 12:12:57 -05:00
William Wilgus
2a825b866a SIMULATOR help text fix yellow
Change-Id: If425ead1c53f8021f6047abc6c440c1343c68e79
2024-12-29 21:46:34 -05:00
William Wilgus
fcbfa494f5 [Feature] Simulator add F1 help text
give a listing of the keys used in the simulator

Change-Id: Ifcb91c59de41c214d050bd175065fabb6cf9eac4
2024-12-29 21:25:48 -05:00
Christian Soffke
9ba59477a1 sdl: improve window resizing on macOS
This enables smooth resizing of the window using a
fixed aspect ratio, instead of snapping into the
correct aspect ratio only when the resize operation
has finished, by using an SDL event filter that gets
events delivered during the resize operation
(whereas SDL_PollEvent blocks until done on macOS).

Change-Id: Ie6614e4b6f49a24469c5ee6a69721c9fbd440dae
2024-12-30 01:08:12 +01:00
Christian Soffke
8ce9d9e39e simulator: maintain LCD position/size when toggling background
Change-Id: Id76464b77b33d531d6075a83038466e18fab3a7f
2024-12-30 01:08:11 +01:00
William Wilgus
8884284da4 simulator hand icon on button region mouse over
add a hand pointing cursor over the buttons

Change-Id: Idb54e084b5b768de845a94c5bb13e4435d9b82e5
2024-12-29 16:43:21 -05:00
Christian Soffke
5e09a9246c sdl: fix shutdown hang on MacOS when SDL threads are used
Change-Id: I2179d2beed89beba1716072fc06b9cc090118364
2024-12-27 11:45:53 +01:00
Christian Soffke
fa8b095f29 sdl: fix: concurrent drawing on Windows
On Windows, we need to prevent the event thread
from drawing at the same time as the main thread,
when window is being adjusted.

Change-Id: I2b4e4a50fec427e53e310593850e2a556a594b31
2024-12-26 12:24:24 +01:00
Christian Soffke
d323d968d8 sdl: adjust texture access pattern to "frequently"
probably doesn't make much of a difference
for our use case but should prevent creation
of temp buffers

Change-Id: Ie2cbefcbd7b8f94bed340f08bf71f764a32ed1ea
2024-12-25 19:24:32 +01:00
Christian Soffke
32cc5ee8f9 simulator: Press Tab to show/hide background
Change-Id: I80e8f629b1bbf37f92d243e190d541e7360e9dea
2024-12-25 08:34:40 -05:00
Christian Soffke
400452180d sdl: Keep texture around, upload LCD-parts only
No need to create a new texture for every
rendered frame, unless the scaling method
has been adjusted.

We also don't need to upload the (unchanged)
player interface to GPU memory repeatedly.

+ Remove unused lcd_display_redraw &
having_new_lcd variables

Change-Id: I5bff6aa2d54347a3f2c3afba8d8d7eb9e39f77f7
2024-12-25 08:34:40 -05:00
Christian Soffke
7aaa722a5d simulator: Adjust scaling using keyboard shortcuts
Press 0-3 to to adjust current zoom level
to 50% (0), 100% (1), 200% (2), or 300% (3).

Press 4 to switch between "best" (linear)
and nearest pixel sampling.

Change-Id: Id10d361659855a0ad9c97e6b341f498f72709ef5
2024-12-25 08:34:40 -05:00
Christian Soffke
759cbf4e5f sdl: Remove usage of SDL_SoftStretch
SDL 2 lets us take advantage of a fixed logical resolution,
where the renderer scales content up or down automatically.

Relative mouse motion is also affected by renderer scaling
by default (see SDL_HINT_MOUSE_RELATIVE_SCALING).

If window zoom has been enabled from the command line,
set scaling quality to "nearest pixel sampling" instead
of "best" to allow pixel peeping.

Change-Id: I4e5c19d36b55c985c26ac5ae64c4a6b8dd9b308d
2024-12-25 08:34:40 -05:00
Christian Soffke
60f3283f48 sdl: make window resizable, enable high DPI
Tested on Linux, MacOS, and Windows.

On MacOS and Windows, we constrain the window's aspect
ratio by adjusting the size when responding to resize
events.

On Linux, I've not found a way to do so, that doesn't
result in fairly stuttery behavior and weird jumpy
behavior of the resize handle, possibly depending
on your window manager. So, black bars are displayed
around the content.
Maybe someone, at some point, finds a way.
(SDL3 seems to have SDL_SetWindowAspectRatio)

When the window is in fullscreen, black bars are
display necessarily, of course, on all systems,
unless the player GUI has exactly the same aspect
ratio as the screen...

Change-Id: I535e6617497611ea57a4c19e08e552f990859cfe
2024-12-25 08:34:40 -05:00
Christian Soffke
79191bf9bb simulator: Fix Sansa Clip display position
Change-Id: I23be28e6bfa4ead326416d0457ffa11c3bf18a54
2024-12-25 12:23:27 +01:00
Solomon Peachy
e9b0aa495b SDL: special-case pulseaudio backend with a smaller PCM buffer size
Pull in a small pile of cleanups as well

Change-Id: I087c553e098e9214ce528d2568c22d90e3e86f04
2024-12-12 18:08:52 -05:00
Solomon Peachy
29e909c25d SDL: Log the version detected
* At build time (in configure script)
 * At runtime (but only for simulator builds)

Change-Id: I01c6f0f39d4c68e3a5a037212b65baf693bb84a9
2024-12-10 09:01:32 -05:00
Solomon Peachy
da3d658880 SDL: Work around build problems with SDL2 < 2.0.6
SDL_AUDIO_ALLOW_SAMPLES_CHANGE was added in 2.0.6, just
ignore it if we're compiling against an old version

Change-Id: Ia317fe9780b9e39b9fa1f882ada845011d4e8e60
2024-12-09 23:35:09 -05:00
Solomon Peachy
d483281fea SDL: Allow SDL_OpenAudioDevice() to override sample count
Change-Id: I4de40a2a168b98e6cc783e4a636903fd88028af4
2024-12-09 21:15:53 -05:00
Solomon Peachy
65d94ecd08 SDL: Allow the audio device used to be specified on the command line
To aid this we display the list of allowed drivers and devices at startup

Change-Id: If27fc2c4873b56cd220a3e3e1ad78e9ede1979e7
2024-12-09 21:06:51 -05:00
Solomon Peachy
b3dac27aa6 SDL: Convert to SDL2's AudioDevice() API
This lets us _demand_ a sane audio configuration that doesn't require
us to convert sample formats.

(Windows always seems to want us to supply 32-bit floating point)

Change-Id: I19113363b33ae99be33afceec50a319c182e9b29
2024-12-09 20:34:21 -05:00