[Linux] GUI discussion

Discussion of development and patch submission.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

[Linux] GUI discussion

Postby AmatCoder » Sat 04 Mar, 2017 11:13 pm

Hi again.

I am interested in building a new GUI for linux (I prefer one GTK based but I am open to suggestions).

Would you be interested in integrating this into mainline? Or maybe would it be better to create my own fork?

Is anyone already working on something like this?
User avatar
leilei
Posts: 436
Joined: Fri 25 Apr, 2014 4:47 pm

Re: [Linux] GUI discussion

Postby leilei » Sun 05 Mar, 2017 3:10 am

I have a soft spot for FLTK only because (on Windows) it doesn't need a hundred of prerequisite dlls installed, doesn't bloat up the binary hugely when statically compiled and it can resemble pretty close to native Windows gui. On the development and linux side i'm not so sure nor am i sure of its application in use of real-time emulation

A good example of fltk in use is Oblige
SarahWalker
Site Admin
Posts: 1334
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Linux] GUI discussion

Postby SarahWalker » Sun 05 Mar, 2017 9:26 am

Tuxality was looking at implementing a GTK+ GUI - http://pcem-emulator.co.uk/phpBB3/viewtopic.php?f=2&t=573#p3941. Might be worth syncing up with him?

I'd certainly be interested in including a proper Linux GUI in mainline.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Mon 06 Mar, 2017 12:12 am

leilei wrote:I have a soft spot for FLTK only because (on Windows) it doesn't need a hundred of prerequisite dlls installed, doesn't bloat up the binary hugely when statically compiled and it can resemble pretty close to native Windows gui. On the development and linux side i'm not so sure nor am i sure of its application in use of real-time emulation


FLTK is nice and would be a good candidate if we wanted a cross-platform GUI.
But if it is just for Linux I believe that GTK is better because:

  • On Linux shared libraries are the standard. On most Linux systems GTK is already installed. However, FLTK would create a new dependency because it is rarely used.
  • GTK is C and it will integrate better with PCem. FLTK is C++ (although it is certainly possible to use it).
  • Visually FLTK is a bit ugly (IMHO) or at least it does not look native on Linux.

But FLTK can be used if there is consensus.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Mon 06 Mar, 2017 12:15 am

SarahWalker wrote:Tuxality was looking at implementing a GTK+ GUI - http://pcem-emulator.co.uk/phpBB3/viewtopic.php?f=2&t=573#p3941. Might be worth syncing up with him?

Ok, I will send a PM to him.

SarahWalker wrote:I'd certainly be interested in including a proper Linux GUI in mainline.

Great! :D
Tuxality
Posts: 3
Joined: Thu 03 Nov, 2016 8:34 pm
Location: Poland
Contact:

Re: [Linux] GUI discussion

Postby Tuxality » Mon 06 Mar, 2017 1:13 am

AmatCoder wrote:Ok, I will send a PM to him.


Thank you for PM. ;) My vote goes for GTK, it will be close to PCem's vibe. If you want we can do this together. ;)
I can start working on this from April I believe as I have quite a lot things to do in real life and I promised on other forum that I'll release some stuff, I don't want to make another delays. ;)
If I remember correctly, I should have some preliminary stub, but I don't know if anything has changed in newer version of PCem. It would be better to start this from scratch in my opinion, it will be easier to plan, maintain code and also splitting task would be better.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Mon 06 Mar, 2017 10:56 pm

Alright, there is no rush, we can wait until April.
When the moment comes, let me know if you need help with this project.

Thanks and regards.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Sun 09 Apr, 2017 9:15 pm

Well, I have exchanged some PM's with Tuxality and we have decided that I should start this project (Tuxality will join when he find some free time).

But there are some technical decisions/options that need to be discussed and it is better to do it here.
So I'll write here some guidelines I would like to follow for discussion (or rejection :roll: ):

  • I'll clone Pcem code to a public github repository to work on this. Patches will be attached in this thread (in hg diff format).
  • GTK+ is the chosen toolkit. It will be compatible with versions 2 and 3.
  • It must be enabled at compile time (i.e. ./configure --enable-gui=gtk2). If not enabled, Allegro gui can still be used.
  • I would like to use a glade file for the interface and link it into the executable with GResource (so PCem will remains as relocatable application).

Anyone against these? (more items may arise later).

PD.- Some patches are needed to fixing some issues related to linux port. I will open a new thread for these.
bit
Posts: 98
Joined: Sun 19 Mar, 2017 7:04 pm

Re: [Linux] GUI discussion

Postby bit » Thu 13 Apr, 2017 7:04 pm

I PMed AmatCoder about wanting to help out with the new Linux GUI and to ask if there's anything that can be used from my own GUI-project that I’ve been working on which is based on wxWidgets and SDL2. He said that it might and that I should post it here so everyone can join in on the discussion.

Here is a screenshot of what the GUI looks like:
Image

As can be seen in the screenshot there are two windows, one is the machine and the other is the display. By default the machine-window is smaller, with only the first three lines and the drive-status icons visible. The graph at the bottom shows a short history of the the emulation speed.
When starting the emulator it is in an “powered off” state, so only the machine-window is visible. Using the toolbar the emulation can be started, paused or stopped (similar to what was mentioned in the config revamp-thread). Starting the emulation pops up the display-window and while it is running the machine-window can be hidden through the menu or Ctrl+Alt+PageUp. Fullscreen is toggled through the menu or with Ctrl+Alt+PageDown.
The main advantage of having the display as a separate window is that while using the emulator it will be through pure SDL2 which has very good support for input-devices.

Most of my focus has been on SDL2 (which can be configured with several options) and the features that can be seen in the machine-window. The majority of the menu and dialogs are ported straight from the Windows-source so it looks and behaves pretty much the same.

Is this something that could be of any use?

The code is available here:
https://github.com/mborjesson/PCem-wx-SDL2
It depends on wxgtk3, sdl2 and openal and to build it use Makefile.linuxXX-wx-sdl2.
To install dependencies on Ubuntu: sudo apt install libwxgtk3.0-dev libsdl2-dev libopenal-dev
To compile it with MinGW on Windows 32-bit download wxMSW-3.1.0_gccXXXTDM_Dev.7z and wxWidgets-3.1.0-headers.7z from https://github.com/wxWidgets/wxWidgets/ ... tag/v3.1.0, SDL2-devel-2.0.5-mingw.tar.gz from http://libsdl.org/download-2.0.php and OpenAL.
Use Makefile.mingw-wx-sdl2 to build it.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Thu 13 Apr, 2017 10:48 pm

I tested this and my thoughts are:

  • Impressive work! :o This is more than I had in mind...Aside from some minor issues the job is done!
  • SDL2 is really great. Now we can resize/fullscreen on Linux...And I believe that now it is faster than Windows port (most probably thanks to OpenGL renderer).
  • It comes with some improvements requested on forum.
  • It can be compiled and used on Windows too (even it could on Mac OS X if someone is brave enough... ;) )

Summarizing: IMHO with this, the Linux port goes from entirely unpolished to being better that Windows port. :shock:

I take my hat off to you, bit.
User avatar
omarsis81
Posts: 545
Joined: Thu 17 Dec, 2015 6:20 pm

Re: [Linux] GUI discussion

Postby omarsis81 » Fri 14 Apr, 2017 1:45 am

I'm not interested in the Linux version, but impressive job from watching the screen! Congrats bit!
User avatar
leilei
Posts: 436
Joined: Fri 25 Apr, 2014 4:47 pm

Re: [Linux] GUI discussion

Postby leilei » Fri 14 Apr, 2017 2:53 am

bit wrote:Use Makefile.mingw-wx-sdl2 to build it.

I assume a newer GCC than 4.7.2 is required? Wxwidgets takes a while to build and then fails memory allocation at linking, and the headers for mingw expect wx/setup.h which isn't there at all

Not a bad idea for a window though, could stylize it after a baby-AT tower with the relevant lights, drive bays and buttons in the right places (and pop open the status window by clicking on the led indicator area)....
SarahWalker
Site Admin
Posts: 1334
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Linux] GUI discussion

Postby SarahWalker » Fri 14 Apr, 2017 1:11 pm

Certainly looks very good! I'm away this weekend, but when I'm back I'll give this a try.
bit
Posts: 98
Joined: Sun 19 Mar, 2017 7:04 pm

Re: [Linux] GUI discussion

Postby bit » Fri 14 Apr, 2017 9:41 pm

Thanks everyone! I'm happy to hear that you like it! :)

AmatCoder wrote:Aside from some minor issues the job is done!

I think the most major features that I haven't ported is joystick- and real CD-ROM-support, but it shouldn't be too much work to add it.
And I agree with SDL2, it's awesome!

omarsis81 wrote:I'm not interested in the Linux version, but impressive job from watching the screen!

Thanks! If you'd like to try it you can build it for Windows :)

leilei wrote:I assume a newer GCC than 4.7.2 is required?

