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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #include "org_zoy_caca_Event.h"
  14. #include <stdlib.h>
  15. #include "caca.h"
  16. JNIEXPORT jint JNICALL
  17. Java_org_zoy_caca_Event_getEventType(JNIEnv *env, jclass cls, jlong ptr)
  18. {
  19. return (jint)caca_get_event_type((caca_event_t *)ptr);
  20. }
  21. JNIEXPORT jint JNICALL
  22. Java_org_zoy_caca_Event_getEventKeyCh(JNIEnv *env, jclass cls, jlong ptr)
  23. {
  24. return caca_get_event_key_ch((caca_event_t *)ptr);
  25. }
  26. JNIEXPORT jint JNICALL
  27. Java_org_zoy_caca_Event_getEventKeyUtf32(JNIEnv *env, jclass cls, jlong ptr)
  28. {
  29. return caca_get_event_key_utf32((caca_event_t *)ptr);
  30. }
  31. JNIEXPORT jstring JNICALL
  32. Java_org_zoy_caca_Event_getEventKeyUtf8(JNIEnv *env, jclass cls, jlong ptr)
  33. {
  34. char *str = malloc(8 * sizeof(char));
  35. caca_get_event_key_utf8((caca_event_t *)ptr, str);
  36. return (*env)->NewStringUTF(env, str);
  37. }
  38. JNIEXPORT jint JNICALL
  39. Java_org_zoy_caca_Event_getEventMouseButton(JNIEnv *env, jclass cls, jlong ptr)
  40. {
  41. return caca_get_event_mouse_button((caca_event_t *)ptr);
  42. }
  43. JNIEXPORT jint JNICALL
  44. Java_org_zoy_caca_Event_getEventMouseX(JNIEnv *env, jclass cls, jlong ptr)
  45. {
  46. return caca_get_event_mouse_x((caca_event_t *)ptr);
  47. }
  48. JNIEXPORT jint JNICALL
  49. Java_org_zoy_caca_Event_getEventMouseY(JNIEnv *env, jclass cls, jlong ptr)
  50. {
  51. return caca_get_event_mouse_y((caca_event_t *)ptr);
  52. }
  53. JNIEXPORT jint JNICALL
  54. Java_org_zoy_caca_Event_getEventResizeWidth(JNIEnv *env, jclass cls, jlong ptr)
  55. {
  56. return caca_get_event_resize_width((caca_event_t *)ptr);
  57. }
  58. JNIEXPORT jint JNICALL
  59. Java_org_zoy_caca_Event_getEventResizeHeight(JNIEnv *env, jclass cls, jlong ptr)
  60. {
  61. return caca_get_event_resize_height((caca_event_t *)ptr);
  62. }
  63. JNIEXPORT void JNICALL
  64. Java_org_zoy_caca_Event_freeEvent(JNIEnv *env, jclass cls, jlong ptr)
  65. {
  66. caca_event_t *ev = (caca_event_t *)ptr;
  67. free(ev);
  68. }