set OpenBSD pitch and duration of the system speaker

This commit is contained in:
Markus Gans 2019-08-10 20:14:44 +02:00
parent 5bd46e32ec
commit bd81fdb069
9 changed files with 247 additions and 50 deletions

View File

@ -1,3 +1,7 @@
2019-08-10 Markus Gans <guru.mail@muenster.de>
* Pitch and duration of system speaker can now be changed
on OpenBSD
2019-08-07 Markus Gans <guru.mail@muenster.de> 2019-08-07 Markus Gans <guru.mail@muenster.de>
* Fixes the Cygwin build * Fixes the Cygwin build

View File

@ -75,7 +75,6 @@ finalcutinclude_HEADERS = \
include/final/fapplication.h \ include/final/fapplication.h \
include/final/fbutton.h \ include/final/fbutton.h \
include/final/fbuttongroup.h \ include/final/fbuttongroup.h \
include/final/fcharmap.h \
include/final/fcheckbox.h \ include/final/fcheckbox.h \
include/final/fcolorpair.h \ include/final/fcolorpair.h \
include/final/fconfig.h \ include/final/fconfig.h \

View File

@ -1032,16 +1032,28 @@ void FTerm::setPalette (FColor index, int r, int g, int b)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if defined(__linux__) #if defined(UNIT_TEST)
void FTerm::setBeep (int Hz, int ms)
{
linux->setBeep (Hz, ms);
freebsd->setBeep (Hz, ms);
openbsd->setBeep (Hz, ms);
}
#elif defined(__linux__)
void FTerm::setBeep (int Hz, int ms) void FTerm::setBeep (int Hz, int ms)
{ {
linux->setBeep (Hz, ms); linux->setBeep (Hz, ms);
} }
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #elif defined(__FreeBSD__) || defined(__DragonFly__)
void FTerm::setBeep (int Hz, int ms) void FTerm::setBeep (int Hz, int ms)
{ {
freebsd->setBeep (Hz, ms); freebsd->setBeep (Hz, ms);
} }
#elif defined(__NetBSD__) || defined(__OpenBSD__)
void FTerm::setBeep (int Hz, int ms)
{
openbsd->setBeep (Hz, ms);
}
#else #else
void FTerm::setBeep (int, int) void FTerm::setBeep (int, int)
{ } { }
@ -1050,10 +1062,16 @@ void FTerm::setBeep (int, int)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::resetBeep() void FTerm::resetBeep()
{ {
#if defined(__linux__) #if defined(UNIT_TEST)
linux->resetBeep(); linux->resetBeep();
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
freebsd->resetBeep(); freebsd->resetBeep();
openbsd->resetBeep();
#elif defined(__linux__)
linux->resetBeep();
#elif defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->resetBeep();
#elif defined(__NetBSD__) || defined(__OpenBSD__)
openbsd->resetBeep();
#endif #endif
} }
@ -2327,8 +2345,8 @@ void FTerm::init (bool disable_alt_screen)
if ( init_values.color_change ) if ( init_values.color_change )
redefineColorPalette(); redefineColorPalette();
// Set 200 Hz beep (100 ms) // Set 220 Hz beep (100 ms)
setBeep(200, 100); setBeep(220, 100);
// Set FTerm signal handler // Set FTerm signal handler
setSignalHandler(); setSignalHandler();

View File

@ -94,11 +94,11 @@ void FTermFreeBSD::setBeep (int Hz, int ms)
if ( ! FTerm::isFreeBSDTerm() ) if ( ! FTerm::isFreeBSDTerm() )
return; return;
// range for frequency: 21-32766 // Range for frequency: 21-32766
if ( Hz < 21 || Hz > 32766 ) if ( Hz < 21 || Hz > 32766 )
return; return;
// range for duration: 0-1999 // Range for duration: 0-1999
if ( ms < 0 || ms > 1999 ) if ( ms < 0 || ms > 1999 )
return; return;
@ -115,8 +115,8 @@ void FTermFreeBSD::resetBeep()
if ( ! FTerm::isFreeBSDTerm() ) if ( ! FTerm::isFreeBSDTerm() )
return; return;
// default frequency: 1491 Hz // Default frequency: 1491 Hz
// default duration: 50 ms // Default duration: 50 ms
FTerm::putstring (CSI "=800;5B"); FTerm::putstring (CSI "=800;5B");
std::fflush(stdout); std::fflush(stdout);
} }
@ -124,7 +124,7 @@ void FTermFreeBSD::resetBeep()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermFreeBSD::init() void FTermFreeBSD::init()
{ {
// initialize BSD console // Initialize BSD console
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
fterm_data = FTerm::getFTermData(); fterm_data = FTerm::getFTermData();
@ -134,10 +134,10 @@ void FTermFreeBSD::init()
if ( meta_sends_escape ) if ( meta_sends_escape )
{ {
// save current left alt key mapping // Save current left alt key mapping
saveFreeBSDAltKey(); saveFreeBSDAltKey();
// map meta key to left alt key // Map meta key to left alt key
setFreeBSDAlt2Meta(); setFreeBSDAlt2Meta();
} }
@ -192,7 +192,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
if ( ret < 0 ) if ( ret < 0 )
return false; return false;
// save current mapping // Save current mapping
bsd_alt_keymap = keymap.key[left_alt].map[0]; bsd_alt_keymap = keymap.key[left_alt].map[0];
return true; return true;
} }

