Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[copy.pl] add gpm copybuffer #674

Open
vague666 opened this issue Nov 8, 2019 · 25 comments
Open

[copy.pl] add gpm copybuffer #674

vague666 opened this issue Nov 8, 2019 · 25 comments

Comments

@vague666
Copy link
Member

vague666 commented Nov 8, 2019

@bw1
It might be possible to use gpm to copy text if in non-X env
There should be a fifo called /dev/gpmdata


> -R[name]
>     Causes gpm to act as a repeater: any mouse data received while in graphic
>     mode will be produced on the fifo /dev/gpmdata in protocol name, given as
>     an optional argument (no space in between !). In principle, you can use the
>     same names as for the -t option, although repeating into some protocols may
>     not be implemented for a while. In addition, you can specify raw as the name,
>     to repeat the mouse data byte by byte, without any protocol translation. If
>     name is omitted, it defaults to msc

Don't know without testing myself if it's possible to write data to gpmdata and paste with mouse middle-button, also, no idea if gpm has to be started with -R for gpmdata to be created
Something to test :)

@bw1 bw1 pinned this issue Nov 8, 2019
@bw1 bw1 unpinned this issue Nov 8, 2019
@bw1
Copy link
Member

bw1 commented Nov 9, 2019

gpm 1.20.7
Available mouse types are:

r name   synonym         description

  mman     The "MouseMan" and similar devices (3/4 bytes per packet).
            Synonyms: Mouseman
  ms       The original ms protocol, with a middle-button extension.
            Synonyms: 
  acecad   Acecad tablet absolute mode(Sumagrapics MM-Series mode)
            Synonyms: 
  bare     Unadorned ms protocol. Needed with some 2-buttons mice.
            Synonyms: Microsoft
  bm       Micro$oft busmice and compatible devices.
            Synonyms: BusMouse
  brw      Fellowes Browser - 4 buttons (and a wheel) (dual protocol?)
            Synonyms: 
  cal      Calcomp UltraSlate
            Synonyms: 
  calr     Calcomp UltraSlate - relative mode
            Synonyms: 
  etouch   EloTouch touch-screens (only button-1 events, by now)
            Synonyms: 
  evdev    Linux Event Device
            Synonyms: 
  exps2    IntelliMouse Explorer (ps2) - 3 buttons, wheel unused
            Synonyms: ExplorerPS/2
  js       Joystick mouse emulation
            Synonyms: Joystick
  genitizer "Genitizer" tablet, in relative mode.
            Synonyms: 
  gunze    Gunze touch-screens (only button-1 events, by now)
            Synonyms: 
* imps2    Microsoft Intellimouse (ps2)-autodetect 2/3 buttons,wheel unused
            Synonyms: 
  logi     Used in some Logitech devices (only serial).
            Synonyms: Logitech
  logim    Turn logitech into Mouse-Systems-Compatible.
            Synonyms: 
  mm       MM series. Probably an old protocol...
            Synonyms: MMSeries
* ms3      Microsoft Intellimouse (serial) - 3 buttons, wheel unused
            Synonyms: 
  ms+      Like 'ms', but allows dragging with the middle button.
            Synonyms: 
  ms+lr    'ms+', but you can reset m by pressing lr (see man page).
            Synonyms: 
* msc      Mouse-Systems-Compatible (5bytes). Most 3-button mice.
            Synonyms: MouseSystems
  mtouch   MicroTouch touch-screens (only button-1 events, by now)
            Synonyms: 
  ncr      Ncr3125pen, found on some laptops
            Synonyms: 
  netmouse Genius NetMouse (ps2) - 2 buttons and 2 buttons 'up'/'down'.
            Synonyms: 
  pnp      Plug and pray. New mice may not run with '-t ms'.
            Synonyms: 
* ps2      Busmice of the ps/2 series. Most busmice, actually.
            Synonyms: PS/2
* sun      'msc' protocol, but only 3 bytes per packet.
            Synonyms: 
