You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.1 KiB
103 lines
2.1 KiB
9 years ago
|
#ifndef _SWAY_KEY_STATE_H
|
||
|
#define _SWAY_KEY_STATE_H
|
||
|
#include <stdbool.h>
|
||
|
#include <stdint.h>
|
||
|
#include "container.h"
|
||
|
|
||
|
/* Keyboard state */
|
||
|
|
||
|
// returns true if key has been pressed, otherwise false
|
||
9 years ago
|
bool check_key(uint32_t key_sym, uint32_t key_code);
|
||
9 years ago
|
|
||
9 years ago
|
// returns true if key_sym matches latest released key.
|
||
|
bool check_released_key(uint32_t key_sym);
|
||
|
|
||
9 years ago
|
// sets a key as pressed
|
||
9 years ago
|
void press_key(uint32_t key_sym, uint32_t key_code);
|
||
9 years ago
|
|
||
|
// unsets a key as pressed
|
||
9 years ago
|
void release_key(uint32_t key_sym, uint32_t key_code);
|
||
9 years ago
|
|
||
9 years ago
|
|
||
9 years ago
|
/* Pointer state */
|
||
|
|
||
|
enum pointer_values {
|
||
|
M_LEFT_CLICK = 272,
|
||
|
M_RIGHT_CLICK = 273,
|
||
|
M_SCROLL_CLICK = 274,
|
||
|
M_SCROLL_UP = 275,
|
||
|
M_SCROLL_DOWN = 276,
|
||
|
};
|
||
|
|
||
9 years ago
|
enum pointer_mode {
|
||
|
// Target
|
||
9 years ago
|
M_FLOATING = 1,
|
||
|
M_TILING = 2,
|
||
9 years ago
|
// Action
|
||
9 years ago
|
M_DRAGGING = 4,
|
||
|
M_RESIZING = 8,
|
||
9 years ago
|
};
|
||
|
|
||
9 years ago
|
struct pointer_button_state {
|
||
|
bool held;
|
||
|
// state at the point it was pressed
|
||
|
int x, y;
|
||
|
swayc_t *view;
|
||
|
};
|
||
|
|
||
9 years ago
|
extern struct pointer_state {
|
||
9 years ago
|
// mouse clicks
|
||
9 years ago
|
struct pointer_button_state left;
|
||
|
struct pointer_button_state right;
|
||
|
struct pointer_button_state scroll;
|
||
9 years ago
|
|
||
9 years ago
|
// change in pointer position
|
||
9 years ago
|
struct {
|
||
|
int x, y;
|
||
|
} delta;
|
||
|
|
||
9 years ago
|
// view pointer is currently over
|
||
9 years ago
|
swayc_t *view;
|
||
|
|
||
|
// Pointer mode
|
||
|
int mode;
|
||
9 years ago
|
} pointer_state;
|
||
|
|
||
9 years ago
|
enum modifier_state {
|
||
|
MOD_STATE_UNCHANGED = 0,
|
||
|
MOD_STATE_PRESSED = 1,
|
||
|
MOD_STATE_RELEASED = 2
|
||
|
};
|
||
|
|
||
8 years ago
|
void pointer_position_set(double new_x, double new_y, bool force_focus);
|
||
9 years ago
|
void center_pointer_on(swayc_t *view);
|
||
9 years ago
|
|
||
9 years ago
|
// on button release unset mode depending on the button.
|
||
|
// on button press set mode conditionally depending on the button
|
||
|
void pointer_mode_set(uint32_t button, bool condition);
|
||
|
|
||
|
// Update mode in mouse motion
|
||
|
void pointer_mode_update(void);
|
||
|
|
||
|
// Reset mode on any keypress;
|
||
|
void pointer_mode_reset(void);
|
||
|
|
||
9 years ago
|
void input_init(void);
|
||
9 years ago
|
|
||
9 years ago
|
/**
|
||
|
* Check if state of mod changed from current state to new_state.
|
||
|
*
|
||
|
* Returns MOD_STATE_UNCHANGED if the state didn't change, MOD_STATE_PRESSED if
|
||
|
* the state changed to pressed and MOD_STATE_RELEASED if the state changed to
|
||
|
* released.
|
||
|
*/
|
||
|
uint32_t modifier_state_changed(uint32_t new_state, uint32_t mod);
|
||
|
|
||
|
/**
|
||
|
* Update the current modifiers state to new_state.
|
||
|
*/
|
||
|
void modifiers_state_update(uint32_t new_state);
|
||
|
|
||
9 years ago
|
#endif
|
||
|
|