Sunday, May 26, 2024

2010 MintBook Pro

A friend gave me her old 2010 MacBook Pro 13" when she upgraded to a new Apple Silicon one. I only wanted to computer to play around with Linux on it. My go-to Linux distro is Mint and I've never had any trouble live-booting it on an Intel Mac so that's what I planned to put on it from the start. But the default Cinnamon Desktop was designed with ex-Windows users in mind and I wanted a more Mac-like experience. Budgie Desktop is, in my opinion, a nicer looking Desktop Environment, but there isn't an official Budgie flavor of Mint. So I wanted to install Budgie too.

Granted a LOT of this is really down to just icons and themes and arranging things on panels to make it look and feel more familiar. You don't have to do this. And none of it will make it run Mac software. But I use a number of cross-platform, open-source apps even on my Mac and Windows machines, so its mostly just about arranging things the way I'm used to.  You can just as easily theme it to be more like Windows if that's what you're used to.

Anyway, if you're up for the adventure, read on!

GET MINT

First, for the 2010 MacBook Pro you are going to need Linux Mint 20.3 “Una” because anything later will not have the Nvidia graphics drivers you need:
https://www.linuxmint.com/edition.php?id=292

The open source "neuveau" graphics drivers do work, and will give you hardware accelerated OpenGL 3D, but they will not do hardware accelerated video encoding/decoding. So if you open a video in YouTube in the browser or try to watch a DVD it will max out the CPU and fans and run very, very HOT. The solution to that problem is to use the proprietary Nvidia drivers. But they were dropped after Linux Mint 20.3 (which is based on Ubuntu Focal Fossa). Which is why we are not installing the latest version of Mint.

Keep in mind that Linux Mint "Una" will only be supported through 2025. If you want to keep an updated operating system on the MacBook after that you'll need to upgrade, but you'll lose built-in support for compatible Nvidia proprietary drivers. In which case you'll have to use an unofficial PPA to manually install the kernel modules. I've also successfully downgraded the kernel itself (that was under Ubuntu), but that brings with it a host of dependency issues for some apps.

INSTALL MINT

Then follow this guide on how to set it up for dual booting:
https://linuxsimply.com/linux-basics/os-installation/dual-boot/ubuntu-on-mac/

The key bit here is to create that 1000MB EFI partition. Yes, you will end up with 2 EFI partitions on the same physical drive. While this is often considered a no-no, it’s not actually against the specification and will only be a problem if you also have a Windows partition. Which you shouldn’t because we’re not triple-booting Windows, Mac, and Linux. Mac OS X and macOS will live happily with more than one EFI partition on a single drive and by doing it this way you’ll be able to keep the normal Apple boot menu you get by holding down the Option key AND you’ll have the normal Grub boot for Linux. You don’t need to mess around with rEFInd or some other boot manager.

If you are also using Bootcamp to put Windows on the Mac you'll want to look into using rEFInd or some other boot manager, because Windows will not play nice with two EFI partitions. I wasn't putting Windows on mine so I didn't have to deal with this.

NVIDIA DRIVERS

The open-source "neuveau" drivers make the fans wind out and the GPU run very hot. You also don’t get hardware accelerated video in Firefox. We need the proprietary Nvidia drivers *but* these are the old 340.x ones AND the 2010 Macbook Pro firmware does not actually activate the VGA card as PCI-E bus master when it hands off to Grub. Consequently, the drivers can’t find the PCI-E registers for the GPU and you get a blank, black screen.

We also don’t have the option to override the graphics at the boot menu because the boot menu won’t show either. Here’s how to fix BOTH problems.

Note that while doing all this I’d recommend you have TimeShift turned on and taking snapshots at each boot. It will create a slight delay between login and desktop while it saves the snapshot, but if you screw up you’ll be able to revert easily.

1. Edit Grub Menu or you won’t ever see it:

sudo xed /etc/default/grub GRUB_TIMEOUT_STYLE=menu GRUB_TIMEOUT=5 GRUB_TERMINAL=console GRUB_GFXMODE=800x600

2. Make sure to turn on TimeShift so you can roll back if you screw stuff up!!

3. Get Ready for Proprietary Nvidia 340 Drivers...

3a. Find your PCI-E Bus IDs:

lshw -businfo -class bridge -class display pci@000:00:17.0 bridge MCP89 PCI Express Bridge pci@000.04:00.0 display MCP89 [GeForce 320M]

(The IDs may be different on your specific computer)
We need the XX:XX.X number after the @

3b. Install Set PCI Module (if necessary):

sudo apt-get install grub-efi-amd64-bin

(odds are it will say it already has the newest version)

3c. Copy Set PCI Module to EFI Boot (if necessary)

sudo cp /usr/lib/grub/x86_64-efi/setpici.* /boot/efi/EFI/ubuntu/x86_64-efi

3d. Create Enable VGA Configuration File:

sudo xed /etc/grub.d/01_enable_vga.conf

3e. Put the following in that file:

cat << EOF insmod setpci setpci -s "00:17.0" 3e.b=8 setpci -s "02:00.0" 04.b=7 EOF

3f. SAVE and Repair Permissions:

sudo chmod 755 /etc/grub.d/01_enable_vga.conf

4. Update Grub:

sudo update-grub

5. Reboot

6. Check PCI Registers after Reboot:

sudo setpci -s “00:17.0” 3e.b > 08 sudo setpci -s “04:00.0” 04.b > 07

Note that the first one might spit back “0a” instead of “08” — it apparently does not matter.

7. Install the Nvidia 340.x proprietary drivers.

Note: Also install the proprietary Broadcom driver so the Wi-fi works.

BE PATIENT! This will take a LONG time to complete.

8. Reboot, enjoy Nvidia graphics and Wi-Fi!

Note: The “LM” boot logo being screwed up is normal. You should then see the “NVIDIA” splash screen shortly thereafter followed by the login screen.

What About In The Future?

Unfortunately Mint “Una” will only be supported up to April 2025. If you want to use a newer version of Linux Mint you’ll have to figure out the Nvidia driver issue yourself. So, if you are reading this in the summer of 2025, assuming the world still exists, your option for any later version of Linux is:

sudo add-apt-repository ppa:kelebek333/nvidia-legacy sudo apt update sudo apt install nvidia-340-updates nvidia-340-updates-dev xorg-modulepath-fix

