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