[test@darkclam ~]$ pacman -Qkk ncurses
ncurses: 3857 total files, 0 altered files
[test@darkclam ~]$ uname -r
5.18.12-arch1-1
[test@darkclam ~]$
Trilby you have been awesome! I do appreciate your input. Does this program work for you when you compile it? Also I downgraded my OS to see if the recent update was the issue. I have ncurses version 6.3-3
]]>The only other thought I'd have is if there was stray input signal coming from somewhere else (a bad keyboard wire, ect), but this would certainly show symptoms in other contexts outside of your program. So sorry, not much help here, but I can confirm your code is good and should work. Can you confirm that your system is up to date and nothing is off with the ncurses package (check pacman -Qkk ncurses).
]]>#include <stdlib.h>
#include <stdio.h>
#include <ncurses.h>
#include <assert.h>
int main(void);
int main()
{
int c = 0;
MEVENT e;
if(initscr() == NULL)
return -5;
raw();
noecho();
cbreak();
keypad(stdscr, TRUE);
curs_set(0);
mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
do
{
c = getch();
printf("%d", c);
if (c == KEY_MOUSE)
printf("mouse was pressed\n");
}while(c != '\n');
clear();
endwin();
return 0;
}
I used the standard printf() function
Can you show the exact code?
]]>Given that 'c' is declared as 'int' and that value is greater than INT_MAX, I gather there was an error in how you checked the value. Did you print it? If so, how?
I used the standard printf() function I outputted the data like this:
./test >> moutput.log
I clicked once on the screen. I took the output (onto stdout I assume) and removed the enter character (to exit the program. It had a value of 10), and the mouse button going back up character (similar if not
exactly the value).
The gibberish comes from the output stored in that log. I opened it up using nano on a terminal and copied the data and pasted it here. I did notice that the value of c exceeds the capabilities of an int type, but I run a 64-bit architecture and OS. That value should be within the range of a long int maybe? But I didn't specify a long int. That is a bit odd. But as you can see in my program I am using a standard form of comparison. I am not sure what else I can do.
]]>The value of 'c' is 279177328944 when I left-clicked my mouse
Given that 'c' is declared as 'int' and that value is greater than INT_MAX, I gather there was an error in how you checked the value. Did you print it? If so, how?
]]>^[[?1049h^[[22;0;0t^[[1;38r^[(B^[[m^[[4l^[[?7h^[[?1h^[=^[[?25l^[[?1003h
^[[?1000h^[[H^[[2J^[[?1000l^[[38;1H^[[?12l^[[?25h^[[?1049l^[[23;0;0t^M^[[?1l^[>10
^[[?1003l
I do not need to use the getmouse() function since I cannot even get past KEY_MOUSE condition (which the value is 409). But I have added it in the past and the condition always fail.
I have compiled the code as follows: gcc -ggdb -o test mouse_events.c -lncurses
I hope that helps!
]]>The terminal recognizes mouse events (I get a bunch of gibberish when I move the mouse or click it).
Can you give an example of this "gibberish"?
But I cannot get past the KEY_MOUSE conditional statement.
Then check what 'c' actually is as well as checking the value at that point of 'KEY_MOUSE' (i.e., print them to the screen or a log).
But what does any of this have to do with the note about "getmouse(&event) == OK" ... that doesn't appear at all in your code sample.
]]>'getmouse(&event) == OK);'
always returns false now. I am unsure how mouse support stopped working. Here is a list of things I have tried:
- Changed my TERM variable to try the program in different terminal emulators including xterm, xterm-256color, vte-256color, and others that has mouse support.
- Compiled a termcap source from https://invisible-island.net/ncurses/terminfo.src.html into a new ~/.terminfo. Changed the path of TERMINFO to only choose this path.
- Downgraded arch to a version during a time I knew the program works
- Checked this forum for solutions
Here is my source code:
#include <stdlib.h>
#include <stdio.h>
#include <ncurses.h>
#include <assert.h>
int main(void);
int main()
{
int c = 0;
MEVENT e;
if(initscr() == NULL)
return -5;
raw();
noecho();
keypad(stdscr, TRUE);
curs_set(0);
printf("\033[?1003h\n");
fflush(stdout);
mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
do
{
c = getch();
if (c == KEY_MOUSE)
printf("mouse was pressed\n");
}while(c != '\n');
printf("\033[?1003l\n");
clear();
endwin();
return 0;
}
The terminal recognizes mouse events (I get a bunch of gibberish when I move the mouse or click it). But I cannot get past the KEY_MOUSE conditional statement. This program worked in the past now it does not. I hope someone can offer a solution! Thank you very much for your time!
]]>