25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

79 lines
2.1 KiB

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