2

I am playing cs1.6 on Ubuntu 20.04 LTS using wine-5.0 (Ubuntu 5.0-3ubuntu1), but I have this weird problem of mouse click in the game, only with pistols and guns, whenever I fast click to shoot after two/one bullets fired theres a delay (mouse dont even shoot bullets for a second) in shooting.

But when I use Enter key for shooting the bullets get fired smoothly (the whole round).

Now I am looking for some way to simulate Enter key pressed on mouse left click.

Can we do that ?

5
  • 1
    Installing a proper mouse driver should solve a lot of issues (and give you the possibility to remap the keys). Logitech G-Hub for example lets you do this.
    – dly
    Commented Oct 27, 2020 at 8:19
  • @dly I dont think this mouse needs a driver ( Logitech wireless m185 ) Commented Oct 27, 2020 at 9:21
  • 1
    Usually they don't, correct. But the software isn't just a driver nowadays. It also comes with some perks to customize your mouse behavior, such as key mapping, DPI settings, etc. I'm not sure how it works with a cheap mouse like that, though.
    – dly
    Commented Oct 27, 2020 at 10:17
  • This question is far outside of the scope of Arqade (the fact that the mouse click is being given to a game is tangential), and belongs on Super User
    – pppery
    Commented Oct 29, 2020 at 18:53
  • 1
    SU is not a good place to solve Counter-Strike problems. The problem is game specific (mouse lags when shooting too quickly) and should be treated as such, regardless of the possible answers. Rebinding a mouse key to the keyboard is only one of the possible solutions - and one of the worst.
    – dly
    Commented Oct 30, 2020 at 9:54

1 Answer 1

0

For those who want to achieve this on Linux,

I made a c++ program to capture mouse click and have Enter key pressed just after.

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <linux/input.h>
#include <cstring>

int main(int argc, char **argv)
{
    struct input_event event;
    int fd, bytes;
    unsigned char data[3];
    bool down = false;

    const char *pDevice = "/dev/input/by-id/usb-Logitech_USB_Receiver-if01-event-mouse";

    fd = open(pDevice, O_RDONLY | O_NONBLOCK);
    if (fd == -1)
    {
        printf("ERROR Opening %s\n", pDevice);
        return -1;
    }

    while (1)
    {
        memset((void *)&event, 0, sizeof(event));
        bytes = read(fd, (void *)&event, sizeof(event));
        if (event.type == 1 && event.code == 272 && event.value == 1)
        {
            down = true;
        }
        if (event.type == 1 && event.code == 272 && event.value == 0)
        {
            down = false;
        }
        if (down)
            system("xdotool key Return");
    }
    return 0;
}

In the above program I tried to read the mouse events and data directly from the device in "/dev/input/by-id", my device events file name is "usb-Logitech_USB_Receiver-if01-event-mouse".

Once you have the events in a variable (i.e event), my mouse left button code is 272, not sure it is the universal code number for mouse left button, event.type = 1 ( not sure about this even ), event.value = 1 is mouse button down/pressed event whereas event.value = 0 is mouse up/released event.

Once mouse is pressed we have to hit Enter key on keyboard, for that I used xdotool, make sure you installed xdotool.

xdotool key Return triggers the Enter key pressed event on keyboard.

compile it to produce an executable named mouse

then you can run it using sudo ./mouse&

& is to run the command in background.

Thats it, now whenever your mouse left key is pressed, the Enter key on your keyboard is pressed until you release the button click.

Note: This program uses 100% cpu coz of the infinite while loop, but its normal.

I tested this on cs1.6 when I fired from pistol using mouse left key down, whole round fired automatically coz of Enter key pressed till I held the mouse key up.

Make sure you put Enter key to Fire in keyboard shotcuts in settings of cs1.6, I have Enter key as primary and - key as alternate to Fire in keyboard shortcuts.

1
  • Just switch to windows, I installed windows10 and found siginificant difference in playing, now my mouse fires pistols intantly as I click, maybe wine makes a software a bit slow in ubuntu, and downloading maps would take hours using wine, now on windows it gets downloaded in seconds. Commented Nov 20, 2020 at 2:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .