GrafX2 2.9.3227
The ultimate 256-color painting program
|
#include <string.h>
#include <limits.h>
#include "gfx2log.h"
#include "global.h"
#include "keyboard.h"
#include "screen.h"
#include "windows.h"
#include "errors.h"
#include "misc.h"
#include "osdep.h"
#include "buttons.h"
#include "input.h"
#include "loadsave.h"
Macros | |
#define | PAD_MAX_SPEED 3 |
#define | D_JOYSTICK_UP (1 << 0) |
#define | D_JOYSTICK_UP_RIGHT (1 << 1) |
#define | D_JOYSTICK_RIGHT (1 << 2) |
#define | D_JOYSTICK_DOWN_RIGHT (1 << 3) |
#define | D_JOYSTICK_DOWN (1 << 4) |
#define | D_JOYSTICK_DOWN_LEFT (1 << 5) |
#define | D_JOYSTICK_LEFT (1 << 6) |
#define | D_JOYSTICK_UP_LEFT (1 << 7) |
#define | JOYSTICK_THRESHOLD (10000) |
This is the sensitivity threshold for the directional pad of a cheap digital joypad on the PC. More... | |
Functions | |
static int | Color_cycling (void) |
int | Has_shortcut (word function) |
Returns true if the function has any shortcut key. More... | |
int | Is_shortcut (word key, word function) |
Returns true if the keycode has been set as a keyboard shortcut for the function. More... | |
int | Move_cursor_with_constraints (int x, int y) |
Called each time there is a cursor move, either triggered by mouse or keyboard shortcuts. More... | |
int | Handle_mouse_btn_change (void) |
int | Handle_special_key_press (void) |
check Keys that emulate mouse moves, etc. More... | |
int | Release_control (int key_code, int modifier) |
static int | Cursor_displace (int step, long delta_x, long delta_y) |
Attempts to move the mouse cursor by the given deltas. More... | |
int | Directional_acceleration (int msec) |
static void | Mouse_Emulation () |
Emulate mouse move with Joystick or specific keys. More... | |
int | Get_input (int sleep_time) |
This is the keyboard/mouse/joystick input polling function. More... | |
void | Adjust_mouse_sensitivity (word fullscreen) |
Adjust mouse sensitivity (and actual mouse input mode) More... | |
Variables | |
int | Input_sticky_control = 0 |
This holds the ID of the GUI control that the mouse is manipulating. More... | |
int | Snap_axis = 0 |
Allows locking movement to X or Y axis: 0=normal, 1=lock on next move, 2=locked horizontally, 3=locked vertically. More... | |
int | Snap_axis_origin_X |
For the :Snap_axis mode, sets the origin's point (in image coordinates) More... | |
int | Snap_axis_origin_Y |
For the :Snap_axis mode, sets the origin's point (in image coordinates) More... | |
char * | Drop_file_name = NULL |
This malloced string is set when a drag-and-drop event brings a file to Grafx2's window. More... | |
word * | Drop_file_name_unicode = NULL |
static byte | Directional_click = 0 |
static byte | Digital_joystick_state = 0 |
static byte | Directional_emulated |
word | Input_new_mouse_X |
word | Input_new_mouse_Y |
word | Input_new_mouse_X_frac |
word | Input_new_mouse_Y_frac |
byte | Input_new_mouse_K |
byte | Button_inverter =0 |
long | Directional_first_move |
long | Directional_last_move |
int | Mouse_moved |
Boolean, Set to true if any cursor movement occurs. More... | |
byte | Pan_shortcut_pressed |
State of the shortcut for panning (SPECIAL_HOLD_PAN) : pressed or not. More... | |
short | Joybutton_shift =-1 |
A button that is marked as "modifier" will. More... | |
short | Joybutton_control =-1 |
Button number that serves as a "ctrl" modifier; -1 for none. More... | |
short | Joybutton_alt =-1 |
Button number that serves as a "alt" modifier; -1 for none. More... | |
short | Joybutton_left_click =0 |
Button number that serves as left click; -1 for none. More... | |
short | Joybutton_right_click =1 |
Button number that serves as right-click; -1 for none. More... | |
#define PAD_MAX_SPEED 3 |
#define D_JOYSTICK_UP (1 << 0) |
#define D_JOYSTICK_UP_RIGHT (1 << 1) |
#define D_JOYSTICK_RIGHT (1 << 2) |
#define D_JOYSTICK_DOWN_RIGHT (1 << 3) |
#define D_JOYSTICK_DOWN (1 << 4) |
#define D_JOYSTICK_DOWN_LEFT (1 << 5) |
#define D_JOYSTICK_LEFT (1 << 6) |
#define D_JOYSTICK_UP_LEFT (1 << 7) |
#define JOYSTICK_THRESHOLD (10000) |
This is the sensitivity threshold for the directional pad of a cheap digital joypad on the PC.
It has been set through trial and error : If value is too large then the movement is randomly interrupted; if the value is too low the cursor will move by itself, controlled by parasits. YR 04/11/2010: I just observed a -8700 when joystick is idle.
|
static |
References Allow_colorcycling, T_Document::backups, Cycling_mode, T_Gradient_range::End, GFX2_GetTicks(), GFX2_SetPalette(), T_Page::Gradients, T_Gradient_range::Inverse, Main, T_List_of_pages::Pages, T_Document::palette, T_Gradient_array::Range, T_Gradient_range::Speed, and T_Gradient_range::Start.
Referenced by Get_input().
int Has_shortcut | ( | word | function | ) |
Returns true if the function has any shortcut key.
References Buttons_Pool, Config_Key, and KEY_NONE.
Returns true if the keycode has been set as a keyboard shortcut for the function.
References Buttons_Pool, and Config_Key.
Referenced by Button_Airbrush_menu(), Button_Anim_time(), Button_Brush_FX(), Button_Colorize_menu(), Button_Constraint_menu(), Button_Copy_page(), Button_Effects(), Button_Gradients(), Button_Grid_menu(), Button_Layer_menu(), Button_Load_or_Save(), Button_Paintbrush_menu(), Button_Palette(), Button_Quick_shade_menu(), Button_Quit_local_function(), Button_Resolution(), Button_Secondary_palette(), Button_Settings(), Button_Sieve_menu(), Button_Skins(), Button_Smooth_menu(), Button_Stats(), Button_Text(), Button_Tilemap_menu(), Button_Tiling_menu(), Button_Transform_menu(), Handle_special_key_press(), Main_handler(), Menu_shade(), Menu_tag_colors(), Save_C64_window(), Save_MOTO_window(), and Window_help().
int Move_cursor_with_constraints | ( | int | x, |
int | y | ||
) |
Called each time there is a cursor move, either triggered by mouse or keyboard shortcuts.
x | new cursor X coordinate |
y | new cursor Y coordinate |
References Config, Current_operation, Hide_cursor, Input_new_mouse_X, Input_new_mouse_Y, T_Document::magnifier_mode, Main, Menu_Y, Mouse_K_unique, T_Config::Mouse_merge_movement, Mouse_moved, Mouse_X, Mouse_Y, Operation, Operation_in_magnifier, Operation_stack_size, Screen_height, Screen_width, T_Document::separator_position, Set_mouse_position(), and T_Document::X_zoom.
Referenced by Cursor_displace(), Get_input(), and Win32_WindowProc().
int Handle_mouse_btn_change | ( | void | ) |
References Hide_cursor, Input_new_mouse_K, Input_sticky_control, Mouse_K, and Mouse_moved.
Referenced by Get_input(), Handle_special_key_press(), Release_control(), and Win32_WindowProc().
int Handle_special_key_press | ( | void | ) |
check Keys that emulate mouse moves, etc.
References D_JOYSTICK_DOWN, D_JOYSTICK_LEFT, D_JOYSTICK_RIGHT, D_JOYSTICK_UP, Directional_click, Directional_emulated, Handle_mouse_btn_change(), Input_new_mouse_K, Is_shortcut(), Key, Keyboard_click_allowed, Pan_shortcut_pressed, SPECIAL_CLICK_LEFT, SPECIAL_CLICK_RIGHT, SPECIAL_HOLD_PAN, SPECIAL_MOUSE_DOWN, SPECIAL_MOUSE_LEFT, SPECIAL_MOUSE_RIGHT, and SPECIAL_MOUSE_UP.
Referenced by Get_input(), and Win32_WindowProc().
int Release_control | ( | int | key_code, |
int | modifier | ||
) |
References Button_inverter, Config, Config_Key, Directional_click, Directional_emulated, GFX2_MOD_SHIFT, Handle_mouse_btn_change(), Input_new_mouse_K, Pan_shortcut_pressed, Snap_axis, SPECIAL_CLICK_LEFT, SPECIAL_CLICK_RIGHT, SPECIAL_HOLD_PAN, SPECIAL_MOUSE_DOWN, SPECIAL_MOUSE_LEFT, SPECIAL_MOUSE_RIGHT, SPECIAL_MOUSE_UP, and T_Config::Swap_buttons.
Referenced by Get_input(), and Win32_WindowProc().
|
static |
Attempts to move the mouse cursor by the given deltas.
step | move multiply factor |
delta_x | 16.16 fixed point value |
delta_y | 16.16 fixed point value |
References Input_new_mouse_X, Input_new_mouse_X_frac, Input_new_mouse_Y, Input_new_mouse_Y_frac, T_Document::magnifier_factor, T_Document::magnifier_mode, Main, Move_cursor_with_constraints(), Screen_height, Screen_width, and T_Document::separator_position.
Referenced by Mouse_Emulation().
int Directional_acceleration | ( | int | msec | ) |
Referenced by Mouse_Emulation().
|
static |
Emulate mouse move with Joystick or specific keys.
References Cursor_displace(), D_JOYSTICK_DOWN, D_JOYSTICK_DOWN_LEFT, D_JOYSTICK_DOWN_RIGHT, D_JOYSTICK_LEFT, D_JOYSTICK_RIGHT, D_JOYSTICK_UP, D_JOYSTICK_UP_LEFT, D_JOYSTICK_UP_RIGHT, Digital_joystick_state, Directional_acceleration(), Directional_emulated, Directional_first_move, Directional_last_move, GFX2_GetTicks(), and PAD_MAX_SPEED.
Referenced by Get_input().
int Get_input | ( | int | sleep_time | ) |
This is the keyboard/mouse/joystick input polling function.
Returns 1 if a significant changed occurred, such as a mouse button pressed or depressed, or a new keypress was in the keyboard buffer. The latest input variables are held in Key, Key_ANSI, Key_UNICODE, Mouse_X, Mouse_Y, Mouse_K. Note that Key, Key_ANSI and Key_UNICODE are not persistent, they will be reset to 0 on subsequent calls to Get_input().
References Button_inverter, Color_cycling(), Compute_paintbrush_coordinates(), Config, Display_cursor(), Drop_file_name, Flush_update(), format, Get_Key_modifiers(), GFX2_DEBUG, GFX2_ERROR, GFX2_INFO, GFX2_Log(), GFX2_WARNING, GFX2_WINDOW_MAXIMIZED, GFX2_WINDOW_MINIMIZED, GFX2_WINDOW_STANDARD, Handle_mouse_btn_change(), Handle_special_key_press(), Input_new_mouse_K, Input_new_mouse_X, Input_new_mouse_Y, Key, Key_ANSI, KEY_MOUSEMIDDLE, KEY_MOUSEWHEELDOWN, KEY_MOUSEWHEELUP, Key_UNICODE, Mouse_Emulation(), Mouse_K, T_Config::Mouse_motion_debounce, Mouse_moved, Mouse_X, Mouse_Y, Move_cursor_with_constraints(), NULL, Pixel_height, Pixel_width, Quit_is_required, Release_control(), render_scale_x, render_scale_y, Resize_height, Resize_width, Update_rect(), user_feedback_required, T_Config::Window_pos_x, T_Config::Window_pos_y, Window_state, X11_display, and X11_window.
Referenced by Button_Anim_continuous_next(), Button_Anim_continuous_prev(), Button_Message_initial(), Button_Select_backcolor(), Button_Select_forecolor(), Curve_3_points_0_5(), Delay_with_active_mouse(), Dropdown_activate(), Get_color_behind_window(), GFX2_GetTextClipboard(), Load_ClipBoard_Image(), Main_handler(), Move_separator(), Move_window(), Readline_ex_unicode(), Redefine_control(), Tilemap_update(), Wait_click_in_palette(), Wait_click_in_shade_table(), Wait_end_of_click(), Window_clicked_button(), and Window_normal_button_onclick().
void Adjust_mouse_sensitivity | ( | word | fullscreen | ) |
Adjust mouse sensitivity (and actual mouse input mode)
Referenced by Init_mode_video().
int Input_sticky_control = 0 |
This holds the ID of the GUI control that the mouse is manipulating.
The input system will reset it to zero when mouse button is released, but it's the engine that will record and retrieve a real control ID.
Referenced by Button_Effects(), Button_Gradients(), Button_Palette(), Handle_mouse_btn_change(), Readline_ex_unicode(), Window_clicked_button(), and Window_get_clicked_button().
int Snap_axis = 0 |
Allows locking movement to X or Y axis: 0=normal, 1=lock on next move, 2=locked horizontally, 3=locked vertically.
Referenced by Compute_paintbrush_coordinates(), and Release_control().
int Snap_axis_origin_X |
For the :Snap_axis mode, sets the origin's point (in image coordinates)
Referenced by Compute_paintbrush_coordinates().
int Snap_axis_origin_Y |
For the :Snap_axis mode, sets the origin's point (in image coordinates)
Referenced by Compute_paintbrush_coordinates().
char* Drop_file_name = NULL |
This malloced string is set when a drag-and-drop event brings a file to Grafx2's window.
Referenced by Get_input(), Main_handler(), and Win32_WindowProc().
Referenced by Main_handler(), and Win32_WindowProc().
|
static |
Referenced by Handle_special_key_press(), and Release_control().
|
static |
Referenced by Mouse_Emulation().
|
static |
Referenced by Handle_special_key_press(), Mouse_Emulation(), and Release_control().
word Input_new_mouse_X |
Referenced by Cursor_displace(), Get_input(), and Move_cursor_with_constraints().
word Input_new_mouse_Y |
Referenced by Cursor_displace(), Get_input(), and Move_cursor_with_constraints().
word Input_new_mouse_X_frac |
Referenced by Cursor_displace().
word Input_new_mouse_Y_frac |
Referenced by Cursor_displace().
byte Input_new_mouse_K |
Referenced by Get_input(), Handle_mouse_btn_change(), Handle_special_key_press(), Release_control(), and Win32_WindowProc().
byte Button_inverter =0 |
Referenced by Get_input(), and Release_control().
long Directional_first_move |
Referenced by Mouse_Emulation().
long Directional_last_move |
Referenced by Mouse_Emulation().
int Mouse_moved |
Boolean, Set to true if any cursor movement occurs.
Referenced by Get_input(), Handle_mouse_btn_change(), and Move_cursor_with_constraints().
byte Pan_shortcut_pressed |
State of the shortcut for panning (SPECIAL_HOLD_PAN) : pressed or not.
Referenced by Handle_special_key_press(), Main_handler(), Pan_view_0_0(), Pan_view_0_2(), and Release_control().
short Joybutton_shift =-1 |
A button that is marked as "modifier" will.
Button number that serves as a "shift" modifier; -1 for none
short Joybutton_control =-1 |
Button number that serves as a "ctrl" modifier; -1 for none.
short Joybutton_alt =-1 |
Button number that serves as a "alt" modifier; -1 for none.
short Joybutton_left_click =0 |
Button number that serves as left click; -1 for none.
short Joybutton_right_click =1 |
Button number that serves as right-click; -1 for none.