Do not #include <termio.h> as it is deprecated in favor of termios.h and avoid non-portable ioctl calls in favour of tcgetattr and tcsetattr.
Showing the changes to src/core/util_console.cpp (1 of 1 file). Show all
Unified · Split
| @@ -92,14 +92,8 @@ void io_addhistory( const char * addme ) · 91 unmodified lines | ||
| 92 | 92 | // kb hit |
| 93 | 93 | #ifndef __PLATFORM_WIN32__ |
| 94 | 94 | #include <string.h> |
| 95 | −#ifdef __PLATFORM_MACOSX__ | |
| 96 | 95 | #include <termios.h> |
| 97 | 96 | static struct termios g_save; |
| 98 | −#else | |
| 99 | − #include <termio.h> | |
| 100 | − static struct termio g_save; | |
| 101 | −#endif | |
| 102 | − | |
| 103 | 97 | #include <unistd.h> |
| 104 | 98 | #include <sys/ioctl.h> |
| 105 | 99 | #else |
| @@ -118,15 +112,9 @@ t_CKBOOL kb_initscr() · 12 unmodified lines | ||
| 118 | 112 | if( g_init ) return FALSE; |
| 119 | 113 | |
| 120 | 114 | #ifndef __PLATFORM_WIN32__ |
| 121 | − | |
| 122 | −#ifdef __PLATFORM_MACOSX__ | |
| 123 | 115 | struct termios term; |
| 124 | − if( ioctl( 0, TIOCGETA, &term ) == -1 ) | |
| 125 | −#else | |
| 126 | − struct termio term; | |
| 127 | − if( ioctl( 0, TCGETA, &term ) == -1 ) | |
| 128 | −#endif | |
| 129 | − { | |
| 116 | + if( tcgetattr(0, &term) == -1 ) | |
| 117 | + { | |
| 130 | 118 | EM_log( CK_LOG_SEVERE, "(kbhit disabled): standard input not a tty!"); |
| 131 | 119 | return FALSE; |
| 132 | 120 | } |
| @@ -142,12 +130,7 @@ t_CKBOOL kb_initscr() · 9 unmodified lines | ||
| 142 | 130 | term.c_cc[VMIN] = 0; |
| 143 | 131 | term.c_cc[VTIME]=0; |
| 144 | 132 | |
| 145 | −#ifdef __PLATFORM_MACOSX__ | |
| 146 | − ioctl( 0, TIOCSETA, &term ); | |
| 147 | −#else | |
| 148 | − ioctl( 0, TCSETA, &term ); | |
| 149 | −#endif | |
| 150 | − | |
| 133 | + tcsetattr( 0, TCSADRAIN, &term ); | |
| 151 | 134 | #endif |
| 152 | 135 | |
| 153 | 136 | g_init = TRUE; |
| @@ -161,11 +144,7 @@ void kb_endwin() · 7 unmodified lines | ||
| 161 | 144 | if( !g_init ) return; |
| 162 | 145 | |
| 163 | 146 | #ifndef __PLATFORM_WIN32__ |
| 164 | −#ifdef __PLATFORM_MACOSX__ | |
| 165 | − ioctl( 0, TIOCSETA, &g_save ); | |
| 166 | −#else | |
| 167 | − ioctl( 0, TCSETA, &g_save ); | |
| 168 | −#endif | |
| 147 | + tcsetattr( 0, TCSADRAIN, &g_save ); | |
| 169 | 148 | #endif |
| 170 | 149 | |
| 171 | 150 | g_init = FALSE; |