mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-09 04:49:39 -10:00
Locale Sensitive Controls and Textfield Input + Add Keyboard Layout sensitive InputBoxes + Remove obsolete helper function * Fig [] usage and remove old keybinding names + Fix Compile Warnings + Fix Compile Warnings 2 + Fix Clang Warnings + Fix faulty style + remove lambda + Change reverse-lookup map to iterating function + Added controlconfigdefault.tbl generator + Fixed gcc warning + Fixed msvc warning + make debug console keyboard layout independent + Expand DCF Functionality for saving control presets + Address Issues * Controls/update tbl (#5) Updates controlconfigdefaults.tbl to write Primary and Secondary bindings. * Added Scripting Hooks for controlsconfigdefault.tbl (#6) * Handle Asserted Switch cases * Controls is a library and should be in the libs folder * Add Lock & EnableScripting Functionality and expose it to scripting API * Added scripting isLocked * Move Key Hooks to register-able callback * Add option to remove hook * Repurpose CCI.used for Axes * Morph bitfield into a singleton class * Add encoding conversion helpers + Add keyname conversion if needed + Merge refactored encoding functions + Change keycode encoding call + remove bad type modifier + Move Conversion functions to util/unicode + Change Encoding Enum to Enum Class + Adapt KeyName call for encoding enum class + Fix Warning due to enum class + Change validation to own function * Make mActionToVal Assertion more helpful * Fix typo * Fix style * Use constant, not magic number * Document Ignored_keys[] * Doxy class controls_lua_override_cache a bit better * Put NameToVal safeties back in * Reorder the +Disable and $Disable: options, and be exclusive * Reorder the +Locked and $Loacked options, and be exclusive * Revert changes in ValToJoy * Revert errant duplicates * Refactor printJoyJSON() to use getJsonArray for consistency * Remove unused FS2toSDL map * Remove ADE_FUNC(AxisActionInverted) * Address gcc-5 issues * Remove unused param for textify_scancode * Declare textify_scancode_universal() in controlsconfig.h for use * Clean up textify_scancode() and *_universal() a smidge for clarity * Address most clang-9 issues * Modernize NULL to nullptr * Expand logic and document in controlsconfig::check_control() for clarity. * Fix typo * Remove unecassary static_cast * Use Assertion instead of Assert within control_config_common_read_section() * mprintf()'s need new lines! Co-authored-by: Birk Magnussen <[email protected]> Co-authored-by: Birk Magnussen <[email protected]>
121 lines
3.5 KiB
C
121 lines
3.5 KiB
C
/*
|
|
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
|
*
|
|
* All source code herein is the property of Volition, Inc. You may not sell
|
|
* or otherwise commercially exploit the source or things you created based on the
|
|
* source.
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MOUSE_H
|
|
#define _MOUSE_H
|
|
|
|
#include "controlconfig/controlsconfig.h"
|
|
#include "globalincs/pstypes.h"
|
|
|
|
extern int Mouse_sensitivity;
|
|
extern bool Use_mouse_to_fly;
|
|
|
|
// call once to init the mouse
|
|
void mouse_init();
|
|
|
|
extern void mouse_mark_button( uint flags, int set );
|
|
|
|
// Fills in xpos & ypos if not NULL.
|
|
// Returns Button states
|
|
// Always returns coordinates clipped to screen coordinates.
|
|
extern int mouse_get_pos( int *xpos, int *ypos );
|
|
// same as above but gets an unscaled reading (ie. the 1024x768/640x480 equivalent)
|
|
extern int mouse_get_pos_unscaled( int *xpos, int *ypos );
|
|
|
|
// get_real_pos could be negative.
|
|
extern void mouse_get_real_pos(int *mx, int *my);
|
|
|
|
extern void mouse_set_pos(int xpos,int ypos);
|
|
|
|
#define MOUSE_LEFT_BUTTON (1<<0)
|
|
#define MOUSE_RIGHT_BUTTON (1<<1)
|
|
#define MOUSE_MIDDLE_BUTTON (1<<2)
|
|
#define MOUSE_X1_BUTTON (1<<3)
|
|
#define MOUSE_X2_BUTTON (1<<4)
|
|
#define MOUSE_WHEEL_UP (1<<5) // Wheel is treated like a pair of buttons, but they don't have a down nor up count
|
|
#define MOUSE_WHEEL_DOWN (1<<6)
|
|
#define MOUSE_WHEEL_LEFT (1<<7)
|
|
#define MOUSE_WHEEL_RIGHT (1<<8)
|
|
|
|
#define MOUSE_NUM_BUTTONS 9
|
|
|
|
// keep the following #defines up to date with the #defines above
|
|
// These mouse_button defines are a quick check to verify the input button is a mouse button
|
|
// Likewise, the mouse_wheel defines quickly check against the mousewheel directions
|
|
#define LOWEST_MOUSE_BUTTON MOUSE_LEFT_BUTTON
|
|
#define HIGHEST_MOUSE_BUTTON MOUSE_X2_BUTTON
|
|
|
|
#define LOWEST_MOUSE_WHEEL MOUSE_WHEEL_UP
|
|
#define HIGHEST_MOUSE_WHEEL MOUSE_WHEEL_RIGHT
|
|
|
|
/**
|
|
* Checks how many times the given mouse button went down since last check
|
|
*
|
|
* @returns 0 if the CC_bind is not CID_MOUSE when Use_mouse_to_fly == false, or
|
|
* @returns 0 if the CC_bind is not CID_JOY0 when Use_mouse_to_fly == true, or
|
|
* @returns 0 if the button id >= NUM_MOUSE_BUTTONS, or
|
|
* @returns 0 if the button did not go down, or
|
|
*
|
|
* @returns the number of times the button went down
|
|
*/
|
|
int mouse_down_count(const CC_bind &bind, int reset_count = 1);
|
|
|
|
int mouse_down_count(int n, int reset_count = 1);
|
|
|
|
/**
|
|
* @brief Returns the number of times button n went from down to up since last call
|
|
*/
|
|
int mouse_up_count(const CC_bind &bind);
|
|
|
|
int mouse_up_count(int n);
|
|
|
|
/**
|
|
* @brief Flushes the mouse's states clean. Called whenever it gains/loses focus
|
|
*/
|
|
void mouse_flush();
|
|
|
|
/**
|
|
* Checks if the given mouse button is down
|
|
*
|
|
* @returns 0 if the CC_bind is not CID_MOUSE when Use_mouse_to_fly == false, or
|
|
* @returns 0 if the CC_bind is not CID_JOY0 when Use_mouse_to_fly == true, or
|
|
* @returns 0 if the button id >= NUM_MOUSE_BUTTONS, or
|
|
* @returns 0 if the button is not down, or
|
|
*
|
|
* @returns 1 if the given button is down
|
|
*/
|
|
int mouse_down(const CC_bind &bind);
|
|
|
|
/**
|
|
* Returns 1 if any of the given mouse buttons are down. 0 otherwise
|
|
*/
|
|
int mouse_down(int btn);
|
|
|
|
void mouse_reset_deltas();
|
|
void mouse_get_delta(int *dx = NULL, int *dy = NULL, int *dz = NULL);
|
|
|
|
void mouse_event(int x, int y, int dx, int dy);
|
|
|
|
/**
|
|
* Called when there is motion on the mouse wheel(s). Supports 2 axes
|
|
*/
|
|
void mousewheel_motion(int x, int y, bool reversed);
|
|
|
|
extern void mouse_force_pos(int x, int y);
|
|
|
|
/**
|
|
* Get the closest distance of a bit mask to 0
|
|
* @note use this to translate mouse button masks to button id's
|
|
*/
|
|
short bit_distance(short x);
|
|
|
|
#endif
|