1. gpm mouse support for linux
- Posted by chaynes Nov 30, 2011
- 2460 views
I am migrating my DOS platform Euphoria programs to the Linux platform. I understand that the mouse is not supported in Linux consoles, and that in order to gain support, I must use GPM. I am running in Puppy Slacko 5.3 (Linux), and have installed GPM. But I don't know what to do next in order to get GPM working. Any help will be greatly appreciated. So far, I have not found a Linux forum that can provide any help.
2. Re: gpm mouse support for linux
- Posted by mattlewis (admin) Nov 30, 2011
- 2452 views
I am migrating my DOS platform Euphoria programs to the Linux platform. I understand that the mouse is not supported in Linux consoles, and that in order to gain support, I must use GPM. I am running in Puppy Slacko 5.3 (Linux), and have installed GPM. But I don't know what to do next in order to get GPM working. Any help will be greatly appreciated. So far, I have not found a Linux forum that can provide any help.
It's been a few years, but I think that I experimented with wrapping gpm in the past. IIRC, most of it seems to be C preprocessor macros, and I eventually gave up.
Matt
3. Re: gpm mouse support for linux
- Posted by jimcbrown (admin) Dec 01, 2014
- 2123 views
Due to it's many macros, GPM is not easy to wrap.
I figure a wrapper should take the route of wxEuphoria, that is, add a C shim library in the middle to make it easier to wrap.
I've prototyped a quick-and-dirty GPM wrapper for Euphoria 4.0.
Here's a demo program (based on the old mouse.exu demo that came with RDS Euphoria): http://openeuphoria.org/pastey/251.wc
Here's the source for the C shim: http://openeuphoria.org/pastey/249.wc
The shim is based on the old C code in be_machine.c that implemented the original M_GET_MOUSE machine function.
Here's the include file that wraps the C shim and gives you back get_mouse(): http://openeuphoria.org/pastey/250.wc
4. Re: gpm mouse support for linux
- Posted by jmduro Dec 05, 2014
- 1999 views
You could also use DosBox. Your programs should run without any change. Of course you need a mouse driver but it supports many of them.
DosBox is really nice and multi-platform. My Dos programs still work on Windows Seven 64 bits, and Dosbox is also available on Android. I use Dosbox Turbo on Android but there is no mouse support. There is only a GamePad support on Dosbox Turbo.
Regards
Jean-Marc
5. Re: gpm mouse support for linux
- Posted by jimcbrown (admin) Dec 05, 2014
- 1963 views
You could also use DosBox. Your programs should run without any change.
That does help the OP out, but there were a few linux/GNU programs that made use of the mouse as well that didn't have a DOS version.
6. Re: gpm mouse support for linux
- Posted by _tom (admin) Dec 05, 2014
- 1965 views
Thanks Jim for the quick response.
So far I could not compile mouse.c to an .so
Jean-Marc, using Dosbox is a creative solution but I can't see that as a popular requirement to get a text editor working.
The problem remains--what simple text editor:
- works both on Windows and Linux
- can edit Euphoria source
- doesn't make Euphoria look behind the times
I'm assuming that some kind of mouse support will be needed for a text editor.
_tom
7. Re: gpm mouse support for linux
- Posted by jimcbrown (admin) Dec 05, 2014
- 1942 views
Thanks Jim for the quick response.
So far I could not compile mouse.c to an .so
What is the console output from the compile attempt?
8. Re: gpm mouse support for linux
- Posted by _tom (admin) Dec 05, 2014
- 1982 views
What is the console output from the compile attempt?
Using Mint17
gpm and libgpm-dev is installed as "libpm2" version 1.20.4-6.1
gcc -o mouse.so -lgpm -shared mouse.c mouse.c:26:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:27:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:31:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:37:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:40:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:42:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:43:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:44:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:45:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:46:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:47:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:48:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:49:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:50:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:51:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:95:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:96:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:111:10: error: #include expects "FILENAME" or <FILENAME> #include ^ mouse.c:187:19: error: unknown type name ‘Gpm_Event’ int Mouse_Handler(Gpm_Event *event, void *clientdata) { ^ mouse.c:202:1: error: unknown type name ‘Gpm_Connect’ static Gpm_Connect conn; ^ mouse.c: In function ‘GetMouse’: mouse.c:216:7: error: request for member ‘eventMask’ in something not a structure or union conn.eventMask = 0xFFFF; // unsigned short ^ mouse.c:217:7: error: request for member ‘defaultMask’ in something not a structure or union conn.defaultMask = 0; ^ mouse.c:218:7: error: request for member ‘minMod’ in something not a structure or union conn.minMod = 0; ^ mouse.c:219:7: error: request for member ‘maxMod’ in something not a structure or union conn.maxMod = ~0; ^ mouse.c:220:3: error: ‘gpm_visiblepointer’ undeclared (first use in this function) gpm_visiblepointer = 1; ^ mouse.c:220:3: note: each undeclared identifier is reported only once for each function it appears in mouse.c:222:3: error: ‘gpm_handler’ undeclared (first use in this function) gpm_handler = Mouse_Handler; ^ mouse.c:222:17: error: ‘Mouse_Handler’ undeclared (first use in this function) gpm_handler = Mouse_Handler; ^ mouse.c:223:3: error: ‘gpm_data’ undeclared (first use in this function) gpm_data = NULL; ^ mouse.c:223:14: error: ‘NULL’ undeclared (first use in this function) gpm_data = NULL; ^
9. Re: gpm mouse support for linux
- Posted by jimcbrown (admin) Dec 05, 2014
- 1970 views
What is the console output from the compile attempt?
Using Mint17
gpm and libgpm-dev is installed as "libpm2" version 1.20.4-6.1
gcc -o mouse.so -lgpm -shared mouse.c mouse.c:26:10: error: #include expects "FILENAME" or <FILENAME> #include
There's a bug in the forum that is not escaping the angle brackets correctly.
If you go to the pastey, and view the HTML source, you should be able to get the correct include statements that way. Once the include statements are fixed, the other errors should go away as well.
10. Re: gpm mouse support for linux
- Posted by jmduro Dec 06, 2014
- 1993 views
If I'd had to build a console program with mouse support for Linux, I'd use ncurses. It supports mouses: http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/mouse.html
Regards
Jean-Marc
11. Re: gpm mouse support for linux
- Posted by jmduro Dec 06, 2014
- 1954 views
Maybe this very old Linux Journal article (1995) can help:
Writing a Mouse-Sensitive Application http://www.linuxjournal.com/article/1136
I tried to play with an old Euphoria code related to ncurses but it is buggy and seems to be 32 bits only, so maybe a new wrapper for ncurses is needed.
Regards
Jean-Marc
12. Re: gpm mouse support for linux
- Posted by jmduro Dec 06, 2014
- 1949 views
I found a discussion about raw mouse events here: http://forum.tinycorelinux.net/index.php?topic=14980.0
They seem to monitor directly /dev/input/mouse0
Regards
Jean-Marc
13. Re: gpm mouse support for linux
- Posted by jmduro Dec 06, 2014
- 1887 views
It seems to be very simple in fact:
include std/get.e include std/io.e integer mousefp integer mousedata, knt mousefp=open("/dev/input/mouse0", "rb") knt = 0 while(1) do --inner mousedata=getc(mousefp) printf(1, "%d: %04x\n", {knt, mousedata}) knt += 1 flush(SCREEN) if get_key() = 'q' then exit end if end while --inner close(mousefp)
Yet there is little job to do to decode mouse events. Regards Jean-Marc
14. Re: gpm mouse support for linux
- Posted by jimcbrown (admin) Dec 08, 2014
- 1852 views
What is the console output from the compile attempt?
Using Mint17
gpm and libgpm-dev is installed as "libpm2" version 1.20.4-6.1
gcc -o mouse.so -lgpm -shared mouse.c mouse.c:26:10: error: #include expects "FILENAME" or <FILENAME> #include
There's a bug in the forum that is not escaping the angle brackets correctly.
If you go to the pastey, and view the HTML source, you should be able to get the correct include statements that way. Once the include statements are fixed, the other errors should go away as well.
Or you can just get the unmangled version, hassle free, at http://openeuphoria.org/mouse.c
I prefer jmduro's solution though. gpm seems to be linux/GNU only (at least it doesn't run on FreeBSD), so there's no portability benefit in using gpm as opposed to reading events directly. (I guess some very old linux/GNU distros might not support /dev/input/mouse and would require reading a different device like /dev/psaux or something, though.) In addition, jmduro's solution is 100% Euphoria code, so the set of potential developers who can help maintain it is higher (as there's no need to deal with C).
15. Re: gpm mouse support for linux
- Posted by _tom (admin) Dec 10, 2014
- 1847 views
Jean-Marc:
Your program works after the permissions to /dev/input/mouse0 are changed. This requires root privileges on Mint17; the changes did not persist after reboot.
Jim Brown:
I compiled mouse.c to an .so but I could not open the shared library. It also looks like gmp (because of its age) is not going to work nicely with the default UTF8 encoding in current terminals.
Conclusions so far...
getting mouse support in a text terminal is beyond my talent level.
_tom