Cursor issue on Raspberry Pi using Erpiam

Hi! I’m new to JUCE and am working on a project for the Raspberry Pi (I have an Rpi 3) using Erpiam by forum user @gbevin. I got everything to cross-compile just fine (eventually since everything is built from source) both using the demo JUCE progam that comes with Erpiam as well as switching that out for my own custom JUCE program.

The problem I am having is that the mouse cursor is not showing up when I run either program on the actual Rpi. The mouse is working because I can see buttons get highlighted when I mouse over them (with my invisible cursor) and I can also click buttons and whatnot. The cursor actually does eventually show up if I mouse over a component that changes the cursor. For example, the demo JUCE program for Erpiam (called erpiam-main) has a large TextEditor component. If I mouse over that the cursor changes to an I-Beam and shows up and after that it stays visible, changing to the standard X cursor if I mouse off of the TextEditor.

Changing cursors in my custom JUCE program either in sub-components or the main window component using “setMouseCursor()” would also never work initially. The cursor would just stay the default cursor for my desktop environment on my PC and an invisible cursor on the Rpi. Eventually, by looking at the erpiam-main code, I was able to determine that by not calling “setResizable(true, true)” in the MainWindow constructor, this caused the cursor changes to start working. This was the case when running my JUCE program both on my PC (Linux) and on the Rpi. It seems like this might be a bug in JUCE, though I have that workaround since I don’t even want my window to be resizable anyway.

However, regardless of what I do, the cursor is never visible on the Rpi when either JUCE program first starts. I have tried a multitude of things including:

  1. Setting the cursor explicitly via the “-fc left_ptr” option to the X command in the script that starts it.

  2. Setting the cursor explicitly using the “xsetroot” command after starting X

  3. Ensuring that the cursor is not being hidden anywhere like with the “-nocursor” argument when starting X, and it’s also not set to hidden in main Erpiam package option “Hide X11 Cursor” in the “make menuconfig”.

  4. In my custom JUCE program in the MainComponent constructor I set the cursor to something else with setMouseCursor. I also tried setting up a timer to change the cursor to something else a few seconds after the program starts (the MainComponent cursor).

Nothing seems to work and the cursor never becomes visible unless I mouse over a Component that has a different cursor set. This isn’t a total show stopper and there might be other hacks I can try, but currently it is very annoying to have to wiggle the mouse around until it happens to go over the right Component when the JUCE program first starts on the Rpi. Oh, I also noticed that if I start xterm at boot instead of a JUCE program then the cursor shows up right away. So I’m not sure whether this is an erpiam/buildroot/TinyX issue or a JUCE issue but it just seems that there is no discernible reason why the cursor should be hidden when the program first starts up.

Has anyone else had this issue or have an idea of things to try? I’m not sure what else to try other than some hacks to work around the issue, but I figured I make a post in the hopes of fixing it the right way first. Thanks!

I was able to fix this with a hack. In my MainComponent constructor I move the cursor to be over a control with and different cursor and then move it back to it’s original location (which I save, and it is apparently the center of the screen). Then the cursor shows up as soon as the GUI pops up. Since in my program I don’t have any controls with a different cursor I have to set one. Then I use a timer to set that control’s cursor back to normal after a second. Strangely if I set the cursor back after doing everything in the constructor, then it doesn’t work and the cursor stays invisible.

The new issue I am having now is that for a few seconds after the JUCE program starts on the Rpi, the cursor doesn’t move when you move the mouse or moves extremely choppy. After a bit it starts moving normally and smooothly. Obviously I couldn’t tell that this was happening when the cursor was invisible and it was always moving smoothly by the time it showed up. This also seems to happen even if you wait like over minute before moving the mouse at all. It always happens the first time you move the mouse, no matter how long I wait.

Can you check your memory consumption and see if the rpi is maybe swapping? I see this sort of behaviour if my RPi starts swapping memory. Then - even if I wait a minute - the first cursor movement probably triggers the kernel to swap in some X11 code/resources and the cursor will move sluggish.

