aboutsummaryrefslogtreecommitdiffstats
path: root/fakekey/fakekey.h
blob: da832235d12d56994aa15a147cebdc6ec160c727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef _HAVE_LIBFAKEKEY_H
#define _HAVE_LIBFAKEKEY_H

#include <stdio.h>
#include <stdlib.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <X11/keysymdef.h>
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#include <X11/Xos.h>
#include <X11/Xproto.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @defgroup FakeKey FakeKey - 
 * @brief yada yada yada
 *
 *
 * Always remember to release held keys
 * @{
 */


/**
 * @typedef FakeKey
 *
 * Opaque structure used for all operations. 
 */ 
typedef struct FakeKey FakeKey;

/**
 * @typedef FakeKeyModifier
 *
 * enumerated types for #mb_pixbuf_img_transform
 */
typedef enum
{
  FAKEKEYMOD_SHIFT   = (1<<1),
  FAKEKEYMOD_CONTROL = (1<<2),
  FAKEKEYMOD_ALT     = (1<<3),
  FAKEKEYMOD_META    = (1<<4)

} FakeKeyModifier;

/** 
 * Initiates FakeKey. 
 * 
 * @param xdpy X Display connection. 
 * 
 * @return new #FakeKey reference on success, NULL on fail.
 */
FakeKey*
fakekey_init(Display *xdpy);


/** 
 * Sends a Keypress to the server for the supplied UTF8 character.
 * 
 * @param fk            #FakeKey refernce from #fakekey_init
 * @param utf8_char_in  Pointer to a single UTF8 Character data.
 * @param len_bytes     Lenth in bytes of character, or -1 in ends with 0
 * @param modifiers     OR'd list of #FakeKeyModifier modifiers keys 
 *                      to press with the key.
 *                      
 * 
 * @return 
 */
int
fakekey_press(FakeKey       *fk, 
	      unsigned char *utf8_char_in,
	      int            len_bytes,
	      int            modifiers);

/** 
 *  Repreats a press of the currently held key ( from #fakekey_press )
 * 
 * @param fk #FakeKey refernce from #fakekey_init
 */
void
fakekey_repeat(FakeKey *fk);


/** 
 * Releases the currently held key ( from #fakekey_press )
 * 
 * @param fk #FakeKey refernce from #fakekey_init
 */
void
fakekey_release(FakeKey *fk);

/** 
 * Resyncs the internal list of keysyms with the server. 
 * Should be called if a MappingNotify event is recieved. 
 *
 * @param fk #FakeKey refernce from #fakekey_init
 * 
 * @return 
 */
int
fakekey_reload_keysyms(FakeKey *fk);

/** 
 * 
 * 
 * @param fk        #FakeKey refernce from #fakekey_init
 * @param keycode   X Keycode to send
 * @param is_press  Is this a press ( or release )
 * @param modifiers 
 * 
 * @return 
 */
int 
fakekey_send_keyevent(FakeKey *fk, 
		      KeyCode  keycode,
		      Bool     is_press,
		      int      modifiers);

/** @} */

#ifdef __cplusplus
}
#endif

#endif /* _HAVE_LIBFAKEKEY_H */