Arqade Asked by Shoyeb Sheikh on January 28, 2021
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 ?
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 %sn", 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.
Correct answer by Shoyeb Sheikh on January 28, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP