Beispiel #1
2
int main1()
{
    int handle, status;
    uint32_t *ip, *pBuf;
    uint32_t maxEvBlk = 4;
    // uint64_t split = 230;
    uint64_t split = 100;


    printf("\nEvent I/O tests...\n");
    status = evOpen("/tmp/firstEventTestC.ev", "s", &handle);
    printf ("    Opened /tmp/firstEventTest.ev, status = %d\n", status);

    status = evIoctl(handle, "N", (void *) (&maxEvBlk));
    printf ("    Changed max events/block to %d, status = %#x\n", maxEvBlk, status);

    status = evIoctl(handle, "S", (void *) (&split));
    printf ("    Changed split to %d, status = %#x\n", split, status);

    printf ("    Write dictionary, status = %d\n",status);
    status = evWriteDictionary(handle, dictionary);

    pBuf = makeFirstEvent(1);

    printf ("    Write first event, status = %d\n",status);
    status = evWriteFirstEvent(handle, pBuf);

    ip = makeEvent();

    printf ("    Write event 1, status = %d\n",status);
    status = evWrite(handle, ip);

    printf ("    Write event 2, status = %d\n",status);
    status = evWrite(handle, ip);

    printf ("    Write event 3, status = %d\n",status);
    status = evWrite(handle, ip);

    status = evClose(handle);
    printf ("    Closed file, status = %d\n\n", status);

    free(pBuf);
    free(ip);
}
Beispiel #2
0
int main(int argc, char **argv)
{
    int handle, status, nevents, nwords, debug=0;
    uint32_t *buffer;
    int i, maxEvBlk = 2;
    char *filename;


    /* The beginning "|" tells evio to open a pipe and write to that
     * so it goes to the stdin of evReadPipe. */
    filename = "|evReadPipe";
    filename = "-";
    

    if (debug) printf("Write to program = %s\n", filename+1);

    status = evOpen(filename, "w", &handle);
    if (debug) printf ("    Opened file, status = %d\n", status);

    status = evWriteDictionary(handle, dictionary);

    buffer = makeEvent();

    if (debug) printEvent(1, buffer);


    for (i=0; i < 3; i++) {
        status = evWrite(handle, buffer);
        if (debug) printf ("    Wrote event to file status = %d\n",status);
    }

    status = evClose(handle);
    if (debug) printf ("    evWritePipe: closed file, status = %d\n\n", status);
 
    free(buffer);
}
int ScriptEngine::onPlayerLeaveChan(int id, int chan)
{
    makeEvent("onPlayerLeaveChan", id, chan);
    return true;
}
int ScriptEngine::onPlayerRemoved(int id)
{
    makeEvent("onPlayerRemoved", id);
    return true;
}
int ScriptEngine::afterPMReceived(int id, const QString &message)
{
    makeEvent("afterPMReceived", id, message);
    return true;
}
int ScriptEngine::afterNewMessage(const QString &message, bool html)
{
    makeEvent("afterNewMessage", message, html);
    return true;
}
int ScriptEngine::afterChannelMessage(const QString &message, int channel, bool html)
{
    makeEvent("afterChannelMessage", message, channel, html);
    return true;
}
void BattleScripting::onSendOut(int spot, int previndex, ShallowBattlePoke *pokemon, bool silent)
{
    PokeProxy *p = new PokeProxy(pokemon);
    makeEvent("onSendOut", spot, previndex, qScriptValueFromValue<PokeProxy*>(myengine, p), silent);
    delete p;
}
Beispiel #9
0
int main (int argc, char *argv[])
{

    char *device = NULL;

    int fd;

    int c;

    struct input_event event;

    int num = -1;
    int caps = -1;
    int scroll = -1;

    int tempValue;

    const struct option long_opts[] = {
      { "input", required_argument, NULL, 'i' },
      { "num", required_argument, NULL, 'n' },
      { "caps" , required_argument, NULL, 'c' },
      { "scroll"  , required_argument, NULL, 's' },
      { NULL, 0, NULL, 0 }
    };


    while ( (c = getopt_long(argc, argv, "i:n:c:s:", long_opts, NULL)) != EOF) {
        switch (c) {
            case 'i':
                device = optarg;
                break;
            case 'n':

                processValue(atoi(optarg),&num);
                break;
            case 'c':
                processValue(atoi(optarg),&caps);
                break;
		    case 's':
                processValue(atoi(optarg),&scroll);
                break;
            case '?':
                usage();
                return 0;

        }
    }


    if (device == NULL) {
        perror_exit("Not a valid input event device found");
    }

    if ((fd = open (device, O_RDWR | O_NONBLOCK)) == -1) {
        perror_exit("Unable to open input event device");
    }


    if (num != -1) {
        makeEvent(&event, LED_NUML, num);
        write(fd, &event, sizeof(struct input_event));
    }


    if (caps != -1) {
        makeEvent(&event, LED_CAPSL, caps);
        write(fd, &event, sizeof(struct input_event));
    }


    if (scroll != -1) {
        makeEvent(&event, LED_SCROLLL, scroll);
        write(fd, &event, sizeof(struct input_event));
    }


    return 0;

}