[Scummvm-git-logs] scummvm master -> 2c7714364ee7801df4d5f22f94f0f2e66c86c8fc
aquadran
aquadran at gmail.com
Sat Feb 13 21:44:50 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2c7714364e ICB: Remove joystick code
Commit: 2c7714364ee7801df4d5f22f94f0f2e66c86c8fc
https://github.com/scummvm/scummvm/commit/2c7714364ee7801df4d5f22f94f0f2e66c86c8fc
Author: PaweÅ KoÅodziejski (aquadran at users.sourceforge.net)
Date: 2021-02-13T22:44:45+01:00
Commit Message:
ICB: Remove joystick code
Changed paths:
engines/icb/direct_input.cpp
engines/icb/movie_pc.cpp
engines/icb/options_manager_pc.cpp
engines/icb/p4.cpp
engines/icb/p4_pc.cpp
engines/icb/player_pc.cpp
diff --git a/engines/icb/direct_input.cpp b/engines/icb/direct_input.cpp
index a78f1f9b0d..931ebffcea 100644
--- a/engines/icb/direct_input.cpp
+++ b/engines/icb/direct_input.cpp
@@ -27,10 +27,6 @@
#include "engines/icb/common/px_rccommon.h"
-#if defined (SDL_BACKEND)
-#include <SDL_joystick.h>
-#endif
-
#include "engines/icb/p4_generic.h"
#include "engines/icb/debug.h"
#include "engines/icb/p4.h"
@@ -44,14 +40,6 @@
namespace ICB {
-uint32 dinputTime = 0;
-
-// Initialise global joystick variables
-// This is given an initial value during init_direct_input() but can be
-// used as a switch to alter joystick behaviour (analogue/digital/off)
-int currentJoystick = NO_JOYSTICK;
-int attachedJoystick = NO_JOYSTICK;
-
// Initialised to unset values
// For mapping purposes
uint8 up_joy = 0xFF;
@@ -67,269 +55,11 @@ uint8 fire_button = 0xFF;
uint8 inventory_button = 0xFF;
uint8 remora_button = 0xFF;
uint8 pause_button = 0xFF;
-
-// These are the structures used to hold the data we are polling for joysticks
-#define MAX_AXES 8
-
-typedef struct {
- bool8 held_down; // For polling
- char name[12]; // For the options screen configuration
-
-} BUTTON;
-
-typedef struct {
- int32 val; // For polling
- char name[12]; // For the options screen configuration
-
-} HALFAXIS;
-
-int g_noButtons = 0; // Available number of buttons
-int g_noAxes = 0; // Available number of axes
-BUTTON g_buttons[32]; // Button data (max 32)
-bool8 g_buttonsRepeats[32]; // Button repeat data (max 32)
-HALFAXIS g_axes[MAX_AXES]; // Axes data (max 8 * 2)
-
-// Fixed defines for mapping
-#define AXIS_1_POS 0
-#define AXIS_1_NEG 1
-#define AXIS_2_POS 2
-#define AXIS_2_NEG 3
-#define AXIS_3_POS 4
-#define AXIS_3_NEG 5
-#define AXIS_4_POS 6
-#define AXIS_4_NEG 7
-
-#define JOY_B1 1
-#define JOY_B2 2
-#define JOY_B3 4
-#define JOY_B4 8
-
-typedef struct {
- uint32 posX;
- uint32 posY;
- uint32 buttons;
-} JoyInfo;
-
-class NTJoystickHandler {
- private:
- int joyThere[16]; // 1 if joystick is plugged in, 0 otherwise
-#if defined (SDL_BACKEND)
- SDL_Joystick *joy[16];
-#endif
- JoyInfo cached_joyinfo[16];
-
- public:
- NTJoystickHandler(void);
- ~NTJoystickHandler(void);
-
- bool8 isValid;
-
- void Init(void);
-
- // HW Query functions: determine whether or not a device exists.
- // Return 0 if no such device, > 0 (depending on device) if it does.
- int QueryJoystick(void); // 0=none, else number of joysticks
- // Input functions: anyone wishing for input needs to call these:
- int GetJoystick(int joynum, JoyInfo *joypos);
- void UpdateJoystick(void);
-};
-
-NTJoystickHandler::NTJoystickHandler(void) {
- memset(joyThere, 0, sizeof(int) * 16);
-
- isValid = FALSE8;
-}
-
-NTJoystickHandler::~NTJoystickHandler(void) {
- for (int x = 0; x < 16; x++) {
- if (joyThere[x]) {
- // FIXME: By the time we're in this destructor, SDL has already been terminated.
- // SDL_JoystickClose(joy[x]);
- }
- }
-}
-
-void NTJoystickHandler::Init() {
- for (int x = 0; x < QueryJoystick(); x++) {
-#if defined (SDL_BACKEND)
- SDL_Joystick *j = SDL_JoystickOpen(x);
- if (j) {
- // there *is* a joystick 'x' installed!
- ++joyThere[x];
- joy[x] = j;
- }
-#endif
- }
- UpdateJoystick();
-}
-
-int NTJoystickHandler::QueryJoystick(void) {
- // if no joystick(s), returns 0 else number of joysticks attached.
- return
-#if defined (SDL_BACKEND)
- (SDL_NumJoysticks());
-#else
- 0;
-#endif
-}
-
-int normalize(int val, int minval, int maxval) {
- // error detection:
- if ((maxval - minval) == 0) {
- return (0);
- }
-
- // zero-base:
- val -= minval;
-
- // normalize to 0..255:
- val = (255L * val) / (maxval - minval);
-
- return (val);
-}
-
-void NTJoystickHandler::UpdateJoystick() {
-#ifdef ENABLE_JOYSTICK
- for (int x = 0; x < 16; x++) {
- if (joyThere[x] && SDL_JoystickGetAttached(joy[x])) {
- cached_joyinfo[x].posX = SDL_JoystickGetAxis(joy[x], 0);
- cached_joyinfo[x].posY = SDL_JoystickGetAxis(joy[x], 1);
- cached_joyinfo[x].buttons = 0;
- if (SDL_JoystickGetButton(joy[x], 0)) {
- cached_joyinfo[x].buttons |= JOY_B1;
- }
- if (SDL_JoystickGetButton(joy[x], 1)) {
- cached_joyinfo[x].buttons |= JOY_B2;
- }
- if (SDL_JoystickGetButton(joy[x], 2)) {
- cached_joyinfo[x].buttons |= JOY_B3;
- }
- if (SDL_JoystickGetButton(joy[x], 3)) {
- cached_joyinfo[x].buttons |= JOY_B4;
- }
- }
- }
-#endif
-}
-
-int NTJoystickHandler::GetJoystick(int joynum, JoyInfo *joypos) {
- if ((joynum >= 16) || (joynum <= 0) || !joyThere[joynum - 1])
- return (0);
-
- memcpy(joypos, &(cached_joyinfo[joynum - 1]), sizeof(JoyInfo));
-
- // normalize the joypos to -127, 0, 127 scale....
- joypos->posX = normalize(joypos->posX, -32768, 32768);
- joypos->posY = normalize(joypos->posY, -32768, 32768);
-
- // To overcome UINT type within JOYINFO struct
- int32 ntX = joypos->posX - 127;
- int32 ntY = joypos->posY - 127;
-
- g_axes[AXIS_1_POS].val = (ntX < 0) ? 0 : ntX;
- g_axes[AXIS_1_NEG].val = (ntX >= 0) ? 0 : ntX;
- g_axes[AXIS_2_POS].val = (ntY < 0) ? 0 : ntY;
- g_axes[AXIS_2_NEG].val = (ntY >= 0) ? 0 : ntY;
-
- return (1);
-}
-
-NTJoystickHandler ntJoystick;
-
-bool PollNTJoystick() {
- ntJoystick.UpdateJoystick();
-
- // State structre
- JoyInfo inf;
-
- // Get current state
- if (ntJoystick.GetJoystick(1, &inf) == 0) {
- ntJoystick.isValid = FALSE8;
- attachedJoystick = NO_JOYSTICK;
- Zdebug("GetJoystick failed");
-
- return false;
- }
-
- // Buttons
-
- if (inf.buttons & JOY_B1)
- g_buttons[0].held_down = TRUE8;
- else
- g_buttons[0].held_down = FALSE8;
-
- if (inf.buttons & JOY_B2)
- g_buttons[1].held_down = TRUE8;
- else
- g_buttons[1].held_down = FALSE8;
-
- if (inf.buttons & JOY_B3)
- g_buttons[2].held_down = TRUE8;
- else
- g_buttons[2].held_down = FALSE8;
-
- if (inf.buttons & JOY_B4)
- g_buttons[3].held_down = TRUE8;
- else
- g_buttons[3].held_down = FALSE8;
-
- return true;
-}
-
bool8 keyboard_buf_scancodes[512]; // SDL_NUM_SCANCODES
bool8 repeats_scancodes[512]; // SDL_NUM_SCANCODES
void Init_direct_input() {
- uint32 k;
-
- // Zero everything out
- for (k = 0; k < 32; k++) {
- g_buttons[k].held_down = FALSE8;
- memset(g_buttons[k].name, 0, 12);
- g_buttonsRepeats[k] = FALSE8;
- }
- for (k = 0; k < MAX_AXES; k++) {
- g_axes[k].val = 0;
- memset(g_axes[k].name, 0, 12);
- }
-
- // Default axes to use (overriden by ini file config)
- up_joy = AXIS_2_NEG;
- down_joy = AXIS_2_POS;
- left_joy = AXIS_1_NEG;
- right_joy = AXIS_1_POS;
-
- // Initialize joystick(s)
- ntJoystick.Init();
-
- if (ntJoystick.QueryJoystick() == 0) {
- ntJoystick.isValid = FALSE8;
-
- Zdebug("Joystick not installed");
-
- currentJoystick = NO_JOYSTICK;
- } else {
- ntJoystick.isValid = TRUE8;
-
- // For development give these defaults
- g_noButtons = 4;
- strcpy(g_buttons[0].name, "Button 1");
- strcpy(g_buttons[1].name, "Button 2");
- strcpy(g_buttons[2].name, "Button 3");
- strcpy(g_buttons[3].name, "Button 4");
- g_noAxes = 2;
- strcpy(g_axes[AXIS_1_POS].name, "+ve X-Axis");
- strcpy(g_axes[AXIS_1_NEG].name, "-ve X-Axis");
- strcpy(g_axes[AXIS_2_POS].name, "+ve Y-Axis");
- strcpy(g_axes[AXIS_2_NEG].name, "-ve Y-Axis");
-
- attachedJoystick = ANALOGUE_JOYSTICK;
- currentJoystick = ANALOGUE_JOYSTICK;
- }
-
SetDefaultKeys();
-
- // Ready to accept all input if we're on NT or not !!!
}
void setKeyState(Common::KeyCode key, bool pressed) { keyboard_buf_scancodes[key] = pressed; }
@@ -342,15 +72,6 @@ void Poll_direct_input() {
for (uint32 i = 0; i < keys; i++) {
keyboard_buf_scancodes[i] = key_state[i] ? TRUE8 : FALSE8;
}
-
- // Already set to NULL if no pad attached so don't worry
- if (ntJoystick.isValid) {
- if (!PollNTJoystick()) {
- ntJoystick.isValid = FALSE8;
- currentJoystick = NO_JOYSTICK;
- Zdebug("PollNTJoystick failed");
- }
- }
#endif
}
@@ -1864,199 +1585,4 @@ const char *GetKeyName(uint32 key) {
}
}
-const char *GetJoystickName() {
- const char *name = NULL;
-
- if (ntJoystick.isValid) {
- name = "Joystick";
- }
-
- return name;
-}
-
-const char *GetButtonName(uint8 part) {
- // Unset
- if (part == 0xFF)
- return NULL;
-
- // Only have 32 buttons maximum
- if (part < 0 || part >= g_noButtons)
- return NULL;
-
- return g_buttons[part].name;
-}
-
-const char *GetAxisName(uint8 part) {
- char *name = NULL;
-
- if (part != 0xFF) {
- if (strcmp(g_axes[part].name, "") != 0)
- name = g_axes[part].name;
- }
-
- return name;
-}
-
-int32 Read_Joystick(uint8 part) {
- // Unset value
- if (part == 0xFF)
- return 0;
-
- if (!ntJoystick.isValid) {
- return 0;
- }
-
- // Axes we are configured to use
- int32 upVal = (up_joy == 0xFF) ? 0 : g_axes[up_joy].val;
- int32 downVal = (down_joy == 0xFF) ? 0 : g_axes[down_joy].val;
- int32 leftVal = (left_joy == 0xFF) ? 0 : g_axes[left_joy].val;
- int32 rightVal = (right_joy == 0xFF) ? 0 : g_axes[right_joy].val;
-
- // Ensure we report axes data with consistent sign
- if (upVal > 0)
- upVal *= -1;
- if (downVal < 0)
- downVal *= -1;
- if (leftVal > 0)
- leftVal *= -1;
- if (rightVal < 0)
- rightVal *= -1;
-
- // Are we returning a digital response
- if (currentJoystick == DIGITAL_JOYSTICK) {
- // Windows98 and NT (both sytem methods modify the same data)
-
- // Map analogue axis values to digital extremes
- if (part == X_AXIS) {
- if (rightVal > 20)
- return JOY_RIGHT;
- else if (leftVal < -20)
- return JOY_LEFT;
- else
- return 0;
- } else if (part == Y_AXIS) {
- if (downVal > 20)
- return JOY_DOWN;
- else if (upVal < -20)
- return JOY_UP;
- else
- return 0;
- } else {
- g_buttonsRepeats[part] = g_buttons[part].held_down;
- return g_buttons[part].held_down;
- }
- } else
- // We want axis ranges please
- if (currentJoystick == ANALOGUE_JOYSTICK) {
- // Get analogue axis values
- if (part == X_AXIS) {
- if ((rightVal > 20) || (leftVal < -20))
- return (leftVal + rightVal);
- else
- return 0;
- } else if (part == Y_AXIS) {
- if ((downVal > 20) || (upVal < -20))
- return (downVal + upVal);
- else
- return 0;
- } else {
- g_buttonsRepeats[part] = g_buttons[part].held_down;
- return g_buttons[part].held_down;
- }
- } else
- return 0;
-}
-
-int32 Read_Joystick_once(uint8 part) {
- // Fuck axis nonsense off
- if (part == X_AXIS || part == Y_AXIS)
- return Read_Joystick(part);
-
- // Unset value
- if (part == 0xFF)
- return 0;
-
- if (!ntJoystick.isValid) {
- return 0;
- }
-
- if (currentJoystick == ANALOGUE_JOYSTICK || currentJoystick == DIGITAL_JOYSTICK) {
- // Button still pressed so return false
- if (g_buttons[part].held_down && g_buttonsRepeats[part])
- return 0;
-
- // Set repeat
- g_buttonsRepeats[part] = g_buttons[part].held_down;
-
- // Return correct value
- return g_buttons[part].held_down;
- }
-
- return 0;
-}
-
-void SetDefaultJoystick() {
- SetDefaultKeys();
-
- up_joy = AXIS_2_NEG;
- down_joy = AXIS_2_POS;
- left_joy = AXIS_1_NEG;
- right_joy = AXIS_1_POS;
-
- // Can only really assume two buttons
- sidestep_button = 0xFF;
- run_button = 0xFF;
- crouch_button = 0xFF;
- interact_button = 0;
- arm_button = 0xFF;
- fire_button = 1;
- inventory_button = 0xFF;
- remora_button = 0xFF;
- pause_button = 0xFF;
-}
-
-void UnsetJoystickConfig() {
- // Unset all
- up_joy = 0xFF;
- down_joy = 0xFF;
- left_joy = 0xFF;
- right_joy = 0xFF;
- sidestep_button = 0xFF;
- run_button = 0xFF;
- crouch_button = 0xFF;
- interact_button = 0xFF;
- arm_button = 0xFF;
- fire_button = 0xFF;
- inventory_button = 0xFF;
- remora_button = 0xFF;
- pause_button = 0xFF;
-}
-
-uint8 GetJoystickButtonPress() {
- for (int32 i = 0; i < g_noButtons; i++) {
- if (Read_Joystick((uint8)i)) {
- return (uint8)i;
- }
- }
-
- // Perhaps we need to loop over axis settings here for directional config too
-
- return 0xFF;
-}
-
-uint8 GetJoystickAxisPress() {
- // Check for the first non-zero positioned axis
- for (int32 i = 0; i < MAX_AXES; i++) {
- // Ignore meaningless data if the axis has no name
- if (strcmp(g_axes[i].name, "") == 0)
- continue;
-
- // Return axis index
- if (g_axes[i].val > 20 || g_axes[i].val < -20)
- return (uint8)i;
- }
-
- return 0xFF;
-}
-
} // End of namespace ICB
diff --git a/engines/icb/movie_pc.cpp b/engines/icb/movie_pc.cpp
index f268aed881..f1d8a076c8 100644
--- a/engines/icb/movie_pc.cpp
+++ b/engines/icb/movie_pc.cpp
@@ -166,12 +166,6 @@ uint32 SequenceManager::DrawFrame(uint32 surface_id) {
Kill();
return FINISHED;
}
- // And also the joystick pause button cos I'm lazy
- if (Read_Joystick_once(pause_button) && !m_loop) {
- // Release Bink object and file
- Kill();
- return FINISHED;
- }
// Don't do bink, fade the screen
if (m_fadeCounter < (255 / m_fadeRate)) {
diff --git a/engines/icb/options_manager_pc.cpp b/engines/icb/options_manager_pc.cpp
index cf005e9644..cd7ba4a310 100644
--- a/engines/icb/options_manager_pc.cpp
+++ b/engines/icb/options_manager_pc.cpp
@@ -2725,27 +2725,10 @@ void OptionsManager::AlterSelected(bool8 _right_) {
switch (m_CONTROL_selected) {
case DEVICE:
- if (currentJoystick == NO_JOYSTICK) {
- SetDefaultJoystick();
- currentJoystick = attachedJoystick;
- } else {
- SetDefaultKeys();
- currentJoystick = NO_JOYSTICK;
- // Ensure we move to actor relative for the keyboard
- g_icb_session->player.Set_control_mode(ACTOR_RELATIVE);
- }
break;
case METHOD: // Force actor relative if we're using the keyboard
- if (currentJoystick == NO_JOYSTICK) {
- g_icb_session->player.Set_control_mode(ACTOR_RELATIVE);
- } else {
- if (g_icb_session->player.Get_control_mode() == SCREEN_RELATIVE) {
- g_icb_session->player.Set_control_mode(ACTOR_RELATIVE);
- } else {
- g_icb_session->player.Set_control_mode(SCREEN_RELATIVE);
- }
- }
+ g_icb_session->player.Set_control_mode(ACTOR_RELATIVE);
break;
default:
@@ -3449,10 +3432,7 @@ void OptionsManager::DoChoice() {
break;
case DEFAULTS:
- if (currentJoystick == NO_JOYSTICK)
- SetDefaultKeys();
- else
- SetDefaultJoystick();
+ SetDefaultKeys();
break;
case DONE:
@@ -3745,66 +3725,8 @@ void OptionsManager::EditSlotLabel() {
static int flash = 0;
char buff[128];
- if (!Read_Joystick(0))
- m_letJoystickQuitEdit = TRUE8;
-
int id = m_slotOffset + m_GAMESLOT_selected;
- // Quit on joystick too
- if ((Read_Joystick(0)) && m_letJoystickQuitEdit) {
- // Not allowed an empty name 'cos thats daft
- if (!VerifyLabel())
- return;
-
- // Construct full filename
- MakeFullSaveFilename(id, buff);
-
- // Now check to see if the file exists (overwrite used slot)
- if (checkFileExists(buff)) { // amode 0
- // Slot is in use so do confirm prompt screen
- m_activeMenu = INGAME_SAVECONFIRM;
- m_SAVECONFIRM_selected = NAY;
- m_editing = FALSE8;
- ForceInGameScreenRefresh();
- return;
- }
-
- // Slot empty so just save without prompting
-
- // Remove cursor from the end of the buffer
- m_editBuffer[m_cursorPos] = '\0';
-
- // Then set the label to equal the buffer
- strcpy(m_slots[id]->label, m_editBuffer);
-
- // Now actually save the game
- g_mission->Save_game_position(buff, m_slots[id]->label, m_slots[id]->secondsPlayed);
- // Aint32 with a thumbnail
- SaveThumbnail(id);
- LoadVisibleThumbnails();
-
- memset(m_editBuffer, '\0', MAX_LABEL_LENGTH);
- m_editing = FALSE8;
- m_GAMESLOT_selected = RETURN;
- m_choiceLimiter = TRUE8;
- }
-
- // User cancallation
- if (Read_DI_once_keys(Common::KEYCODE_ESCAPE)) {
- if (m_emptySlotFlag == 0) {
- // Slot was previously empty so delete on cancellation
- delete m_slots[id];
- m_slots[id] = NULL;
- } else {
- // Just need to restore time played to cancel
- m_slots[id]->secondsPlayed = m_emptySlotFlag;
- }
-
- memset(m_editBuffer, '\0', MAX_LABEL_LENGTH);
- m_editing = FALSE8;
- m_choiceLimiter = FALSE8;
- }
-
if (KeyWaiting()) {
ReadKey(&c);
@@ -4977,8 +4899,6 @@ void OptionsManager::DrawPageIndicator(uint32 x, uint32 y, bool8 up, bool8 selec
void OptionsManager::GetKeyAssignment() {
uint32 keypressed = Get_DI_key_press();
- uint8 joystickpressed = GetJoystickButtonPress();
- uint8 joystickAxisPressed = GetJoystickAxisPress();
// Change selected function using the enter key (so ensure this doesn't get immediately assigned)
if ((keypressed == Common::KEYCODE_RETURN) && m_configLimiter) {
@@ -4987,7 +4907,7 @@ void OptionsManager::GetKeyAssignment() {
return;
}
- if ((joystickpressed == 0) && m_configLimiter) {
+ if (m_configLimiter) {
// Now allowed to assign a button
m_configLimiter = FALSE8;
// Hacky fuck fuck!
@@ -4995,220 +4915,6 @@ void OptionsManager::GetKeyAssignment() {
return;
}
- if (currentJoystick != NO_JOYSTICK) {
- // Are we assigning directional control on the joystick
-
- if (joystickAxisPressed != 0xFF) {
- if ((m_CONTROL_selected == UP_CROUCH || m_CONTROL_selected == DOWN_INTERACT || m_CONTROL_selected == LEFT_ARM || m_CONTROL_selected == RIGHT_ATTACK) &&
- m_controlPage1) {
- // Check reassignment
- if (left_joy == joystickAxisPressed)
- left_joy = 0xFF;
- else if (right_joy == joystickAxisPressed)
- right_joy = 0xFF;
- else if (up_joy == joystickAxisPressed)
- up_joy = 0xFF;
- else if (down_joy == joystickAxisPressed)
- down_joy = 0xFF;
-
- switch (m_CONTROL_selected) {
- case UP_CROUCH:
- up_joy = joystickAxisPressed;
- break;
- case DOWN_INTERACT:
- down_joy = joystickAxisPressed;
- break;
- case LEFT_ARM:
- left_joy = joystickAxisPressed;
- break;
- case RIGHT_ATTACK:
- right_joy = joystickAxisPressed;
- break;
-
- // Only assign axes to directional control
- default:
- return;
- }
-
- // Done my shit thanks
- m_awaitingKeyPress = FALSE8;
- m_editing = FALSE8;
- m_configLimiter = TRUE8;
-
- g_system->delayMillis(200);
- return;
- }
-
- // Chances are sliders will always return some value so ignore and continue
- }
-
- // Check for button with priority when we have a joystick
-
- if (joystickpressed != 0xFF) {
- // Can't assign buttons to directional controls
- if ((m_CONTROL_selected == UP_CROUCH || m_CONTROL_selected == DOWN_INTERACT || m_CONTROL_selected == LEFT_ARM || m_CONTROL_selected == RIGHT_ATTACK) &&
- m_controlPage1)
- return;
-
- if (GetButtonName(joystickpressed) == NULL)
- return;
-
- // Check reassignment
- if (sidestep_button == joystickpressed)
- sidestep_button = 0xFF;
- else if (run_button == joystickpressed)
- run_button = 0xFF;
- else if (crouch_button == joystickpressed)
- crouch_button = 0xFF;
- else if (interact_button == joystickpressed)
- interact_button = 0xFF;
- else if (arm_button == joystickpressed)
- arm_button = 0xFF;
- else if (fire_button == joystickpressed)
- fire_button = 0xFF;
- else if (inventory_button == joystickpressed)
- inventory_button = 0xFF;
- else if (remora_button == joystickpressed)
- remora_button = 0xFF;
- else if (pause_button == joystickpressed)
- pause_button = 0xFF;
-
- switch (m_CONTROL_selected) {
- case UP_CROUCH:
- crouch_button = joystickpressed;
- break;
- case DOWN_INTERACT:
- interact_button = joystickpressed;
- break;
- case LEFT_ARM:
- arm_button = joystickpressed;
- break;
- case RIGHT_ATTACK:
- fire_button = joystickpressed;
- break;
- case RUN_INVENTORY:
- if (m_controlPage1)
- run_button = joystickpressed;
- else
- inventory_button = joystickpressed;
- break;
- case SIDESTEP_REMORA:
- if (m_controlPage1)
- sidestep_button = joystickpressed;
- else
- remora_button = joystickpressed;
- break;
- case PAUSE:
- pause_button = joystickpressed;
- break;
-
- default:
- return;
- }
-
- // Done my shit thanks
- m_awaitingKeyPress = FALSE8;
- m_editing = FALSE8;
- m_configLimiter = TRUE8;
-
- g_system->delayMillis(200);
- return;
- }
- }
-
- if (keypressed != 0) {
- // Joystick control is selected so don't assign keys to directional control
- if ((m_CONTROL_selected == UP_CROUCH || m_CONTROL_selected == DOWN_INTERACT || m_CONTROL_selected == LEFT_ARM || m_CONTROL_selected == RIGHT_ATTACK) &&
- m_controlPage1) {
- if (currentJoystick != NO_JOYSTICK)
- return;
- }
-
- // Ban the use of keys with no names
- if (GetKeyName(keypressed) == NULL)
- return;
-
- // Check the assignment hasn't already been used
- if (up_key == keypressed)
- up_key = 0;
- else if (down_key == keypressed)
- down_key = 0;
- else if (left_key == keypressed)
- left_key = 0;
- else if (right_key == keypressed)
- right_key = 0;
- else if (sidestep_key == keypressed)
- sidestep_key = 0;
- else if (run_key == keypressed)
- run_key = 0;
- else if (crouch_key == keypressed)
- crouch_key = 0;
- else if (interact_key == keypressed)
- interact_key = 0;
- else if (arm_key == keypressed)
- arm_key = 0;
- else if (fire_key == keypressed)
- fire_key = 0;
- else if (inventory_key == keypressed)
- inventory_key = 0;
- else if (remora_key == keypressed)
- remora_key = 0;
- else if (pause_key == keypressed)
- return;
-
- switch (m_CONTROL_selected) {
- case UP_CROUCH:
- if (m_controlPage1)
- up_key = keypressed;
- else
- crouch_key = keypressed;
- break;
- case DOWN_INTERACT:
- if (m_controlPage1)
- down_key = keypressed;
- else
- interact_key = keypressed;
- break;
- case LEFT_ARM:
- if (m_controlPage1)
- left_key = keypressed;
- else
- arm_key = keypressed;
- break;
- case RIGHT_ATTACK:
- if (m_controlPage1)
- right_key = keypressed;
- else
- fire_key = keypressed;
- break;
- case RUN_INVENTORY:
- if (m_controlPage1)
- run_key = keypressed;
- else
- inventory_key = keypressed;
- break;
- case SIDESTEP_REMORA:
- if (m_controlPage1)
- sidestep_key = keypressed;
- else
- remora_key = keypressed;
- break;
- case PAUSE:
- pause_key = keypressed;
- break;
-
- default:
- return;
- }
-
- // Done my shit thanks
- m_awaitingKeyPress = FALSE8;
- m_editing = FALSE8;
- m_configLimiter = TRUE8;
-
- g_system->delayMillis(200);
- }
-
m_assignFlash++;
if (m_assignFlash == 10)
m_assignFlash = 0;
@@ -5315,17 +5021,7 @@ void OptionsManager::DrawControllerConfiguration() {
msg = GetTextFromReference(HashString("opt_device"));
temp = CalculateStringWidth(msg);
DisplayText(ad, pitch, msg, m_margin - temp, 130, (m_CONTROL_selected == DEVICE) ? SELECTEDFONT : NORMALFONT, FALSE8);
- if (currentJoystick == NO_JOYSTICK)
- msg = GetTextFromReference(HashString("opt_keyboard"));
- else {
- // Change this to use DirectX device names later (for joysticks only)
- msg = GetJoystickName();
-
- // This returns NULL if there's no joystick so we can force keyboard
- if (msg == NULL) {
- msg = GetTextFromReference(HashString("opt_keyboard"));
- }
- }
+ msg = GetTextFromReference(HashString("opt_keyboard"));
DisplayText(ad, pitch, msg, m_margin + 5, 130, NORMALFONT, FALSE8);
msg = GetTextFromReference(HashString("opt_controlmethod"));
@@ -5532,20 +5228,14 @@ void OptionsManager::DrawControls(uint32 surface_id) {
msg = screenRelative ? GetTextFromReference(HashString("opt_up")) : GetTextFromReference(HashString("opt_forwards"));
temp = CalculateStringWidth(msg);
- if (currentJoystick != NO_JOYSTICK)
- msg2 = GetAxisName(up_joy);
- else
- msg2 = GetKeyName(up_key);
+ msg2 = GetKeyName(up_key);
if (msg2 == NULL)
msg2 = "???";
} else {
msg = GetTextFromReference(HashString("opt_crouch"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (crouch_button != 0xFF))
- msg2 = GetButtonName(crouch_button);
- else
- msg2 = GetKeyName(crouch_key);
+ msg2 = GetKeyName(crouch_key);
if (msg2 == NULL)
msg2 = "???";
}
@@ -5559,20 +5249,14 @@ void OptionsManager::DrawControls(uint32 surface_id) {
msg = screenRelative ? GetTextFromReference(HashString("opt_down")) : GetTextFromReference(HashString("opt_backwards"));
temp = CalculateStringWidth(msg);
- if (currentJoystick != NO_JOYSTICK)
- msg2 = GetAxisName(down_joy);
- else
- msg2 = GetKeyName(down_key);
+ msg2 = GetKeyName(down_key);
if (msg2 == NULL)
msg2 = "???";
} else {
msg = GetTextFromReference(HashString("opt_interact"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (interact_button != 0xFF))
- msg2 = GetButtonName(interact_button);
- else
- msg2 = GetKeyName(interact_key);
+ msg2 = GetKeyName(interact_key);
if (msg2 == NULL)
msg2 = "???";
}
@@ -5586,20 +5270,14 @@ void OptionsManager::DrawControls(uint32 surface_id) {
msg = screenRelative ? GetTextFromReference(HashString("opt_left")) : GetTextFromReference(HashString("opt_turnleft"));
temp = CalculateStringWidth(msg);
- if (currentJoystick != NO_JOYSTICK)
- msg2 = GetAxisName(left_joy);
- else
- msg2 = GetKeyName(left_key);
+ msg2 = GetKeyName(left_key);
if (msg2 == NULL)
msg2 = "???";
} else {
msg = GetTextFromReference(HashString("opt_arm"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (arm_button != 0xFF))
- msg2 = GetButtonName(arm_button);
- else
- msg2 = GetKeyName(arm_key);
+ msg2 = GetKeyName(arm_key);
if (msg2 == NULL)
msg2 = "???";
}
@@ -5613,20 +5291,14 @@ void OptionsManager::DrawControls(uint32 surface_id) {
msg = screenRelative ? GetTextFromReference(HashString("opt_right")) : GetTextFromReference(HashString("opt_turnright"));
temp = CalculateStringWidth(msg);
- if (currentJoystick != NO_JOYSTICK)
- msg2 = GetAxisName(right_joy);
- else
- msg2 = GetKeyName(right_key);
+ msg2 = GetKeyName(right_key);
if (msg2 == NULL)
msg2 = "???";
} else {
msg = GetTextFromReference(HashString("opt_attack"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (fire_button != 0xFF))
- msg2 = GetButtonName(fire_button);
- else
- msg2 = GetKeyName(fire_key);
+ msg2 = GetKeyName(fire_key);
if (msg2 == NULL)
msg2 = "???";
}
@@ -5640,20 +5312,14 @@ void OptionsManager::DrawControls(uint32 surface_id) {
msg = GetTextFromReference(HashString("opt_run"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (run_button != 0xFF))
- msg2 = GetButtonName(run_button);
- else
- msg2 = GetKeyName(run_key);
+ msg2 = GetKeyName(run_key);
if (msg2 == NULL)
msg2 = "???";
} else {
msg = GetTextFromReference(HashString("opt_inventory"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (inventory_button != 0xFF))
- msg2 = GetButtonName(inventory_button);
- else
- msg2 = GetKeyName(inventory_key);
+ msg2 = GetKeyName(inventory_key);
if (msg2 == NULL)
msg2 = "???";
}
@@ -5667,20 +5333,14 @@ void OptionsManager::DrawControls(uint32 surface_id) {
msg = GetTextFromReference(HashString("opt_sidestep"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (sidestep_button != 0xFF))
- msg2 = GetButtonName(sidestep_button);
- else
- msg2 = GetKeyName(sidestep_key);
+ msg2 = GetKeyName(sidestep_key);
if (msg2 == NULL)
msg2 = "???";
} else {
msg = GetTextFromReference(HashString("opt_remora"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (remora_button != 0xFF))
- msg2 = GetButtonName(remora_button);
- else
- msg2 = GetKeyName(remora_key);
+ msg2 = GetKeyName(remora_key);
if (msg2 == NULL)
msg2 = "???";
}
@@ -5694,10 +5354,7 @@ void OptionsManager::DrawControls(uint32 surface_id) {
msg = GetTextFromReference(HashString("opt_pause"));
temp = CalculateStringWidth(msg);
- if ((currentJoystick != NO_JOYSTICK) && (pause_button != 0xFF))
- msg2 = GetButtonName(pause_button);
- else
- msg2 = GetKeyName(pause_key);
+ msg2 = GetKeyName(pause_key);
if (msg2 == NULL)
msg2 = "???";
@@ -6908,25 +6565,25 @@ void OptionsManager::PollInput() {
}
// Selection (up down input)
- if (Read_DI_keys(Common::KEYCODE_DOWN) || Read_DI_keys(down_key) || Read_Joystick(Y_AXIS) > 100) {
+ if (Read_DI_keys(Common::KEYCODE_DOWN) || Read_DI_keys(down_key)) {
MoveSelected(TRUE8);
- } else if (Read_DI_keys(Common::KEYCODE_UP) || Read_DI_keys(up_key) || Read_Joystick(Y_AXIS) < -100) {
+ } else if (Read_DI_keys(Common::KEYCODE_UP) || Read_DI_keys(up_key)) {
MoveSelected(FALSE8);
} else {
m_moveLimiter = FALSE8;
}
// Choose command
- if (Read_DI_keys(Common::KEYCODE_RETURN) || Read_DI_keys(fire_key) || Read_DI_keys(interact_key) || Read_Joystick(0)) {
+ if (Read_DI_keys(Common::KEYCODE_RETURN) || Read_DI_keys(fire_key) || Read_DI_keys(interact_key)) {
DoChoice();
} else {
m_choiceLimiter = FALSE8;
}
// Alter current selection (left right input)
- if (Read_DI_keys(Common::KEYCODE_LEFT) || Read_DI_keys(left_key) || Read_Joystick(X_AXIS) < -100) {
+ if (Read_DI_keys(Common::KEYCODE_LEFT) || Read_DI_keys(left_key)) {
AlterSelected(FALSE8);
- } else if (Read_DI_keys(Common::KEYCODE_RIGHT) || Read_DI_keys(right_key) || Read_Joystick(X_AXIS) > 100) {
+ } else if (Read_DI_keys(Common::KEYCODE_RIGHT) || Read_DI_keys(right_key)) {
AlterSelected(TRUE8);
} else {
m_alterLimiter = FALSE8;
@@ -7152,7 +6809,7 @@ void OptionsManager::DrawSlideShow() {
char slideFile[128];
// Quit
- if (Read_DI_once_keys(Common::KEYCODE_ESCAPE) || Read_Joystick_once(pause_button)) {
+ if (Read_DI_once_keys(Common::KEYCODE_ESCAPE)) {
m_slideshowActive = FALSE8;
DrawWidescreenBorders();
return;
@@ -7210,14 +6867,14 @@ void OptionsManager::DrawSlideShow() {
// Could do an effect on the working buffer here
} else {
// Alter current visible slide (on left right input)
- if (Read_DI_keys(Common::KEYCODE_LEFT) || Read_DI_keys(left_key) || Read_Joystick(X_AXIS) < -100) {
+ if (Read_DI_keys(Common::KEYCODE_LEFT) || Read_DI_keys(left_key)) {
if (!m_slideLimiter) {
m_slideLimiter = TRUE8;
// Caught by the swap slide routine above
m_slideWadger = -WADGE_INCREMENTS;
}
- } else if (Read_DI_keys(Common::KEYCODE_RIGHT) || Read_DI_keys(right_key) || Read_Joystick(X_AXIS) > 100) {
+ } else if (Read_DI_keys(Common::KEYCODE_RIGHT) || Read_DI_keys(right_key)) {
if (!m_slideLimiter) {
m_slideLimiter = TRUE8;
@@ -7513,7 +7170,7 @@ int32 Crediter::DoScreen() {
bool8 onlastMovieFrame = FALSE8;
// Are we done
- if (m_endOfCredits == 0 || Read_DI_keys(Common::KEYCODE_ESCAPE) || Read_Joystick_once(pause_button)) {
+ if (m_endOfCredits == 0 || Read_DI_keys(Common::KEYCODE_ESCAPE)) {
if (m_logoAttached)
surface_manager->Kill_surface(m_logoSurfaceID);
if (m_movieBackdrop)
diff --git a/engines/icb/p4.cpp b/engines/icb/p4.cpp
index 0d9b977bd9..fc057f30b4 100644
--- a/engines/icb/p4.cpp
+++ b/engines/icb/p4.cpp
@@ -97,7 +97,7 @@ void _stub::Process_stub() {
// menu is reachable regardless of the players state (ie in conversation)
if (mode[stub] == __mission_and_console) {
{
- if ((Read_DI_once_keys(pause_key)) || (Read_Joystick_once(pause_button))) {
+ if (Read_DI_once_keys(pause_key)) {
if (!g_theOptionsManager->HasControl())
g_theOptionsManager->StartInGameOptions();
return;
diff --git a/engines/icb/p4_pc.cpp b/engines/icb/p4_pc.cpp
index f87d82fd0e..20e535db70 100644
--- a/engines/icb/p4_pc.cpp
+++ b/engines/icb/p4_pc.cpp
@@ -137,11 +137,6 @@ void ReadConfigFromIniFile() {
// Control device
temp = config.readIntSetting("Controller Settings", "Device", 0);
- if (temp == 0)
- currentJoystick = NO_JOYSTICK;
- else
- currentJoystick = ANALOGUE_JOYSTICK;
-
// A call to this will validate the above setting
Poll_direct_input();
@@ -197,51 +192,6 @@ void ReadConfigFromIniFile() {
if (GetKeyName((uint8)temp))
pause_key = (uint8)temp;
- // Unset all joystick
- UnsetJoystickConfig();
-
- // Joystick mappings
- temp = config.readIntSetting("Joystick Mappings", "Up", 0);
- if (GetAxisName((uint8)temp))
- up_joy = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Down", 0);
- if (GetAxisName((uint8)temp))
- down_joy = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Left", 0);
- if (GetAxisName((uint8)temp))
- left_joy = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Right", 0);
- if (GetAxisName((uint8)temp))
- right_joy = (uint8)temp;
-
- temp = config.readIntSetting("Joystick Mappings", "Sidestep", 0);
- if (GetButtonName((uint8)temp))
- sidestep_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Run", 0);
- if (GetButtonName((uint8)temp))
- run_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Crouch", 0);
- if (GetButtonName((uint8)temp))
- crouch_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Interact", 0);
- if (GetButtonName((uint8)temp))
- interact_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Arm", 0);
- if (GetButtonName((uint8)temp))
- arm_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Attack", 0);
- if (GetButtonName((uint8)temp))
- fire_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Inventory", 0);
- if (GetButtonName((uint8)temp))
- inventory_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Remora", 0);
- if (GetButtonName((uint8)temp))
- remora_button = (uint8)temp;
- temp = config.readIntSetting("Joystick Mappings", "Pause", 0);
- if (GetButtonName((uint8)temp))
- pause_button = (uint8)temp;
-
// Read the movie library settings
for (uint32 i = 0; i < TOTAL_NUMBER_OF_MOVIES; i++) {
temp = config.readIntSetting("Movie Library", pxVString("%X", HashString(g_movieLibrary[i].filename)), 0);
@@ -278,8 +228,6 @@ void Save_config_file() {
config.writeSetting("Video Settings", "Semitransparency", tempBuff);
sprintf(tempBuff, "%d", px.actorShadows);
- sprintf(tempBuff, "%d", currentJoystick);
- config.writeSetting("Controller Settings", "Device", pxVString("%d", currentJoystick));
sprintf(tempBuff, "%d", g_icb_session->player.Get_control_mode());
config.writeSetting("Controller Settings", "Method", pxVString("%d", g_icb_session->player.Get_control_mode()));
@@ -310,33 +258,6 @@ void Save_config_file() {
sprintf(tempBuff, "%d", pause_key);
config.writeSetting("Keyboard Mappings", "Pause", tempBuff);
- sprintf(tempBuff, "%d", up_joy);
- config.writeSetting("Joystick Mappings", "Up", tempBuff);
- sprintf(tempBuff, "%d", down_joy);
- config.writeSetting("Joystick Mappings", "Down", tempBuff);
- sprintf(tempBuff, "%d", left_joy);
- config.writeSetting("Joystick Mappings", "Left", tempBuff);
- sprintf(tempBuff, "%d", right_joy);
- config.writeSetting("Joystick Mappings", "Right", tempBuff);
- sprintf(tempBuff, "%d", sidestep_button);
- config.writeSetting("Joystick Mappings", "Sidestep", tempBuff);
- sprintf(tempBuff, "%d", run_button);
- config.writeSetting("Joystick Mappings", "Run", tempBuff);
- sprintf(tempBuff, "%d", crouch_button);
- config.writeSetting("Joystick Mappings", "Crouch", tempBuff);
- sprintf(tempBuff, "%d", interact_button);
- config.writeSetting("Joystick Mappings", "Interact", tempBuff);
- sprintf(tempBuff, "%d", arm_button);
- config.writeSetting("Joystick Mappings", "Arm", tempBuff);
- sprintf(tempBuff, "%d", fire_button);
- config.writeSetting("Joystick Mappings", "Attack", tempBuff);
- sprintf(tempBuff, "%d", inventory_button);
- config.writeSetting("Joystick Mappings", "Inventory", tempBuff);
- sprintf(tempBuff, "%d", remora_button);
- config.writeSetting("Joystick Mappings", "Remora", tempBuff);
- sprintf(tempBuff, "%d", pause_button);
- config.writeSetting("Joystick Mappings", "Pause", tempBuff);
-
char temp[1024];
// Has the game been completed
diff --git a/engines/icb/player_pc.cpp b/engines/icb/player_pc.cpp
index 719f19df65..965e89dbca 100644
--- a/engines/icb/player_pc.cpp
+++ b/engines/icb/player_pc.cpp
@@ -106,53 +106,44 @@ void _player::Update_input_state() {
// analogue devices
// Are we trying to find a new pan value
- static uint32 hunting = 0;
g_targetPan = 0;
g_playerPan = NEAREST_INT(log->pan * 4096.0f);
- int screenPan = 0;
int clastCameraPan = NEAREST_INT(lastCameraPan * 4096.0f);
int cdeltaCameraPan = NEAREST_INT(deltaCameraPan * 4096.0f);
int stairs = 0;
int ladders = 0;
- int turn_tolerance = STOOD_TURN_TOLERANCE;
- int hard_turn_tolerance = STOOD_HARD_TURN_TOLERANCE;
-
// Defaults
cur_state.turn = __NO_TURN;
cur_state.bitflag = 0;
- // Make sure we have a set to use !
- // Use lazy logic evaluation
- int haveCamera_ = MS->set.OK();
-
Poll_direct_input();
// Button controls are universal for all control modes
- if ((Read_DI_keys(fire_key)) || (Read_Joystick(fire_button))) // Attack
+ if (Read_DI_keys(fire_key)) // Attack
cur_state.SetButton(__ATTACK);
- if ((Read_DI_keys(interact_key)) || (Read_Joystick(interact_button))) // Interact
+ if (Read_DI_keys(interact_key)) // Interact
cur_state.SetButton(__INTERACT);
- if ((Read_DI_keys(inventory_key)) || (Read_Joystick(inventory_button))) // Inventory
+ if (Read_DI_keys(inventory_key)) // Inventory
cur_state.SetButton(__INVENTORY);
- if ((Read_DI_keys(arm_key)) || (Read_Joystick(arm_button))) // Arm/unarm
+ if (Read_DI_keys(arm_key)) // Arm/unarm
cur_state.SetButton(__ARMUNARM);
- if ((Read_DI_keys(remora_key)) || (Read_Joystick(remora_button))) // Remora
+ if (Read_DI_keys(remora_key)) // Remora
cur_state.SetButton(__REMORA);
- if ((Read_DI_keys(crouch_key)) || (Read_Joystick(crouch_button))) // Crouch
+ if (Read_DI_keys(crouch_key)) // Crouch
cur_state.SetButton(__CROUCH);
- if ((Read_DI_keys(sidestep_key)) || (Read_Joystick(sidestep_button))) // Sidestep
+ if (Read_DI_keys(sidestep_key)) // Sidestep
cur_state.SetButton(__SIDESTEP);
- if ((Read_DI_keys(run_key)) || (Read_Joystick(run_button))) // Jog
+ if (Read_DI_keys(run_key)) // Jog
cur_state.SetButton(__JOG);
// No control whilst sliding down a ladder !
@@ -180,414 +171,6 @@ void _player::Update_input_state() {
g_playerPan = NEAREST_INT(4096.0f * MS->stairs[stair_num].pan_ref);
}
- if (currentJoystick != NO_JOYSTICK) {
- // If we are in inventory or remora mode then we should accept input
- // from the keyboard by default (force attached joystick to digital)
- if ((player_status == REMORA) || (player_status == INVENTORY)) {
- // This mode will accept keyboard and joystick
- currentJoystick = DIGITAL_JOYSTICK;
- } else {
- // Set joystick type to whatever is attached
- currentJoystick = attachedJoystick;
-
- // Set control mode dependent on attached device
- if (currentJoystick != ANALOGUE_JOYSTICK) {
- // Force mode for digital control device
- Set_control_mode(ACTOR_RELATIVE);
- }
- }
-
- // Only allow SCREEN_RELATIVE control if we have an analogue device
- if ((Get_control_mode() == SCREEN_RELATIVE) && (haveCamera_ == 1)) {
- PXcamera &camera = MSS.GetCamera();
-
- int32 cameraPan = camera.pan;
-
- if ((cameraPan > 2048) || (cameraPan < -2048)) {
- // Make it +/- HALF_TURN
- if (cameraPan > 0)
- cameraPan -= 4096;
- else
- cameraPan += 4096;
- }
-
- screenPan = cameraPan;
-
- // Catch if the screen pan has never been set
- if (clastCameraPan > 2 * 4096) {
- screenPan = cameraPan;
- cdeltaCameraPan = 0;
- panCycle = 0;
- clastCameraPan = cameraPan;
- } else {
- // Have we changed camera angles ?
- if (clastCameraPan != cameraPan) {
- // Compute the new deltaCameraPan
- cdeltaCameraPan = cameraPan - screenPan;
- // Make -2048 -> 2048
- if (cdeltaCameraPan > 2048)
- cdeltaCameraPan -= 4096;
- else if (cdeltaCameraPan < -2048)
- cdeltaCameraPan += 4096;
-
- cdeltaCameraPan = cdeltaCameraPan / CAMERA_SMOOTH_CYCLES;
- panCycle = 0;
- }
-
- if (panCycle < CAMERA_SMOOTH_CYCLES) {
- screenPan += cdeltaCameraPan;
- panCycle++;
- } else {
- screenPan = cameraPan;
- }
- }
-
- // Read joystick values
- int x = Read_Joystick(Y_AXIS);
- int y = Read_Joystick(X_AXIS);
- int padlr = (x * x) + (y * y);
-
- // Set new direction to hunt for
- if (padlr > 0) {
- if (x == 0) {
- g_joyPan = 1024;
- } else {
- // This works jes' fine
- g_joyPan = NEAREST_INT((atan((float)y / (float)x) / TWO_PI) * 4096.0f);
- }
-
- if ((x < 0) && (y > 0))
- g_joyPan += 2048;
- if ((x <= 0) && (y <= 0))
- g_joyPan += 2048;
-
- // Directly down
- if (g_joyPan == 0)
- g_joyPan = 1;
-
- // Hunted for pan = g_joyPan - screenPan
- g_targetPan = g_joyPan - screenPan;
-
- // Make 0-4096
- g_targetPan = g_targetPan % 4096;
- // Looking for a new pan value
- hunting = 1;
- } else {
- // Within deadzone so reset all
- hunting = 0;
- g_joyPan = 0;
- g_targetPan = g_playerPan;
- cur_state.turn = __NO_TURN;
- cur_state.momentum = __STILL;
- }
-
- // If running then always running
- if (cur_state.IsButtonSet(__JOG)) {
- if (player_status == STOOD)
- cur_state.momentum = __FORWARD_1;
- else
- cur_state.momentum = __FORWARD_2;
- } else
- // Sidestep can be used as a brake
- if (cur_state.IsButtonSet(__SIDESTEP)) {
- if (player_status != STOOD)
- cur_state.momentum = __STILL;
- }
-
- if (hunting) {
- // Correct to get 0-4096
- if (g_playerPan < 0)
- g_playerPan += 4096;
-
- ASSERT1(((g_playerPan >= 0) && (g_playerPan <= 4096)), "Bad g_playerPan %d", g_playerPan);
-
- // So we should have a g_targetPan the character is trying to turn to
- int delta = g_targetPan - g_playerPan;
-
- delta = delta % 4096;
-
- if (delta > 2048)
- delta -= 4096;
- if (delta < -2048)
- delta += 4096;
-
- int absDelta = abs(delta);
-
- // Has the run been pressed
- if (cur_state.IsButtonSet(__JOG)) {
- // Not hunting for a pan value anymore
- hunting = 0;
-
- if (stairs == 1) {
- // No turning on stairs whilst running
- turn_tolerance = NO_TURN_TOLERANCE;
- // Run : go from stand -> walk -> run
- if (absDelta < FACING_FORWARDS) {
- if (player_status == STOOD_ON_STAIRS)
- cur_state.momentum = __FORWARD_1;
- else
- cur_state.momentum = __FORWARD_2;
- } else {
- // Turn LEFT or RIGHT you decide whilst running
- if (delta > turn_tolerance)
- cur_state.turn = __LEFT;
- else if (delta < -turn_tolerance)
- cur_state.turn = __RIGHT;
- }
- } else if (ladders == 1) {
- // RUN on ladder means slide down it fireman style
- cur_state.momentum = __FORWARD_2;
- } else {
- turn_tolerance = RUN_TURN_TOLERANCE;
-
- // Turn LEFT or RIGHT you decide whilst running
- if (delta > turn_tolerance)
- cur_state.turn = __LEFT;
- else if (delta < -turn_tolerance)
- cur_state.turn = __RIGHT;
- }
- } else if (cur_state.IsButtonSet(__SIDESTEP)) {
- hunting = 0;
-
- if (stairs == 1) {
- // No turning on stairs whilst running
- turn_tolerance = NO_TURN_TOLERANCE;
-
- // Run : go from stand -> walk -> run
- if (absDelta < FACING_FORWARDS) {
- if (player_status == STOOD_ON_STAIRS)
- cur_state.momentum = __FORWARD_1;
- else
- cur_state.momentum = __FORWARD_2;
- } else {
- // Turn LEFT or RIGHT you decide whilst running
- if (delta > turn_tolerance)
- cur_state.turn = __LEFT;
- else if (delta < -turn_tolerance)
- cur_state.turn = __RIGHT;
- }
- } else if (ladders == 1) {
- // RUN on ladder means slide down it fireman style
- cur_state.momentum = __FORWARD_2;
- } else {
- turn_tolerance = RUN_TURN_TOLERANCE;
-
- // The back facing 90 degrees is step backwards
- if (absDelta > FACING_BACKWARDS) {
- cur_state.momentum = __BACKWARD_1;
- }
- // So just left or right based on sign
- // This means sidestep left or right
- else {
- if (delta > 0)
- cur_state.turn = __LEFT;
- else
- cur_state.turn = __RIGHT;
- }
- }
- } else {
- // Nope, normal screen relative movement
-
- // Catch if not pressing run but running ! then start walking
- if (cur_state.momentum == __FORWARD_2) {
- cur_state.momentum = __FORWARD_1;
- }
-
- // Have different turn tolerances for standing and walking
- if (stairs == 1) {
- turn_tolerance = STAIR_TURN_TOLERANCE;
- } else if (ladders == 1) {
- // No turning on ladders
- turn_tolerance = NO_TURN_TOLERANCE;
- } else if (player_status == WALKING) {
- turn_tolerance = WALK_TURN_TOLERANCE;
- } else {
- turn_tolerance = STOOD_TURN_TOLERANCE;
- hard_turn_tolerance = STOOD_HARD_TURN_TOLERANCE;
- }
-
- // Get these checks dealt with first
- if (ladders == 1) {
- // Just need to test for going down the ladder i.e. BACKWARDS
- if (absDelta > FACING_BACKWARDS) {
- cur_state.momentum = __BACKWARD_1;
- } else if (absDelta < FACING_FORWARDS) {
- cur_state.momentum = __FORWARD_1;
- }
-
- return;
- }
-
- // Turn LEFT or RIGHT you decide
- if (delta > hard_turn_tolerance) {
- cur_state.turn = __HARD_LEFT;
- } else if (delta < -hard_turn_tolerance) {
- cur_state.turn = __HARD_RIGHT;
- } else if (delta > turn_tolerance) {
- cur_state.turn = __LEFT;
- } else if (delta < -turn_tolerance) {
- cur_state.turn = __RIGHT;
- }
- // So at the right direction start walking
- else {
- if (ladders == 1) {
- // Just need to test for going down the ladder i.e. BACKWARDS
- if (absDelta > FACING_BACKWARDS) {
- cur_state.momentum = __BACKWARD_1;
- } else if (absDelta < FACING_FORWARDS) {
- cur_state.momentum = __FORWARD_1;
- }
- } else if ((stairs == 0) || (absDelta < FACING_FORWARDS)) {
- hunting = 0;
-
- // Are past the dead zone
- if (padlr > 0) {
- // Walk
- cur_state.momentum = __FORWARD_1;
- }
- }
- }
- }
- } // if(hunting)
- else if (ladders == 1) {
- // RUN on ladder means slide down it fireman style
- if (cur_state.IsButtonSet(__JOG)) {
- cur_state.momentum = __FORWARD_2;
- }
- }
-
- // Can only use HARD_LEFT & HARD_RIGHT when STOOD
- if (player_status != STOOD) {
- if (cur_state.turn == __HARD_LEFT)
- cur_state.turn = __LEFT;
- else if (cur_state.turn == __HARD_RIGHT)
- cur_state.turn = __RIGHT;
- }
- } // Get_control_mode() == SCREEN_RELATIVE
-
- if (Get_control_mode() == ACTOR_RELATIVE) {
- // Don't need to draw this
- _DRAWCOMPASS_ = 0;
-
- // Two modes of actor relative, analogue and digital
- if (currentJoystick == ANALOGUE_JOYSTICK) {
- int x = Read_Joystick(X_AXIS);
- int y = Read_Joystick(Y_AXIS);
- int padlr = (x * x) + (y * y);
-
- // If running then always running
- if (cur_state.IsButtonSet(__JOG)) {
- if (player_status == STOOD)
- cur_state.momentum = __FORWARD_1;
- else
- cur_state.momentum = __FORWARD_2;
-
- // Turn left/right whilst walking/running
- if (padlr > SECOND_ZONE) {
- if (x < 0)
- cur_state.turn = __LEFT;
- else
- cur_state.turn = __RIGHT;
- }
- } else
- // Are we out of the deadzone
- if (padlr > 0) {
- // We want to turn right
- if (x > 0) {
- // We want to turn right fast
- if (x > SECOND_ZONE) {
- // Only allowed to hard turn when stood still and not sidestepping
- if ((cur_state.momentum == __STILL) && (!cur_state.IsButtonSet(__SIDESTEP))) {
- // Also consider button restraints
- if (cur_state.IsButtonSet(__ARMUNARM) || cur_state.IsButtonSet(__CROUCH))
- cur_state.turn = __RIGHT;
- else
- cur_state.turn = __HARD_RIGHT;
- } else
- cur_state.turn = __RIGHT;
- }
- // Turn right
- else
- cur_state.turn = __RIGHT;
- } else
- // We want to turn left
- if (x < 0) {
- // We want to turn left fast
- if (x < -SECOND_ZONE) {
- // Only allowed to hard turn when stood still and not sidestepping
- if ((cur_state.momentum == __STILL) && (!cur_state.IsButtonSet(__SIDESTEP))) {
- // Also consider button restraints
- if (cur_state.IsButtonSet(__ARMUNARM) || cur_state.IsButtonSet(__CROUCH))
- cur_state.turn = __LEFT;
- else
- cur_state.turn = __HARD_LEFT;
- } else
- cur_state.turn = __LEFT;
- }
- // Turn left
- else
- cur_state.turn = __LEFT;
- }
- // Don't want to turn at all
- else
- cur_state.turn = __NO_TURN;
-
- // We want move forward
- if (y < 0) {
- // Can't move forward with sidestep held (unless on stairs or ladders)
- if (cur_state.IsButtonSet(__SIDESTEP) && stairs == 0 && ladders == 0) {
- cur_state.momentum = __STILL;
- } else
- // We want to walk
- cur_state.momentum = __FORWARD_1;
- } else
- // We want to move backwards
- if (y > 0) {
- cur_state.momentum = __BACKWARD_1;
- }
- // Don't want to move
- else
- cur_state.momentum = __STILL;
- } else {
- // Within deadzone so don't move or turn
- cur_state.momentum = __STILL;
- cur_state.turn = __NO_TURN;
- }
- } // End of Analogue actor relative controls
- else {
- // Digital actor relative controls (same as keys)
- // If running then always running
- if (cur_state.IsButtonSet(__JOG)) {
- if (player_status == STOOD)
- cur_state.momentum = __FORWARD_1;
- else
- cur_state.momentum = __FORWARD_2;
- } else
- // Forward/backward - one or the other
- if ((Read_DI_keys(up_key)) || (Read_Joystick(Y_AXIS) == JOY_UP)) {
- // Can't move forward with sidestep held (unless on stairs or ladders)
- if (cur_state.IsButtonSet(__SIDESTEP) && stairs == 0 && ladders == 0) {
- cur_state.momentum = __STILL;
- } else
- // We want to walk
- cur_state.momentum = __FORWARD_1;
- } else if ((Read_DI_keys(down_key)) || (Read_Joystick(Y_AXIS) == JOY_DOWN))
- cur_state.momentum = __BACKWARD_1;
- else
- cur_state.momentum = __STILL;
-
- // Left/right
- if ((Read_DI_keys(left_key)) || (Read_Joystick(X_AXIS) == JOY_LEFT)) {
- cur_state.turn = __LEFT;
- } else if ((Read_DI_keys(right_key)) || (Read_Joystick(X_AXIS) == JOY_RIGHT)) {
- cur_state.turn = __RIGHT;
- } else
- cur_state.turn = __NO_TURN;
-
- } // End of Digital actor relative control
- }
-
- }
// No Joystick
else {
// Keyboard support (generic controls)
@@ -627,91 +210,6 @@ void _player::Update_input_state() {
}
void _player::DrawCompass() {
- // User can disable joystick in which case mode is forced to actor
- // relative and only the keys will work until the joystick is enabled
- if (currentJoystick != NO_JOYSTICK) {
- // Only draw compass in THREED mode and not while player is in inventory or remora mode
- if ((px.display_mode == THREED) && (player_status != REMORA) && (player_status != INVENTORY) && _DRAWCOMPASS_) {
- uint32 pitch;
- uint8 *ad;
-
-#define COMPASS_LENGTH 50.0f
-#define COMPASS_OX 60
-#define COMPASS_OY 420
-
- _rgb purple = {250, 60, 200, 0};
- _rgb turq = {0, 250, 250, 0};
- _rgb yellow = {250, 250, 0, 0};
-
- ad = surface_manager->Lock_surface(working_buffer_id);
- pitch = surface_manager->Get_pitch(working_buffer_id);
-
- if (g_joyPan == 0) {
- // Centered/Within deadzone (display a cross)
- General_draw_line_24_32(COMPASS_OX, COMPASS_OY - 5, COMPASS_OX, COMPASS_OY + 5, &yellow, ad, pitch);
- General_draw_line_24_32(COMPASS_OX - 5, COMPASS_OY, COMPASS_OX + 5, COMPASS_OY, &yellow, ad, pitch);
- } else {
- float theta = ((float)g_joyPan / 4096.0f) * TWO_PI;
-
- int x = NEAREST_INT(COMPASS_LENGTH * PXsin(theta));
- int y = NEAREST_INT(COMPASS_LENGTH * PXcos(theta));
-
- General_draw_line_24_32(COMPASS_OX, COMPASS_OY, (int16)(COMPASS_OX + x), (int16)(COMPASS_OY + y), &yellow, ad, pitch);
- }
-
- // Get the actor's screen position
- PXvector origin_world, origin_scrn;
- origin_world = log->mega->actor_xyz;
- bool8 result;
- PXcamera &camera = MSS.GetCamera();
- PXWorldToFilm(origin_world, camera, result, origin_scrn);
-
- PXvector point_world, point_scrn;
-
- int dx, dy;
-
- double s_ang, c_ang;
-
- s_ang = PXsin(((float)g_targetPan / 4096.0f) * TWO_PI);
- c_ang = PXcos(((float)g_targetPan / 4096.0f) * TWO_PI);
-
- int sang = FIXED_POINT_ANG(s_ang);
- int cang = FIXED_POINT_ANG(c_ang);
-
- point_world.x = (float)(origin_world.x + (COMPASS_LENGTH * sang / 4096));
- point_world.y = origin_world.y;
- point_world.z = (float)(origin_world.z + (COMPASS_LENGTH * cang / 4096));
-
- PXWorldToFilm(point_world, camera, result, point_scrn);
-
- dx = NEAREST_INT(point_scrn.x - origin_scrn.x);
- dy = NEAREST_INT(point_scrn.y - origin_scrn.y);
-
- CHECKDXDY(dx, dy)
-
- General_draw_line_24_32(COMPASS_OX, COMPASS_OY, (int16)(COMPASS_OX + dx), (int16)(COMPASS_OY - dy), &turq, ad, pitch);
-
- s_ang = PXsin(((float)g_playerPan / 4096.0f) * TWO_PI);
- c_ang = PXcos(((float)g_playerPan / 4096.0f) * TWO_PI);
-
- sang = FIXED_POINT_ANG(s_ang);
- cang = FIXED_POINT_ANG(c_ang);
-
- point_world.x = (float)(origin_world.x + (COMPASS_LENGTH * sang / 4096));
- point_world.y = origin_world.y;
- point_world.z = (float)(origin_world.z + (COMPASS_LENGTH * cang / 4096));
- PXWorldToFilm(point_world, camera, result, point_scrn);
-
- dx = NEAREST_INT(point_scrn.x - origin_scrn.x);
- dy = NEAREST_INT(point_scrn.y - origin_scrn.y);
-
- CHECKDXDY(dx, dy)
-
- General_draw_line_24_32(COMPASS_OX, COMPASS_OY, (int16)(COMPASS_OX + dx), (int16)(COMPASS_OY - dy), &purple, ad, pitch);
-
- surface_manager->Unlock_surface(working_buffer_id);
- }
- }
}
} // End of namespace ICB
More information about the Scummvm-git-logs
mailing list