You could try to build with wxWidgets 3.0.2, there are pre-built binaries for GCC 4.7.1 and 4.8.1 available at https://github.com/wxWidgets/wxWidgets/ ... tag/v3.0.2 (wxMSW-3.0.2_gccXXXTDM_Dev.7z). The pre-built binaries have the wx/setup.h-file placed in lib/mswu.
I also attempted to build wxWidgets from source and I agree that it wasn't a fun experience.

Cool idea to skin the machine window like small tower! :)

SarahWalker wrote:Certainly looks very good! I'm away this weekend, but when I'm back I'll give this a try.

Thanks! I hope you'll like it!
If it's alright with you I can provide a compiled Windows-version so it will be easier to test.
User avatar
TheMechanist
Posts: 36
Joined: Mon 03 Apr, 2017 6:59 pm

Re: [Linux] GUI discussion

Postby TheMechanist » Sat 15 Apr, 2017 7:04 pm

For me GUI development, and above all cross platform, was always a torture, so thanks to all, that accept that challenge ..

.. if I may, I'd recommend a very underrated cross platform gui toolkit ..

Supports Win32 native, Linux with GTK2/3 & Motif, and is pure C and very straight forward, with little dependencies and overhead and of course opensource & MIT licensed .. a long development history and still active

IUP

http://webserver2.tecgraf.puc-rio.br/iup/
User avatar
leilei
Posts: 436
Joined: Fri 25 Apr, 2014 4:47 pm

Re: [Linux] GUI discussion

Postby leilei » Sun 16 Apr, 2017 7:50 am

bit wrote:You could try to build with wxWidgets 3.0.2, there are pre-built binaries for GCC 4.7.1 and 4.8.1 available at https://github.com/wxWidgets/wxWidgets/ ... tag/v3.0.2 (wxMSW-3.0.2_gccXXXTDM_Dev.7z). The pre-built binaries have the wx/setup.h-file placed in lib/mswu.


Tried that

Code: Select all

$ make -f Makefile.mingw-wx-sdl2 g++ -DRELEASE_BUILD -O3 -march=i686 -fomit-frame-pointer -msse2 -mstackrealign -c wx-main.cc
In file included from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/wx/defs.h:27:0,
                 from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/wx/wxprec.h:12,
                 from wx-app.h:4,
                 from wx-main.cc:1:
c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/wx/platform.h:183:22:fatal error: wx/setup.h: No such file or directory
compilation terminated.
make: *** [wx-main.o] Error 1

:(

Probably wants me to build it :/
ahurst
Posts: 4
Joined: Fri 21 Aug, 2015 3:18 am

Re: [Linux] GUI discussion

Postby ahurst » Wed 19 Apr, 2017 12:20 am

Hey all,

Just reporting in that bit's SDL2 version of PCem builds and runs under OS X with minimal hassle, which is lightyears ahead of the Allegro version where you had to force it to compile in 32-bit using an 8-year old SDK because Allegro 4 depended on ancient deprecated frameworks on OS X. All that was required was

Code: Select all

brew install wxmac sdl2


along with maybe openal-soft (I already had it installed, so unsure if it's required). After that, 'make -f Makefile.osx64-wx-sdl2' resulted in a working binary in the 'src' directory, which started up fine once it was moved to the same directory as the 'roms' folder. I tested out Need For Speed II SE in Windows 95 with Voodoo 2 emulation, which ran somewhat choppily but playably:

Image

I also managed to get NeXTSTEP 3.3 for Intel up and running with full 32-bit colour using the Diamond Stealth 3D 2000 card:

Image


The only major bug I've found is that enabling dynarec on either the Voodoo 2 or the CPU causes an instant crash, meaning that speeds are somewhat slow and that none of the Pentium CPUs are useable. Does this happen on Linux as well or is it just a Mac thing?
bit
Posts: 98
Joined: Sun 19 Mar, 2017 7:04 pm

Re: [Linux] GUI discussion

Postby bit » Wed 19 Apr, 2017 7:47 am

leilei wrote:Probably wants me to build it :/

Did you copy the contents from /lib/gcc471TDM_dll/mswu/ to your include folder? setup.h can be found there.

ahurst wrote:Just reporting in that bit's SDL2 version of PCem builds and runs under OS X with minimal hassle

Nice to see it working! I don't own a Mac so I borrowed a Mac Mini just to get it working. I noticed the same issue with dynarec too but since I didn't have much time available with the Mac i couldn't investigate it. It doesn't happen on Linux though so I guess there's something in the recompiler code.
EDIT: CPU dynarec that is. The Voodoo recompiler works on Linux 32-bit but crashes on 64-bit.
User avatar
leilei
Posts: 436
Joined: Fri 25 Apr, 2014 4:47 pm

Re: [Linux] GUI discussion

Postby leilei » Sun 30 Apr, 2017 12:17 pm

I just got it working in Windows :)

I had to modify the makefile.mingw-wx-sdl2 file to change the wx libs to -lwxbase30ud -lwxmsw30ud_core -lwxmsw30ud_xrc and add -std=gnu99 to the cflags however, as it had this to complain about:

Code: Select all

wx-sdl2-video.c:311:9: error: 'for' loop initial declarations are only allowed in C99 mode
wx-sdl2-video.c:311:9: note: use option -std=c99 or -std=gnu99 to compile your code


I must mention the resulting binary is huge (10mb) and the dlls it depends on are also huge, but that's probably to expected of the typical huge 'nix UI toolkits


So far of what i've tried, what I really hate is Ctrl-End not working half of the time and it's not giving an exception to Alt-F4 (which shouldn't close PCem when the mouse is locked in). Personally i've always had bad luck with SDL2 and input on Windows so I'm not surprised at all by this.

Still not a bad proof of concept though. Voodoo2 dynarec+Pentium dynarec works fine for me BTW
bit
Posts: 98
Joined: Sun 19 Mar, 2017 7:04 pm

Re: [Linux] GUI discussion

Postby bit » Sun 30 Apr, 2017 6:27 pm

leilei wrote:I just got it working in Windows :)

I had to modify the makefile.mingw-wx-sdl2 file to change the wx libs to -lwxbase30ud -lwxmsw30ud_core -lwxmsw30ud_xrc and add -std=gnu99 to the cflags however, as it had this to complain about:

Code: Select all

wx-sdl2-video.c:311:9: error: 'for' loop initial declarations are only allowed in C99 mode
wx-sdl2-video.c:311:9: note: use option -std=c99 or -std=gnu99 to compile your code


I must mention the resulting binary is huge (10mb) and the dlls it depends on are also huge, but that's probably to expected of the typical huge 'nix UI toolkits


So far of what i've tried, what I really hate is Ctrl-End not working half of the time and it's not giving an exception to Alt-F4 (which shouldn't close PCem when the mouse is locked in). Personally i've always had bad luck with SDL2 and input on Windows so I'm not surprised at all by this.

Still not a bad proof of concept though. Voodoo2 dynarec+Pentium dynarec works fine for me BTW


Nice! Thanks for testing! :)
Yeah wxWidgets is a pretty big library.

Regarding your issues with Ctrl-End and Alt-F4 I've been working on a fix for these which seems to work like it should but is untested. Since you can now run it on Windows I decided to commit these changes so if you like I'd be happy if you could test them out :)
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Mon 01 May, 2017 3:23 am

leilei wrote:[...]I must mention the resulting binary is huge (10mb) and the dlls it depends on are also huge, but that's probably to expected of the typical huge 'nix UI toolkits[...]

When I cross-compiled this for Windows I was able to build an static executable (without dependencies) of only 3.3mb (UPX'ed, of course ;) ).
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [Linux] GUI discussion

Postby Battler » Mon 01 May, 2017 12:21 pm

My main problem with using this GUI on Windows would be fact it uses SDL for input which on Windows refers back to DirectInput from what I know, which according to Microsoft themselves should not be used for keyboard because it breaks when the host OS is set to a keyboard layout that is not English (US).
startmenu
Posts: 103
Joined: Sat 29 Nov, 2014 7:39 am

Re: [Linux] GUI discussion

Postby startmenu » Mon 01 May, 2017 12:53 pm

I just build a 64-bit PCem-wx-SDL2 https://github.com/mborjesson/PCem-wx-SDL2
It seems impossible that a SDL display window and control window can be merged into one window.
Attachments
screen2.png
screen2.png (227.68 KiB) Viewed 3228 times
Last edited by startmenu on Mon 01 May, 2017 2:49 pm, edited 1 time in total.
A. Naim
Posts: 75
Joined: Thu 09 Jul, 2015 5:06 pm

Re: [Linux] GUI discussion

Postby A. Naim » Mon 01 May, 2017 1:55 pm

startmenu wrote:I just build a 64-bit PCem-wx-SDL2 https://github.com/mborjesson/PCem-wx-SDL2
It seems impossible that a SDL display window and control window cannot be merged into one window.

Gonna explain this. :) The tl;dr is that theoretically, there's nothing stopping you; it just doesn't work that well, is platform specific, and doesn't integrate with your game engine very well.

Theoretically, you *can display Win32 controls on top of a DirectX window.

Practically, though, it's too much trouble to bother. Especially when you go full-screen. Win32 doesn't integrate with DirectX unless you write the integration code yourself...In which case, it's not really integration; more like gluing two different things together and hoping nothing breaks.