View File

@ -160,7 +160,7 @@ bool FTermLinux::isLinuxConsole()
char arg = 0; char arg = 0;
int fd_tty = FTerm::getTTYFileDescriptor(); int fd_tty = FTerm::getTTYFileDescriptor();
// get keyboard type an compare // Get keyboard type an compare
return ( fsystem->isTTY(fd_tty) return ( fsystem->isTTY(fd_tty)
&& fsystem->ioctl(fd_tty, KDGKBTYPE, &arg) == 0 && fsystem->ioctl(fd_tty, KDGKBTYPE, &arg) == 0
&& ((arg == KB_101) || (arg == KB_84)) ); && ((arg == KB_101) || (arg == KB_84)) );
@ -169,7 +169,7 @@ bool FTermLinux::isLinuxConsole()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinux::init() void FTermLinux::init()
{ {
// initialize Linux console // Initialize Linux console
if ( ! fsystem ) if ( ! fsystem )
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
@ -289,7 +289,7 @@ bool FTermLinux::loadVGAFont()
if ( ret != 0 ) if ( ret != 0 )
vga_font = false; vga_font = false;
// unicode character mapping // Unicode character mapping
struct unimapdesc unimap; struct unimapdesc unimap;
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs) unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
/ sizeof(unipair) ); / sizeof(unipair) );
@ -330,7 +330,7 @@ bool FTermLinux::loadNewFont()
if ( ret != 0 ) if ( ret != 0 )
new_font = false; new_font = false;
// unicode character mapping // Unicode character mapping
struct unimapdesc unimap; struct unimapdesc unimap;
unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs) unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs)
/ sizeof(unipair) ); / sizeof(unipair) );
@ -429,11 +429,11 @@ void FTermLinux::setBeep (int Hz, int ms)
if ( ! FTerm::isLinuxTerm() ) if ( ! FTerm::isLinuxTerm() )
return; return;
// range for frequency: 21-32766 // Range for frequency: 21-32766
if ( Hz < 21 || Hz > 32766 ) if ( Hz < 21 || Hz > 32766 )
return; return;
// range for duration: 0-1999 // Range for duration: 0-1999
if ( ms < 0 || ms > 1999 ) if ( ms < 0 || ms > 1999 )
return; return;
@ -449,8 +449,8 @@ void FTermLinux::resetBeep()
if ( ! FTerm::isLinuxTerm() ) if ( ! FTerm::isLinuxTerm() )
return; return;
// default frequency: 750 Hz // Default frequency: 750 Hz
// default duration: 125 ms // Default duration: 125 ms
FTerm::putstring ( CSI "10;750]" FTerm::putstring ( CSI "10;750]"
CSI "11;125]" ); CSI "11;125]" );
std::fflush(stdout); std::fflush(stdout);
@ -550,7 +550,7 @@ bool FTermLinux::getScreenFont()
if ( fd_tty < 0 ) if ( fd_tty < 0 )
return false; return false;
// initialize unused padding bytes in struct // Initialize unused padding bytes in struct
std::memset (&font, 0, sizeof(console_font_op)); std::memset (&font, 0, sizeof(console_font_op));
font.op = KD_FONT_OP_GET; font.op = KD_FONT_OP_GET;
@ -559,7 +559,7 @@ bool FTermLinux::getScreenFont()
font.height = 32; font.height = 32;
font.charcount = 512; font.charcount = 512;
// initialize with 0 // Initialize with 0
try try
{ {
static constexpr std::size_t data_size = 4 * 32 * 512; static constexpr std::size_t data_size = 4 * 32 * 512;
@ -571,7 +571,7 @@ bool FTermLinux::getScreenFont()
return false; return false;
} }
// font operation // Font operation
if ( fsystem ) if ( fsystem )
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
@ -602,7 +602,7 @@ bool FTermLinux::getUnicodeMap()
screen_unicode_map.entry_ct = 0; screen_unicode_map.entry_ct = 0;
screen_unicode_map.entries = nullptr; screen_unicode_map.entries = nullptr;
// get count // Get count
if ( fsystem ) if ( fsystem )
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map); ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
@ -623,7 +623,7 @@ bool FTermLinux::getUnicodeMap()
return false; return false;
} }
// get unicode-to-font mapping from kernel // Get unicode-to-font mapping from kernel
if ( fsystem ) if ( fsystem )
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map); ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
@ -641,7 +641,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey()
char subcode = 6; // Shift state command + return value char subcode = 6; // Shift state command + return value
// fill bit field with 0 // Fill bit field with 0
std::memset (&mod_key, 0x00, sizeof(mod_key)); std::memset (&mod_key, 0x00, sizeof(mod_key));
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE) // TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
@ -675,7 +675,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
if ( fd_tty < 0 ) if ( fd_tty < 0 )
return -1; return -1;
// initialize unused padding bytes in struct // Initialize unused padding bytes in struct
std::memset (&font, 0x00, sizeof(console_font_op)); std::memset (&font, 0x00, sizeof(console_font_op));
font.op = KD_FONT_OP_SET; font.op = KD_FONT_OP_SET;
@ -693,7 +693,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
try try
{ {
font.data = new uChar[data_size](); // initialize with 0 font.data = new uChar[data_size](); // Initialize with 0
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -707,7 +707,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
, font.height); , font.height);
} }
// font operation // Font operation
if ( fsystem ) if ( fsystem )
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
@ -744,14 +744,14 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap)
do do
{ {
// clear the unicode-to-font table // Clear the unicode-to-font table
if ( fsystem ) if ( fsystem )
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice); ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
if ( ret != 0 ) if ( ret != 0 )
return -1; return -1;
// put the new unicode-to-font mapping in kernel // Put the new unicode-to-font mapping in kernel
if ( fsystem ) if ( fsystem )
ret = fsystem->ioctl (fd_tty, PIO_UNIMAP, unimap); ret = fsystem->ioctl (fd_tty, PIO_UNIMAP, unimap);

View File

@ -61,7 +61,7 @@ bool FTermOpenBSD::isBSDConsole()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermOpenBSD::init() void FTermOpenBSD::init()
{ {
// initialize BSD workstation console // Initialize BSD workstation console
fsystem = FTerm::getFSystem(); fsystem = FTerm::getFSystem();
@ -70,10 +70,10 @@ void FTermOpenBSD::init()
if ( meta_sends_escape ) if ( meta_sends_escape )
{ {
// save current left alt key mapping // Save current left alt key mapping
saveBSDConsoleEncoding(); saveBSDConsoleEncoding();
// alt key generate ESC prefix // Alt key generate ESC prefix
setBSDConsoleMetaEsc(); setBSDConsoleMetaEsc();
} }
} }
@ -88,6 +88,52 @@ void FTermOpenBSD::finish()
resetBSDConsoleEncoding(); resetBSDConsoleEncoding();
} }
//----------------------------------------------------------------------
bool FTermOpenBSD::setBeep (int Hz, int ms)
{
if ( ! isBSDConsole() )
return false;
// Range for frequency: 21-32766
if ( Hz < 21 || Hz > 32766 )
return false;
// Range for duration: 0-1999
if ( ms < 0 || ms > 1999 )
return false;
wskbd_bell_data bell;
bell.which = WSKBD_BELL_DOALL;
bell.pitch = Hz;
bell.period = ms;
bell.volume = 50; // 50% volume
if ( fsystem && fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
return false;
else
return true;
}
//----------------------------------------------------------------------
bool FTermOpenBSD::resetBeep()
{
wskbd_bell_data default_bell;
// Gets the default setting for the bell
if ( fsystem
&& fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
return false;
default_bell.which = WSKBD_BELL_DOALL;
// Sets the bell settings
if ( fsystem
&& fsystem->ioctl(0, WSKBDIO_SETBELL, &default_bell) < 0 )
return false;
else
return true;
}
// private methods of FTermOpenBSD // private methods of FTermOpenBSD
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -102,7 +148,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
if ( ret < 0 ) if ( ret < 0 )
return false; return false;
// save current encoding // Save current encoding
bsd_keyboard_encoding = k_encoding; bsd_keyboard_encoding = k_encoding;
return true; return true;
} }
@ -120,7 +166,7 @@ bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermOpenBSD::setBSDConsoleMetaEsc() bool FTermOpenBSD::setBSDConsoleMetaEsc()
{ {
static constexpr kbd_t meta_esc = 0x20; // generate ESC prefix on ALT-key static constexpr kbd_t meta_esc = 0x20; // Generate ESC prefix on ALT-key
return setBSDConsoleEncoding (bsd_keyboard_encoding | meta_esc); return setBSDConsoleEncoding (bsd_keyboard_encoding | meta_esc);
} }

View File

@ -40,7 +40,22 @@
#if defined(UNIT_TEST) #if defined(UNIT_TEST)
#define WSKBDIO_GETENCODING uInt32(0x4004570F) #define WSKBDIO_GETENCODING uInt32(0x4004570F)
#define WSKBDIO_SETENCODING uInt32(0x80045710) #define WSKBDIO_SETENCODING uInt32(0x80045710)
#define WSKBDIO_GETDEFAULTBELL uInt32(0x40105706)
#define WSKBDIO_SETBELL uInt32(0x80105703)
#define WSKBD_BELL_DOPITCH 0x1 // get/set pitch
#define WSKBD_BELL_DOPERIOD 0x2 // get/set period
#define WSKBD_BELL_DOVOLUME 0x4 // get/set volume
#define WSKBD_BELL_DOALL 0x7 // all of the above
typedef uInt32 kbd_t; typedef uInt32 kbd_t;
struct wskbd_bell_data
{
uInt which; // values to get/set
uInt pitch; // pitch, in Hz
uInt period; // period, in milliseconds
uInt volume; // percentage of max volume
};
#elif defined(__NetBSD__) || defined(__OpenBSD__) #elif defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/time.h> #include <sys/time.h>
#include <dev/wscons/wsconsio.h> #include <dev/wscons/wsconsio.h>
@ -87,6 +102,8 @@ class FTermOpenBSD final
// Methods // Methods
static void init(); static void init();
static void finish(); static void finish();
static bool setBeep (int, int);
static bool resetBeep();
private: private:
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)