@alspacka I wanted to resurrect this thread. I am currently trying to install Erpiam on my Raspberry Pi 3. I’m currently just waiting for a HiFiBerry DAC+ to arrive in the mail. I had a few different questions that I was hoping either you or anyone else might help answer since I’m a Linux noob:

  1. Is the Erpiam build supposed to fail if the RPI 3 is not connected to a DAC? As of now, my build fails but I’m assuming its because the kernel expects for a DAC to be connected.

  2. How do you switch out the JUCE demo program to your own custom program? Is there somewhere in the folder hierarchy where you put your JUCE source code? Or is it that you have to build and load Erpiam to the Pi and then subsequently build the JUCE project on the Pi?

  3. Would you possible be willing to share your JUCE project? Sounds like you have already made some progress with your hacks that might be helpful.

I finally got @gbevin’s Erpiam working. Awesomesauce. Can someone elaborate on how to change the JUCE program? I’m not too familiar with Linux or Buildroot. I thought the easiest way to get things working was by hacking the erpiam-main.mk file and replacing the ERPIAM_MAIN_SITE to whatever github URL your own project resides. But what confuses me is the two directories specified in that file:

define ERPIAM_MAIN_BUILD_CMDS
(TARGET_MAKE_ENV) (MAKE) (TARGET_CONFIGURE_OPTS) CONFIG=Release TARGET_ARCH=-march=(ERPIAM_MAIN_TARGET_ARCH) -C $(@D)/Builds/LinuxMakefile
endef

define ERPIAM_MAIN_INSTALL_TARGET_CMDS
(INSTALL) -m 0755 -D (@D)/Builds/LinuxMakefile/build/erpiam-main $(TARGET_DIR)/usr/bin/erpiam-main
endef

I can’t seem to change these two directory paths to find my local project files and my own makefile. I thought I would build it to have the same name “erpiam-main”. Figured this would be the easiest way to go. Anyone here a BuildRoot user? I could use some guidance. @fabian @ftonello do you guys have any suggestions?

I’m no Buildroot expert, but I have managed to get my JUCE application to run using erpiam (also thanks to @gbevin

Assuming your application is called “MyApplication”:

  1. Make new directory in buildroot/packages with the name of your application (e.g myapplication).
  2. Add two files to that directory; first “Config.in” and second “myapplication.mk”.
  3. Edit “Config.in” with something similar to:
config BR2_PACKAGE_MY_APPLICATION
        bool "My Application"
        select BR2_ALSA_LIB
        select BR2_PACKAGE_FREETYPE
        select BR2_PACKAGE_LIBCURL
        select BR2_PACKAGE_XLIB_LIBEXT
        select BR2_PACKAGE_XLIB_LIBX11
        select BR2_PACKAGE_XLIB_LIBXCURSOR
        select BR2_PACKAGE_XLIB_LIBXINERAMA
        select BR2_PACKAGE_XLIB_LIBXRANDR
        depends on BR2_INSTALL_LIBSTDCPP
        depends on BR2_TOOLCHAIN_HAS_THREADS
        depends on BR2_TOOLCHAIN_USES_GLIBC
        help
          My new cool application description

(See erpiam-main’s “Config.in” for more details. This is where you add some buildroot dependencies).

  1. Edit myapplication.mk with something similar to:
    MY_APPLICATION_SITE_METHOD = git
    MY_APPLICATION_VERSION = master
    MY_APPLICATION_SITE = [Path/To/Git/Repo.git]
    MY_APPLICATION_DEPENDENCIES = alsa-lib freetype libcurl xlib_libX11 xlib_libXext xlib_libXcursor xlib_libXinerama xlib_libXrandr

    ifeq ($(BR2_i386),y)
    	MY_APPLICATION_TARGET_ARCH = x86
    else ifeq ($(BR2_x86_64),y)
    	MY_APPLICATION_TARGET_ARCH = x64
    else ifeq ($(BR2_powerpc),y)
    	MY_APPLICATION_TARGET_ARCH = ppc
    else ifeq ($(BR2_arm)$(BR2_armeb),y)
    	MY_APPLICATION_TARGET_ARCH = armv7-a
    else ifeq ($(BR2_mips),y)
    	MY_APPLICATION_TARGET_ARCH = mips
    else ifeq ($(BR2_mipsel),y)
    	MY_APPLICATION_TARGET_ARCH = mipsel
    else
    	MY_APPLICATION_TARGET_ARCH = $(BR2_ARCH)
    endif

    define MY_APPLICATION_BUILD_CMDS
    	$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) CONFIG=Release TARGET_ARCH=-march=$(MY_APPLICATION_TARGET_ARCH) -C $(@D)/Builds/LinuxMakefile
    endef

    define MY_APPLICATION_INSTALL_TARGET_CMDS
    	$(INSTALL) -m 0755 -D $(@D)/Builds/LinuxMakefile/build/[Name of My Application binary] $(TARGET_DIR)/usr/bin/[Name of My Application Binary]
    endef

    $(eval $(generic-package))
  1. In buildroot/package find “Config.in”.
    Under menu "Target packages" add your application entry:
source "package/myapplication/Config.in"
  1. Run make erpiam_defconfig.

  2. make menuconfig and enable My Application (it will be in whatever submenu you added it to it buildroot/package/Config.in.

  3. edit buildroot/board/erpiam/overlay/etc/init.d/S99Main. Replace erpiam-main with [name of MyApplication binary].

  4. Run make

  5. Profit!

Hopefully that gets you going. That has worked for me. Obviously you’ll want to add any extra dependencies that your application requires.

But what confuses me is the two directories specified in that file:

Git will pull your repo. This says where to find the makefile [ProjectRoot]/Builds/LinuxMakefile

define ERPIAM_MAIN_BUILD_CMDS
(TARGET_MAKE_ENV) (MAKE) (TARGET_CONFIGURE_OPTS) CONFIG=Release TARGET_ARCH=-march=(ERPIAM_MAIN_TARGET_ARCH) -C $(@D)/Builds/LinuxMakefile
endef

Once built, you need to install the built binary to a location in your Linux filesystem. This copies the built binary from [ProjectRoot]/Builds/LinuxMakefile/build/erpiam-main to Linux location /usr/bin/erpiam-main

define ERPIAM_MAIN_INSTALL_TARGET_CMDS
(INSTALL) -m 0755 -D (@D)/Builds/LinuxMakefile/build/erpiam-main $(TARGET_DIR)/usr/bin/erpiam-main
endef

3 Likes

Thanks @samspreadborough! Very helpful information. That will keep me busy for a while :wink:

@samspreadborough just a couple follow-up questions. I ended up trying to build a different JUCE project. The build was successful but once I loaded the image to my SD card and booted the RPi, all that popped up was a blank black screen. I think this might have had something to do with the menuconfig target packages option. I noticed that when I selected “MyApplication” it also automatically selected “Erpiam”. That seemed fine to me at the time. Is that supposed to happen? Any thoughts on would could be causing the blank screen?

From my understanding, Erpiam is needed as it’s the base components for the custom Buildroot. Erpiam-main is a demo application, and can be removed from menuconfig.

I’ve struggled with the blank screen situation also. I believe it is because the application is unable to connect to an x11 server. If you find a solution for this, please let me know!

It seems that if we could somehow be able to configure the terminal to launch at startup within our application, then we might be able to resolve the x11 server issue:

@samspreadborough is there somewhere in the Erpiam/MyApplication files we could add the following lines:

  • apt install lxde lxde-core lxterminal lxappearance
  • apt install lightdm
  • apt install xinit
apt install raspberrypi-ui-mods
sudo apt-get install xutils
sudo raspi-config

Seems like that could resolve our issues according to the link above.

If they’re not a Buildroot package already, they’d need to be created. Then you’d just add them as a dependency to the MyApplication.mk file.

I’ll take a look tomorrow

I tried adding those dependencies in the MyApplication.mk file and rebuilding the image. Unfortunately, I still have the same blank screen problem :frowning:

@samspreadborough have you had a chance to take a look at it any further?