erjiang / huion-keys

Linux program to create custom bindings for Huion tablet hotkeys
GNU General Public License v3.0
13 stars 4 forks source link

xdo struct missing modmap and keymap members #1

Closed erjiang closed 4 years ago

erjiang commented 4 years ago

I tried on ArchLinux with, for installing packages: sudo pacman -S base-devel xdo python-cffi

My version of:

doing

 python xdo_build.py

I have the following errors:

_xdo_cffi.c: In function '_cffi_checkfld__xdo_t':
_xdo_cffi.c:5106:32: error: 'xdo_t' {aka 'struct xdo'} has no member named 'modmap'
 5106 |   { XModifierKeymap * *tmp = &p->modmap; (void)tmp; }
      |                                ^~
_xdo_cffi.c:5107:30: error: 'xdo_t' {aka 'struct xdo'} has no member named 'keymap'
 5107 |   { unsigned long * *tmp = &p->keymap; (void)tmp; }
      |                              ^~
In file included from _xdo_cffi.c:61:
_xdo_cffi.c: At top level:
_xdo_cffi.c:5269:15: error: 'xdo_t' {aka 'struct xdo'} has no member named 'modmap'
 5269 |   { "modmap", offsetof(xdo_t, modmap),
      |               ^~~~~~~~
_xdo_cffi.c:5270:34: error: 'xdo_t' {aka 'struct xdo'} has no member named 'modmap'
 5270 |               sizeof(((xdo_t *)0)->modmap),
      |                                  ^~
In file included from _xdo_cffi.c:61:
_xdo_cffi.c:5272:15: error: 'xdo_t' {aka 'struct xdo'} has no member named 'keymap'
 5272 |   { "keymap", offsetof(xdo_t, keymap),
      |               ^~~~~~~~
_xdo_cffi.c:5273:34: error: 'xdo_t' {aka 'struct xdo'} has no member named 'keymap'
 5273 |               sizeof(((xdo_t *)0)->keymap),
      |                                  ^~

The xdo sturcture in /usr/include/xdo.h:

/**
 * The main context.
 */
typedef struct xdo {

  /** The Display for Xlib */
  Display *xdpy;

  /** The display name, if any. NULL if not specified. */
  char *display_name;

  /** @internal Array of known keys/characters */
  charcodemap_t *charcodes;

  /** @internal Length of charcodes array */
  int charcodes_len;

  /** @internal highest keycode value */
  int keycode_high; /* highest and lowest keycodes */

  /** @internal lowest keycode value */
  int keycode_low;  /* used by this X server */

  /** @internal number of keysyms per keycode */
  int keysyms_per_keycode;

  /** Should we close the display when calling xdo_free? */
  int close_display_when_freed;

  /** Be extra quiet? (omits some error/message output) */
  int quiet;

  /** Enable debug output? */
  int debug;

  /** Feature flags, such as XDO_FEATURE_XTEST, etc... */
  int features_mask;

} xdo_t;

Originally posted by @Popolon in https://github.com/DIGImend/digimend-kernel-drivers/issues/463#issuecomment-720002404

erjiang commented 4 years ago

I went down the rabbit-hole of figuring out where the modmap and keymap members came from, because they are not in the upstream code. It looks like upstream added modmap, then keymap, then removed them at some point (which is bad because it breaks the ABI). However, the Debian maintainer kept them in to avoid breaking the ABI.

In this codebase, we aren't touching the xdo struct anyways, so it should be fine to remove them, which I have done in https://github.com/erjiang/huion-keys/commit/07759535c2e9aac7b55c71d47cfcf6433fc90995

@Popolon can you check out the latest version and see if it compiles for you?

Popolon commented 4 years ago

It works perfectly ! Thanks too much :+1: .thanks🙏🏻🙇🏻‍♂️

Popolon commented 4 years ago

I tested a bit more, it doesn't accept . and , keycodes. I mainly use my tablet with pencil2D (a foss 2d animation software). And this by default use alt+,/alt+, for going one key frame forward or backward.

Error: Invalid key sequence 'alt+.'
Failure converting key sequence 'alt+.' to keycodes
Error: Invalid key sequence 'alt+.'
Failure converting key sequence 'alt+.' to keycodes

I can change shortcut in software, so I will put an alpha character to use it,

strangely key 2, 3 and 4 that I've assigned to respectively m (move), p(pen) and e(eraser) send other signal, don't know wich one exactly.

Popolon commented 4 years ago

Debuging information give

Got button 0
Sending b'v'

where button 1 is set to v in config file, this inconsistency could trouble users.

Popolon commented 4 years ago

I understood. xdo, only understand coma (for ,) and perod (for .)

It works partially, on my desktop: for exemple if I set the slider to

scroll_up=comma
scroll_down=period

And I test it in a terminal, I have the following answers:

..6.,,,,666666.6668,8,...8,8666..6......6,888,6.6..,,,,,8,8...

some 6 and 8 are added to commas and periods It's probably the same problem than with keyse 2.3,4 that few times send the good signal. the same way, the first button sometime send v (I have set), some time, left mouse button, and so select text on terminal).

erjiang commented 4 years ago

@Popolon moved your latest issue to #3. Let's continue there. Closing this issue for now.