void js_quit(void) { BYTE i; for (i = PORT1; i < PORT_MAX; i++) { js_close(&js[i]); } }
static int js_process_events(int joystick) { unsigned int size = sizeof(je); int j; int r; int tfd = timer_getfd(); if(tfd < 0) { size = sizeof(*je); } if((r = read(joystick_fd[joystick], je, size)) > 0) { for(j=0; j<r/sizeof(*je); ++j) { js_process_event(joystick, je+j); if(event_callback == GE_PushEvent) { return 1; } } if(r < 0 && errno != EAGAIN) { js_close(joystick); } } return 0; }
void js_quit() { int i; for(i=0; i<=max_joystick_id; ++i) { js_close(i); } }
int main (int argc, char **argv) { char *mname = ""; rb.buf = (char *) malloc ((unsigned) (rb.size = 0)); if (argc > 1) mname = argv[1]; if ((js = js_open (mname, 0)) == NULL) err (); if ((env = js_connect (js, "kana")) == NULL) err (); if ((fzk_file = js_file_read (env, FZK_FILE)) == -1) err (); if ((kihon_file = js_file_read (env, KIHON_DIC)) == -1) err (); if ((setto_file = js_file_read (env, SETTO_DIC)) == -1) err (); if (js_fuzokugo_set (env, fzk_file) == -1) err (); if ((kihon_dic_no = js_dic_add (env, kihon_file, -1, WNN_DIC_ADD_NOR, 1, WNN_DIC_RDONLY, WNN_DIC_RDONLY, NULL, NULL)) == -1) err (); if ((setto_dic_no = js_dic_add (env, setto_file, -1, WNN_DIC_ADD_NOR, 1, WNN_DIC_RDONLY, WNN_DIC_RDONLY, NULL, NULL)) == -1) err (); p_set (env); if ((rev_env = js_connect (js, "kanji")) == NULL) err (); if ((fzk_file = js_file_read (rev_env, FZK_FILE)) == -1) err (); if ((rev_file = js_file_read (rev_env, KIHON_DIC)) == -1) err (); if ((rev_setto_file = js_file_read (rev_env, SETTO_DIC)) == -1) err (); if (js_fuzokugo_set (rev_env, fzk_file) == -1) err (); if ((rev_dic_no = js_dic_add (rev_env, kihon_file, -1, WNN_DIC_ADD_REV, 1, WNN_DIC_RDONLY, WNN_DIC_RDONLY, NULL, NULL)) == -1) err (); if ((rev_setto_dic_no = js_dic_add (rev_env, setto_file, -1, WNN_DIC_ADD_REV, 1, WNN_DIC_RDONLY, WNN_DIC_RDONLY, NULL, NULL)) == -1) err (); p_set (rev_env); #ifdef DEBUG printf ("Now discard file push any key\n"); getchar (); js_file_discard (rev_env, rev_file); printf ("Now discard file\n"); #endif henkan (); js_close (js); }
BYTE js_read_event(_js_event *event, _js *joy) { SWORD bytes; BYTE size = sizeof(*event); if ((bytes = read(joy->fd, event, size)) == size) { return (EXIT_OK); } if (errno == ENODEV) { js_close(joy); } return (EXIT_ERROR); }
int main ( int argc, char** argv ) { if( argc < 2 ) { fprintf( stderr, "Please specify a joystick device file\n" ); return 1; } Joystick* joy = js_open( argv[1] ); if( joy == NULL ) { fprintf( stderr, "Opening of %s failed\n", argv[1] ); return 1; } printf( "Joystick Name: %s\n", joy->name ); printf( "Axes count: %d\n", joy->axis_count ); printf( "Button count: %d\n", joy->button_count ); js_close( joy ); return 0; }