Reboot.

Note that PPA repo should work to build the kernel module for any Linux. Keep in mind you need to use X11 because this old Nvidia card is incompatible with Wayland.

You could also try rolling back the kernel in a later version, which I’ve done before myself, but you’re asking for a ton of trouble. You’re better off risking the PPA above.

INSTALLING BUDGIE

Linux Mint’s default Cinnamon Desktop is designed to ease the learning curve for Windows users coming over to Linux. It is therefore designed with classic Windows in mind. But we’re on a Mac. We’re making a “MintBook Pro” here, so lets get something a little more Mac-like on it! IMO that means putting Budgie Desktop on it. Budgie has a very clean, modern aesthetic, there are very macOS-like themes and icon sets for it.

There no longer is a Global Menu available for Cinnamon Desktop nor a good, working one for Gnome. So you either have to use KDE Plasma, Budgie, or XFCE to get one that is Mac-like. XFCE would work zippy on this hardware. Budgie looks nicer and gets updated more often. Plasma is a bit too much for this hardware. So...Budgie it is!

But you can’t just install Budgie from the Linux Mint Repo. That will break your system! You need to add the Ubuntu Budgie project PPA and install it from there.

sudo add-apt-repository ppa:ubuntubudgie/backports sudo apt update

Okay, so we don’t actually want to just make this into Ubuntu Budgie or we could have just installed that instead. In order to make sure we just get the bits of Budgie we actually need and want copy and paste the following into your terminal:

sudo apt install budgie-analogue-clock-applet budgie-app-launcher-applet budgie-applications-menu-applet budgie-appmenu-applet budgie-brightness-controller-applet budgie-calendar-applet budgie-clipboard-applet budgie-clockworks-applet budgie-core budgie-countdown-applet budgie-cpufreq-applet budgie-cputemp-applet budgie-desktop-doc budgie-desktop-environment budgie-desktop budgie-dropby-applet budgie-extras-common budgie-extras-daemon budgie-fuzzyclock-applet budgie-haste-applet budgie-hotcorners-applet budgie-indicator-applet budgie-kangaroo-applet budgie-keyboard-autoswitch-applet budgie-lightpad-applet budgie-network-manager-applet budgie-performance-gauge-applet budgie-pixel-saver-applet budgie-previews-applet budgie-previews budgie-quickchar budgie-quicknote-applet budgie-recentlyused-applet budgie-rotation-lock-applet budgie-screenshot-applet budgie-showtime-applet budgie-sntray-plugin budgie-sys-monitor-applet budgie-sysmonitor-applet budgie-takeabreak-applet budgie-trash-applet budgie-visualspace-applet budgie-wallstreet budgie-weathershow-applet budgie-window-shuffler budgie-workspace-stopwatch-applet budgie-workspace-wallpaper-applet plymouth-theme-ubuntu-budgie-logo plymouth-theme-ubuntu-budgie-text ubuntu-budgie-themes plank

You’ll be missing: budgie-desktop-view and budgie-control-center because they are not in the backports PPA for some reason. The first one means your desktop icons won’t be clickable. Well, technically they are clickable, they just won’t open anything. So...

sudo apt-get install nautilus

That will fix the desktop icons. Budgie’s fall-back for making that “legacy” function work is Nautilus file manager. Which Linux Mint doesn’t have by default (Cinnamon uses Nemo, MATE uses Caja, and XFCE uses Thunar).

Note that if you switch back and forth between Budgie and Cinnamon the desktop icons may or may not work properly in one or the other, especially depending on if you changed the settings. I don't know if this is because it's just a toggle and the two DEs fight each other or what, but suffice to say that it's considered a "legacy" feature so don't expect it to be fixed. I'm not sure why some people hate putting things on the desktop so much that this is considered an outdated idea?

Menubar

I spent quite a bit of time tweaking the Budgie menubar panel to get it the way I wanted. I removed the "Start" menu, since that's not a very Mac-like thing to have. In its place I put the "User" applet with the Log Out/Shutdown/Restart where the Apple menu you would be, since I've got a bit of muscle memory for going there to shutdown or restart my computer.  

I've got the Global Menu next to that, which unfortunately doesn't work for every app, but does for enough of them. IMO too many of the Linux DEs are moving away from having window menus entirely, borrowing UI cues from mobile apps that don't make sense on a mouse-driven desktop, but Budgie and KDE still not only have some love for window menus but the global menu as well. 

On the other end I added a screen brightness control because the keyboard ones won't work (see below), then notifications, network, battery, volume, bluetooth, clock, and the widget/notifications panel (not that I really use those, I don't use them on my Macs either).  But it all feels very cozy and familiar!

DO NOT UNINSTALL CINNAMON DESKTOP! We need it as a backup in case Budgie breaks, and completely uninstalling it may remove dependencies for some of the Mint apps and utilities and break things.

THEME BUDGIE

Let’s make this thing *look* like macOS already! Bring on the the themes! Some people call Budgie “Gnome Done Right” so the good news is we can just get our themes from Gnome Look:

WhiteSur Gtk Theme: https://www.gnome-look.org/p/1403328

You’ll want to grab both the WhiteSur-Light and WhiteSur-Dark themes.

For modern macOS use the “WhiteSur” icon set: https://www.gnome-look.org/p/1405756

LOGIN SCREEN

Linux Mint uses the LightDM Greeter login. There are only four themes available for it on Gnome Look and none of them are Mac-like.

I didn’t bother changing mine too much since you don’t spend too much time on that screen anyway, but if you want to change yours a little Mint has its own “Login Window” utility for that. In Budgie you’ll find it under the main menu -> System Tools -> Login Window. If you can’t find it you can open it via the Terminal with:

sudo lightdm-settings

But it’s pretty basic, so if you want even MORE control over what it looks:

sudo apt update sudo apt-get install lightdm-gtk-greeter-settings

And that will install a nice GUI for customizing the login screen.

Alternatively, if you trust installing random things from GitHub there are:

lightdm-webkit-theme-macos (which has more recent macOS login screen appearance)
https://github.com/ZoomTen/lightdm-webkit-theme-macos?tab=readme-ov-file

LightDM Webkit MacOSX Theme (for older OS X appearance)
https://github.com/Wattos/LightDM-Webkit-MacOSX-Theme

...and Aqua LightDM Webkit Theme which is newish macOS Catalina-like:
https://github.com/paysonwallach/aqua-lightdm-webkit-theme

Like I said, how much time do you spend on that screen or looking at it? I didn’t waste much time on it myself. I've run into problems swapping the login on Linux before and wound up with a system with no functional login screen. Install and use at your own risk.

WEBCAM FIX

sudo apt-get install gucview

The GTK UVC Video Viewer is the solution to your Facetime Webcam woes. But it will only do 640x480 video at 15 fps probably. Pretty terrible! But it works.

MACBOOK MEDIA BUTTONS

If the keyboard brightness, volume, and eject buttons are not working on your keyboard you will need to install “Pommed” to enable them. I didn’t need to do this, the keys worked “out of the box” after installing Linux Mint, except for the screen brightness buttons, which I’m not sure can be made to work (see section below about “Screen Brightness”).

sudo apt update sudo apt install pommed

Make sure “pommed” is added to the end of /etc/rc.local so it runs on startup. You may need to edit the pommed.conf file manually to set a keybinding betwen your eject button (for optical discs) and the eject command.

SCREEN BRIGHTNESS

The buttons will not work with the legacy proprietary Nvidia drivers.
BUT! You can use the Nvidia Settings panel to adjust the brightness!

NVIDIA X Server Settings —> LVDS-0 (Apple) —> Color Correction Tab.

(make sure to “Confirm” changes!)

FILE MANAGER

If, like me, you like the Column View for files you’re out of luck. I think only a now defunct version of Dolphin File Manager had that. I don’t know why it’s so widely hated, or how it could possibly be more difficult to implement than a tree-view (it’s just a tree view horizontally really). Anyway, if you’re coming from a Mac you’ll expect to be able to do certain things in the file manager from the context menu so let’s fix that.

Click on the desktop so you get the generic Global Menu, then select “Edit -> Preferences” and in the left-hand column select “Context Menu” then make sure to check:

  • Duplicate
  • Make Link (this is the same as “Alias” on Mac)

LAUNCHPAD

I don’t really like or use Launchpad, but if you do you can get the same functionality on Linux.

Download and install “Lightpad” app and put it on your dock.

If you don’t want the old “rocket” icon and want the new multi-color squares icon you’ll need to go to:

/usr/share/

Right+click on the “applications” folder and “Open as Root”

Navigate to the “LightPad” app, right+click on it and select “Properties”

Click on the rocket icon and then “Browse” and select “File System” in the left column, then Home/yourusuername/.local/share/icons/WhiteSur-Light/Preferences (or WhiteSur-Dark if you’re using Dark theme)

Find the icon named “preferences-desktop-apps” and select that, set it as the icon for LightPad and you’re done.

You have to do it that way because “root” owns the file.

CUSTOMIZE APPLICATIONS DOCKLET ICON

Since I don’t use Launchpad on my Macs I usually add the “Applications” folder to the Dock. You can do the same with Mint Budgie and Plank but it’s less than ideal because it’s lists every application in alphabetical order in a long, long scrolling list. It also has the disadvantage that once you put it on Plank you can’t move it around nor can you drag it off the Plank to get rid of it!

If you did that and can’t figure out how to delete it go inside your home directory and find the “.config” folder (if you can’t see one, right+click and select “Show Hidden Files”) then inside that go to:

/plank/dock1/launchers/

Find the file named “applicaitons.dockitem” and move it to the trash. Gone off Plank!

So what you probably want is something more like the Windows “Start” menu with apps categorized. And Plank has an “Applications” docklet just for that!

It *does* adopt whatever icon is set in the theme for either “gnome-applications” or “gnome-main-menu” but if the theme you apply doesn’t set icons for those you’ll need to do so yourself. Also, it appears the icon *has* to be in PNG format, SVG doesn’t seem to work, and it will fallback to whatever is in the “gnome” icons folder under:

/usr/share/icons/gnome/256x256/categories/

(or whichever icon sub-size Plank is using based on your size preference)

If you want to change the icon there, which will also apply it to ALL users on the system, you have to open that location with “root” privileges.

If you don’t want to mess with the system-wide icons, just make sure to put a PNG version of the file in a requisite folder in your home directory and it should pick it up there as well.

ADD DOWNLOADS & DOCUMENTS TO PLANK

I also usually like to drag the “Downloads” and “Documents” folders onto the Dock in macOS. That doesn’t work as nicely on Linux. Yes, you can drag them from your Home folder onto Plank, but you’ll get a black square that you have to right+click on and select “Open in file browser” which is inconvenient, and the icon doesn’t indicate what it is.

But we can solve that problem with a custom launcher!

In your Home folder (or where ever, it doesn’t matter where) right+click and select “New Document —> Empty Document” and rename it “Downloads.desktop” and open it in your Text Editor. Put the following in it:

#!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application Terminal=false Exec=nemo /home/yourusername/Downloads Name=Downloads Comment=Downloads folder Icon=default-folder-download

Save it. Right+click and select “Properties” then go to “Permissions” tab and select the checkbox for “Allow executing file as a program.” Close the properties dialog.

For housekeeping purposes I created a hidden folder in my Home directory named “.launchers” and put the file in there, so there won’t be two “Downloads” folders in my Home folder.

Now drag that .desktop file onto Plank, and when you click it Nemo File Manager will automatically open to your Downloads folder.

You can do the same for the other special Home folders. It may be easier to customize the icon from the Properties dialog as well because you can pick it visually.

Note that if you move the original launcher file you’ll have to delete the one from Plank and drag-and-drop the launcher again from its new location or the one on Plank will be dead.

Faux Windows Too?

Since I didn't uninstall Cinnamon Desktop I decided to theme that to look like Windows 10. In case I had to hand this computer off to someone who is a Windows user instead of a Mac user, there's no reason not to have Cinnamon set up to look familiar for them, right? I wasn't installing actual Windows with Bootcamp on it anyway, but now without ever leaving Linux both faux user interfaces are available.

Final Thoughts

I set this up as a macOS-Linux dual boot system because I've never actually installed Linux ON a Mac before. Booted off Live CDs, DVDs, and USB drives sure, but I've never partitioned a Mac drive and put Linux on the machine. And in case I screwed that up I wanted to make sure I could still get into macOS to undo/fix things. When I went to wipe this MacBook though it had been upgraded as far as it could go to "High Sierra." Unfortunately that's one of the macOS versions with a BROKEN RECOVERY system! Sierra is the other one. So I couldn't actually use Recovery to wipe it. Thankfully I still had my "Snow Leopard" installation disc, which (just to give you an idea how long ago 2010 was, THAT was what originally shipped on this MacBook Pro!). So I was able to wipe the drive and do a clean install of that. Then I headed to the Apple Website to download the "El Capitan" installer, the last one I can install that I know doesn't have a broken Recovery. You want to go download these installers instead of trying to use any you archived, because these ones have been re-signed so they'll actually work.

Arguably, now that I know everything works, I could probably remove macOS - but this isn't a "daily driver" laptop so I don't really need to claw back the storage space. I am a bit disappointed that Linux Mint doesn't really run any faster on this hardware than Mac OS X or macOS. But the specs are pretty low by modern standards. I wasn't expecting a speed-demon, but usually Linux runs a little better than either macOS or Windows on the same hardware. I guess this little laptop is already giving 110%. And that extra 10% right now is that it is running a current operating system.

Sunday, February 11, 2024

ROM Collection Browser on Kodi 20 Nexus + Launch External Emulator

 


First a little back story:  After a failed Ubuntu update I ended up reworking my HTPC built from junk/cast-off parts.  I think I'm done with Ubuntu though, which is a rant for another day.  I ended up installing Linux Mint on this box again.  I don't know why I even bother trying other distros anymore, I always circle back to Mint.  Though in this case not the current version of Mint, I had to step back a bit because of the ancient Nvidia graphics card in this computer.  The proprietary drivers aren't available on the current version, and I know from messing around with Ubuntu 22.04 that the open-source "Nouveau" drivers aren't stable enough, and you have to extract binaries from the proprietary drivers to get hardware video encoding/decoding to work, except (in my experience) it just froze or crashed the entire computer as soon as I started playing a video.  Which rendered my HTPC useless.  So, anyway, I ended up going with Linux Mint 20.

Unlike under Ubuntu 20.04 I was able to actually install Kodi 20 Nexus.  Okay, so I was able to install it, but it would crash immediately on opening. So I was stuck on Kodi 19 Matrix but couldn't use Retroplayer because of an unmet and uninstallable dependency.  So I ended up having to point Kodi to open every game ROM in external emulators.  Which thankfully isn't that hard with IAGL or Advanced Emulator Launcher.

