Re: xkbcommon: Converting keysym to keycode

2021-12-06 Thread adlo
Basically the program I’m working on was originally designed for X11, and I’m 
trying to adapt it to Wayland. I’m trying to find an equivalent to 
XKeysymToKeycode().

> it doesn't, but if you look at xkbcli how-to-type and it's source
> (tools/how-to-type.c) that's the closest approximation.

What does this program do? Does it iterate through all possible keycodes and 
lookup the keysym for them?
> 
> Main reason is that the keycode->keysym conversion is one-way only and it's
> not 100% reliable to go back. e.g. if a modifier is locked/latched you cannot
> access certain keysyms without unlocking that modifier, etc.

How would I deal with capital letters with regards to getting a keycode from a 
keysym?

> KEY_TAB is defined in linux/input-event-codes.h. XKB uses those keycodes + 8
> for the evdev ruleset (see /usr/share/X11/xkb/keycodes/evdev for the mapping)
> and it goes from there. If you're using a different ruleset you're going to
> get interesting results but evdev is effectively hardcoded everywhere anyway,
> so you won't.

Is linux/input-event-codes.h keycodes or keysyms?

Re: xkbcommon: Converting keysym to keycode

2021-12-06 Thread adlo
Does xkbcommon have modifier masks, like that used in the “state” field of 
XKeyEvent?

> On 4 Dec 2021, at 08:34, adlo  wrote:
> 
> Basically the program I’m working on was originally designed for X11, and 
> I’m trying to adapt it to Wayland. I’m trying to find an equivalent to 
> XKeysymToKeycode().
> 
>> it doesn't, but if you look at xkbcli how-to-type and it's source
>> (tools/how-to-type.c) that's the closest approximation.
> 
> What does this program do? Does it iterate through all possible keycodes and 
> lookup the keysym for them?
>> 
>> Main reason is that the keycode->keysym conversion is one-way only and it's
>> not 100% reliable to go back. e.g. if a modifier is locked/latched you cannot
>> access certain keysyms without unlocking that modifier, etc.
> 
> How would I deal with capital letters with regards to getting a keycode from 
> a keysym?
> 
>> KEY_TAB is defined in linux/input-event-codes.h. XKB uses those keycodes + 8
>> for the evdev ruleset (see /usr/share/X11/xkb/keycodes/evdev for the mapping)
>> and it goes from there. If you're using a different ruleset you're going to
>> get interesting results but evdev is effectively hardcoded everywhere anyway,
>> so you won't.
> 
> Is linux/input-event-codes.h keycodes or keysyms?


Re: xkbcommon: Converting keysym to keycode

2021-12-06 Thread Peter Hutterer
On Sat, Dec 04, 2021 at 08:34:49AM +, adlo wrote:
> Basically the program I’m working on was originally designed for X11, and I’m 
> trying to adapt it to Wayland. I’m trying to find an equivalent to 
> XKeysymToKeycode().
> 
> > it doesn't, but if you look at xkbcli how-to-type and it's source
> > (tools/how-to-type.c) that's the closest approximation.
> 
> What does this program do? Does it iterate through all possible keycodes and 
> lookup the keysym for them?

please look at the source, it's not a huge program.

> > 
> > Main reason is that the keycode->keysym conversion is one-way only and it's
> > not 100% reliable to go back. e.g. if a modifier is locked/latched you 
> > cannot
> > access certain keysyms without unlocking that modifier, etc.
> 
> How would I deal with capital letters with regards to getting a keycode from 
> a keysym?

there's no such thing as a capital letter with keycodes, keycodes are really
just "this physical key has been pressed". so capital letters usually resolve
to a sequence - shift down, keycode, shift up. That is where the difficult
bits start.

> 
> > KEY_TAB is defined in linux/input-event-codes.h. XKB uses those keycodes + 8
> > for the evdev ruleset (see /usr/share/X11/xkb/keycodes/evdev for the 
> > mapping)
> > and it goes from there. If you're using a different ruleset you're going to
> > get interesting results but evdev is effectively hardcoded everywhere 
> > anyway,
> > so you won't.
> 
> Is linux/input-event-codes.h keycodes or keysyms?

keycodes, but they have semantic naming for easier association.

Cheers,
  Peter


Re: xkbcommon: Converting keysym to keycode

2021-12-06 Thread adlo
> On 5 Dec 2021, at 05:15, Peter Hutterer  wrote:
> 
> please look at the source, it's not a huge program.

I have looked at the source, it’s just that I can’t see anything that’s 
directly related to what I’m trying to do. It calls 
xkb_keymap_key_get_mods_for_level(), which seems to be related to getting the 
mods, and it seems to have things that get the name of a key, or get a key from 
the name, but I can’t see anything that looks like it’s related to getting or 
approximating a keycode from a keysym.



Absolute mouse position retrieval

2021-12-06 Thread Jesse Van Gavere
For a device we're making, it's necessary to have a daemon running on servers 
which frequently polls the absolute mouse location and transmits this to our 
device, this is a necessary feature to have correct operation of our device.
The problem we're running into is that on an old OS this will work without 
issue as X allows us to easily poll the absolute position of a mouse pointer, 
however under Wayland this is not possible and our customers will be moving to 
these (I know they can fall back to X but we're assuming they'll move to 
Wayland when upgrading) I've seen posts that said mouse position 
retrieval/warping is not present because it's a security risk.
Are there any plans to add support for this after all or is there any way to 
add necessary support to get this functionality working again?

Regards,
Jesse




Re: Absolute mouse position retrieval

2021-12-06 Thread Simon Ser
> For a device we’re making, it’s necessary to have a daemon running on
> servers which frequently polls the absolute mouse location and
> transmits this to our device, this is a necessary feature to have
> correct operation of our device.

Can you expand on this?

Writing a device driver in user-space which connects to X11 or Wayland
is not the right way to do it.


RE: Absolute mouse position retrieval

2021-12-06 Thread Jesse Van Gavere
We're not using a device driver, it's a very small application that uses 
XInput2 to wait for mouse events using XNextEvent and when it sees a mouse 
event it gets the current position through XQueryPointer and transmits that 
over a serial link to our device. I was just wondering if a similar feature on 
Wayland exists or it's a feature that will be added/can be added by us one way 
or another.

-Original Message-
From: Simon Ser  
Sent: Monday, 6 December 2021 12:10
To: Jesse Van Gavere 
Cc: wayland-devel@lists.freedesktop.org
Subject: Re: Absolute mouse position retrieval

> For a device we’re making, it’s necessary to have a daemon running on 
> servers which frequently polls the absolute mouse location and 
> transmits this to our device, this is a necessary feature to have 
> correct operation of our device.

Can you expand on this?

Writing a device driver in user-space which connects to X11 or Wayland is not 
the right way to do it.


Re: Absolute mouse position retrieval

2021-12-06 Thread Jonas Ådahl
The way this seems to be implemented seems quite similar to screen
casting. With screen casting you can get per screen cast stream absolute
cursor positions "streamed" via the PipeWire metadata, only that it will
be alongside actual screen content as well, which I imagine is not
something you need.

Maybe it could be explored whether it makes sense to do this via the
screen casting API, i.e. via PipeWire stream negotiation, by making it
possible to not including the actual screen content when streaming. It
might be a bit "overkill" but it'd have the benefit of being able to
reuse all the sandbox permission management, portal dialog
implementations, and related things that this involves.


Jonas

On Mon, Dec 06, 2021 at 11:19:06AM +, Jesse Van Gavere wrote:
> We're not using a device driver, it's a very small application that uses 
> XInput2 to wait for mouse events using XNextEvent and when it sees a mouse 
> event it gets the current position through XQueryPointer and transmits that 
> over a serial link to our device. I was just wondering if a similar feature 
> on Wayland exists or it's a feature that will be added/can be added by us one 
> way or another.
> 
> -Original Message-
> From: Simon Ser  
> Sent: Monday, 6 December 2021 12:10
> To: Jesse Van Gavere 
> Cc: wayland-devel@lists.freedesktop.org
> Subject: Re: Absolute mouse position retrieval
> 
> > For a device we’re making, it’s necessary to have a daemon running on 
> > servers which frequently polls the absolute mouse location and 
> > transmits this to our device, this is a necessary feature to have 
> > correct operation of our device.
> 
> Can you expand on this?
> 
> Writing a device driver in user-space which connects to X11 or Wayland is not 
> the right way to do it.