- Mouse clicks to Joystick button

- Better sound in Game Mode: It would not shut off the sound system, therefore no "Fade In" or "Soft Start" effect by OpenAL
This commit is contained in:
tudnai 2020-06-24 21:05:55 -07:00
parent fb85a5f122
commit b67c69a660
2 changed files with 71 additions and 24 deletions

View File

@ -466,42 +466,42 @@ class ViewController: NSViewController {
override func flagsChanged(with event: NSEvent) {
switch event.modifierFlags.intersection(.deviceIndependentFlagsMask) {
case [.shift]:
setIO(0xC061, 0);
setIO(0xC062, 0);
setIO(0xC063, 0); // inverted (bit 7: not pressed)
setIO(0xC061, 0)
setIO(0xC062, 0)
setIO(0xC063, 0) // inverted (bit 7: not pressed)
// print("shift key is pressed")
// case [.control]:
// print("control key is pressed")
case [.option] :
setIO(0xC061, 1 << 7);
setIO(0xC062, 0);
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
setIO(0xC061, 1 << 7)
setIO(0xC062, 0)
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
// print("option key is pressed")
case [.command]:
// print("Command key is pressed")
setIO(0xC061, 0);
setIO(0xC062, 1 << 7);
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
setIO(0xC061, 0)
setIO(0xC062, 1 << 7)
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
// case [.control, .shift]:
// print("control-shift keys are pressed")
case [.option, .shift]:
setIO(0xC061, 1 << 7);
setIO(0xC062, 0);
setIO(0xC063, 0); // inverted (bit 7: not pressed)
setIO(0xC061, 1 << 7)
setIO(0xC062, 0)
setIO(0xC063, 0) // inverted (bit 7: not pressed)
// print("option-shift keys are pressed")
case [.command, .shift]:
setIO(0xC061, 0);
setIO(0xC062, 1 << 7);
setIO(0xC063, 0); // inverted (bit 7: not pressed)
setIO(0xC061, 0)
setIO(0xC062, 1 << 7)
setIO(0xC063, 0) // inverted (bit 7: not pressed)
// print("command-shift keys are pressed")
// case [.control, .option]:
// print("control-option keys are pressed")
// case [.control, .command]:
// print("control-command keys are pressed")
case [.option, .command]:
setIO(0xC061, 1 << 7);
setIO(0xC062, 1 << 7);
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
setIO(0xC061, 1 << 7)
setIO(0xC062, 1 << 7)
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
// print("option-command keys are pressed")
// case [.shift, .control, .option]:
// print("shift-control-option keys are pressed")
@ -510,8 +510,8 @@ class ViewController: NSViewController {
// case [.control, .option, .command]:
// print("control-option-command keys are pressed")
case [.shift, .command, .option]:
setIO(0xC061, 1 << 7);
setIO(0xC062, 1 << 7);
setIO(0xC061, 1 << 7)
setIO(0xC062, 1 << 7)
setIO(0xC063, 0); // inverted (bit 7: not pressed)
// print("shift-command-option keys are pressed")
// case [.shift, .control, .option, .command]:
@ -521,9 +521,9 @@ class ViewController: NSViewController {
// case [.capsLock]:
// print("capsLock key is pressed")
default:
setIO(0xC061, 0);
setIO(0xC062, 0);
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
setIO(0xC061, 0)
setIO(0xC062, 0)
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
// print("no modifier keys are pressed")
}
}
@ -733,7 +733,44 @@ class ViewController: NSViewController {
}
}
}
override func mouseDown(with event: NSEvent) {
if ( Mouse2Joystick ) {
setIO(0xC061, 1 << 7)
}
}
override func mouseUp(with event: NSEvent) {
if ( Mouse2Joystick ) {
setIO(0xC061, 0)
}
}
override func rightMouseDown(with event: NSEvent) {
if ( Mouse2Joystick ) {
setIO(0xC062, 1 << 7)
}
}
override func rightMouseUp(with event: NSEvent) {
if ( Mouse2Joystick ) {
setIO(0xC062, 0)
}
}
override func otherMouseDown(with event: NSEvent) {
if ( Mouse2Joystick ) {
setIO(0xC063, 0) // inverted (bit 7: 0 = pressed)
}
}
override func otherMouseUp(with event: NSEvent) {
if ( Mouse2Joystick ) {
setIO(0xC063, 1 << 7) // inverted (bit 7: 1 = not pressed)
}
}
func Input() {
// Mouse 2 JoyStick (Game Controller / Paddle)

View File

@ -177,6 +177,9 @@ void spkr_init() {
// Set-up sound source and play buffer
alGenSources(SOURCES_COUNT, spkr_src);
al_check_error();
alSourcei(spkr_src[SPKR_SRC_GAME_SFX], AL_SOURCE_RELATIVE, AL_TRUE);
al_check_error();
alSourcei(spkr_src[SPKR_SRC_GAME_SFX], AL_LOOPING, AL_FALSE);
al_check_error();
alSourcef(spkr_src[SPKR_SRC_GAME_SFX], AL_ROLLOFF_FACTOR, 0);
@ -190,6 +193,8 @@ void spkr_init() {
// Set-up disk motor sound source and play buffer
alSourcei(spkr_src[SPKR_SRC_DISK_MOTOR_SFX], AL_SOURCE_RELATIVE, AL_TRUE);
al_check_error();
alSourcei(spkr_src[SPKR_SRC_DISK_MOTOR_SFX], AL_LOOPING, AL_TRUE);
al_check_error();
alSourcef(spkr_src[SPKR_SRC_DISK_MOTOR_SFX], AL_ROLLOFF_FACTOR, 0);
@ -203,6 +208,8 @@ void spkr_init() {
// Set-up disk arm sound source and play buffer
alSourcei(spkr_src[SPKR_SRC_DISK_ARM_SFX], AL_SOURCE_RELATIVE, AL_TRUE);
al_check_error();
alSourcei(spkr_src[SPKR_SRC_DISK_ARM_SFX], AL_LOOPING, AL_FALSE);
al_check_error();
alSourcef(spkr_src[SPKR_SRC_DISK_ARM_SFX], AL_ROLLOFF_FACTOR, 0);
@ -216,6 +223,8 @@ void spkr_init() {
// Set-up disk io error sound source and play buffer
alSourcei(spkr_src[SPKR_SRC_DISK_IOERR_SFX], AL_SOURCE_RELATIVE, AL_TRUE);
al_check_error();
alSourcei(spkr_src[SPKR_SRC_DISK_IOERR_SFX], AL_LOOPING, AL_FALSE);
al_check_error();
alSourcef(spkr_src[SPKR_SRC_DISK_IOERR_SFX], AL_ROLLOFF_FACTOR, 0);
@ -358,7 +367,8 @@ void spkr_update() {
if ( freeBuffers ) {
if ( --spkr_play_time == 0 ) {
// in Game Mode do not fade out and stop playing
if ( ( cpuMode_game != cpuMode ) && ( --spkr_play_time == 0 ) ) {
float fadeLevel = spkr_level - SPKR_LEVEL_ZERO;
if ( spkr_level != SPKR_LEVEL_ZERO ) {