Merge 1.x into master #1
File diff suppressed because it is too large
Load Diff
|
@ -72,13 +72,13 @@ final class Getch
|
|||
if (null === self::$ffi) {
|
||||
$osFamily = PHP_OS_FAMILY;
|
||||
if ('Windows' === $osFamily) {
|
||||
$declarations = self::DECLARATIONS . ' int _kbhit();';
|
||||
$declarations = self::DECLARATIONS.' int _kbhit();';
|
||||
self::$ffi = FFI::cdef($declarations, self::WINDOWS_LIBRARY);
|
||||
} elseif ('Linux' === $osFamily) {
|
||||
if (!file_exists($linuxLibrary)) {
|
||||
throw new RuntimeException(sprintf('Could not find library file %s.', $linuxLibrary));
|
||||
}
|
||||
$declarations = self::DECLARATIONS . ' int cinPeek();';
|
||||
$declarations = self::DECLARATIONS.' int cinPeek();';
|
||||
self::$ffi = FFI::cdef($declarations, $linuxLibrary);
|
||||
} else {
|
||||
throw new RuntimeException(sprintf('Sorry, %s is not supported yet.', $osFamily));
|
||||
|
@ -92,10 +92,13 @@ final class Getch
|
|||
if ($ffi->_kbhit()) {
|
||||
$result = $ffi->_getch();
|
||||
$ffi->_ungetch($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $ffi->cinPeek();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue