source: libcaca/trunk/java/org_zoy_caca_Event.c @ 4197

Last change on this file since 4197 was 4197, checked in by Sam Hocevar, 10 years ago

Java bindings, courtesy of Adrien Grand <jpountz@dinauz.org>.

File size: 2.2 KB
Line 
1/**
2 *  libcaca       Java bindings for libcaca
3 *  Copyright (c) 2009 Adrien Grand <jpountz@dinauz.org>
4 *
5 *  $Id$
6 *
7 *  This library is free software. It comes without any warranty, to
8 *  the extent permitted by applicable law. You can redistribute it
9 *  and/or modify it under the terms of the Do What The Fuck You Want
10 *  To Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "org_zoy_caca_Event.h"
15
16#include <stdlib.h>
17#include "caca.h"
18
19JNIEXPORT jint JNICALL
20Java_org_zoy_caca_Event_getEventType(JNIEnv *env, jclass cls, jlong ptr)
21{
22  return (jint)caca_get_event_type((caca_event_t *)ptr);
23}
24
25JNIEXPORT jint JNICALL
26Java_org_zoy_caca_Event_getEventKeyCh(JNIEnv *env, jclass cls, jlong ptr)
27{
28  return caca_get_event_key_ch((caca_event_t *)ptr);
29}
30
31JNIEXPORT jint JNICALL
32Java_org_zoy_caca_Event_getEventKeyUtf32(JNIEnv *env, jclass cls, jlong ptr)
33{
34  return caca_get_event_key_utf32((caca_event_t *)ptr);
35}
36
37JNIEXPORT jstring JNICALL
38Java_org_zoy_caca_Event_getEventKeyUtf8(JNIEnv *env, jclass cls, jlong ptr)
39{
40  char *str = malloc(8 * sizeof(char));
41  caca_get_event_key_utf8((caca_event_t *)ptr, str);
42  return (*env)->NewStringUTF(env, str);
43}
44
45JNIEXPORT jint JNICALL
46Java_org_zoy_caca_Event_getEventMouseButton(JNIEnv *env, jclass cls, jlong ptr)
47{
48  return caca_get_event_mouse_button((caca_event_t *)ptr);
49}
50
51JNIEXPORT jint JNICALL
52Java_org_zoy_caca_Event_getEventMouseX(JNIEnv *env, jclass cls, jlong ptr)
53{
54  return caca_get_event_mouse_x((caca_event_t *)ptr);
55}
56
57JNIEXPORT jint JNICALL
58Java_org_zoy_caca_Event_getEventMouseY(JNIEnv *env, jclass cls, jlong ptr)
59{
60  return caca_get_event_mouse_y((caca_event_t *)ptr);
61}
62
63JNIEXPORT jint JNICALL
64Java_org_zoy_caca_Event_getEventResizeWidth(JNIEnv *env, jclass cls, jlong ptr)
65{
66  return caca_get_event_resize_width((caca_event_t *)ptr);
67}
68
69JNIEXPORT jint JNICALL
70Java_org_zoy_caca_Event_getEventResizeHeight(JNIEnv *env, jclass cls, jlong ptr)
71{
72  return caca_get_event_resize_height((caca_event_t *)ptr);
73}
74
75JNIEXPORT void JNICALL
76Java_org_zoy_caca_Event_freeEvent(JNIEnv *env, jclass cls, jlong ptr)
77{
78  caca_event_t *ev = (caca_event_t *)ptr;
79  free(ev);
80}
Note: See TracBrowser for help on using the repository browser.