fix Termux build

This commit is contained in:
tildearrow 2022-06-23 16:23:46 -05:00
parent 1b5396e814
commit b90552dfb1
2 changed files with 36 additions and 0 deletions

View file

@ -537,6 +537,24 @@ endif()
if (NOT WIN32 AND NOT APPLE)
list(APPEND GUI_SOURCES src/gui/icon.c)
include(CheckIncludeFile)
CHECK_INCLUDE_FILE(sys/io.h SYS_IO_FOUND)
CHECK_INCLUDE_FILE(linux/input.h LINUX_INPUT_FOUND)
CHECK_INCLUDE_FILE(linux/kd.h LINUX_KD_FOUND)
if (SYS_IO_FOUND)
list(APPEND DEPENDENCIES_DEFINES HAVE_SYS_IO)
message(STATUS "PC speaker output: outb()")
endif()
if (LINUX_INPUT_FOUND)
list(APPEND DEPENDENCIES_DEFINES HAVE_LINUX_INPUT)
message(STATUS "PC speaker output: evdev")
endif()
if (LINUX_KD_FOUND)
list(APPEND DEPENDENCIES_DEFINES HAVE_LINUX_KD)
message(STATUS "PC speaker output: KIOCSOUND")
endif()
endif()
set(USED_SOURCES ${ENGINE_SOURCES} ${AUDIO_SOURCES} src/main.cpp)

View file

@ -27,11 +27,17 @@
#include <sys/select.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef HAVE_LINUX_INPUT
#include <linux/input.h>
#endif
#ifdef HAVE_LINUX_KD
#include <linux/kd.h>
#endif
#include <time.h>
#ifdef HAVE_SYS_IO
#include <sys/io.h>
#endif
#endif
#define PCSPKR_DIVIDER 4
#define CHIP_DIVIDER 1
@ -80,6 +86,7 @@ void DivPlatformPCSpeaker::pcSpeakerThread() {
}
if (beepFD>=0) {
switch (realOutMethod) {
#ifdef HAVE_LINUX_INPUT
case 0: { // evdev
static struct input_event ie;
ie.time.tv_sec=r.tv_sec;
@ -98,11 +105,14 @@ void DivPlatformPCSpeaker::pcSpeakerThread() {
}
break;
}
#endif
#ifdef HAVE_LINUX_KD
case 1: // KIOCSOUND (on tty)
if (ioctl(beepFD,KIOCSOUND,r.val)<0) {
logW("ioctl error! %s",strerror(errno));
}
break;
#endif
case 2: { // /dev/port
unsigned char bOut;
bOut=0;
@ -144,11 +154,14 @@ void DivPlatformPCSpeaker::pcSpeakerThread() {
}
break;
}
#ifdef HAVE_LINUX_KD
case 3: // KIOCSOUND (on stdout)
if (ioctl(beepFD,KIOCSOUND,r.val)<0) {
logW("ioctl error! %s",strerror(errno));
}
break;
#endif
#ifdef HAVE_SYS_IO
case 4: // outb()
if (r.val==0) {
outb(inb(0x61)&(~3),0x61);
@ -163,6 +176,7 @@ void DivPlatformPCSpeaker::pcSpeakerThread() {
}
}
break;
#endif
}
} else {
//logV("not writing because fd is less than 0");
@ -544,6 +558,7 @@ void DivPlatformPCSpeaker::reset() {
break;
case 4: // outb()
beepFD=-1;
#ifdef HAVE_SYS_IO
if (ioperm(0x61,8,1)<0) {
logW("ioperm 0x61: %s",strerror(errno));
break;
@ -557,6 +572,9 @@ void DivPlatformPCSpeaker::reset() {
break;
}
beepFD=STDOUT_FILENO;
#else
errno=ENOSYS;
#endif
break;
}
if (beepFD<0) {