keyhook.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 23 Mar 2016 16:47:24 -0400
branchgtkui
changeset 48 5b2b972c5078
parent 45 cf6a06f368e6
permissions -rw-r--r--
Added some debug code for keypresses.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
// !!! FIXME: this is X11 specific.  :(
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
#include <stdio.h>
45
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
     4
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
     5
#if 1
17
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
#include <stdlib.h>
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
#include <string.h>
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
#include <pthread.h>
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
#include <unistd.h>
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#include <X11/Xlib.h>
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
#include <X11/Xlibint.h>
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
#include <X11/extensions/record.h>
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
#include "keyhook.h"
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
static volatile int keyPressFlags = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
static volatile int sawKeyCombo = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
static void keyhookCallback(XPointer priv, XRecordInterceptData *data)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
{
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
    const xEvent *xev = (const xEvent *) data->data;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
    if (data->category == XRecordFromServer)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
    {
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
        if (xev->u.u.type == KeyPress)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
        {
48
5b2b972c5078 Added some debug code for keypresses.
Ryan C. Gordon <icculus@icculus.org>
parents: 45
diff changeset
    26
            const BYTE keycode = xev->u.u.detail;
5b2b972c5078 Added some debug code for keypresses.
Ryan C. Gordon <icculus@icculus.org>
parents: 45
diff changeset
    27
5b2b972c5078 Added some debug code for keypresses.
Ryan C. Gordon <icculus@icculus.org>
parents: 45
diff changeset
    28
            //printf("Pressed X11 keycode %u\n", (unsigned int) keycode);
5b2b972c5078 Added some debug code for keypresses.
Ryan C. Gordon <icculus@icculus.org>
parents: 45
diff changeset
    29
17
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
            // !!! FIXME: don't hardcode these keycodes.
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
            if ((keycode == 64) && (keyPressFlags == 0))
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
                keyPressFlags++;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
            else if ((keycode == 133) && (keyPressFlags == 1))
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
                keyPressFlags++;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
            else if ((keycode == 51) && (keyPressFlags == 2))
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
            {
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
                sawKeyCombo = 1;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
                keyPressFlags = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
            } // else if
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
            else
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
                keyPressFlags = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
        } // if
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
        else if (xev->u.u.type == KeyRelease)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
        {
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
            keyPressFlags = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
        } // else if
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
    } // if
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    XRecordFreeData(data);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
} // keyhookCallback
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
// every example I've seen needs two Display connections...one for the
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
//  keyhook, and one to control it.
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
static Display *ctrldpy = NULL;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
static Display *datadpy = NULL;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
static XRecordContext xrc = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
int initKeyHook(void)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
{
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    int major = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
    int minor = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
    XRecordRange *xrr = NULL;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
    XRecordClientSpec xrcs = XRecordAllClients;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
    if (ctrldpy)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
        return 0;  // already initialized.
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
    ctrldpy = XOpenDisplay(NULL);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
    if (!ctrldpy)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
        goto failed;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
    XSynchronize(ctrldpy, True);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
    datadpy = XOpenDisplay(NULL);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
    if (!datadpy)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
        goto failed;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
    else if (!XRecordQueryVersion(ctrldpy, &major, &minor))
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
        goto failed;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
    else if ((xrr = XRecordAllocRange()) == NULL)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
        goto failed;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
    memset(xrr, '\0', sizeof (*xrr));
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
    xrr->device_events.first = KeyPress;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
    xrr->device_events.last = KeyPress;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
    if ((xrc = XRecordCreateContext(ctrldpy, 0, &xrcs, 1, &xrr, 1)) == 0)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
        goto failed;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
    else if (!XRecordEnableContextAsync(datadpy, xrc, keyhookCallback, NULL))
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
        goto failed;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
    XFree(xrr);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
    xrr = NULL;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
    return 1;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
failed:
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
    deinitKeyHook();
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
    if (xrr) XFree(xrr);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
    return 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
} // initKeyHook
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
void deinitKeyHook(void)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
{
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
    if (ctrldpy)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
    {
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
        if (xrc)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
        {
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
            XRecordDisableContext(ctrldpy, xrc);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
            XRecordFreeContext(ctrldpy, xrc);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
        } // if
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
        XCloseDisplay(ctrldpy);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
    } // if
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
    if (datadpy)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
        XCloseDisplay(datadpy);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
    ctrldpy = NULL;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
    datadpy = NULL;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
    xrc = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
    sawKeyCombo = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
    keyPressFlags = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
} // deinitKeyHook
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
int pumpKeyHook(void)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
{
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
    if (!datadpy)
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
        return 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
    sawKeyCombo = 0;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
    XRecordProcessReplies(datadpy);
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
    return sawKeyCombo;
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
} // pumpKeyHook
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
45
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   138
#else
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   139
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   140
int initKeyHook(void) { return 1; }
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   141
void deinitKeyHook(void) {}
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   142
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   143
int pumpKeyHook(void)
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   144
{
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   145
static int x = 50;
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   146
const int retval = (x == 50);
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   147
if (++x > 50) x = 0;
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   148
if (retval) printf("fire it!\n");
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   149
return retval;
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   150
}
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   151
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   152
#endif
cf6a06f368e6 Moved to a more robust GTK UI.
Ryan C. Gordon <icculus@icculus.org>
parents: 17
diff changeset
   153
17
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
// end of keyhook.c ...
e884dbb403cc Added keyhook code, reworked things to use it.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155