mirror of
https://github.com/trudnai/Steve2.git
synced 2024-05-31 15:41:35 +00:00
- 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:
parent
fb85a5f122
commit
b67c69a660
|
@ -466,42 +466,42 @@ class ViewController: NSViewController {
|
||||||
override func flagsChanged(with event: NSEvent) {
|
override func flagsChanged(with event: NSEvent) {
|
||||||
switch event.modifierFlags.intersection(.deviceIndependentFlagsMask) {
|
switch event.modifierFlags.intersection(.deviceIndependentFlagsMask) {
|
||||||
case [.shift]:
|
case [.shift]:
|
||||||
setIO(0xC061, 0);
|
setIO(0xC061, 0)
|
||||||
setIO(0xC062, 0);
|
setIO(0xC062, 0)
|
||||||
setIO(0xC063, 0); // inverted (bit 7: not pressed)
|
setIO(0xC063, 0) // inverted (bit 7: not pressed)
|
||||||
// print("shift key is pressed")
|
// print("shift key is pressed")
|
||||||
// case [.control]:
|
// case [.control]:
|
||||||
// print("control key is pressed")
|
// print("control key is pressed")
|
||||||
case [.option] :
|
case [.option] :
|
||||||
setIO(0xC061, 1 << 7);
|
setIO(0xC061, 1 << 7)
|
||||||
setIO(0xC062, 0);
|
setIO(0xC062, 0)
|
||||||
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
|
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
|
||||||
// print("option key is pressed")
|
// print("option key is pressed")
|
||||||
case [.command]:
|
case [.command]:
|
||||||
// print("Command key is pressed")
|
// print("Command key is pressed")
|
||||||
setIO(0xC061, 0);
|
setIO(0xC061, 0)
|
||||||
setIO(0xC062, 1 << 7);
|
setIO(0xC062, 1 << 7)
|
||||||
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
|
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
|
||||||
// case [.control, .shift]:
|
// case [.control, .shift]:
|
||||||
// print("control-shift keys are pressed")
|
// print("control-shift keys are pressed")
|
||||||
case [.option, .shift]:
|
case [.option, .shift]:
|
||||||
setIO(0xC061, 1 << 7);
|
setIO(0xC061, 1 << 7)
|
||||||
setIO(0xC062, 0);
|
setIO(0xC062, 0)
|
||||||
setIO(0xC063, 0); // inverted (bit 7: not pressed)
|
setIO(0xC063, 0) // inverted (bit 7: not pressed)
|
||||||
// print("option-shift keys are pressed")
|
// print("option-shift keys are pressed")
|
||||||
case [.command, .shift]:
|
case [.command, .shift]:
|
||||||
setIO(0xC061, 0);
|
setIO(0xC061, 0)
|
||||||
setIO(0xC062, 1 << 7);
|
setIO(0xC062, 1 << 7)
|
||||||
setIO(0xC063, 0); // inverted (bit 7: not pressed)
|
setIO(0xC063, 0) // inverted (bit 7: not pressed)
|
||||||
// print("command-shift keys are pressed")
|
// print("command-shift keys are pressed")
|
||||||
// case [.control, .option]:
|
// case [.control, .option]:
|
||||||
// print("control-option keys are pressed")
|
// print("control-option keys are pressed")
|
||||||
// case [.control, .command]:
|
// case [.control, .command]:
|
||||||
// print("control-command keys are pressed")
|
// print("control-command keys are pressed")
|
||||||
case [.option, .command]:
|
case [.option, .command]:
|
||||||
setIO(0xC061, 1 << 7);
|
setIO(0xC061, 1 << 7)
|
||||||
setIO(0xC062, 1 << 7);
|
setIO(0xC062, 1 << 7)
|
||||||
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
|
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
|
||||||
// print("option-command keys are pressed")
|
// print("option-command keys are pressed")
|
||||||
// case [.shift, .control, .option]:
|
// case [.shift, .control, .option]:
|
||||||
// print("shift-control-option keys are pressed")
|
// print("shift-control-option keys are pressed")
|
||||||
|
@ -510,8 +510,8 @@ class ViewController: NSViewController {
|
||||||
// case [.control, .option, .command]:
|
// case [.control, .option, .command]:
|
||||||
// print("control-option-command keys are pressed")
|
// print("control-option-command keys are pressed")
|
||||||
case [.shift, .command, .option]:
|
case [.shift, .command, .option]:
|
||||||
setIO(0xC061, 1 << 7);
|
setIO(0xC061, 1 << 7)
|
||||||
setIO(0xC062, 1 << 7);
|
setIO(0xC062, 1 << 7)
|
||||||
setIO(0xC063, 0); // inverted (bit 7: not pressed)
|
setIO(0xC063, 0); // inverted (bit 7: not pressed)
|
||||||
// print("shift-command-option keys are pressed")
|
// print("shift-command-option keys are pressed")
|
||||||
// case [.shift, .control, .option, .command]:
|
// case [.shift, .control, .option, .command]:
|
||||||
|
@ -521,9 +521,9 @@ class ViewController: NSViewController {
|
||||||
// case [.capsLock]:
|
// case [.capsLock]:
|
||||||
// print("capsLock key is pressed")
|
// print("capsLock key is pressed")
|
||||||
default:
|
default:
|
||||||
setIO(0xC061, 0);
|
setIO(0xC061, 0)
|
||||||
setIO(0xC062, 0);
|
setIO(0xC062, 0)
|
||||||
setIO(0xC063, 1 << 7); // inverted (bit 7: not pressed)
|
setIO(0xC063, 1 << 7) // inverted (bit 7: not pressed)
|
||||||
// print("no modifier keys are 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() {
|
func Input() {
|
||||||
// Mouse 2 JoyStick (Game Controller / Paddle)
|
// Mouse 2 JoyStick (Game Controller / Paddle)
|
||||||
|
|
|
@ -177,6 +177,9 @@ void spkr_init() {
|
||||||
// Set-up sound source and play buffer
|
// Set-up sound source and play buffer
|
||||||
alGenSources(SOURCES_COUNT, spkr_src);
|
alGenSources(SOURCES_COUNT, spkr_src);
|
||||||
al_check_error();
|
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);
|
alSourcei(spkr_src[SPKR_SRC_GAME_SFX], AL_LOOPING, AL_FALSE);
|
||||||
al_check_error();
|
al_check_error();
|
||||||
alSourcef(spkr_src[SPKR_SRC_GAME_SFX], AL_ROLLOFF_FACTOR, 0);
|
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
|
// 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);
|
alSourcei(spkr_src[SPKR_SRC_DISK_MOTOR_SFX], AL_LOOPING, AL_TRUE);
|
||||||
al_check_error();
|
al_check_error();
|
||||||
alSourcef(spkr_src[SPKR_SRC_DISK_MOTOR_SFX], AL_ROLLOFF_FACTOR, 0);
|
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
|
// 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);
|
alSourcei(spkr_src[SPKR_SRC_DISK_ARM_SFX], AL_LOOPING, AL_FALSE);
|
||||||
al_check_error();
|
al_check_error();
|
||||||
alSourcef(spkr_src[SPKR_SRC_DISK_ARM_SFX], AL_ROLLOFF_FACTOR, 0);
|
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
|
// 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);
|
alSourcei(spkr_src[SPKR_SRC_DISK_IOERR_SFX], AL_LOOPING, AL_FALSE);
|
||||||
al_check_error();
|
al_check_error();
|
||||||
alSourcef(spkr_src[SPKR_SRC_DISK_IOERR_SFX], AL_ROLLOFF_FACTOR, 0);
|
alSourcef(spkr_src[SPKR_SRC_DISK_IOERR_SFX], AL_ROLLOFF_FACTOR, 0);
|
||||||
|
@ -358,7 +367,8 @@ void spkr_update() {
|
||||||
|
|
||||||
if ( freeBuffers ) {
|
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;
|
float fadeLevel = spkr_level - SPKR_LEVEL_ZERO;
|
||||||
|
|
||||||
if ( spkr_level != SPKR_LEVEL_ZERO ) {
|
if ( spkr_level != SPKR_LEVEL_ZERO ) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user