Using your game engine to display a GUI, OTOH, integrates with everything else in your game, and works on all the same platforms as your game engine, not just Windows.

* At least you could in the DX9 era, which is the last time I checked.

Edit: Since you probably have seen games where the DX window is inside a Win32 setup, I should probably explain that one.

DX (not sure if all versions, or only past some version) can display in a Win32 panel (and presumably, a Win16 panel, although I don't actually know) just fine. You just give it full control of that panel, and off you go. In this case, Win32/16 effectively never directly interact; commands get passed from the Win32/16 controls to your game engine, which then translates them and tells the graphics engine what to display. This is effectively the same thing as giving DX full control of a Win32/16 window, except scaled down to a panel.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Mon 01 May, 2017 3:25 pm

Battler wrote:My main problem with using this GUI on Windows would be fact it uses SDL for input which on Windows refers back to DirectInput from what I know, which according to Microsoft themselves should not be used for keyboard because it breaks when the host OS is set to a keyboard layout that is not English (US).


This GUI uses SDL2 version and, as far as I know, DirectInput for keyboard input was dropped from SDL1.x to SDL2.
AmatCoder
Posts: 28
Joined: Thu 02 Mar, 2017 8:45 pm

Re: [Linux] GUI discussion

Postby AmatCoder » Mon 01 May, 2017 4:16 pm

A. Naim wrote:Gonna explain this. :) The tl;dr is that theoretically, there's nothing stopping you; it just doesn't work that well, is platform specific, and doesn't integrate with your game engine very well.

Theoretically, you *can display Win32 controls on top of a DirectX window.

Practically, though, it's too much trouble to bother. Especially when you go full-screen. Win32 doesn't integrate with DirectX unless you write the integration code yourself...In which case, it's not really integration; more like gluing two different things together and hoping nothing breaks.

Using your game engine to display a GUI, OTOH, integrates with everything else in your game, and works on all the same platforms as your game engine, not just Windows.

* At least you could in the DX9 era, which is the last time I checked.

With SDL2 and wxwidgets is not so difficult.
We could use SDL_GetWindowWMInfo to get native handle (HWND on Windows) from SDL window and wxNativeWindow to embed it in the wxwidgets application.
EluanCM
Posts: 28
Joined: Tue 27 Oct, 2015 2:07 pm
Contact:

Re: [Linux] GUI discussion

Postby EluanCM » Mon 01 May, 2017 4:23 pm

AmatCoder wrote:
Battler wrote:My main problem with using this GUI on Windows would be fact it uses SDL for input which on Windows refers back to DirectInput from what I know, which according to Microsoft themselves should not be used for keyboard because it breaks when the host OS is set to a keyboard layout that is not English (US).


This GUI uses SDL2 version and, as far as I know, DirectInput for keyboard input was dropped from SDL1.x to SDL2.


We with international keyboards were used to automatically think of a US layout in games in the 90's and early 2000's, no big deal. But for something like PCem it would be bad.

I can confirm that SDL2 has proper support for international layouts from my experience writing games.
A. Naim
Posts: 75
Joined: Thu 09 Jul, 2015 5:06 pm

Re: [Linux] GUI discussion

Postby A. Naim » Mon 01 May, 2017 7:23 pm

AmatCoder wrote:With SDL2 and wxwidgets is not so difficult.
We could use SDL_GetWindowWMInfo to get native handle (HWND on Windows) from SDL window and wxNativeWindow to embed it in the wxwidgets application.

My reading of their post was that they wanted it the other way around. And please quote my entire post.

I do not want to have to start posting multiple posts for the next three minutes as I finish fixing up my posts.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [Linux] GUI discussion

Postby Battler » Tue 02 May, 2017 7:24 pm

- EluanCM: But does SDL2 pass the raw scan codes through its API? Because if it doesn't, it's pretty much useless as you have to retranslate whatever SDL2 now uses for key codes back to raw scan codes, and if the SDL2 key codes are not directly 1:1 mapped to scan codes, you will never get the accurate sequence back. And do special keys (such as the Japanese JIS layout keys (kana, half/full, etc.)) get passed? And are the Windows Registry scan code remappings respected?
buka
Posts: 11
Joined: Tue 17 Nov, 2015 9:13 pm

Re: [Linux] GUI discussion

Postby buka » Wed 17 May, 2017 7:09 pm

I just wanted to say THANK YOU SO MUCH. @bit I'm finally able to get rid of DOSBox for good. This port is almost perfect, work beautifully under Arch Linux

Return to “Development”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest