donniebreve / touchcursor-linux

TouchCursor style keyboard remapping for Linux.
GNU General Public License v2.0
133 stars 28 forks source link

Error on `make` command #35

Closed mattiasJohnson closed 2 years ago

mattiasJohnson commented 2 years ago

When I do the make command inside touchcursor-linux I get the following error:

mattias:touchcursor-linux$ make
gcc -g -Wall -c src/keys.c -o obj/keys.o
src/keys.c: In function ‘convertKeyStringToCode’:
src/keys.c:455:72: error: ‘KEY_NOTIFICATION_CENTER’ undeclared (first use in this function)
  455 |     else if (strcmp(keyString, "KEY_NOTIFICATION_CENTER") == 0) return KEY_NOTIFICATION_CENTER;
      |                                                                        ^~~~~~~~~~~~~~~~~~~~~~~
src/keys.c:455:72: note: each undeclared identifier is reported only once for each function it appears in
src/keys.c:456:65: error: ‘KEY_PICKUP_PHONE’ undeclared (first use in this function); did you mean ‘KEY_VIDEOPHONE’?
  456 |     else if (strcmp(keyString, "KEY_PICKUP_PHONE") == 0) return KEY_PICKUP_PHONE;
      |                                                                 ^~~~~~~~~~~~~~~~
      |                                                                 KEY_VIDEOPHONE
src/keys.c:457:65: error: ‘KEY_HANGUP_PHONE’ undeclared (first use in this function)
  457 |     else if (strcmp(keyString, "KEY_HANGUP_PHONE") == 0) return KEY_HANGUP_PHONE;
      |                                                                 ^~~~~~~~~~~~~~~~
src/keys.c:483:67: error: ‘KEY_FN_RIGHT_SHIFT’ undeclared (first use in this function); did you mean ‘KEY_RIGHTSHIFT’?
  483 |     else if (strcmp(keyString, "KEY_FN_RIGHT_SHIFT") == 0) return KEY_FN_RIGHT_SHIFT;
      |                                                                   ^~~~~~~~~~~~~~~~~~
      |                                                                   KEY_RIGHTSHIFT
src/keys.c:532:1: warning: control reaches end of non-void function [-Wreturn-type]
  532 | }
      | ^
make: *** [Makefile:35: obj/keys.o] Error 1

I am running Ubuntu 20.04.

Adda0 commented 2 years ago

Hello, these keys are declared in linux/input-event-codes.h header file. These keys were added in a patch in September 2020. See Linux kernel source code if interested. And the file should be located at /usr/include/linux/input-event-codes.h.

I believe the kernel version of your Ubuntu system is older than that (well, except for security patches and so on), so maybe this commit is not merged to the kernel source code yet. I would suggest simply commenting these lines out (with // at the beginning of the particular lines) or removing them altogether and ignoring the warning, which will disappear as soon as you comment all the lines that give you errors. You will not be able to use those keys, but that should not be a problem (unless you really need these specifically, in which case you have to update your kernel or manually update this particular file – might not work anyway, but who knows).

I tried to clone the repo and execute the make on a clean Ubuntu 20.04-LTS virtual machine today and sure enough, these keys are not there yet. After commenting out said lines, TouchCursor will compile and will work without an issue. The little warning at the end is caused by those missing includes, so that is not something to worry about. Have fun with TouchCursor.

For reference, that part of the file should look like this when you are done editing:

    else if (strcmp(keyString, "KEY_10CHANNELSDOWN") == 0) return KEY_10CHANNELSDOWN;
    else if (strcmp(keyString, "KEY_IMAGES") == 0) return KEY_IMAGES;
    //else if (strcmp(keyString, "KEY_NOTIFICATION_CENTER") == 0) return KEY_NOTIFICATION_CENTER;
    //else if (strcmp(keyString, "KEY_PICKUP_PHONE") == 0) return KEY_PICKUP_PHONE;
    //else if (strcmp(keyString, "KEY_HANGUP_PHONE") == 0) return KEY_HANGUP_PHONE;
    else if (strcmp(keyString, "KEY_DEL_EOL") == 0) return KEY_DEL_EOL;
    else if (strcmp(keyString, "KEY_DEL_EOS") == 0) return KEY_DEL_EOS;
    else if (strcmp(keyString, "KEY_INS_LINE") == 0) return KEY_INS_LINE;
    else if (strcmp(keyString, "KEY_DEL_LINE") == 0) return KEY_DEL_LINE;
    else if (strcmp(keyString, "KEY_FN") == 0) return KEY_FN;
    else if (strcmp(keyString, "KEY_FN_ESC") == 0) return KEY_FN_ESC;
    else if (strcmp(keyString, "KEY_FN_F1") == 0) return KEY_FN_F1;
    else if (strcmp(keyString, "KEY_FN_F2") == 0) return KEY_FN_F2;
    else if (strcmp(keyString, "KEY_FN_F3") == 0) return KEY_FN_F3;
    else if (strcmp(keyString, "KEY_FN_F4") == 0) return KEY_FN_F4;
    else if (strcmp(keyString, "KEY_FN_F5") == 0) return KEY_FN_F5;
    else if (strcmp(keyString, "KEY_FN_F6") == 0) return KEY_FN_F6;
    else if (strcmp(keyString, "KEY_FN_F7") == 0) return KEY_FN_F7;
    else if (strcmp(keyString, "KEY_FN_F8") == 0) return KEY_FN_F8;
    else if (strcmp(keyString, "KEY_FN_F9") == 0) return KEY_FN_F9;
    else if (strcmp(keyString, "KEY_FN_F10") == 0) return KEY_FN_F10;
    else if (strcmp(keyString, "KEY_FN_F11") == 0) return KEY_FN_F11;
    else if (strcmp(keyString, "KEY_FN_F12") == 0) return KEY_FN_F12;
    else if (strcmp(keyString, "KEY_FN_1") == 0) return KEY_FN_1;
    else if (strcmp(keyString, "KEY_FN_2") == 0) return KEY_FN_2;
    else if (strcmp(keyString, "KEY_FN_D") == 0) return KEY_FN_D;
    else if (strcmp(keyString, "KEY_FN_E") == 0) return KEY_FN_E;
    else if (strcmp(keyString, "KEY_FN_F") == 0) return KEY_FN_F;
    else if (strcmp(keyString, "KEY_FN_S") == 0) return KEY_FN_S;
    else if (strcmp(keyString, "KEY_FN_B") == 0) return KEY_FN_B;
    //else if (strcmp(keyString, "KEY_FN_RIGHT_SHIFT") == 0) return KEY_FN_RIGHT_SHIFT;
    else if (strcmp(keyString, "KEY_BRL_DOT1") == 0) return KEY_BRL_DOT1;
    else if (strcmp(keyString, "KEY_BRL_DOT2") == 0) return KEY_BRL_DOT2;
donniebreve commented 2 years ago

I thought maybe this was the case, then thought there’s no way the header file was updated so recently. @mattiasJohnson it’s time to switch to Arch (just kidding 😆). As always, @Adda0 the effort here is outstanding.

I suppose we should remove the offending keys for now.

mattiasJohnson commented 2 years ago

Thanks for the quick help now indeed after having commented out those lines in touchcursor-linux/src/keys.h it lets me install the program! I will probably wait with Arch for a bit as long as I get touchcursor running I'm pretty content with running Ubuntu:) I do have another issue trying to run the program, I've used this on many machines before and haven't had any problems so a bit strange but in any case I'll make that a separate issue

Adda0 commented 2 years ago

I suppose we should remove the offending keys for now.

Considering there are not so many users who need to use these specific keys, I guess, I believe that might be better for overall compatibility with other distros and mainly any Ubuntu-based ones. Maybe add them (uncomment, preferably, instead of now removing and then adding again) in a few months again, but... that might not be enough. Due to LTS cycle for Ubuntu, Ubuntu 20.4 will be here (and any distros based on it) for a while and if they do not update the kernel version except for some patches, it could be quite a long while (until 2025, to be exact). Depends. For now, though, I see compatibility with Ubuntu out of the box as a hard requirement.

Either that, or we could declare these keys ourselves, of course, but that is a highly messy solution to deal with the problem here prone to further errors in the future, if we continue solving the future problems this way, I would say.

donniebreve commented 2 years ago

For now, though, I see compatibility with Ubuntu out of the box as a hard requirement.

I agree that this is a nice goal to have.

@Adda0 What do you think about something like this: https://github.com/donniebreve/touchcursor-linux/pull/37

Adda0 commented 2 years ago

What do you think about something like this: #37

As I said in the review, as a quick and easy solution, this will work quite fine. If we find ourselves wanting to implement something more robust, why not, but we really should not need much more beyond this, I think.