114114//#define snprintf _snprintf
115115#endif
116116#else
117+ #ifndef __DEVKITPRO__
117118#include <termios.h>
118119#include <sys/ioctl.h>
119120#include <poll.h>
121+ #endif
120122#define USE_TERMIOS
121123#define HAVE_UNISTD_H
122124#endif
@@ -248,7 +250,9 @@ static int checkForColor(const char *buf, int *colors, int *size)
248250
249251#if defined(USE_TERMIOS )
250252static void linenoiseAtExit (void );
253+ #ifndef __DEVKITPRO__
251254static struct termios orig_termios ; /* in order to restore at exit */
255+ #endif
252256static int rawmode = 0 ; /* for atexit() function to check if restore is needed*/
253257static int atexit_registered = 0 ; /* register atexit just 1 time */
254258
@@ -269,6 +273,7 @@ static int isUnsupportedTerm(void) {
269273}
270274
271275static int enableRawMode (struct current * current ) {
276+ #ifndef __DEVKITPRO__
272277 struct termios raw ;
273278
274279 current -> fd = STDIN_FILENO ;
@@ -280,12 +285,14 @@ static int enableRawMode(struct current *current) {
280285 errno = ENOTTY ;
281286 return -1 ;
282287 }
288+ #endif
283289
284290 if (!atexit_registered ) {
285291 atexit (linenoiseAtExit );
286292 atexit_registered = 1 ;
287293 }
288294
295+ #ifndef __DEVKITPRO__
289296 raw = orig_termios ; /* modify the original mode */
290297 /* input modes: no break, no CR to NL, no parity check, no strip char,
291298 * no start/stop output control. */
@@ -306,20 +313,25 @@ static int enableRawMode(struct current *current) {
306313 goto fatal ;
307314 }
308315 rawmode = 1 ;
316+ #endif
309317 return 0 ;
310318}
311319
312320static void disableRawMode (struct current * current ) {
321+ #ifndef __DEVKITPRO__
313322 /* Don't even check the return value as it's too late. */
314323 if (rawmode && tcsetattr (current -> fd ,TCSADRAIN ,& orig_termios ) != -1 )
315324 rawmode = 0 ;
325+ #endif
316326}
317327
318328/* At exit we'll try to fix the terminal to the initial conditions. */
319329static void linenoiseAtExit (void ) {
330+ #ifndef __DEVKITPRO__
320331 if (rawmode ) {
321332 tcsetattr (STDIN_FILENO , TCSADRAIN , & orig_termios );
322333 }
334+ #endif
323335 linenoiseHistoryFree ();
324336}
325337
@@ -388,8 +400,9 @@ static void setCursorPos(struct current *current, int x)
388400 */
389401static int fd_read_char (int fd , int timeout )
390402{
391- struct pollfd p ;
392403 unsigned char c ;
404+ #ifndef __DEVKITPRO__
405+ struct pollfd p ;
393406
394407 p .fd = fd ;
395408 p .events = POLLIN ;
@@ -398,6 +411,7 @@ static int fd_read_char(int fd, int timeout)
398411 /* timeout */
399412 return -1 ;
400413 }
414+ #endif
401415 if (read (fd , & c , 1 ) != 1 ) {
402416 return -1 ;
403417 }
@@ -410,8 +424,9 @@ static int fd_read_char(int fd, int timeout)
410424 */
411425static int fd_read (struct current * current )
412426{
413- struct pollfd p ;
414427 int ret ;
428+ #ifndef __DEVKITPRO__
429+ struct pollfd p ;
415430 p .fd = current -> fd ;
416431 p .events = POLLIN ;
417432 while (1 ) {
@@ -427,6 +442,7 @@ static int fd_read(struct current *current)
427442 else
428443 break ;
429444 }
445+ #endif
430446#ifdef USE_UTF8
431447 char buf [4 ];
432448 int n ;
@@ -499,12 +515,14 @@ static int queryCursor(int fd, int* cols)
499515 */
500516static int getWindowSize (struct current * current )
501517{
518+ #ifndef __DEVKITPRO__
502519 struct winsize ws ;
503520
504521 if (ioctl (STDOUT_FILENO , TIOCGWINSZ , & ws ) == 0 && ws .ws_col != 0 ) {
505522 current -> cols = ws .ws_col ;
506523 return 0 ;
507524 }
525+ #endif
508526
509527 /* Failed to query the window size. Perhaps we are on a serial terminal.
510528 * Try to query the width by sending the cursor as far to the right
0 commit comments