Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

org_zoy_caca_Event.c 2.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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://www.wtfpl.net/ 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. }