View File

@ -39,6 +39,24 @@
#include <conemu.h> #include <conemu.h>
#include <final/final.h> #include <final/final.h>
#define CPPUNIT_ASSERT_CSTRING(expected, actual) \
check_c_string (expected, actual, CPPUNIT_SOURCELINE())
//----------------------------------------------------------------------
void check_c_string ( const char* s1
, const char* s2
, CppUnit::SourceLine sourceLine )
{
if ( s1 == 0 && s2 == 0 ) // Strings are equal
return;
if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal
return;
::CppUnit::Asserter::fail ("Strings are not equal", sourceLine);
}
namespace test namespace test
{ {
@ -1675,38 +1693,47 @@ void FTermLinuxTest::linuxCursorStyleTest()
linux.setCursorStyle (finalcut::fc::default_cursor); linux.setCursorStyle (finalcut::fc::default_cursor);
CPPUNIT_ASSERT ( characters == CSI "?0c" ); CPPUNIT_ASSERT ( characters == CSI "?0c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?0c" );
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::invisible_cursor); linux.setCursorStyle (finalcut::fc::invisible_cursor);
CPPUNIT_ASSERT ( characters == CSI "?1c" ); CPPUNIT_ASSERT ( characters == CSI "?1c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::invisible_cursor );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?1c" );
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::underscore_cursor); linux.setCursorStyle (finalcut::fc::underscore_cursor);
CPPUNIT_ASSERT ( characters == CSI "?2c" ); CPPUNIT_ASSERT ( characters == CSI "?2c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?2c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::underscore_cursor );
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::lower_third_cursor); linux.setCursorStyle (finalcut::fc::lower_third_cursor);
CPPUNIT_ASSERT ( characters == CSI "?3c" ); CPPUNIT_ASSERT ( characters == CSI "?3c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?3c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_third_cursor );
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::lower_half_cursor); linux.setCursorStyle (finalcut::fc::lower_half_cursor);
CPPUNIT_ASSERT ( characters == CSI "?4c" ); CPPUNIT_ASSERT ( characters == CSI "?4c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?4c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::lower_half_cursor );
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::two_thirds_cursor); linux.setCursorStyle (finalcut::fc::two_thirds_cursor);
CPPUNIT_ASSERT ( characters == CSI "?5c" ); CPPUNIT_ASSERT ( characters == CSI "?5c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?5c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::two_thirds_cursor );
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::full_block_cursor); linux.setCursorStyle (finalcut::fc::full_block_cursor);
CPPUNIT_ASSERT ( characters == CSI "?6c" ); CPPUNIT_ASSERT ( characters == CSI "?6c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?6c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::full_block_cursor );
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::default_cursor); linux.setCursorStyle (finalcut::fc::default_cursor);
CPPUNIT_ASSERT ( characters == CSI "?0c" ); CPPUNIT_ASSERT ( characters == CSI "?0c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?0c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor );
characters.clear(); characters.clear();
linux.setCursorStyle (linux.getCursorStyle()); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?0c" ); CPPUNIT_ASSERT ( characters == CSI "?0c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?0c" );
CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor ); CPPUNIT_ASSERT ( linux.getCursorStyle() == finalcut::fc::default_cursor );
characters.clear(); characters.clear();
data->setCursorHidden (true); data->setCursorHidden (true);
@ -1717,6 +1744,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
characters.clear(); characters.clear();
linux.setCursorStyle (linux.getCursorStyle()); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?1c" ); CPPUNIT_ASSERT ( characters == CSI "?1c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?1c" );
characters.clear(); characters.clear();
data->setCursorHidden (true); data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::underscore_cursor); linux.setCursorStyle (finalcut::fc::underscore_cursor);
@ -1726,6 +1754,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
characters.clear(); characters.clear();
linux.setCursorStyle (linux.getCursorStyle()); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?2c" ); CPPUNIT_ASSERT ( characters == CSI "?2c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?2c" );
characters.clear(); characters.clear();
data->setCursorHidden (true); data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::lower_third_cursor); linux.setCursorStyle (finalcut::fc::lower_third_cursor);
@ -1735,6 +1764,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
characters.clear(); characters.clear();
linux.setCursorStyle (linux.getCursorStyle()); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?3c" ); CPPUNIT_ASSERT ( characters == CSI "?3c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?3c" );
characters.clear(); characters.clear();
data->setCursorHidden (true); data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::lower_half_cursor); linux.setCursorStyle (finalcut::fc::lower_half_cursor);
@ -1744,6 +1774,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
characters.clear(); characters.clear();
linux.setCursorStyle (linux.getCursorStyle()); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?4c" ); CPPUNIT_ASSERT ( characters == CSI "?4c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?4c" );
characters.clear(); characters.clear();
data->setCursorHidden (true); data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::two_thirds_cursor); linux.setCursorStyle (finalcut::fc::two_thirds_cursor);
@ -1753,6 +1784,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
characters.clear(); characters.clear();
linux.setCursorStyle (linux.getCursorStyle()); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?5c" ); CPPUNIT_ASSERT ( characters == CSI "?5c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?5c" );
characters.clear(); characters.clear();
data->setCursorHidden (true); data->setCursorHidden (true);
linux.setCursorStyle (finalcut::fc::full_block_cursor); linux.setCursorStyle (finalcut::fc::full_block_cursor);
@ -1762,6 +1794,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
characters.clear(); characters.clear();
linux.setCursorStyle (linux.getCursorStyle()); linux.setCursorStyle (linux.getCursorStyle());
CPPUNIT_ASSERT ( characters == CSI "?6c" ); CPPUNIT_ASSERT ( characters == CSI "?6c" );
CPPUNIT_ASSERT_CSTRING ( linux.getCursorStyleString(), CSI "?6c" );
characters.clear(); characters.clear();
linux.finish(); linux.finish();

View File

@ -84,9 +84,11 @@ class FSystemTest : public finalcut::FSystem
int putchar (int) override; int putchar (int) override;
int tputs (const char*, int, int (*)(int)) override; int tputs (const char*, int, int (*)(int)) override;
uid_t getuid() override; uid_t getuid() override;
wskbd_bell_data& getBell();
private: private:
kbd_t kbdencoding = 512; kbd_t kbdencoding = 512;
wskbd_bell_data system_bell;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -95,6 +97,11 @@ class FSystemTest : public finalcut::FSystem
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FSystemTest::FSystemTest() // constructor FSystemTest::FSystemTest() // constructor
{ {
// Initialize bell values
system_bell.which = 0;
system_bell.pitch = 1500;
system_bell.period = 100;
system_bell.volume = 50;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -153,6 +160,43 @@ int FSystemTest::ioctl (int fd, uLong request, ...)
break; break;
} }
case WSKBDIO_GETDEFAULTBELL:
{
req_string = "WSKBDIO_GETDEFAULTBELL";
wskbd_bell_data* spk = static_cast<wskbd_bell_data*>(argp);
spk->which = 0;
spk->pitch = 1500;
spk->period = 100;
spk->volume = 50;
ret_val = 0;
break;
}
case WSKBDIO_SETBELL:
{
req_string = "WSKBDIO_SETBELL";
wskbd_bell_data* spk = static_cast<wskbd_bell_data*>(argp);
if ( spk->which & WSKBD_BELL_DOPITCH )
system_bell.pitch = spk->pitch;
else
system_bell.pitch = 1500;
if ( spk->which & WSKBD_BELL_DOPERIOD )
system_bell.period = spk->period;
else
system_bell.period = 100;
if ( spk->which & WSKBD_BELL_DOVOLUME )
system_bell.volume = spk->volume;
else
system_bell.volume = 50;
spk->which = WSKBD_BELL_DOALL;
ret_val = 0;
break;
}
case TIOCGWINSZ: case TIOCGWINSZ:
req_string = "TIOCGWINSZ"; req_string = "TIOCGWINSZ";
struct winsize* win_size = static_cast<winsize*>(argp); struct winsize* win_size = static_cast<winsize*>(argp);
@ -230,6 +274,12 @@ uid_t FSystemTest::getuid()
return 0; return 0;
} }
//----------------------------------------------------------------------
wskbd_bell_data& FSystemTest::getBell()
{
return system_bell;
}
} // namespace test } // namespace test
@ -441,6 +491,8 @@ void ftermopenbsdTest::openbsdConsoleTest()
unsetenv("KONSOLE_DCOP"); unsetenv("KONSOLE_DCOP");
unsetenv("TMUX"); unsetenv("TMUX");
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys);
wskbd_bell_data& speaker = fsystest->getBell();
openbsd.disableMetaSendsEscape(); openbsd.disableMetaSendsEscape();
openbsd.init(); openbsd.init();
term_detection->detect(); term_detection->detect();
@ -474,6 +526,34 @@ void ftermopenbsdTest::openbsdConsoleTest()
CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); CPPUNIT_ASSERT ( ! data->hasShadowCharacter() );
CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() );
CPPUNIT_ASSERT ( speaker.pitch == 1500 );
CPPUNIT_ASSERT ( speaker.period == 100 );
CPPUNIT_ASSERT ( speaker.volume == 50 );
openbsd.setBeep (20, 100); // Hz < 21
CPPUNIT_ASSERT ( speaker.pitch == 1500 );
CPPUNIT_ASSERT ( speaker.period == 100 );
CPPUNIT_ASSERT ( speaker.volume == 50 );
openbsd.setBeep (32767, 100); // Hz > 32766
CPPUNIT_ASSERT ( speaker.pitch == 1500 );
CPPUNIT_ASSERT ( speaker.period == 100 );
CPPUNIT_ASSERT ( speaker.volume == 50 );
openbsd.setBeep (200, -1); // ms < 0
CPPUNIT_ASSERT ( speaker.pitch == 1500 );
CPPUNIT_ASSERT ( speaker.period == 100 );
CPPUNIT_ASSERT ( speaker.volume == 50 );
openbsd.setBeep (200, 2000); // ms > 1999
CPPUNIT_ASSERT ( speaker.pitch == 1500 );
CPPUNIT_ASSERT ( speaker.period == 100 );
CPPUNIT_ASSERT ( speaker.volume == 50 );
openbsd.setBeep (200, 100); // 200 Hz - 100 ms
CPPUNIT_ASSERT ( speaker.pitch == 200 );
CPPUNIT_ASSERT ( speaker.period == 100 );
CPPUNIT_ASSERT ( speaker.volume == 50 );
openbsd.resetBeep();
CPPUNIT_ASSERT ( speaker.pitch == 1500 );
CPPUNIT_ASSERT ( speaker.period == 100 );
CPPUNIT_ASSERT ( speaker.volume == 50 );
openbsd.finish(); openbsd.finish();
closeConEmuStdStreams(); closeConEmuStdStreams();