But on my new Linux Mint 20 installation I've run into various issues.  First of all many of the Libretro cores for Retroplayer are still unavailable because they fail to build.  Secondly, Advanced Emulator Launcher hasn't been updated for Kodi 20 Nexus so I had to try the development version, with which I ran into other problems. So I tried the Advanced Kodi Launcher forked from it, which is under more active development. But ran into issues with that as well (namely that some browse dialogs weren't working for me). I also didn't like how AKL clutters up my "Games" section with all it's add-on modules. I mean, I get why it's modular, but it's a shame there's no way to hide all of its modules from showing up in the Games Add-ons list, and with the same icon as AKL itself.

Honestly, what I *wanted* to use was Emulation Station Desktop Edition for a retro gaming library, but I can't get it to run on my Linux Mint 20 system.  It crashes on open because it can't find OpenGL.  I don't know if that's because it requires Wayland instead of X or something?  I didn't look into it.  But I can't use Wayland on this system because of the old Nvidia graphics card.  I tried the regular Emulation Station as well and hit the same problem.  I didn't bother trying to build it from source myself, I decided to just focus on using Kodi for my retro gaming library UI.

ROM COLLECTION BROWSER for KODI NEXUS

Which led me to try the "ROM Collection Browser" (RCB) which I've never used before. It's the closest out of the box to Emulation Station, and unlike AKL which requires you to switch your entire Kodi skin to get the cool UI options, RCB lets you access the cool UI layouts without switching your Kodi skin at all.  

However, RCB also has not been updated yet for Kodi 20 Nexus, but someone did fork it for that purpose.  You can find it here:

https://github.com/Trihy/romcollectionbrowser

I needed to download the Master not one of the releases because only the Master branch had been updated to look for Python 3.  You also need to install the RCB Service add-on for Matrix or it won't work. I get a moment of graphics glitches whenever I first open it, but it doesn't affect using it.

Keep in mind that RCB is intended to be navigated with a game controller not a mouse.  It is virtually unusable with a mouse.  D-Pad Up will get you the left-hand menu, D-Pad Down will get the right-hand menu.

However, and this isn't anything wrong with RCB, but too many of the Retroplayer cores are missing or broken to run some ROMs in Retroplayer at all.  

BROKEN/MISSING RETROPLAYER CORES

If you go look at the Team XBMC PPA you'll see that many of the Libretro cores fail to build on various Ubuntu versions and so are not available to install via APT.  You could try to build them yourself from source, but they may just fail for you too.

For example, on my HTPC system there are dozens of Retroplayer cores that are not installable via APT. I can download the package and try to install them manually, but they usually have some unmet dependency I can't satisfy either.

"Zach Morris" who makes the excellent Internet Archive Game Library (IAGL) plugin also maintains a Libretro Buildbox that generates Retroplayer cores.  However as THIS PAGE shows, not all of them work as intended, and I can tell you from personal experience that even some with the status "Works" my not necessarily work for you.

POINTING RCB TO EXTERNAL EMULATORS

For any Retroplayer cores you can't get to work you'll need to launch those games in an external emulator.  But I had difficulty finding instructions on exactly how to DO that in RCB.  So I'm documenting it here, if only for my future self who will likely have forgotten how to do it.

First you need to get to the left-hand menu and select "Edit Collections"


That pops up the dialog box. On that you need to go down the buttons on the left to "Launchers" 

 


 
...and at the top select the specific Collection you need to set a launcher for.

 

At the bottom you need to turn OFF the switch for "Use Retroplayer" because, well, we're not using Retroplayer. That will enable all the dimmed out option in the middle.


I'm going to assume you have a working installation of Retroarch on the same system, but this method should work with any external emulator so long as you get the path and parameters right.

Select "Emulator Cmd" which won't let you just type it in, it makes you browse for the binary to execute:

 

 



Note that the path to the binary will be different if you're using a Snap or Flatpack version of Retroarch and obviously will be different if you're pointing to a different emulator.  Now we need to send the right "Emulator Params" to actually launch the game:

 

In my case these was the magic parameters to enter:


-L /home/htpc/.config/retroarch/cores/bluemsx_libretro.so "%rom%"

Obviously you'd need to make sure the username is yours. I'm using "htpc" because that's what this box is for.  For each game platform you need to launch externally in Retroarch you'd need to change the core *.so file it is invoking.  So, for example, an NES game to use the Mesen emulator core would be:

-L /home/htpc/.config/retroarch/cores/mesen-s_libretro.so "%rom%" 

I think you get the idea.

Side note: I couldn't get the Retroplayer BlueMSX core to work even with the extracted "Machines" and "Databases" placed in:

~/.kodi/userdata/addon_data/game.libretro.bluemsx_libretro_buildbot/resources/system/

But they work fine inside ~/.config/retroarch/system/

Which is why I'm launching those games in Retroarch instead of Retroplayer.

(If you don't know what extracted files I'm talking about see the BlueMSX core instructions here: https://docs.libretro.com/library/bluemsx/).

YMMV.




Sunday, March 6, 2022

Fixing An Ancient Racing Wheel Controller

 I recently built up another Home Theater PC with some retro-gaming apps on it.  One of the games I wanted to play was an old one I think is one of the best racing games of all time called "Breakneck 2" originally from 1998 (I wrote about it on this blog about a decade ago, it's from Germany and was originally released as "N.I.C.E.2 Excessive Speed" in Europe).  This game is the only reason I even own a racing wheel game controller.

Notice the "Windows 98" compatibility!


 

But the wheel is 24 years old and over the years it has been stored in basements and attics and garages, not to mention the actual use (abuse?). So I'm not surprised it broke inside almost immediately after I started using it this time.

The shattered plastic "yoke" from inside wheel


But the part that broke is a textbook case for using a 3D printer: to reproduce a plastic part that is unavailable.  And I happen to have a 3D printer.

Granted the 3D printer is not a good one.  It's garbage.  LITERALLY.  It was intercepted on its way to a dumpster.  It's a "Tiko" delta printer that was part of a Kickstarter campaign.  On the plus side, unlike a lot of crowdfunded tech projects, they actually DID deliver some units.  But they bankrupted themselves in the process and went out of business.

The biggest issue with this printer is that the built-in "slicer" software is terrible.  But if you use some other program to slice your models and feed the printer raw "gcode" files it works a LOT better!  But you are still limited by the actual capabilities of the printer, and if you need precision parts that will fit together?  Not gonna happen.  Not without doing some filing and shaping, and even then the still may not fit together.

Anyway, the tldr; is after a number of false starts and failures I FINALLY got a 3D printed replacement part to work and got the wheel working again.  Below is my frustrating journey to once again drive some windy old virtual roads at insane speeds.

Plan A: Fix The Original Part

 

original part glued back together

My first thought was just to try and fix the broken part.  Using some superglue I was able to reassemble it.  But this is a part that has a lot of torsional pressure and other forces acting on it.  I thought it would probably just break into pieces again, so at this point I took as accurate measurements off of it as I could.  I thought maybe if I just clad it with some 3D printed pieces to strengthen it then it might work.  So I made a model in SketchUp 2017, exported it as an STL file, generated a gcode file, and printed it:

Printing the part

In case you're wondering, this printer doesn't have a heated bed.  After many frustrating attempt to print things I discovered that putting a piece of printer paper over the bed was the perfect thing for PLA plastic adhesion.  My models no longer break away from the bed and get dragged around by the print head.  You have to tear the part off the paper, but you can simply use water to get all the paper off.


So I made flat pieces for both sides of the Yoke and superglued them to it, then filled in the gaps with expanding Gorilla Glue.  There are rollers that are supposed to go on those pegs.  The rollers ride against a piece of bungee cord to create resistance (this is not a force-feedback wheel). The rollers were only held on by a tiny peg, one of which was broken and even if could find the piece it would never hold.  So I drilled out the pegs and held the rollers with screws and washers:

I have no idea if this glued-together part would've worked because I could NOT get it reinstalled.  The steering shaft is knurled and you could see the imprint of the knurling inside the "tower" on the Yoke, but I couldn't actually get the part to go back down over the shaft.  I suspect it may have been pressed into place at the factory or heated and pushed on, gripping itself as it cooled and contracted.  I couldn't hammer it down onto the shaft because I was sure THAT would just break it into a million pieces again.

 

Okay, so on to Plan B!

Plan B: 3D Print A Replacement Part

My first thought was, since the original piece is very dense, heavy plastic, and has a lot of forces acting on it, I should try and print my replacement part with 100% density too.  Which would take forever, but it would be literally solid plastic.  But I had to quickly abandon that plan because at that density the little Tiko printer starts experiencing pronounced layer shifting:

That meant I had to rework my model a bit to create some interior structure so I could hopefully stop the layers shifting on me.

But there was still some layer shifting, especially when it got to printing the "tower" that goes around the knurled shaft.  Also, because of the limitations of the printer's precision (or severe lack of it) I could NOT get the inside diameter of that tower correct.  I ended up printing a whole bunch of revisions:


 And STILL couldn't get it right.  The inside diameter of the tower not only has to fit over the knurled shaft the outside diameter has to fit inside the "resistance arch" with the bungee cord.  So on that last one on the right I tried to slowly, and carefully hone out the interior large enough to install it.  Which resulted in it eventually breaking off entirely:

DOH! 

This project went through MANY revisions on the fly:

The many revisions of the Yoke
 

These were all done in SketchUp 2017 which is the only 3D modeling software I really know how to use.  I've tried to build things in Blender, Cheetah3D, and FreeCad with great difficulty.  At least with SketchUp I know I can slam together something really fast.

So in that last revision I decided to approach this a different way.  Since I absolutely could NOT get that inside diameter right I figured I'd design a multi-part model that could CLAMP around the knurled shaft.  That led to this:

The "tower" is printed separately and superglued to the base parts.

With some screws I found in the kitchen junk drawer. 
No idea what they're from, but they went through the holes and were long enough.

Okay, so another problem you run into with 3D printing (and not just with my literally garbage printer) is prints that curl up on the ends as the part cools.  It's more of a problem with ABS plastic than PLA but can happen with either, especially on a printer without a heated bed.

So, to get the parts to match up and be flat I had to heat up a cup of water in the microwave.  For PLA you need it about 150 degrees.  Dip the part in the hot water for a few seconds until it just become pliable enough to reshape it.  If you leave it in too long or the water is too hot, though, you're part will become TOO pliable and will also shrink.  See how the top piece in that photo is a little narrower than the bottom piece?  It shrank a bit.  See that little dip in the top edge next to the longer screw?  My thumb made that.

Reassembly

Now that I had a part that would actually FIT the time came to put everything back together.

When I was trying to get the other attempted Yokes on I had to cut the wires to the buttons in the middle of the steering wheel.  Ironically with the two-piece clamp Yoke I wouldn't have needed to do that.  But what's done is done.  You may have noticed in that disassembled photo up above that there's a part labeled "Weird Dummy Board."  The wires from the steering wheel buttons went to this board that doesn't seem to DO anything:

The wires just connect to one side and there are circuit traces that just go straight across to wires of the same colors.  Why?  Perhaps there was some other model of this wheel with a different board there for some other features this one doesn't have?  No idea.
 

The stupid "Dummy Board"

 

The advantage of getting rid of this useless board was the wires I'd snipped were long enough to reach the ultimate board connector without my needing to solder pigtails onto them.  So, goodbye Dummy Board!

Once I clamped the Yoke on the knurled shaft I had to reinstall the resistance arch over it.  That was secured with four weak little screws from the front panel.  I drilled everything out a little larger and put in some beefier bolts.  Found these Allen-head ones in a box of junk that dressed it up nicely.

Resistance Arch and Clamp Yoke installed

The Clamp Yoke's bolts sticking out aren't a problem, and give enough extra for some lock-nuts.

Next up is reinstalling the gear-driven potentiometer that actually tracks the position of the wheel.  The trick with this is to make sure the wheel is in the center position and the potentiometer is in the middle position and drop everything into place and screw it down.  If you get this wrong your steering wheel will be off-center when you're driving straight.

With everything back in place it's time to reconnect those steering wheel button wires to the connector (sans the "Dummy Board"):


 




Wires bundled and everything is reconnected to the main circuit board!

I did ultimately have to partially disassemble this again because on my first test with it the steering shaft knurling just ground out the inside of the Clamp Yoke tower.  PLA plastic is pretty soft and the forces acting on it just turned the knurling into a file.  My solution to that problem was to permanently GLUE the clamp onto the shaft with two-part epoxy.  It means I will NEVER be able to get this apart again, but once the epoxy resin hardened that clamp isn't going anywhere.

Another issue was that, after 24 years, all the grease had basically gone away.  The only grease I had on hand was some plumber's faucet grease.  I put that on the outside of the tower and on the steering gears.  The only downside to that is the wheel works VERY easily and smoothly.  Though, I'm not sure if maybe that's what it was like when it was new?  I can't remember.  Maybe I just got used to the way it felt without any grease left in it.  Of course, that probably played a role in why the original yoke broke.

Anyway, everything fixed in place again and reassembled it was time to CALIBRATE it!

Calibrating it on Linux with QJoyPad utility

And last, but not least, taking it for a test run around the Breakneck 2 Corsica track:

If, by chance, you have one of these old Thrustmaster racing wheels that has also broken the Yoke here are the STL files of my final revision:

Thrustmaster_Yoke_Rev9.zip

Of course I make no guarantees for how long it will last.  So far mine hasn't broken again, but I've also been careful not to crank on it too hard.









Sunday, January 23, 2022

XP-PEN Display Tablet Express Keys "fix" for M1 Mac

UPDATE 7 FEBRUARY 2023
A macOS update apparently made the version 2.0 drivers stop working.  I also ran into an issue where, because I'm using custom display profile overrides the tablet settings app cannot find the names of my displays nor could it tell there were two of them (it sees both displays as one ultrawide).  After some playing around with both newer and older drivers I am now recommending you use the version 2.1.6 driver.  It does have a bug that causes it to sometimes lose all your custom settings (like hotkey assignments), which you can mitigate by locking the actual settings file so it's "read only."  (You can find it at ~/Library/Preferences/com.ugee.pentabletsetting.plist and lock it by right+clicking and select "Get Info" then in that dialog tick the "Lock" box)  But don't do that until after you've finished getting everything set up the way you like.  Also, some apps simply won't accept your custom settings from this driver.  For example, even with the default button assignments on my tablet where K1 = increase brush size, K2 = decrease brush size, CSP sees the first one correctly - but inconsistently - and the second one as "eye dropper."  Even if I assign those to "]" and "[" it shows at the bottom of the display that the tablet IS using the configured keyboard character, but CSP ignores it.  In Affinity Photo, though, it all works as intended.  So this comes with a heavy dose of YMMV.  You can still try the version 2.0 drivers and see if they work for you, but otherwise:

DOWNLOAD THE XP-PEN 2.1.6 DRIVERS FOR macOS

The 2.1.6 drivers *should* automatically create entries for the macOS Privacy settings as shown below in the original post, but you'll want to make sure they are checked, and your tablet will not work until you restart your Mac.  On restart you'll likely see a bunch of privacy/security pop-ups and you need to authorize all of them.

------------ original post follows --------------

Both I and one of my friends own the same model XP-PEN Artist 15.6 display tablet and M1 Macs.  It's a nice tablet for the money but the support for Mac users is terrible, especially since the M1 "Apple Silicon" chip was introduced.  The tablet itself is actually made by Ugee and I think XP-PEN is just one of many "brands" the same tablets are sold under (their websites have the same layout, the driver files are the same versions, the interface for their preferences app is the same, they just swap out some images).

So, anyway, the "New UI" version 3.x drivers are garbage.  They absolutely do NOT work.  Version 3.0.5 would at least detect the tablet if you unplugged it and plugged it back in, though you couldn't configure the pen or the Express Keys as none of the sections would appear in the left-hand column of the preferences app.  The versions after that won't detect the tablet at all. 

I'm using the USB-C to USB-A + HDMI cable that came with my tablet because I'm mirroring my primary display to the tablet through an HDMI splitter.  I haven't tried connecting my display tablet with a USB-C cable, but from what I've read on their forums and Reddit, it doesn't sound like that would make any difference.

The (as of this writing) current 2.1.8.2 drivers are listed as the "Official" ones on XP-PEN's website, and if you have an M1 Mac they will get you up and running, but you won't be able to assign your Express Keys.  There's a bug in those drivers that won't let you reassign them properly and I doubt they'll ever fix it because they've moved on to developing their worthless 3.x drivers.

The Express Keys bug was also present in 2.1.7 version of the drivers and a different bug was present in the 2.1.6 drivers.  The 2.1.6 will let you reassign the functions of the keys, but they were inconsistent in actually working.  When yo press one it displays a message across the bottom of the screen confirming not only that the button was pushed by tells you in bright green lettering what it's supposed to do.  Except on a M1 Mac it wouldn't always actually do it (the drivers seem to work fine on my Intel Mac).

XP-PEN frustratingly does not provide an archive of older versions of their drivers.  And, no, you can't get them through the Internet Archive Wayback Machine either.  Thankfully between three computers I had installers for several different older versions.

After installing and testing and uninstalling ALL of them on my M1 Mac I finally found ONE that actually works the way it's supposed to!

The Version 2.0 drivers that ACTUALLY WORK are, ironically, the oldest ones I have.  The ones I downloaded when I bought my tablet.

You can get them from my Google Drive but installing them in Big Sur is not exactly straight forward.

1. UNINSTALL your current XP-PEN drivers!  Use the "Uninstall" app in the same folder as the Settings app.

2. RESTART your computer to make sure it's gone.

3. Download the installer ZIP from that link in the line above.

4. Unzip it and inside there should be one file: XP-Pen Mac(20180425).pkg 

5. Right+Click on that file so the context menu shows up.

6. Press the OPTION key on your keyboard and then select "Open" from the context menu.

7. The macOS Gatekeeper will warn you about opening it, go ahead and do it anyway.

8. Run the installer and wait for it to finish.

9. It will finish saying "Installation Failed!" but it's a liar, the installation worked just fine. Close the installer.

10. Go to Applications --> PenTablet --> PenTabletSetting.app and open it.

11.  Authorize the app in any macOS security and privacy pop-ups you see.

12. Open System Preferences and go to Security & Privacy

13. Click the padlock icon in the lower left and  enter your login password to unlock it.

14. Scroll the left column down to "Accessibility"

15. Click the [+] button under the list on the right and navigate to:
Applications --> PenTablet --> PenTabletSetting.app

16. Click the [+] button again and this time navigate to:
Macintosh HD --> Library --> Application Support --> PenTablet --> PenTabletDriver.app

17. Now scroll the list on the left to "Input Monitoring" (and we're going to do the same...)

18. Click the [+] button under the list on the right and navigate to:
Applications --> PenTablet --> PenTabletSetting.app

19. Click the [+] button again and this time navigate to:
Macintosh HD --> Library --> Application Support --> PenTablet --> PenTabletDriver.app

20. Restart your M1 Mac.

21. Plug in your XP-PEN display tablet.

22. Go to Applications --> PenTablet --> PenTabletSetting.app and you should be able to set your preferences for pen buttons, pressure, display mapping, and Express Key assignment.

23. EXIT the settings app.

Your settings should now be usable with your tablet.  When you press one of the Express Keys on the tablet you should see a gray bar across the bottom of the screen with text telling you what action is assigned to that button.

When you re-open the settings app be aware you may need to select your tablet from the drop-down list at the top before it will actually load your custom settings.  I had made my pen pressure softer but when I reopened the settings app it wasn't showing the curve I'd set for the pen, but after selecting "Artist 15.6" from the list at the top it loaded my settings.  They seem to be persistent after that, but if they revert to showing defaults I'd try selecting the tablet in the drop-down first, just to see if your custom settings load.

This WILL fix your issue assigning the Express Keys custom functions.  Whether using these old drivers ends up causing you other problems I can't say.


Tuesday, January 21, 2020

Running Clip Studio Paint in Wine on Linux


I would love it if Celsys released a Linux version of their Clip Studio apps, but I highly doubt that will ever happen.  Though if it did it would go a long way toward me being able to ditch both macOS and Windows (at least for my personal projects).  So, without a native Linux version what to do?  Try to run it in Wine (read more about Wine here).  Emphasis on the word "try" because it can be rather difficult to get programs to actually work in Wine.  They have an App Database which can often help you decide if it's even worth the trouble, which it often is not.

Well, with that stellar sales pitch I'll tell you that Clip Studio Paint 1.9.7 and Clip Studio Modeler 1.9.1 both worked for me in Wine 3.0.1 and Wine 4.0.3 on Kubuntu Linux 18.04 LTS.  You should see similar results with just about any Linux distribution, especially the Debian-based ones like Ubuntu and its derivatives.  I only installed the "trial" versions, but I tested as much as I could and everything I tested seemed to work just like it does on my Windows 10 machine.

Clip Studio Paint 1.9.7 running in Kubuntu Linux 18.04.  As you can see the 3D features also work.


However, I would strongly recommend if you have an actual Windows machine, or if you have a copy of Windows you can install on a partition on your machine and dual boot, that would be the preferable solution.  But let's say you don't have a copy of Windows, or you hate it with passion, or you're not sure you'll use Clip Studio often enough to dedicate a drive partition to it.  Ok then, let's install Wine and configure it for running the Clip Studio apps...

Install WINE


1. Open whatever package manager your distribution uses and search for "Wine" and mark it for installation along with whatever dependencies it needs.  

Sometimes the version available in your distro's repo is really old, in which case you'll want to add the Wine repository as a new source and pull it directly from there.  I'm using Wine 3.0.1 (the latest in my Kubuntu LTS repo), though 4.0.3 is the latest stable release available from Wine HQ.  

However, having the latest release isn't always an advantage with Wine, you'll want to check the app database to see if your particular application(s) are listed and what success or problems others have reported.

Note that you can also install the Wine HQ Release Key and Repository source using the Terminal (this would be for my Kubuntu 18.04 LTS install, but any Debian-based distro would be similar):

wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key
sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
sudo apt-get update
sudo apt-get install —install-reccommends winehq-staging

This will allow you to easily install the latest stable or development releases, as well as force previous versions if that's what you need.

Another reason you may want to use the official Wine HQ repo is for reasons I don't know some of the ones in the Ubuntu repos were missing the Wine Gecko and Wine Mono components, which I had to download separately and manually install.  The one from the official Wine repo was complete.

As I said in the intro, I did test this with both Wine 3.0.1 and 4.0.3 and it worked in both of them, and should presumably also work in all the versions in between.

Install WineTricks


2. Install WineTricks from your package manager, along with whatever dependencies it has.

3. Make sure "cabextract" is installed.  If it's not, install it with your package manager.

Install DLLs Clip Studio Needs


4. Run WineTricks and make sure the radio button for Default Wine Prefix is selected and click OK.

5. Select "Install a Windows DLL or component" and click OK.

6. One by one, in the order they are listed install:

vcrun2005
vcrun2008
vcrun2010
vcrun2012
vcrun2013
vcrun2015 or vcrun2017 (you can't have both, I'd recommend 2017)
vcrun6
vcrun6sp6
msxml4
msxml6
mfc40
mfc42

I honestly don't know if all of those are actually necessary but they were the ones listed in the Linux Mint forum post I found that pointed me in the right direction and it shouldn't hurt anything to install all of them.  If any of them do conflict with your running some other software in Wine you can always use Wine Config to create a custom profile just for that app that excludes the problematic one(s).

Install the Clip Studio App(s)


7. Download and run the Windows installer for Clip Studio Paint.  Note that the shortcut icons on your desktop may show the Wine icon instead of the app.  This is because it actually has to run Wine first.  You can edit the shortcut and assign the correct icon to it under the right+click context menu —> Properties though it may correct itself after a reboot.

8. (optional) Download and run the Windows installer for Clip Studio Modeler if you want to set up 3D objects and characters.  This download will also install the Clip Studio materials management app, which does NOT completely work (see below).

9. Try to open and run each of the Clip Studio apps to make sure they actually work.  If the desktop icons placed during installation don't work use Wine's file "Explorer" to navigate to your fake "C:" drive and drill down to the:

"Program Files (x86)" folder → CELSYS → CLIP STUDIO 1.5 → CLIP STUDIO PAINT → CLIPStudioPaint.exe  

Wine has a file Explorer like old-school Windows


If it crashes or freezes instead of running you probably need to change the Windows version in the Wine Config to Windows XP.


Clip Studio Modeler 1.9.1 running in Kubuntu Linux 18.04.  As you can see the 3D setup functions appear to work.


Configure Your Tablet


10. If you have a Wacom tablet and are using KDE as your desktop environment, they have a Wacom Tablet preference panel you can install from Discover (it's sort of like KDE's App Store), but no guarantees it actually works.  If you have some other kind of graphics tablet and it doesn't have a Linux driver (since most don't) you can try installing the generic "Graphics Tablet" app for system settings.  Again, no guarantees it will work.  Getting your graphics table to work, and particularly trying to get pressure sensitivity to work, can be a real bear on Linux.  For example, XP-Pen graphics and display tablets actually do have a native Linux driver available, but you have to run it with "sudo" from a terminal and keep the control panel open in the background (it doesn't appear to be persistent).  YMMV.

Problems Encountered


1. The desktop shortcuts created by Wine don't always open the apps or take such a long time to open them you think it didn't work.  They're far more likely to work if you already have something open in Wine (like the Config utility or Explorer).  Similarly, the links in the Clip Studio app sidebar don't always work for launching Paint and Modeler either.  Sometimes they do, sometimes there's a lag in Wine and they fail to open.  It's far more reliable to navigate with Wine's Explorer app and open the EXE files directly.

2. If you are using Wine 3.x you MUST set Wine Config to "Windows XP" which will trigger an "unsupported OS" warning when you open the Clip Studio apps, but they will work anyway.  If you select any Windows version later than XP you will have problems.  For example, on my system Windows 7, 8, or 8.1 would let the program run, but the canvas would be blank instead of white.  Window 10 would cause a page fault on startup and crash the program.  In Wine 4.x you can set it to Windows XP, 7, 8, or 8.1 but it will page fault if you set it to Windows 10.

3. The CLIP Studio management app does not work properly.  It relies heavily on loading HTML content both from remote servers and a local folder.  The web code uses CSS3 querySelectorAll and the Wine implementation of the mshtml.dll is too old to support it, so the web content fails to load (which is most of the app).  If you have a CLIP account, you should manage it through your web browser instead because you can't do it from this app.  So what does work?  Well, you can use it for maintenance on your Materials and Work folders.  In fact, because the interface is broken, the ONLY way you can get to the management sections for Work or Materials is to first do a Gear → Maintenance → Organize Work Tags / Organize Materials Folders.  At the end of those relatively fast operations it will take you to the management subsections.  You can also use the app to download the large package of Materials when you first run it.

The Clip Studio Assets Management app running in Kubuntu Linux 18.04 (Notice that a LOT of it does NOT load!)


4. Be wary of updates!  An update to the Clip Studio apps, an update to Wine, or an update to any shared Linux library could break the whole thing.  Running apps in Wine is often a fragile balancing act.  When a new update comes along for the Clip Apps you should RENAME your existing "CLIP STUDIO 1.5" folder to something else, like maybe the actual version number (in my case "CLIP STUDIO 1.9") and then install the update, which will create a NEW "CLIP STUDIO 1.5" folder.  That way if the new version doesn't work under Wine you can simply run the previous version without having to reinstall it.

5. Pressure sensitivity can be difficult if not impossible to get working in Wine.  Odds are you will not get it to work, so you'll have to live with fixed pen and brush sizes.  If you don't usually use variable line widths anyway this won't be a problem, but in Wine most graphics tablets only work in "mouse mode."  Also, even if you get pressure sensitivity to work in one program in Wine that doesn't mean it will work in another program.  Recent releases of Wine are supposed to have improved graphics tablet detection, but it's still pretty buggy.

6. It should probably also go without saying, but I'll say it anyway: don't expect any technical support from Celsys if you're running their software in Wine.  For any problems you encounter you're far more likely to find your answers in a Wine or Linux forum anyway.

If you can't live with all this uncertainty then you should probably run Clip Studio in a Virtual Machine running actual Windows (though if you have a copy of Windows you'd be even better off just running a dual-boot set-up to run Clip Studio in Windows directly on your actual hardware).