* summa    Summagraphics or Genius tablet absolute mode(MM-Series)
            Synonyms: 
  syn      The "Synaptics" serial TouchPad.
            Synonyms: synaptics
  synps2   The "Synaptics" PS/2 TouchPad
            Synonyms: synaptics_ps2
  twid     Twidddler keyboard
            Synonyms: 
  vsxxxaa  The DEC VSXXX-AA/GA serial mouse on DEC workstations.
            Synonyms: 
  wacom    Wacom Protocol IV Tablets: Pen+Mouse, relative+absolute mode
            Synonyms: 
  wp       Genius WizardPad tablet
            Synonyms: wizardpad

@bw1 bw1 added the enhancement label Nov 9, 2019
@bw1
Copy link
Member

bw1 commented Nov 11, 2019

@vague666

@vague666
Copy link
Member Author

What is the question?

@bw1
Copy link
Member

bw1 commented Nov 11, 2019

i read. the fifo speaks a mouse protocol and the fifo is for reading.

fifo /dev/gpmdata in protocol name
                             ^^^^^

where can i put the string?

@vague666
Copy link
Member Author

The gpm daemon must be started with -R, for example -Rms3 (this worked for me)
Then I could do echo test > /dev/gpmdata; cat /dev/gpmdata
Although the cat didn't exit, but attempted to read more from gpmdata, not sure if that can be modified

@bw1
Copy link
Member

bw1 commented Nov 11, 2019

bash-4.3# echo test > /dev/gpmdata; cat /dev/gpmdata
C>C<C<C;C<C;C<C<C<C<C<C<C=C=C>C?C?L>L>L=L;L:L9L:L9L:L;L;L;L;L<L<L>L>L?L?L?@L?L?@@L?@L?@L?L?L?L?test
C?C>C=C>C>C?C>C?C?C?C?@@@@@@@@L?L?L=L<L<L<L<L<L<L;L<L<L=L=L=L>L>L>L>L?L?L?L?C?L?C?O??C?O??C?O??O>?O>?C>C>C=C=C=C>C=C=C>C=C=C>C?C?@@@@@@@@@@@@@@@@@L?L?L>L>L=L=L<L<L<L=L=L=L>L>L?L?L?^C

@vague666
Copy link
Member Author

Try some other mouse types is all I can say. I tested in a centos vm, change both -t and -R to the gpm daemon

@bw1
Copy link
Member

bw1 commented Nov 12, 2019

[src ]$ print **/(*.c|*.h) |xargs grep fifofd
daemon/getmousedata.c:   if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep)
daemon/getmousedata.c:      write(fifofd, data, howmany);
daemon/getmousedata.c:         if (kd_mode!=KD_TEXT && fifofd != -1 && opt_rawrep && j > 0)
daemon/getmousedata.c:            write(fifofd, edata-i, j);
daemon/gpm.c:int fifofd=-1;
daemon/processmouse.c:      if (fifofd != -1 && ! opt_rawrep) {
daemon/processmouse.c:         repeated_type->repeat_fun(event, fifofd); /* itz Jan 11 1999 */
daemon/startup.c:      if((fifofd=open(GPM_NODE_FIFO, O_RDWR|O_NONBLOCK)) < 0)
headers/daemon.h:extern int              fifofd;

@bw1
Copy link
Member

bw1 commented Nov 12, 2019

man:console_ioctl

TIOCLINUX, subcode=2
    Set selection. argp points to a 

    struct {
       char  subcode;
       short xs, ys, xe, ye;
       short sel_mode;
    };

    xs and ys are the starting column and row. xe and ye are the ending column and row. (Upper left corner is row=column=1.) sel_mode is 0 for character-by-character selection, 1 for word-by-word selection, or 2 for line-by-line selection. The indicated screen characters are highlighted and saved in the static array sel_buffer in devices/char/console.c. 
TIOCLINUX, subcode=3
    Paste selection. The characters in the selection buffer are written to fd. 

@vague666
Copy link
Member Author

@bw1
Copy link
Member

bw1 commented Nov 12, 2019

https://0x0.st/zE6U.gz

@vague666
Copy link
Member Author

Did the upload somehow fuck up the filename?
Not really sure what I should do with the fifoexample

@bw1
Copy link
Member

bw1 commented Nov 12, 2019

Did the upload somehow fuck up the filename?

fifoexample.tar.gz

Not really sure what I should do with the fifoexample
$> ./run.sh
gcc -o openfifo openfifo.c
ein test

 $>cat run.sh 
#!/bin/sh
make
mkfifo fifo
./openfifo&
echo 'ein test' > fifo
cat fifo

@vague666
Copy link
Member Author

I still don't know what that is supposed to mean. Why the c program?
/dev/gpmdata is created when the gpm daemon is run with -R, after that you can redirect data to the device and read from it. Depending on the mouse type the data might be dirty with protocol bits but changing -t and -R until the data is valid should work
In the script just add writing to /dev/gpmdata to paste from irssi and document the need for -R, like I said, -Rms3 worked for me and might work for others

@bw1
Copy link
Member

bw1 commented Nov 13, 2019

🤕

@bw1
Copy link
Member

bw1 commented Nov 13, 2019

graph

@vague666
Copy link
Member Author

I run all my centos without X. If you have possibility to try on a system without X please do but I don't think the fifo means X is/has to be installed, just that any mouse data in graphic mode, could mean both vesafb and X I guess, will be repeated in /dev/gpmdata, nothing stops you from using the device to move data around, ie echo test > /dev/gpmdata; cat /dev/gpmdata, but the fifo will only be created if you start gpm with -R[type/protocol]

@vague666
Copy link
Member Author

-R[name]
Causes gpm to act as a repeater: any mouse data received while in graphic mode will be produced on the fifo /dev/gpmdata in protocol name, given as an optional argument (no space in between !). In principle, you can use the same names as for the -t option, although repeating into some protocols may not be implemented for a while. In addition, you can specify raw as the name, to repeat the mouse data byte by byte, without any protocol translation. If name is omitted, it defaults to msc. Using gpm in repeater mode, you can configure the X server to use its fifo as a mouse device. This option is useful for bus-mouse owners to override the single-open limitation. It is also an easy way to manage those stupid dual-mode mice which force you to keep the middle button down while changing video mode. The option is forced on by the -M option.

@bw1
Copy link
Member

bw1 commented Nov 13, 2019

/etc/rc.d/rc.gpm

# There is another way to run GPM, where it acts as a repeater outputting a
# virtual MouseSystems mouse on /dev/gpmdata.  This is useful for feeding
# gpm's data to X, especially if you've got a busmouse (in that situation X
# and gpm may not coexist without using a repeater).  To try running a GPM
# repeater for X, change the gpm command line to look like this:
# /usr/sbin/gpm -R msc -m /dev/mouse -t ps2
# Then, make sure that the mouse configuration in your XF86Config file refers
# to the repeater device (/dev/gpmdata) and a MouseSystems mouse type.  If you
# edit the file directly, you'll want the lines to look like this (minus the
# comment marks '#' shown here, of course):
#Section "Pointer"
#    Protocol    "MouseSystems"
#    Device      "/dev/gpmdata"

@vague666
Copy link
Member Author

I don't know what you mean by that. X is not required from what I can see. Just add a possibility to print data to /dev/gpmdata to the script and document the need to run gpm with -R

@bw1
Copy link
Member

bw1 commented Nov 13, 2019

/dev/gpmdata is a output of gpm.

@vague666
Copy link
Member Author

/dev/gpmdata is created when gpm is run with -R. It's a normal fifo, you can write to it and read from it. X has no bearing on it in this case

@bw1
Copy link
Member

bw1 commented Nov 13, 2019

graph

bw1 added a commit to bw1/scripts.irssi.org that referenced this issue Nov 16, 2019
@bw1
Copy link
Member

bw1 commented Nov 16, 2019

f447306

@jwilk
Copy link
Contributor

jwilk commented Apr 11, 2024

Just add a possibility to print data to /dev/gpmdata to the script

This is completely wrong. /dev/gpmdata is not for passing text around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants