History

undo test commenting out code with preprocessor directives

Jack Atherton committed 7 years ago

Commit b91dd1e1 parent db1a1dd26 files · +7454 −7195Browse files

Showing the changes to src/core/chuck_lang.cpp (1 of 26 files). Show all

Unified · Split

src/core/chuck_lang.cpp+1314−1292
@@ -38,9 +38,16 @@ · 37 unmodified lines
3838 #include "chuck_vm.h"
3939 #include "chuck_errmsg.h"
4040 #include "chuck_ugen.h"
41−//#include "hidio_sdl.h"
41+
42+#ifndef __DISABLE_HID__
43+#include "hidio_sdl.h"
44+#endif
45+
4246 #include "util_string.h"
43−//#include "util_serial.h"
47+
48+#ifndef __DISABLE_SERIAL__
49+#include "util_serial.h"
50+#endif
4451
4552 #ifndef __DISABLE_MIDI__
4653 #include "midiio_rtmidi.h"
@@ -839,164 +846,166 @@ error: · 792 unmodified lines
839846
840847
841848
849+#ifndef __DISABLE_FILEIO__
842850 //-----------------------------------------------------------------------------
843851 // name: init_class_fileio()
844852 // desc: ...
845853 //-----------------------------------------------------------------------------
846−//t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type )
847−//{
848−// // init as base class
849−// Chuck_DL_Func * func = NULL;
850−//
851−// // log
852−// EM_log( CK_LOG_SEVERE, "class 'fileio'" );
853−//
854−// // init as base class
855−// // TODO: ctor/dtor?
856−// // TODO: replace dummy with pure function
857−// if( !type_engine_import_class_begin( env, type, env->global(), fileio_ctor, fileio_dtor ) )
858−// return FALSE;
859−//
860−// // add open(string)
861−// func = make_new_mfun( "int", "open", fileio_open );
862−// func->add_arg( "string", "path" );
863−// if( !type_engine_import_mfun( env, func ) ) goto error;
864−//
865−// // add open(string, flags)
866−// func = make_new_mfun( "int", "open", fileio_openflags );
867−// func->add_arg( "string", "path" );
868−// func->add_arg( "int", "flags" );
869−// if( !type_engine_import_mfun( env, func ) ) goto error;
870−//
871−// // add good()
872−// func = make_new_mfun( "int", "good", fileio_good );
873−// if( !type_engine_import_mfun( env, func ) ) goto error;
874−//
875−// // add close()
876−// func = make_new_mfun( "void", "close", fileio_close );
877−// if( !type_engine_import_mfun( env, func ) ) goto error;
878−//
879−// // add flush()
880−// func = make_new_mfun( "void", "flush", fileio_flush );
881−// if( !type_engine_import_mfun( env, func ) ) goto error;
882−//
883−// // add mode()
884−// func = make_new_mfun( "int", "mode", fileio_getmode );
885−// if( !type_engine_import_mfun( env, func ) ) goto error;
886−//
887−// // add mode(int)
888−// func = make_new_mfun( "int", "mode", fileio_setmode );
889−// func->add_arg( "int", "flag" );
890−// if( !type_engine_import_mfun( env, func ) ) goto error;
891−//
892−// // add size()
893−// func = make_new_mfun( "int", "size", fileio_size );
894−// if( !type_engine_import_mfun( env, func ) ) goto error;
895−//
896−// // add seek(int)
897−// func = make_new_mfun( "void", "seek", fileio_seek );
898−// func->add_arg( "int", "pos" );
899−// if( !type_engine_import_mfun( env, func ) ) goto error;
900−//
901−// // add tell()
902−// func = make_new_mfun( "int", "tell", fileio_tell );
903−// if( !type_engine_import_mfun( env, func ) ) goto error;
904−//
905−// // add isDir()
906−// func = make_new_mfun( "int", "isDir", fileio_isdir );
907−// if( !type_engine_import_mfun( env, func ) ) goto error;
908−//
909−// // add dirList()
910−// func = make_new_mfun( "string[]", "dirList", fileio_dirlist );
911−// if( !type_engine_import_mfun( env, func ) ) goto error;
912−//
913−// // add read()
914−// // func = make_new_mfun( "string", "read", fileio_read );
915−// // func->add_arg( "int", "length" );
916−// // if( !type_engine_import_mfun( env, func ) ) goto error;
917−//
918−// // add readLine()
919−// func = make_new_mfun( "string", "readLine", fileio_readline );
920−// if( !type_engine_import_mfun( env, func ) ) goto error;
921−//
922−// // add readInt()
923−// // func = make_new_mfun( "int", "readInt", fileio_readint );
924−// // if( !type_engine_import_mfun( env, func ) ) goto error;
925−//
926−// // add readInt(int)
927−// func = make_new_mfun( "int", "readInt", fileio_readintflags );
928−// func->add_arg( "int", "flags" );
929−// if( !type_engine_import_mfun( env, func ) ) goto error;
930−//
931−// // add readFloat()
932−// // func = make_new_mfun( "float", "readFloat", fileio_readfloat );
933−// // if( !type_engine_import_mfun( env, func ) ) goto error;
934−//
935−// // add eof()
936−// func = make_new_mfun( "int", "eof", fileio_eof );
937−// if( !type_engine_import_mfun( env, func ) ) goto error;
938−//
939−// // add more()
940−// func = make_new_mfun( "int", "more", fileio_more );
941−// if( !type_engine_import_mfun( env, func ) ) goto error;
942−//
943−// // add write(string)
944−// func = make_new_mfun( "void", "write", fileio_writestring );
945−// func->add_arg( "string", "val" );
946−// if( !type_engine_import_mfun( env, func ) ) goto error;
947−//
948−// // add write(int)
949−// func = make_new_mfun( "void", "write", fileio_writeint );
950−// func->add_arg( "int", "val" );
951−// if( !type_engine_import_mfun( env, func ) ) goto error;
952−//
953−// // add write(int,flags)
954−// func = make_new_mfun( "void", "write", fileio_writeintflags );
955−// func->add_arg( "int", "val" );
956−// func->add_arg( "int", "flags" );
957−// if( !type_engine_import_mfun( env, func ) ) goto error;
958−//
959−// // add write(float)
960−// func = make_new_mfun( "void", "write", fileio_writefloat );
961−// func->add_arg( "float", "val" );
962−// if( !type_engine_import_mfun( env, func ) ) goto error;
963−//
964−// // add FLAG_READ_WRITE
965−// if( !type_engine_import_svar( env, "int", "READ_WRITE",
966−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READ_WRITE ) ) goto error;
967−//
968−// // add FLAG_READONLY
969−// if( !type_engine_import_svar( env, "int", "READ",
970−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READONLY ) ) goto error;
971−//
972−// // add FLAG_WRITEONLY
973−// if( !type_engine_import_svar( env, "int", "WRITE",
974−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_WRITEONLY ) ) goto error;
975−//
976−// // add FLAG_APPEND
977−// if( !type_engine_import_svar( env, "int", "APPEND",
978−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_APPEND ) ) goto error;
979−//
980−// // add TYPE_ASCII
981−// if( !type_engine_import_svar( env, "int", "ASCII",
982−// TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_ASCII ) ) goto error;
983−//
984−// // add TYPE_BINARY
985−// if( !type_engine_import_svar( env, "int", "BINARY",
986−// TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_BINARY ) ) goto error;
987−//
988−// // end the class import
989−// type_engine_import_class_end( env );
990−//
991−// return TRUE;
992−//
993−//error:
994−//
995−// // end the class import
996−// type_engine_import_class_end( env );
997−//
998−// return FALSE;
999−//}
854+t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type )
855+{
856+ // init as base class
857+ Chuck_DL_Func * func = NULL;
858+
859+ // log
860+ EM_log( CK_LOG_SEVERE, "class 'fileio'" );
861+
862+ // init as base class
863+ // TODO: ctor/dtor?
864+ // TODO: replace dummy with pure function
865+ if( !type_engine_import_class_begin( env, type, env->global(), fileio_ctor, fileio_dtor ) )
866+ return FALSE;
867+
868+ // add open(string)
869+ func = make_new_mfun( "int", "open", fileio_open );
870+ func->add_arg( "string", "path" );
871+ if( !type_engine_import_mfun( env, func ) ) goto error;
872+
873+ // add open(string, flags)
874+ func = make_new_mfun( "int", "open", fileio_openflags );
875+ func->add_arg( "string", "path" );
876+ func->add_arg( "int", "flags" );
877+ if( !type_engine_import_mfun( env, func ) ) goto error;
878+
879+ // add good()
880+ func = make_new_mfun( "int", "good", fileio_good );
881+ if( !type_engine_import_mfun( env, func ) ) goto error;
882+
883+ // add close()
884+ func = make_new_mfun( "void", "close", fileio_close );
885+ if( !type_engine_import_mfun( env, func ) ) goto error;
886+
887+ // add flush()
888+ func = make_new_mfun( "void", "flush", fileio_flush );
889+ if( !type_engine_import_mfun( env, func ) ) goto error;
890+
891+ // add mode()
892+ func = make_new_mfun( "int", "mode", fileio_getmode );
893+ if( !type_engine_import_mfun( env, func ) ) goto error;
894+
895+ // add mode(int)
896+ func = make_new_mfun( "int", "mode", fileio_setmode );
897+ func->add_arg( "int", "flag" );
898+ if( !type_engine_import_mfun( env, func ) ) goto error;
899+
900+ // add size()
901+ func = make_new_mfun( "int", "size", fileio_size );
902+ if( !type_engine_import_mfun( env, func ) ) goto error;
903+
904+ // add seek(int)
905+ func = make_new_mfun( "void", "seek", fileio_seek );
906+ func->add_arg( "int", "pos" );
907+ if( !type_engine_import_mfun( env, func ) ) goto error;
908+
909+ // add tell()
910+ func = make_new_mfun( "int", "tell", fileio_tell );
911+ if( !type_engine_import_mfun( env, func ) ) goto error;
912+
913+ // add isDir()
914+ func = make_new_mfun( "int", "isDir", fileio_isdir );
915+ if( !type_engine_import_mfun( env, func ) ) goto error;
916+
917+ // add dirList()
918+ func = make_new_mfun( "string[]", "dirList", fileio_dirlist );
919+ if( !type_engine_import_mfun( env, func ) ) goto error;
920+
921+ // add read()
922+ // func = make_new_mfun( "string", "read", fileio_read );
923+ // func->add_arg( "int", "length" );
924+ // if( !type_engine_import_mfun( env, func ) ) goto error;
925+
926+ // add readLine()
927+ func = make_new_mfun( "string", "readLine", fileio_readline );
928+ if( !type_engine_import_mfun( env, func ) ) goto error;
929+
930+ // add readInt()
931+ // func = make_new_mfun( "int", "readInt", fileio_readint );
932+ // if( !type_engine_import_mfun( env, func ) ) goto error;
933+
934+ // add readInt(int)
935+ func = make_new_mfun( "int", "readInt", fileio_readintflags );
936+ func->add_arg( "int", "flags" );
937+ if( !type_engine_import_mfun( env, func ) ) goto error;
938+
939+ // add readFloat()
940+ // func = make_new_mfun( "float", "readFloat", fileio_readfloat );
941+ // if( !type_engine_import_mfun( env, func ) ) goto error;
942+
943+ // add eof()
944+ func = make_new_mfun( "int", "eof", fileio_eof );
945+ if( !type_engine_import_mfun( env, func ) ) goto error;
946+
947+ // add more()
948+ func = make_new_mfun( "int", "more", fileio_more );
949+ if( !type_engine_import_mfun( env, func ) ) goto error;
950+
951+ // add write(string)
952+ func = make_new_mfun( "void", "write", fileio_writestring );
953+ func->add_arg( "string", "val" );
954+ if( !type_engine_import_mfun( env, func ) ) goto error;
955+
956+ // add write(int)
957+ func = make_new_mfun( "void", "write", fileio_writeint );
958+ func->add_arg( "int", "val" );
959+ if( !type_engine_import_mfun( env, func ) ) goto error;
960+
961+ // add write(int,flags)
962+ func = make_new_mfun( "void", "write", fileio_writeintflags );
963+ func->add_arg( "int", "val" );
964+ func->add_arg( "int", "flags" );
965+ if( !type_engine_import_mfun( env, func ) ) goto error;
966+
967+ // add write(float)
968+ func = make_new_mfun( "void", "write", fileio_writefloat );
969+ func->add_arg( "float", "val" );
970+ if( !type_engine_import_mfun( env, func ) ) goto error;
971+
972+ // add FLAG_READ_WRITE
973+ if( !type_engine_import_svar( env, "int", "READ_WRITE",
974+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READ_WRITE ) ) goto error;
975+
976+ // add FLAG_READONLY
977+ if( !type_engine_import_svar( env, "int", "READ",
978+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READONLY ) ) goto error;
979+
980+ // add FLAG_WRITEONLY
981+ if( !type_engine_import_svar( env, "int", "WRITE",
982+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_WRITEONLY ) ) goto error;
983+
984+ // add FLAG_APPEND
985+ if( !type_engine_import_svar( env, "int", "APPEND",
986+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_APPEND ) ) goto error;
987+
988+ // add TYPE_ASCII
989+ if( !type_engine_import_svar( env, "int", "ASCII",
990+ TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_ASCII ) ) goto error;
991+
992+ // add TYPE_BINARY
993+ if( !type_engine_import_svar( env, "int", "BINARY",
994+ TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_BINARY ) ) goto error;
995+
996+ // end the class import
997+ type_engine_import_class_end( env );
998+
999+ return TRUE;
1000+
1001+error:
1002+
1003+ // end the class import
1004+ type_engine_import_class_end( env );
1005+
1006+ return FALSE;
1007+}
1008+#endif
10001009
10011010
10021011
@@ -1633,442 +1642,443 @@ error: · 630 unmodified lines
16331642
16341643
16351644
1636−//// static
1637−//static t_CKUINT HidIn_offset_data = 0;
1638−//
1639−//static t_CKUINT HidMsg_offset_device_type = 0;
1640−//static t_CKUINT HidMsg_offset_device_num = 0;
1641−//static t_CKUINT HidMsg_offset_type = 0;
1642−//static t_CKUINT HidMsg_offset_which = 0;
1643−//static t_CKUINT HidMsg_offset_idata = 0;
1644−//static t_CKUINT HidMsg_offset_fdata = 0;
1645−//static t_CKUINT HidMsg_offset_when = 0;
1646−//static t_CKUINT HidMsg_offset_deltax = 0;
1647−//static t_CKUINT HidMsg_offset_deltay = 0;
1648−//static t_CKUINT HidMsg_offset_axis_position = 0; // deprecated
1649−//static t_CKUINT HidMsg_offset_axis_position2 = 0;
1650−//static t_CKUINT HidMsg_offset_scaled_axis_position = 0; // deprecated
1651−//static t_CKUINT HidMsg_offset_hat_position = 0;
1652−//static t_CKUINT HidMsg_offset_cursorx = 0;
1653−//static t_CKUINT HidMsg_offset_cursory = 0;
1654−//static t_CKUINT HidMsg_offset_scaledcursorx = 0;
1655−//static t_CKUINT HidMsg_offset_scaledcursory = 0;
1656−//static t_CKUINT HidMsg_offset_x = 0;
1657−//static t_CKUINT HidMsg_offset_y = 0;
1658−//static t_CKUINT HidMsg_offset_z = 0;
1659−//static t_CKUINT HidMsg_offset_touchx = 0; // added 1.3.0.0
1660−//static t_CKUINT HidMsg_offset_touchy = 0; // added 1.3.0.0
1661−//static t_CKUINT HidMsg_offset_touchsize = 0; // added 1.3.0.0
1662−//static t_CKUINT HidMsg_offset_ascii = 0;
1663−//static t_CKUINT HidMsg_offset_key = 0;
1664−//
1665−//static t_CKUINT HidOut_offset_data = 0;
1666−
1667−////-----------------------------------------------------------------------------
1668−//// name: init_class_HID()
1669−//// desc: ...
1670−////-----------------------------------------------------------------------------
1671−//t_CKBOOL init_class_HID( Chuck_Env * env )
1672−//{
1673−// Chuck_DL_Func * func = NULL;
1674−//
1675−// // init base class
1676−// if( !type_engine_import_class_begin( env, "HidMsg", "Object",
1677−// env->global(), NULL, NULL ) )
1678−// return FALSE;
1679−//
1680−// // add member variable
1681−// HidMsg_offset_device_type = type_engine_import_mvar( env, "int", "deviceType", FALSE );
1682−// if( HidMsg_offset_device_type == CK_INVALID_OFFSET ) goto error;
1683−//
1684−// // add member variable
1685−// HidMsg_offset_device_num = type_engine_import_mvar( env, "int", "deviceNum", FALSE );
1686−// if( HidMsg_offset_device_num == CK_INVALID_OFFSET ) goto error;
1687−//
1688−// // add member variable
1689−// HidMsg_offset_type = type_engine_import_mvar( env, "int", "type", FALSE );
1690−// if( HidMsg_offset_type == CK_INVALID_OFFSET ) goto error;
1691−//
1692−// // add member variable
1693−// HidMsg_offset_which = type_engine_import_mvar( env, "int", "which", FALSE );
1694−// if( HidMsg_offset_which == CK_INVALID_OFFSET ) goto error;
1695−//
1696−// // add member variable
1697−// HidMsg_offset_idata = type_engine_import_mvar( env, "int", "idata", FALSE );
1698−// if( HidMsg_offset_idata == CK_INVALID_OFFSET ) goto error;
1699−//
1700−// // add member variable
1701−// HidMsg_offset_fdata = type_engine_import_mvar( env, "float", "fdata", FALSE );
1702−// if( HidMsg_offset_fdata == CK_INVALID_OFFSET ) goto error;
1703−//
1704−// // add member variable
1705−// HidMsg_offset_when = type_engine_import_mvar( env, "time", "when", FALSE );
1706−// if( HidMsg_offset_when == CK_INVALID_OFFSET ) goto error;
1707−//
1708−// // add member variable
1709−// HidMsg_offset_deltax = type_engine_import_mvar( env, "int", "deltaX", FALSE );
1710−// if( HidMsg_offset_deltax == CK_INVALID_OFFSET ) goto error;
1711−//
1712−// // add member variable
1713−// HidMsg_offset_deltay = type_engine_import_mvar( env, "int", "deltaY", FALSE );
1714−// if( HidMsg_offset_deltay == CK_INVALID_OFFSET ) goto error;
1715−//
1716−// // add member variable
1717−// HidMsg_offset_cursorx = type_engine_import_mvar( env, "int", "cursorX", FALSE );
1718−// if( HidMsg_offset_cursorx == CK_INVALID_OFFSET ) goto error;
1719−//
1720−// // add member variable
1721−// HidMsg_offset_cursory = type_engine_import_mvar( env, "int", "cursorY", FALSE );
1722−// if( HidMsg_offset_cursory == CK_INVALID_OFFSET ) goto error;
1723−//
1724−// // add member variable
1725−// HidMsg_offset_scaledcursorx = type_engine_import_mvar( env, "float", "scaledCursorX", FALSE );
1726−// if( HidMsg_offset_scaledcursorx == CK_INVALID_OFFSET ) goto error;
1727−//
1728−// // add member variable
1729−// HidMsg_offset_scaledcursory = type_engine_import_mvar( env, "float", "scaledCursorY", FALSE );
1730−// if( HidMsg_offset_scaledcursory == CK_INVALID_OFFSET ) goto error;
1731−//
1732−// // add member variable
1733−// HidMsg_offset_x = type_engine_import_mvar( env, "int", "x", FALSE );
1734−// if( HidMsg_offset_x == CK_INVALID_OFFSET ) goto error;
1735−//
1736−// // add member variable
1737−// HidMsg_offset_y = type_engine_import_mvar( env, "int", "y", FALSE );
1738−// if( HidMsg_offset_y == CK_INVALID_OFFSET ) goto error;
1739−//
1740−// // add member variable
1741−// HidMsg_offset_z = type_engine_import_mvar( env, "int", "z", FALSE );
1742−// if( HidMsg_offset_z == CK_INVALID_OFFSET ) goto error;
1743−//
1744−// // add member variable (added 1.3.0.0)
1745−// HidMsg_offset_touchx = type_engine_import_mvar( env, "float", "touchX", FALSE );
1746−// if( HidMsg_offset_touchx == CK_INVALID_OFFSET ) goto error;
1747−//
1748−// // add member variable (added 1.3.0.0)
1749−// HidMsg_offset_touchy = type_engine_import_mvar( env, "float", "touchY", FALSE );
1750−// if( HidMsg_offset_touchy == CK_INVALID_OFFSET ) goto error;
1751−//
1752−// // add member variable (added 1.3.0.0)
1753−// HidMsg_offset_touchsize = type_engine_import_mvar( env, "float", "touchSize", FALSE );
1754−// if( HidMsg_offset_touchsize == CK_INVALID_OFFSET ) goto error;
1755−//
1756−// // add member variable
1757−// HidMsg_offset_axis_position = type_engine_import_mvar( env, "int", "axis_position", FALSE );
1758−// if( HidMsg_offset_axis_position == CK_INVALID_OFFSET ) goto error;
1759−//
1760−// // add member variable
1761−// HidMsg_offset_axis_position2 = type_engine_import_mvar( env, "float", "axisPosition", FALSE );
1762−// if( HidMsg_offset_axis_position2 == CK_INVALID_OFFSET ) goto error;
1763−//
1764−// // add member variable
1765−// HidMsg_offset_hat_position = type_engine_import_mvar( env, "int", "hatPosition", FALSE );
1766−// if( HidMsg_offset_hat_position == CK_INVALID_OFFSET ) goto error;
1767−//
1768−// // add member variable
1769−// HidMsg_offset_ascii = type_engine_import_mvar( env, "int", "ascii", FALSE );
1770−// if( HidMsg_offset_ascii == CK_INVALID_OFFSET ) goto error;
1771−//
1772−// // add member variable
1773−// HidMsg_offset_key = type_engine_import_mvar( env, "int", "key", FALSE );
1774−// if( HidMsg_offset_key == CK_INVALID_OFFSET ) goto error;
1775−//
1776−// // add member variable
1777−// HidMsg_offset_scaled_axis_position = type_engine_import_mvar( env, "float", "scaled_axis_position", FALSE );
1778−// if( HidMsg_offset_scaled_axis_position == CK_INVALID_OFFSET ) goto error;
1779−//
1780−// // add is_axis_motion()
1781−// func = make_new_mfun( "int", "is_axis_motion", HidMsg_is_axis_motion ); // deprecated
1782−// if( !type_engine_import_mfun( env, func ) ) goto error;
1783−//
1784−// // add isAxisMotion()
1785−// func = make_new_mfun( "int", "isAxisMotion", HidMsg_is_axis_motion );
1786−// if( !type_engine_import_mfun( env, func ) ) goto error;
1787−//
1788−// // add is_button_down()
1789−// func = make_new_mfun( "int", "is_button_down", HidMsg_is_button_down ); // deprecated
1790−// if( !type_engine_import_mfun( env, func ) ) goto error;
1791−//
1792−// // add isButtonDown()
1793−// func = make_new_mfun( "int", "isButtonDown", HidMsg_is_button_down );
1794−// if( !type_engine_import_mfun( env, func ) ) goto error;
1795−//
1796−// // add is_button_up()
1797−// func = make_new_mfun( "int", "is_button_up", HidMsg_is_button_up ); // deprecated
1798−// if( !type_engine_import_mfun( env, func ) ) goto error;
1799−//
1800−// // add isButtonUp()
1801−// func = make_new_mfun( "int", "isButtonUp", HidMsg_is_button_up );
1802−// if( !type_engine_import_mfun( env, func ) ) goto error;
1803−//
1804−// // add is_mouse_motion()
1805−// func = make_new_mfun( "int", "is_mouse_motion", HidMsg_is_mouse_motion ); // deprecated
1806−// if( !type_engine_import_mfun( env, func ) ) goto error;
1807−//
1808−// // add isMouseMotion()
1809−// func = make_new_mfun( "int", "isMouseMotion", HidMsg_is_mouse_motion );
1810−// if( !type_engine_import_mfun( env, func ) ) goto error;
1811−//
1812−// // add is_hat_motion()
1813−// func = make_new_mfun( "int", "is_hat_motion", HidMsg_is_hat_motion ); // deprecated
1814−// if( !type_engine_import_mfun( env, func ) ) goto error;
1815−//
1816−// // add isHatMotion()
1817−// func = make_new_mfun( "int", "isHatMotion", HidMsg_is_hat_motion );
1818−// if( !type_engine_import_mfun( env, func ) ) goto error;
1819−//
1820−// // add isWheelMotion()
1821−// func = make_new_mfun( "int", "isWheelMotion", HidMsg_is_wheel_motion );
1822−// if( !type_engine_import_mfun( env, func ) ) goto error;
1823−//
1824−// // end the class import
1825−// type_engine_import_class_end( env );
1826−//
1827−//
1828−// // register deprecate
1829−// type_engine_register_deprecate( env, "HidIn", "Hid" );
1830−//
1831−// // init base class Hid (copy of HidIn + constants)
1832−// if( !type_engine_import_class_begin( env, "Hid", "Event",
1833−// env->global(), HidIn_ctor, HidIn_dtor ) )
1834−// return FALSE;
1835−//
1836−// // add open()
1837−// func = make_new_mfun( "int", "open", HidIn_open );
1838−// func->add_arg( "int", "type" );
1839−// func->add_arg( "int", "num" );
1840−// if( !type_engine_import_mfun( env, func ) ) goto error;
1841−//
1842−// // add open()
1843−// func = make_new_mfun( "int", "open", HidIn_open_named );
1844−// func->add_arg( "string", "name" );
1845−// if( !type_engine_import_mfun( env, func ) ) goto error;
1846−//
1847−// // add openJoystick()
1848−// func = make_new_mfun( "int", "openJoystick", HidIn_open_joystick );
1849−// func->add_arg( "int", "num" );
1850−// if( !type_engine_import_mfun( env, func ) ) goto error;
1851−//
1852−// // add openMouse()
1853−// func = make_new_mfun( "int", "openMouse", HidIn_open_mouse );
1854−// func->add_arg( "int", "num" );
1855−// if( !type_engine_import_mfun( env, func ) ) goto error;
1856−//
1857−// // add openKeyboard()
1858−// func = make_new_mfun( "int", "openKeyboard", HidIn_open_keyboard );
1859−// func->add_arg( "int", "num" );
1860−// if( !type_engine_import_mfun( env, func ) ) goto error;
1861−//
1862−// // add openTiltSensor()
1863−// func = make_new_mfun( "int", "openTiltSensor", HidIn_open_tiltsensor );
1864−// if( !type_engine_import_mfun( env, func ) ) goto error;
1865−//
1866−// // add good()
1867−// func = make_new_mfun( "int", "good", HidIn_good );
1868−// if( !type_engine_import_mfun( env, func ) ) goto error;
1869−//
1870−// // add num()
1871−// func = make_new_mfun( "int", "num", HidIn_num );
1872−// if( !type_engine_import_mfun( env, func ) ) goto error;
1873−//
1874−// // add name()
1875−// func = make_new_mfun( "string", "name", HidIn_name );
1876−// if( !type_engine_import_mfun( env, func ) ) goto error;
1877−//
1878−// // add printerr()
1879−// func = make_new_mfun( "void", "printerr", HidIn_printerr );
1880−// func->add_arg( "int", "print_or_not" );
1881−// if( !type_engine_import_mfun( env, func ) ) goto error;
1882−//
1883−// // add recv()
1884−// func = make_new_mfun( "int", "recv", HidIn_recv );
1885−// func->add_arg( "HidMsg", "msg" );
1886−// if( !type_engine_import_mfun( env, func ) ) goto error;
1887−//
1888−// // add read()
1889−// func = make_new_mfun( "int", "read", HidIn_read );
1890−// func->add_arg( "int", "type" );
1891−// func->add_arg( "int", "which" );
1892−// func->add_arg( "HidMsg", "msg" );
1893−// if( !type_engine_import_mfun( env, func ) ) goto error;
1894−//
1895−// // add send()
1896−// func = make_new_mfun( "int", "send", HidIn_send );
1897−// func->add_arg( "HidMsg", "msg" );
1898−// if( !type_engine_import_mfun( env, func ) ) goto error;
1899−//
1900−// // add can_wait()
1901−// func = make_new_mfun( "int", "can_wait", HidIn_can_wait );
1902−// if( !type_engine_import_mfun( env, func ) ) goto error;
1903−//
1904−// // add readTiltSensor()
1905−// func = make_new_sfun( "int[]", "readTiltSensor", HidIn_read_tilt_sensor );
1906−// if( !type_engine_import_sfun( env, func ) ) goto error;
1907−//
1908−// // add globalTiltPollRate()
1909−// func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_ctrl_tiltPollRate );
1910−// func->add_arg( "dur", "d" );
1911−// if( !type_engine_import_sfun( env, func ) ) goto error;
1912−//
1913−// // add globalTiltPollRate()
1914−// func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_cget_tiltPollRate );
1915−// if( !type_engine_import_sfun( env, func ) ) goto error;
1916−//
1917−// // add startCursorTrack()
1918−// func = make_new_sfun( "int", "startCursorTrack", HidIn_start_cursor_track );
1919−// if( !type_engine_import_sfun( env, func ) ) goto error;
1920−//
1921−// // add stopCursorTrack()
1922−// func = make_new_sfun( "int", "stopCursorTrack", HidIn_stop_cursor_track );
1923−// if( !type_engine_import_sfun( env, func ) ) goto error;
1924−//
1925−// // add member variable
1926−// HidIn_offset_data = type_engine_import_mvar( env, "int", "@Hid_data", FALSE );
1927−// if( HidIn_offset_data == CK_INVALID_OFFSET ) goto error;
1928−//
1929−// // add static member variable joystick
1930−// if( type_engine_import_svar( env, "int", "JOYSTICK", TRUE,
1931−// ( t_CKUINT ) &CK_HID_DEV_JOYSTICK ) == FALSE )
1932−// goto error;
1933−//
1934−// // add static member variable keyboard
1935−// if( type_engine_import_svar( env, "int", "KEYBOARD", TRUE,
1936−// ( t_CKUINT ) &CK_HID_DEV_KEYBOARD ) == FALSE )
1937−// goto error;
1938−//
1939−// // add static member variable mouse
1940−// if( type_engine_import_svar( env, "int", "MOUSE", TRUE,
1941−// ( t_CKUINT ) &CK_HID_DEV_MOUSE ) == FALSE )
1942−// goto error;
1943−//
1944−// // add static member variable wii_remote
1945−// if( type_engine_import_svar( env, "int", "WII_REMOTE", TRUE,
1946−// ( t_CKUINT ) &CK_HID_DEV_WIIREMOTE ) == FALSE )
1947−// goto error;
1948−//
1949−// // add static member variable wii_remote
1950−// if( type_engine_import_svar( env, "int", "TILT_SENSOR", TRUE,
1951−// ( t_CKUINT ) &CK_HID_DEV_TILTSENSOR ) == FALSE )
1952−// goto error;
1953−//
1954−// // add static member variable tablet
1955−// if( type_engine_import_svar( env, "int", "TABLET", TRUE,
1956−// ( t_CKUINT ) &CK_HID_DEV_TABLET ) == FALSE )
1957−// goto error;
1958−//
1959−// // add static member variable axisMotion
1960−// if( type_engine_import_svar( env, "int", "AXIS_MOTION", TRUE,
1961−// ( t_CKUINT ) &CK_HID_JOYSTICK_AXIS ) == FALSE )
1962−// goto error;
1963−//
1964−// // add static member variable buttonDown
1965−// if( type_engine_import_svar( env, "int", "BUTTON_DOWN", TRUE,
1966−// ( t_CKUINT ) &CK_HID_BUTTON_DOWN ) == FALSE )
1967−// goto error;
1968−//
1969−// // add static member variable buttonUp
1970−// if( type_engine_import_svar( env, "int", "BUTTON_UP", TRUE,
1971−// ( t_CKUINT ) &CK_HID_BUTTON_UP ) == FALSE )
1972−// goto error;
1973−//
1974−// // add static member variable joystickHat
1975−// if( type_engine_import_svar( env, "int", "JOYSTICK_HAT", TRUE,
1976−// ( t_CKUINT ) &CK_HID_JOYSTICK_HAT ) == FALSE )
1977−// goto error;
1978−//
1979−// // add static member variable JOYSTICK_BALL
1980−// if( type_engine_import_svar( env, "int", "JOYSTICK_BALL", TRUE,
1981−// ( t_CKUINT ) &CK_HID_JOYSTICK_BALL ) == FALSE )
1982−// goto error;
1983−//
1984−// // add static member variable mouseMotion
1985−// if( type_engine_import_svar( env, "int", "MOUSE_MOTION", TRUE,
1986−// ( t_CKUINT ) &CK_HID_MOUSE_MOTION ) == FALSE )
1987−// goto error;
1988−//
1989−// // add static member variable mouseWheel
1990−// if( type_engine_import_svar( env, "int", "MOUSE_WHEEL", TRUE,
1991−// ( t_CKUINT ) &CK_HID_MOUSE_WHEEL ) == FALSE )
1992−// goto error;
1993−//
1994−// // add static member variable DEVICE_CONNECTED
1995−// if( type_engine_import_svar( env, "int", "DEVICE_CONNECTED", TRUE,
1996−// ( t_CKUINT ) &CK_HID_DEVICE_CONNECTED ) == FALSE )
1997−// goto error;
1998−//
1999−// // add static member variable DEVICE_DISCONNECTED
2000−// if( type_engine_import_svar( env, "int", "DEVICE_DISCONNECTED", TRUE,
2001−// ( t_CKUINT ) &CK_HID_DEVICE_DISCONNECTED ) == FALSE )
2002−// goto error;
2003−//
2004−// // add static member variable ACCELEROMETER
2005−// if( type_engine_import_svar( env, "int", "ACCELEROMETER", TRUE,
2006−// ( t_CKUINT ) &CK_HID_ACCELEROMETER ) == FALSE )
2007−// goto error;
2008−//
2009−// // add static member variable LED
2010−// if( type_engine_import_svar( env, "int", "LED", TRUE,
2011−// ( t_CKUINT ) &CK_HID_LED ) == FALSE )
2012−// goto error;
2013−//
2014−// // add static member variable LED
2015−// if( type_engine_import_svar( env, "int", "FORCE_FEEDBACK", TRUE,
2016−// ( t_CKUINT ) &CK_HID_FORCE_FEEDBACK ) == FALSE )
2017−// goto error;
2018−//
2019−// // end the class import
2020−// type_engine_import_class_end( env );
2021−//
2022−// /*
2023−// // init base class
2024−// if( !type_engine_import_class_begin( env, "HidOut", "Object",
2025−// env->global(), HidOut_ctor ) )
2026−// return FALSE;
2027−//
2028−// // add open()
2029−// func = make_new_mfun( "int", "open", HidOut_open );
2030−// func->add_arg( "int", "port" );
2031−// if( !type_engine_import_mfun( env, func ) ) goto error;
2032−//
2033−// // add good()
2034−// func = make_new_mfun( "int", "good", HidOut_good );
2035−// if( !type_engine_import_mfun( env, func ) ) goto error;
2036−//
2037−// // add num()
2038−// func = make_new_mfun( "int", "num", HidOut_num );
2039−// if( !type_engine_import_mfun( env, func ) ) goto error;
2040−//
2041−// // add name()
2042−// func = make_new_mfun( "string", "name", HidOut_name );
2043−// if( !type_engine_import_mfun( env, func ) ) goto error;
2044−//
2045−// // add printerr()
2046−// func = make_new_mfun( "void", "printerr", HidOut_printerr );
2047−// func->add_arg( "int", "print_or_not" );
2048−// if( !type_engine_import_mfun( env, func ) ) goto error;
2049−//
2050−// // add send()
2051−// func = make_new_mfun( "int", "send", HidOut_send );
2052−// func->add_arg( "HidMsg", "msg" );
2053−// if( !type_engine_import_mfun( env, func ) ) goto error;
2054−//
2055−// // add member variable
2056−// HidOut_offset_data = type_engine_import_mvar( env, "int", "@HidOut_data", FALSE );
2057−// if( HidOut_offset_data == CK_INVALID_OFFSET ) goto error;
2058−//
2059−// // end the class import
2060−// type_engine_import_class_end( env );
2061−// */
2062−// return TRUE;
2063−//
2064−//error:
2065−//
2066−// // end the class import
2067−// type_engine_import_class_end( env );
2068−//
2069−// return FALSE;
2070−//}
1645+#ifndef __DISABLE_HID__
1646+// static
1647+static t_CKUINT HidIn_offset_data = 0;
1648+
1649+static t_CKUINT HidMsg_offset_device_type = 0;
1650+static t_CKUINT HidMsg_offset_device_num = 0;
1651+static t_CKUINT HidMsg_offset_type = 0;
1652+static t_CKUINT HidMsg_offset_which = 0;
1653+static t_CKUINT HidMsg_offset_idata = 0;
1654+static t_CKUINT HidMsg_offset_fdata = 0;
1655+static t_CKUINT HidMsg_offset_when = 0;
1656+static t_CKUINT HidMsg_offset_deltax = 0;
1657+static t_CKUINT HidMsg_offset_deltay = 0;
1658+static t_CKUINT HidMsg_offset_axis_position = 0; // deprecated
1659+static t_CKUINT HidMsg_offset_axis_position2 = 0;
1660+static t_CKUINT HidMsg_offset_scaled_axis_position = 0; // deprecated
1661+static t_CKUINT HidMsg_offset_hat_position = 0;
1662+static t_CKUINT HidMsg_offset_cursorx = 0;
1663+static t_CKUINT HidMsg_offset_cursory = 0;
1664+static t_CKUINT HidMsg_offset_scaledcursorx = 0;
1665+static t_CKUINT HidMsg_offset_scaledcursory = 0;
1666+static t_CKUINT HidMsg_offset_x = 0;
1667+static t_CKUINT HidMsg_offset_y = 0;
1668+static t_CKUINT HidMsg_offset_z = 0;
1669+static t_CKUINT HidMsg_offset_touchx = 0; // added 1.3.0.0
1670+static t_CKUINT HidMsg_offset_touchy = 0; // added 1.3.0.0
1671+static t_CKUINT HidMsg_offset_touchsize = 0; // added 1.3.0.0
1672+static t_CKUINT HidMsg_offset_ascii = 0;
1673+static t_CKUINT HidMsg_offset_key = 0;
1674+
1675+static t_CKUINT HidOut_offset_data = 0;
1676+
1677+//-----------------------------------------------------------------------------
1678+// name: init_class_HID()
1679+// desc: ...
1680+//-----------------------------------------------------------------------------
1681+t_CKBOOL init_class_HID( Chuck_Env * env )
1682+{
1683+ Chuck_DL_Func * func = NULL;
1684+
1685+ // init base class
1686+ if( !type_engine_import_class_begin( env, "HidMsg", "Object",
1687+ env->global(), NULL, NULL ) )
1688+ return FALSE;
1689+
1690+ // add member variable
1691+ HidMsg_offset_device_type = type_engine_import_mvar( env, "int", "deviceType", FALSE );
1692+ if( HidMsg_offset_device_type == CK_INVALID_OFFSET ) goto error;
1693+
1694+ // add member variable
1695+ HidMsg_offset_device_num = type_engine_import_mvar( env, "int", "deviceNum", FALSE );
1696+ if( HidMsg_offset_device_num == CK_INVALID_OFFSET ) goto error;
1697+
1698+ // add member variable
1699+ HidMsg_offset_type = type_engine_import_mvar( env, "int", "type", FALSE );
1700+ if( HidMsg_offset_type == CK_INVALID_OFFSET ) goto error;
1701+
1702+ // add member variable
1703+ HidMsg_offset_which = type_engine_import_mvar( env, "int", "which", FALSE );
1704+ if( HidMsg_offset_which == CK_INVALID_OFFSET ) goto error;
1705+
1706+ // add member variable
1707+ HidMsg_offset_idata = type_engine_import_mvar( env, "int", "idata", FALSE );
1708+ if( HidMsg_offset_idata == CK_INVALID_OFFSET ) goto error;
1709+
1710+ // add member variable
1711+ HidMsg_offset_fdata = type_engine_import_mvar( env, "float", "fdata", FALSE );
1712+ if( HidMsg_offset_fdata == CK_INVALID_OFFSET ) goto error;
1713+
1714+ // add member variable
1715+ HidMsg_offset_when = type_engine_import_mvar( env, "time", "when", FALSE );
1716+ if( HidMsg_offset_when == CK_INVALID_OFFSET ) goto error;
1717+
1718+ // add member variable
1719+ HidMsg_offset_deltax = type_engine_import_mvar( env, "int", "deltaX", FALSE );
1720+ if( HidMsg_offset_deltax == CK_INVALID_OFFSET ) goto error;
1721+
1722+ // add member variable
1723+ HidMsg_offset_deltay = type_engine_import_mvar( env, "int", "deltaY", FALSE );
1724+ if( HidMsg_offset_deltay == CK_INVALID_OFFSET ) goto error;
1725+
1726+ // add member variable
1727+ HidMsg_offset_cursorx = type_engine_import_mvar( env, "int", "cursorX", FALSE );
1728+ if( HidMsg_offset_cursorx == CK_INVALID_OFFSET ) goto error;
1729+
1730+ // add member variable
1731+ HidMsg_offset_cursory = type_engine_import_mvar( env, "int", "cursorY", FALSE );
1732+ if( HidMsg_offset_cursory == CK_INVALID_OFFSET ) goto error;
1733+
1734+ // add member variable
1735+ HidMsg_offset_scaledcursorx = type_engine_import_mvar( env, "float", "scaledCursorX", FALSE );
1736+ if( HidMsg_offset_scaledcursorx == CK_INVALID_OFFSET ) goto error;
1737+
1738+ // add member variable
1739+ HidMsg_offset_scaledcursory = type_engine_import_mvar( env, "float", "scaledCursorY", FALSE );
1740+ if( HidMsg_offset_scaledcursory == CK_INVALID_OFFSET ) goto error;
1741+
1742+ // add member variable
1743+ HidMsg_offset_x = type_engine_import_mvar( env, "int", "x", FALSE );
1744+ if( HidMsg_offset_x == CK_INVALID_OFFSET ) goto error;
1745+
1746+ // add member variable
1747+ HidMsg_offset_y = type_engine_import_mvar( env, "int", "y", FALSE );
1748+ if( HidMsg_offset_y == CK_INVALID_OFFSET ) goto error;
1749+
1750+ // add member variable
1751+ HidMsg_offset_z = type_engine_import_mvar( env, "int", "z", FALSE );
1752+ if( HidMsg_offset_z == CK_INVALID_OFFSET ) goto error;
1753+
1754+ // add member variable (added 1.3.0.0)
1755+ HidMsg_offset_touchx = type_engine_import_mvar( env, "float", "touchX", FALSE );
1756+ if( HidMsg_offset_touchx == CK_INVALID_OFFSET ) goto error;
1757+
1758+ // add member variable (added 1.3.0.0)
1759+ HidMsg_offset_touchy = type_engine_import_mvar( env, "float", "touchY", FALSE );
1760+ if( HidMsg_offset_touchy == CK_INVALID_OFFSET ) goto error;
1761+
1762+ // add member variable (added 1.3.0.0)
1763+ HidMsg_offset_touchsize = type_engine_import_mvar( env, "float", "touchSize", FALSE );
1764+ if( HidMsg_offset_touchsize == CK_INVALID_OFFSET ) goto error;
1765+
1766+ // add member variable
1767+ HidMsg_offset_axis_position = type_engine_import_mvar( env, "int", "axis_position", FALSE );
1768+ if( HidMsg_offset_axis_position == CK_INVALID_OFFSET ) goto error;
1769+
1770+ // add member variable
1771+ HidMsg_offset_axis_position2 = type_engine_import_mvar( env, "float", "axisPosition", FALSE );
1772+ if( HidMsg_offset_axis_position2 == CK_INVALID_OFFSET ) goto error;
1773+
1774+ // add member variable
1775+ HidMsg_offset_hat_position = type_engine_import_mvar( env, "int", "hatPosition", FALSE );
1776+ if( HidMsg_offset_hat_position == CK_INVALID_OFFSET ) goto error;
1777+
1778+ // add member variable
1779+ HidMsg_offset_ascii = type_engine_import_mvar( env, "int", "ascii", FALSE );
1780+ if( HidMsg_offset_ascii == CK_INVALID_OFFSET ) goto error;
1781+
1782+ // add member variable
1783+ HidMsg_offset_key = type_engine_import_mvar( env, "int", "key", FALSE );
1784+ if( HidMsg_offset_key == CK_INVALID_OFFSET ) goto error;
1785+
1786+ // add member variable
1787+ HidMsg_offset_scaled_axis_position = type_engine_import_mvar( env, "float", "scaled_axis_position", FALSE );
1788+ if( HidMsg_offset_scaled_axis_position == CK_INVALID_OFFSET ) goto error;
1789+
1790+ // add is_axis_motion()
1791+ func = make_new_mfun( "int", "is_axis_motion", HidMsg_is_axis_motion ); // deprecated
1792+ if( !type_engine_import_mfun( env, func ) ) goto error;
1793+
1794+ // add isAxisMotion()
1795+ func = make_new_mfun( "int", "isAxisMotion", HidMsg_is_axis_motion );
1796+ if( !type_engine_import_mfun( env, func ) ) goto error;
1797+
1798+ // add is_button_down()
1799+ func = make_new_mfun( "int", "is_button_down", HidMsg_is_button_down ); // deprecated
1800+ if( !type_engine_import_mfun( env, func ) ) goto error;
1801+
1802+ // add isButtonDown()
1803+ func = make_new_mfun( "int", "isButtonDown", HidMsg_is_button_down );
1804+ if( !type_engine_import_mfun( env, func ) ) goto error;
1805+
1806+ // add is_button_up()
1807+ func = make_new_mfun( "int", "is_button_up", HidMsg_is_button_up ); // deprecated
1808+ if( !type_engine_import_mfun( env, func ) ) goto error;
1809+
1810+ // add isButtonUp()
1811+ func = make_new_mfun( "int", "isButtonUp", HidMsg_is_button_up );
1812+ if( !type_engine_import_mfun( env, func ) ) goto error;
1813+
1814+ // add is_mouse_motion()
1815+ func = make_new_mfun( "int", "is_mouse_motion", HidMsg_is_mouse_motion ); // deprecated
1816+ if( !type_engine_import_mfun( env, func ) ) goto error;
1817+
1818+ // add isMouseMotion()
1819+ func = make_new_mfun( "int", "isMouseMotion", HidMsg_is_mouse_motion );
1820+ if( !type_engine_import_mfun( env, func ) ) goto error;
1821+
1822+ // add is_hat_motion()
1823+ func = make_new_mfun( "int", "is_hat_motion", HidMsg_is_hat_motion ); // deprecated
1824+ if( !type_engine_import_mfun( env, func ) ) goto error;
1825+
1826+ // add isHatMotion()
1827+ func = make_new_mfun( "int", "isHatMotion", HidMsg_is_hat_motion );
1828+ if( !type_engine_import_mfun( env, func ) ) goto error;
1829+
1830+ // add isWheelMotion()
1831+ func = make_new_mfun( "int", "isWheelMotion", HidMsg_is_wheel_motion );
1832+ if( !type_engine_import_mfun( env, func ) ) goto error;
1833+
1834+ // end the class import
1835+ type_engine_import_class_end( env );
1836+
1837+
1838+ // register deprecate
1839+ type_engine_register_deprecate( env, "HidIn", "Hid" );
1840+
1841+ // init base class Hid (copy of HidIn + constants)
1842+ if( !type_engine_import_class_begin( env, "Hid", "Event",
1843+ env->global(), HidIn_ctor, HidIn_dtor ) )
1844+ return FALSE;
1845+
1846+ // add open()
1847+ func = make_new_mfun( "int", "open", HidIn_open );
1848+ func->add_arg( "int", "type" );
1849+ func->add_arg( "int", "num" );
1850+ if( !type_engine_import_mfun( env, func ) ) goto error;
1851+
1852+ // add open()
1853+ func = make_new_mfun( "int", "open", HidIn_open_named );
1854+ func->add_arg( "string", "name" );
1855+ if( !type_engine_import_mfun( env, func ) ) goto error;
1856+
1857+ // add openJoystick()
1858+ func = make_new_mfun( "int", "openJoystick", HidIn_open_joystick );
1859+ func->add_arg( "int", "num" );
1860+ if( !type_engine_import_mfun( env, func ) ) goto error;
20711861
1862+ // add openMouse()
1863+ func = make_new_mfun( "int", "openMouse", HidIn_open_mouse );
1864+ func->add_arg( "int", "num" );
1865+ if( !type_engine_import_mfun( env, func ) ) goto error;
1866+
1867+ // add openKeyboard()
1868+ func = make_new_mfun( "int", "openKeyboard", HidIn_open_keyboard );
1869+ func->add_arg( "int", "num" );
1870+ if( !type_engine_import_mfun( env, func ) ) goto error;
1871+
1872+ // add openTiltSensor()
1873+ func = make_new_mfun( "int", "openTiltSensor", HidIn_open_tiltsensor );
1874+ if( !type_engine_import_mfun( env, func ) ) goto error;
1875+
1876+ // add good()
1877+ func = make_new_mfun( "int", "good", HidIn_good );
1878+ if( !type_engine_import_mfun( env, func ) ) goto error;
1879+
1880+ // add num()
1881+ func = make_new_mfun( "int", "num", HidIn_num );
1882+ if( !type_engine_import_mfun( env, func ) ) goto error;
1883+
1884+ // add name()
1885+ func = make_new_mfun( "string", "name", HidIn_name );
1886+ if( !type_engine_import_mfun( env, func ) ) goto error;
1887+
1888+ // add printerr()
1889+ func = make_new_mfun( "void", "printerr", HidIn_printerr );
1890+ func->add_arg( "int", "print_or_not" );
1891+ if( !type_engine_import_mfun( env, func ) ) goto error;
1892+
1893+ // add recv()
1894+ func = make_new_mfun( "int", "recv", HidIn_recv );
1895+ func->add_arg( "HidMsg", "msg" );
1896+ if( !type_engine_import_mfun( env, func ) ) goto error;
1897+
1898+ // add read()
1899+ func = make_new_mfun( "int", "read", HidIn_read );
1900+ func->add_arg( "int", "type" );
1901+ func->add_arg( "int", "which" );
1902+ func->add_arg( "HidMsg", "msg" );
1903+ if( !type_engine_import_mfun( env, func ) ) goto error;
1904+
1905+ // add send()
1906+ func = make_new_mfun( "int", "send", HidIn_send );
1907+ func->add_arg( "HidMsg", "msg" );
1908+ if( !type_engine_import_mfun( env, func ) ) goto error;
1909+
1910+ // add can_wait()
1911+ func = make_new_mfun( "int", "can_wait", HidIn_can_wait );
1912+ if( !type_engine_import_mfun( env, func ) ) goto error;
1913+
1914+ // add readTiltSensor()
1915+ func = make_new_sfun( "int[]", "readTiltSensor", HidIn_read_tilt_sensor );
1916+ if( !type_engine_import_sfun( env, func ) ) goto error;
1917+
1918+ // add globalTiltPollRate()
1919+ func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_ctrl_tiltPollRate );
1920+ func->add_arg( "dur", "d" );
1921+ if( !type_engine_import_sfun( env, func ) ) goto error;
1922+
1923+ // add globalTiltPollRate()
1924+ func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_cget_tiltPollRate );
1925+ if( !type_engine_import_sfun( env, func ) ) goto error;
1926+
1927+ // add startCursorTrack()
1928+ func = make_new_sfun( "int", "startCursorTrack", HidIn_start_cursor_track );
1929+ if( !type_engine_import_sfun( env, func ) ) goto error;
1930+
1931+ // add stopCursorTrack()
1932+ func = make_new_sfun( "int", "stopCursorTrack", HidIn_stop_cursor_track );
1933+ if( !type_engine_import_sfun( env, func ) ) goto error;
1934+
1935+ // add member variable
1936+ HidIn_offset_data = type_engine_import_mvar( env, "int", "@Hid_data", FALSE );
1937+ if( HidIn_offset_data == CK_INVALID_OFFSET ) goto error;
1938+
1939+ // add static member variable joystick
1940+ if( type_engine_import_svar( env, "int", "JOYSTICK", TRUE,
1941+ ( t_CKUINT ) &CK_HID_DEV_JOYSTICK ) == FALSE )
1942+ goto error;
1943+
1944+ // add static member variable keyboard
1945+ if( type_engine_import_svar( env, "int", "KEYBOARD", TRUE,
1946+ ( t_CKUINT ) &CK_HID_DEV_KEYBOARD ) == FALSE )
1947+ goto error;
1948+
1949+ // add static member variable mouse
1950+ if( type_engine_import_svar( env, "int", "MOUSE", TRUE,
1951+ ( t_CKUINT ) &CK_HID_DEV_MOUSE ) == FALSE )
1952+ goto error;
1953+
1954+ // add static member variable wii_remote
1955+ if( type_engine_import_svar( env, "int", "WII_REMOTE", TRUE,
1956+ ( t_CKUINT ) &CK_HID_DEV_WIIREMOTE ) == FALSE )
1957+ goto error;
1958+
1959+ // add static member variable wii_remote
1960+ if( type_engine_import_svar( env, "int", "TILT_SENSOR", TRUE,
1961+ ( t_CKUINT ) &CK_HID_DEV_TILTSENSOR ) == FALSE )
1962+ goto error;
1963+
1964+ // add static member variable tablet
1965+ if( type_engine_import_svar( env, "int", "TABLET", TRUE,
1966+ ( t_CKUINT ) &CK_HID_DEV_TABLET ) == FALSE )
1967+ goto error;
1968+
1969+ // add static member variable axisMotion
1970+ if( type_engine_import_svar( env, "int", "AXIS_MOTION", TRUE,
1971+ ( t_CKUINT ) &CK_HID_JOYSTICK_AXIS ) == FALSE )
1972+ goto error;
1973+
1974+ // add static member variable buttonDown
1975+ if( type_engine_import_svar( env, "int", "BUTTON_DOWN", TRUE,
1976+ ( t_CKUINT ) &CK_HID_BUTTON_DOWN ) == FALSE )
1977+ goto error;
1978+
1979+ // add static member variable buttonUp
1980+ if( type_engine_import_svar( env, "int", "BUTTON_UP", TRUE,
1981+ ( t_CKUINT ) &CK_HID_BUTTON_UP ) == FALSE )
1982+ goto error;
1983+
1984+ // add static member variable joystickHat
1985+ if( type_engine_import_svar( env, "int", "JOYSTICK_HAT", TRUE,
1986+ ( t_CKUINT ) &CK_HID_JOYSTICK_HAT ) == FALSE )
1987+ goto error;
1988+
1989+ // add static member variable JOYSTICK_BALL
1990+ if( type_engine_import_svar( env, "int", "JOYSTICK_BALL", TRUE,
1991+ ( t_CKUINT ) &CK_HID_JOYSTICK_BALL ) == FALSE )
1992+ goto error;
1993+
1994+ // add static member variable mouseMotion
1995+ if( type_engine_import_svar( env, "int", "MOUSE_MOTION", TRUE,
1996+ ( t_CKUINT ) &CK_HID_MOUSE_MOTION ) == FALSE )
1997+ goto error;
1998+
1999+ // add static member variable mouseWheel
2000+ if( type_engine_import_svar( env, "int", "MOUSE_WHEEL", TRUE,
2001+ ( t_CKUINT ) &CK_HID_MOUSE_WHEEL ) == FALSE )
2002+ goto error;
2003+
2004+ // add static member variable DEVICE_CONNECTED
2005+ if( type_engine_import_svar( env, "int", "DEVICE_CONNECTED", TRUE,
2006+ ( t_CKUINT ) &CK_HID_DEVICE_CONNECTED ) == FALSE )
2007+ goto error;
2008+
2009+ // add static member variable DEVICE_DISCONNECTED
2010+ if( type_engine_import_svar( env, "int", "DEVICE_DISCONNECTED", TRUE,
2011+ ( t_CKUINT ) &CK_HID_DEVICE_DISCONNECTED ) == FALSE )
2012+ goto error;
2013+
2014+ // add static member variable ACCELEROMETER
2015+ if( type_engine_import_svar( env, "int", "ACCELEROMETER", TRUE,
2016+ ( t_CKUINT ) &CK_HID_ACCELEROMETER ) == FALSE )
2017+ goto error;
2018+
2019+ // add static member variable LED
2020+ if( type_engine_import_svar( env, "int", "LED", TRUE,
2021+ ( t_CKUINT ) &CK_HID_LED ) == FALSE )
2022+ goto error;
2023+
2024+ // add static member variable LED
2025+ if( type_engine_import_svar( env, "int", "FORCE_FEEDBACK", TRUE,
2026+ ( t_CKUINT ) &CK_HID_FORCE_FEEDBACK ) == FALSE )
2027+ goto error;
2028+
2029+ // end the class import
2030+ type_engine_import_class_end( env );
2031+
2032+ /*
2033+ // init base class
2034+ if( !type_engine_import_class_begin( env, "HidOut", "Object",
2035+ env->global(), HidOut_ctor ) )
2036+ return FALSE;
2037+
2038+ // add open()
2039+ func = make_new_mfun( "int", "open", HidOut_open );
2040+ func->add_arg( "int", "port" );
2041+ if( !type_engine_import_mfun( env, func ) ) goto error;
2042+
2043+ // add good()
2044+ func = make_new_mfun( "int", "good", HidOut_good );
2045+ if( !type_engine_import_mfun( env, func ) ) goto error;
2046+
2047+ // add num()
2048+ func = make_new_mfun( "int", "num", HidOut_num );
2049+ if( !type_engine_import_mfun( env, func ) ) goto error;
2050+
2051+ // add name()
2052+ func = make_new_mfun( "string", "name", HidOut_name );
2053+ if( !type_engine_import_mfun( env, func ) ) goto error;
2054+
2055+ // add printerr()
2056+ func = make_new_mfun( "void", "printerr", HidOut_printerr );
2057+ func->add_arg( "int", "print_or_not" );
2058+ if( !type_engine_import_mfun( env, func ) ) goto error;
2059+
2060+ // add send()
2061+ func = make_new_mfun( "int", "send", HidOut_send );
2062+ func->add_arg( "HidMsg", "msg" );
2063+ if( !type_engine_import_mfun( env, func ) ) goto error;
2064+
2065+ // add member variable
2066+ HidOut_offset_data = type_engine_import_mvar( env, "int", "@HidOut_data", FALSE );
2067+ if( HidOut_offset_data == CK_INVALID_OFFSET ) goto error;
2068+
2069+ // end the class import
2070+ type_engine_import_class_end( env );
2071+ */
2072+ return TRUE;
2073+
2074+error:
2075+
2076+ // end the class import
2077+ type_engine_import_class_end( env );
2078+
2079+ return FALSE;
2080+}
2081+#endif
20722082
20732083
20742084
@@ -2962,313 +2972,319 @@ CK_DLL_SFUN( io_newline ) · 887 unmodified lines
29622972 }
29632973
29642974
2975+
2976+
2977+#ifndef __DISABLE_FILEIO__
29652978 //-----------------------------------------------------------------------------
29662979 // FileIO API
29672980 //-----------------------------------------------------------------------------
2968−//CK_DLL_CTOR( fileio_ctor )
2969−//{ }
2970−//
2971−//CK_DLL_DTOR( fileio_dtor )
2972−//{ }
2973−//
2974−//CK_DLL_MFUN( fileio_open )
2975−//{
2976−// std::string filename = GET_NEXT_STRING(ARGS)->str();
2977−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2978−// t_CKINT default_flags =
2979−// Chuck_IO_File::FLAG_READ_WRITE | Chuck_IO_File::TYPE_ASCII;
2980−//
2981−// RETURN->v_int = f->open(filename, default_flags);
2982−//}
2983−//
2984−//CK_DLL_MFUN( fileio_openflags )
2985−//{
2986−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2987−// std::string filename = GET_NEXT_STRING(ARGS)->str();
2988−// t_CKINT flags = GET_NEXT_INT(ARGS);
2989−//
2990−// RETURN->v_int = f->open(filename, flags);
2991−//}
2992−//
2993−//CK_DLL_MFUN( fileio_close )
2994−//{
2995−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2996−// f->close();
2997−//}
2998−//
2999−//CK_DLL_MFUN( fileio_good )
3000−//{
3001−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3002−// RETURN->v_int = f->good();
3003−//}
3004−//
3005−//CK_DLL_MFUN( fileio_flush )
3006−//{
3007−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3008−// f->flush();
3009−//}
3010−//
3011−//CK_DLL_MFUN( fileio_getmode )
3012−//{
3013−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3014−// RETURN->v_int = f->mode();
3015−//}
3016−//
3017−//CK_DLL_MFUN( fileio_setmode )
3018−//{
3019−// t_CKINT flag = GET_NEXT_INT(ARGS);
3020−//
3021−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3022−// f->mode( flag );
3023−// RETURN->v_int = 0;
3024−//}
3025−//
3026−//CK_DLL_MFUN( fileio_size )
3027−//{
3028−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3029−// RETURN->v_int = f->size();
3030−//}
3031−//
3032−//CK_DLL_MFUN( fileio_seek )
3033−//{
3034−// t_CKINT pos = GET_NEXT_INT(ARGS);
3035−//
3036−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3037−// f->seek(pos);
3038−//}
3039−//
3040−//CK_DLL_MFUN( fileio_tell )
3041−//{
3042−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3043−// RETURN->v_int = f->tell();
3044−//}
3045−//
3046−//CK_DLL_MFUN( fileio_isdir )
3047−//{
3048−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3049−// RETURN->v_int = f->isDir();
3050−//}
3051−//
3052−//CK_DLL_MFUN( fileio_dirlist )
3053−//{
3054−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3055−// Chuck_Array4 * a = f->dirList();
3056−// RETURN->v_object = a;
3057−//}
3058−//
3059−///*
3060−//CK_DLL_MFUN( fileio_read )
3061−//{
3062−// t_CKINT len = GET_NEXT_INT(ARGS);
3063−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3064−//
3065−// Chuck_String * s = f->read( len );
3066−// RETURN->v_object = s;
3067−//}
3068−//*/
3069−//
3070−//CK_DLL_MFUN( fileio_readline )
3071−//{
3072−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3073−// Chuck_String * ret = f->readLine();
3074−// RETURN->v_object = ret;
3075−//}
3076−//
3077−//CK_DLL_MFUN( fileio_readint )
3078−//{
3079−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3080−// t_CKINT defaultflags = Chuck_IO::INT32;
3081−//
3082−// /* (ATODO: doesn't look like asynchronous reading will work)
3083−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3084−// {
3085−// // set up arguments
3086−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3087−// args->RETURN = (void *)RETURN;
3088−// args->fileio_obj = f;
3089−// args->intArg = defaultflags;
3090−// // set shred to wait for I/O completion
3091−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3092−// // start thread
3093−// bool ret = f->m_thread->start( f->readInt_thread, (void *)args );
3094−// if (!ret) {
3095−// cerr << "m_thread->start failed; recreating m_thread" << endl;
3096−// delete f->m_thread;
3097−// f->m_thread = new XThread;
3098−// ret = f->m_thread->start( f->readInt_thread, (void *)args );
3099−// if (!ret) {
3100−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3101−// }
3102−// }
3103−// } else {*/
3104−// t_CKINT ret = f->readInt( defaultflags );
3105−// RETURN->v_int = ret;
3106−// //}
3107−// // ATODO: Debug
3108−// //sleep(1);
3109−// //cerr << "fileio_readint exiting" << endl;
3110−//}
3111−//
3112−//CK_DLL_MFUN( fileio_readintflags )
3113−//{
3114−// t_CKINT flags = GET_NEXT_INT(ARGS);
3115−//
3116−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3117−// t_CKINT ret = f->readInt( flags );
3118−//
3119−// RETURN->v_int = ret;
3120−//}
3121−//
3122−//CK_DLL_MFUN( fileio_readfloat )
3123−//{
3124−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3125−// t_CKFLOAT ret = f->readFloat();
3126−// RETURN->v_float = ret;
3127−//}
3128−//
3129−//CK_DLL_MFUN( fileio_eof )
3130−//{
3131−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3132−// t_CKBOOL ret = f->eof();
3133−// RETURN->v_int = ret;
3134−//}
3135−//
3136−//CK_DLL_MFUN( fileio_more )
3137−//{
3138−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3139−// t_CKBOOL ret = !f->eof();
3140−// RETURN->v_int = ret;
3141−//}
3142−//
3143−//CK_DLL_MFUN( fileio_writestring )
3144−//{
3145−// std::string val = GET_NEXT_STRING(ARGS)->str();
3146−//
3147−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3148−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3149−// {
3150−// // set up arguments
3151−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3152−// args->RETURN = (void *)RETURN;
3153−// args->fileio_obj = f;
3154−// args->stringArg = std::string(val);
3155−// // set shred to wait for I/O completion
3156−// assert( SHRED != NULL );
3157−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3158−// // start thread
3159−// bool ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3160−// if (!ret) {
3161−// // for some reason, the XThread object needs to be
3162−// // deleted and reconstructed every time after call #375
3163−// delete f->m_thread;
3164−// f->m_thread = new XThread;
3165−// ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3166−// if (!ret) {
3167−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3168−// }
3169−// }
3170−// } else {
3171−// f->write(val);
3172−// }
3173−//}
3174−//
3175−//CK_DLL_MFUN( fileio_writeint )
3176−//{
3177−// t_CKINT val = GET_NEXT_INT(ARGS);
3178−//
3179−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3180−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3181−// {
3182−// // set up arguments
3183−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3184−// args->RETURN = (void *)RETURN;
3185−// args->fileio_obj = f;
3186−// args->intArg = val;
3187−// // set shred to wait for I/O completion
3188−// assert( SHRED != NULL );
3189−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3190−// // start thread
3191−// bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3192−// if (!ret) {
3193−// // for some reason, the XThread object needs to be
3194−// // deleted and reconstructed every time after call #375
3195−// delete f->m_thread;
3196−// f->m_thread = new XThread;
3197−// ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3198−// if (!ret) {
3199−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3200−// }
3201−// }
3202−// } else {
3203−// f->write(val);
3204−// }
3205−//}
3206−//
3207−//CK_DLL_MFUN( fileio_writeintflags )
3208−//{
3209−// t_CKINT val = GET_NEXT_INT(ARGS);
3210−// t_CKINT flags = GET_NEXT_INT(ARGS);
3211−//
3212−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3213−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3214−// {
3215−// // TODO: pass flags in args
3216−// // set up arguments
3217−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3218−// args->RETURN = (void *)RETURN;
3219−// args->fileio_obj = f;
3220−// args->intArg = val;
3221−// // set shred to wait for I/O completion
3222−// assert( SHRED != NULL );
3223−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3224−// // start thread
3225−// bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3226−// if (!ret) {
3227−// // for some reason, the XThread object needs to be
3228−// // deleted and reconstructed every time after call #375
3229−// delete f->m_thread;
3230−// f->m_thread = new XThread;
3231−// ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3232−// if (!ret) {
3233−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3234−// }
3235−// }
3236−// } else {
3237−// f->write(val, flags);
3238−// }
3239−//}
3240−//
3241−//CK_DLL_MFUN( fileio_writefloat )
3242−//{
3243−// t_CKFLOAT val = GET_NEXT_FLOAT(ARGS);
3244−//
3245−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3246−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3247−// {
3248−// // set up arguments
3249−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3250−// args->RETURN = (void *)RETURN;
3251−// args->fileio_obj = f;
3252−// args->floatArg = val;
3253−// // set shred to wait for I/O completion
3254−// assert( SHRED != NULL );
3255−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3256−// // start thread
3257−// bool ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3258−// if (!ret) {
3259−// // for some reason, the XThread object needs to be
3260−// // deleted and reconstructed every time after call #375
3261−// delete f->m_thread;
3262−// f->m_thread = new XThread;
3263−// ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3264−// if (!ret) {
3265−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3266−// }
3267−// }
3268−// } else {
3269−// f->write(val);
3270−// }
3271−//}
2981+CK_DLL_CTOR( fileio_ctor )
2982+{ }
2983+
2984+CK_DLL_DTOR( fileio_dtor )
2985+{ }
2986+
2987+CK_DLL_MFUN( fileio_open )
2988+{
2989+ std::string filename = GET_NEXT_STRING(ARGS)->str();
2990+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2991+ t_CKINT default_flags =
2992+ Chuck_IO_File::FLAG_READ_WRITE | Chuck_IO_File::TYPE_ASCII;
2993+
2994+ RETURN->v_int = f->open(filename, default_flags);
2995+}
2996+
2997+CK_DLL_MFUN( fileio_openflags )
2998+{
2999+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3000+ std::string filename = GET_NEXT_STRING(ARGS)->str();
3001+ t_CKINT flags = GET_NEXT_INT(ARGS);
3002+
3003+ RETURN->v_int = f->open(filename, flags);
3004+}
3005+
3006+CK_DLL_MFUN( fileio_close )
3007+{
3008+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3009+ f->close();
3010+}
3011+
3012+CK_DLL_MFUN( fileio_good )
3013+{
3014+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3015+ RETURN->v_int = f->good();
3016+}
3017+
3018+CK_DLL_MFUN( fileio_flush )
3019+{
3020+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3021+ f->flush();
3022+}
3023+
3024+CK_DLL_MFUN( fileio_getmode )
3025+{
3026+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3027+ RETURN->v_int = f->mode();
3028+}
3029+
3030+CK_DLL_MFUN( fileio_setmode )
3031+{
3032+ t_CKINT flag = GET_NEXT_INT(ARGS);
3033+
3034+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3035+ f->mode( flag );
3036+ RETURN->v_int = 0;
3037+}
3038+
3039+CK_DLL_MFUN( fileio_size )
3040+{
3041+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3042+ RETURN->v_int = f->size();
3043+}
3044+
3045+CK_DLL_MFUN( fileio_seek )
3046+{
3047+ t_CKINT pos = GET_NEXT_INT(ARGS);
3048+
3049+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3050+ f->seek(pos);
3051+}
3052+
3053+CK_DLL_MFUN( fileio_tell )
3054+{
3055+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3056+ RETURN->v_int = f->tell();
3057+}
3058+
3059+CK_DLL_MFUN( fileio_isdir )
3060+{
3061+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3062+ RETURN->v_int = f->isDir();
3063+}
3064+
3065+CK_DLL_MFUN( fileio_dirlist )
3066+{
3067+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3068+ Chuck_Array4 * a = f->dirList();
3069+ RETURN->v_object = a;
3070+}
3071+
3072+/*
3073+CK_DLL_MFUN( fileio_read )
3074+{
3075+ t_CKINT len = GET_NEXT_INT(ARGS);
3076+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3077+
3078+ Chuck_String * s = f->read( len );
3079+ RETURN->v_object = s;
3080+}
3081+*/
3082+
3083+CK_DLL_MFUN( fileio_readline )
3084+{
3085+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3086+ Chuck_String * ret = f->readLine();
3087+ RETURN->v_object = ret;
3088+}
3089+
3090+CK_DLL_MFUN( fileio_readint )
3091+{
3092+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3093+ t_CKINT defaultflags = Chuck_IO::INT32;
3094+
3095+ /* (ATODO: doesn't look like asynchronous reading will work)
3096+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3097+ {
3098+ // set up arguments
3099+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3100+ args->RETURN = (void *)RETURN;
3101+ args->fileio_obj = f;
3102+ args->intArg = defaultflags;
3103+ // set shred to wait for I/O completion
3104+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3105+ // start thread
3106+ bool ret = f->m_thread->start( f->readInt_thread, (void *)args );
3107+ if (!ret) {
3108+ cerr << "m_thread->start failed; recreating m_thread" << endl;
3109+ delete f->m_thread;
3110+ f->m_thread = new XThread;
3111+ ret = f->m_thread->start( f->readInt_thread, (void *)args );
3112+ if (!ret) {
3113+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3114+ }
3115+ }
3116+ } else {*/
3117+ t_CKINT ret = f->readInt( defaultflags );
3118+ RETURN->v_int = ret;
3119+ //}
3120+ // ATODO: Debug
3121+ //sleep(1);
3122+ //cerr << "fileio_readint exiting" << endl;
3123+}
3124+
3125+CK_DLL_MFUN( fileio_readintflags )
3126+{
3127+ t_CKINT flags = GET_NEXT_INT(ARGS);
3128+
3129+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3130+ t_CKINT ret = f->readInt( flags );
3131+
3132+ RETURN->v_int = ret;
3133+}
3134+
3135+CK_DLL_MFUN( fileio_readfloat )
3136+{
3137+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3138+ t_CKFLOAT ret = f->readFloat();
3139+ RETURN->v_float = ret;
3140+}
3141+
3142+CK_DLL_MFUN( fileio_eof )
3143+{
3144+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3145+ t_CKBOOL ret = f->eof();
3146+ RETURN->v_int = ret;
3147+}
3148+
3149+CK_DLL_MFUN( fileio_more )
3150+{
3151+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3152+ t_CKBOOL ret = !f->eof();
3153+ RETURN->v_int = ret;
3154+}
3155+
3156+CK_DLL_MFUN( fileio_writestring )
3157+{
3158+ std::string val = GET_NEXT_STRING(ARGS)->str();
3159+
3160+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3161+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3162+ {
3163+ // set up arguments
3164+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3165+ args->RETURN = (void *)RETURN;
3166+ args->fileio_obj = f;
3167+ args->stringArg = std::string(val);
3168+ // set shred to wait for I/O completion
3169+ assert( SHRED != NULL );
3170+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3171+ // start thread
3172+ bool ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3173+ if (!ret) {
3174+ // for some reason, the XThread object needs to be
3175+ // deleted and reconstructed every time after call #375
3176+ delete f->m_thread;
3177+ f->m_thread = new XThread;
3178+ ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3179+ if (!ret) {
3180+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3181+ }
3182+ }
3183+ } else {
3184+ f->write(val);
3185+ }
3186+}
3187+
3188+CK_DLL_MFUN( fileio_writeint )
3189+{
3190+ t_CKINT val = GET_NEXT_INT(ARGS);
3191+
3192+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3193+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3194+ {
3195+ // set up arguments
3196+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3197+ args->RETURN = (void *)RETURN;
3198+ args->fileio_obj = f;
3199+ args->intArg = val;
3200+ // set shred to wait for I/O completion
3201+ assert( SHRED != NULL );
3202+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3203+ // start thread
3204+ bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3205+ if (!ret) {
3206+ // for some reason, the XThread object needs to be
3207+ // deleted and reconstructed every time after call #375
3208+ delete f->m_thread;
3209+ f->m_thread = new XThread;
3210+ ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3211+ if (!ret) {
3212+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3213+ }
3214+ }
3215+ } else {
3216+ f->write(val);
3217+ }
3218+}
3219+
3220+CK_DLL_MFUN( fileio_writeintflags )
3221+{
3222+ t_CKINT val = GET_NEXT_INT(ARGS);
3223+ t_CKINT flags = GET_NEXT_INT(ARGS);
3224+
3225+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3226+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3227+ {
3228+ // TODO: pass flags in args
3229+ // set up arguments
3230+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3231+ args->RETURN = (void *)RETURN;
3232+ args->fileio_obj = f;
3233+ args->intArg = val;
3234+ // set shred to wait for I/O completion
3235+ assert( SHRED != NULL );
3236+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3237+ // start thread
3238+ bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3239+ if (!ret) {
3240+ // for some reason, the XThread object needs to be
3241+ // deleted and reconstructed every time after call #375
3242+ delete f->m_thread;
3243+ f->m_thread = new XThread;
3244+ ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3245+ if (!ret) {
3246+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3247+ }
3248+ }
3249+ } else {
3250+ f->write(val, flags);
3251+ }
3252+}
3253+
3254+CK_DLL_MFUN( fileio_writefloat )
3255+{
3256+ t_CKFLOAT val = GET_NEXT_FLOAT(ARGS);
3257+
3258+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3259+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3260+ {
3261+ // set up arguments
3262+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3263+ args->RETURN = (void *)RETURN;
3264+ args->fileio_obj = f;
3265+ args->floatArg = val;
3266+ // set shred to wait for I/O completion
3267+ assert( SHRED != NULL );
3268+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3269+ // start thread
3270+ bool ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3271+ if (!ret) {
3272+ // for some reason, the XThread object needs to be
3273+ // deleted and reconstructed every time after call #375
3274+ delete f->m_thread;
3275+ f->m_thread = new XThread;
3276+ ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3277+ if (!ret) {
3278+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3279+ }
3280+ }
3281+ } else {
3282+ f->write(val);
3283+ }
3284+}
3285+#endif
3286+
3287+
32723288
32733289
32743290 //-----------------------------------------------------------------------------
@@ -4336,403 +4352,409 @@ CK_DLL_MFUN( MidiOut_send ) · 1061 unmodified lines
43364352 #endif // __DISABLE_MIDI__
43374353
43384354
4339−////-----------------------------------------------------------------------------
4340−//// HidMsg API
4341−////-----------------------------------------------------------------------------
4342−//CK_DLL_MFUN( HidMsg_is_axis_motion )
4343−//{
4344−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4345−// CK_HID_JOYSTICK_AXIS ? 1 : 0 );
4346−//}
4347−//
4348−//CK_DLL_MFUN( HidMsg_is_button_down )
4349−//{
4350−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4351−// CK_HID_BUTTON_DOWN ? 1 : 0 );
4352−//}
4353−//
4354−//CK_DLL_MFUN( HidMsg_is_button_up )
4355−//{
4356−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4357−// CK_HID_BUTTON_UP ? 1 : 0 );
4358−//}
4359−//
4360−//CK_DLL_MFUN( HidMsg_is_mouse_motion )
4361−//{
4362−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4363−// CK_HID_MOUSE_MOTION ? 1 : 0 );
4364−//}
4365−//
4366−//CK_DLL_MFUN( HidMsg_is_hat_motion )
4367−//{
4368−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4369−// CK_HID_JOYSTICK_HAT ? 1 : 0 );
4370−//}
4371−//
4372−//CK_DLL_MFUN( HidMsg_is_wheel_motion )
4373−//{
4374−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4375−// CK_HID_MOUSE_WHEEL ? 1 : 0 );
4376−//}
4377−//
4378−////-----------------------------------------------------------------------------
4379−//// HidIn API
4380−////-----------------------------------------------------------------------------
4381−//CK_DLL_CTOR( HidIn_ctor )
4382−//{
4383−// HidIn * min = new HidIn;
4384−// min->SELF = SELF;
4385−// OBJ_MEMBER_INT(SELF, HidIn_offset_data) = (t_CKINT)min;
4386−//}
4387−//
4388−//CK_DLL_DTOR( HidIn_dtor )
4389−//{
4390−// delete (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4391−// OBJ_MEMBER_INT(SELF, HidIn_offset_data) = 0;
4392−//}
4393−//
4394−//CK_DLL_MFUN( HidIn_open )
4395−//{
4396−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4397−// t_CKINT type = GET_NEXT_INT(ARGS);
4398−// t_CKINT num = GET_NEXT_INT(ARGS);
4399−// // CK_FPRINTF_STDERR( "HidIn_open %li %li\n", type, num );
4400−// RETURN->v_int = min->open( SHRED->vm_ref, type, num );
4401−//}
4402−//
4403−//CK_DLL_MFUN( HidIn_open_named )
4404−//{
4405−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4406−// Chuck_String * name = GET_NEXT_STRING(ARGS);
4407−// std::string s = name->str();
4408−// RETURN->v_int = min->open( SHRED->vm_ref, s );
4409−//}
4410−//
4411−//CK_DLL_MFUN( HidIn_open_joystick )
4412−//{
4413−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4414−// t_CKINT num = GET_NEXT_INT(ARGS);
4415−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_JOYSTICK, num );
4416−//}
4417−//
4418−//CK_DLL_MFUN( HidIn_open_mouse )
4419−//{
4420−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4421−// t_CKINT num = GET_NEXT_INT(ARGS);
4422−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_MOUSE, num );
4423−//}
4424−//
4425−//CK_DLL_MFUN( HidIn_open_keyboard )
4426−//{
4427−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4428−// t_CKINT num = GET_NEXT_INT(ARGS);
4429−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_KEYBOARD, num );
4430−//}
4431−//
4432−//CK_DLL_MFUN( HidIn_open_tiltsensor )
4433−//{
4434−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4435−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 );
4436−//}
4437−//
4438−//CK_DLL_MFUN( HidIn_good )
4439−//{
4440−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4441−// RETURN->v_int = (t_CKINT)min->good();
4442−//}
4443−//
4444−//CK_DLL_MFUN( HidIn_num )
4445−//{
4446−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4447−// RETURN->v_int = min->num();
4448−//}
4449−//
4450−//CK_DLL_MFUN( HidIn_printerr )
4451−//{
4452−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4453−// t_CKINT print_or_not = GET_CK_INT(ARGS);
4454−// min->set_suppress( !print_or_not );
4455−//}
4456−//
4457−//CK_DLL_MFUN( HidIn_name )
4458−//{
4459−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4460−// // TODO: memory leak, please fix, Thanks.
4461−// // Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4462−// // only if valid
4463−// // if( min->good() )
4464−// // a->str = min->phin->getPortName( min->num() );
4465−// // TODO: is null problem?
4466−// RETURN->v_string = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4467−// RETURN->v_string->set( min->name() );
4468−//}
4469−//
4470−//CK_DLL_MFUN( HidIn_recv )
4471−//{
4472−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4473−// Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4474−// HidMsg the_msg;
4475−// RETURN->v_int = min->recv( &the_msg );
4476−// if( RETURN->v_int )
4477−// {
4478−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4479−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4480−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4481−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4482−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4483−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4484−//
4485−// // mouse motion specific member variables
4486−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4487−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4488−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4489−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4490−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4491−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4492−//
4493−// // axis motion specific member variables
4494−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4495−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4496−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4497−//
4498−// // hat motion specific variables
4499−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4500−//
4501−// // keyboard specific variables
4502−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4503−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4504−//
4505−// // accelerometer (tilt sensor, wii remote) specific members
4506−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4507−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4508−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4509−//
4510−// // multitouch stuff - added 1.3.0.0
4511−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchx) = the_msg.fdata[0];
4512−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchy) = the_msg.fdata[1];
4513−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchsize) = the_msg.fdata[2];
4514−// }
4515−//}
4516−//
4517−//CK_DLL_MFUN( HidIn_read )
4518−//{
4519−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4520−// t_CKINT type = GET_NEXT_INT(ARGS);
4521−// t_CKINT num = GET_NEXT_INT(ARGS);
4522−// Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4523−//
4524−// HidMsg the_msg;
4525−//
4526−// RETURN->v_int = min->read( type, num, &the_msg );
4527−//
4528−// if( RETURN->v_int )
4529−// {
4530−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4531−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4532−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4533−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4534−//
4535−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4536−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4537−//
4538−// // mouse motion specific member members
4539−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4540−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4541−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4542−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4543−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4544−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4545−//
4546−// // joystick axis specific member members
4547−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4548−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4549−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4550−//
4551−// // joystick hat specific member members
4552−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4553−//
4554−// // keyboard specific members
4555−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4556−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4557−//
4558−// // accelerometer (tilt sensor, wii remote) specific members
4559−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4560−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4561−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4562−// }
4563−//}
4564−//
4565−//CK_DLL_MFUN( HidIn_send )
4566−//{
4567−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4568−// Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4569−//
4570−// HidMsg the_msg;
4571−// the_msg.device_type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_type );
4572−// the_msg.device_num = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_num );
4573−// the_msg.type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_type );
4574−// the_msg.eid = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_which );
4575−// the_msg.idata[0] = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_idata );
4576−//
4577−// RETURN->v_int = min->send( &the_msg );
4578−//}
4579−//
4580−//CK_DLL_MFUN( HidIn_can_wait )
4581−//{
4582−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4583−// RETURN->v_int = min->empty();
4584−//}
4585−//
4586−//CK_DLL_SFUN( HidIn_read_tilt_sensor )
4587−//{
4588−// static HidIn * hi;
4589−// static t_CKBOOL hi_good = TRUE;
4590−//
4591−// Chuck_Array4 * array = new Chuck_Array4( FALSE, 3 );
4592−// array->set( 0, 0 );
4593−// array->set( 1, 0 );
4594−// array->set( 2, 0 );
4595−//
4596−// // TODO: reference count?
4597−// array->add_ref();
4598−// RETURN->v_object = array;
4599−//
4600−// if( hi_good == FALSE )
4601−// return;
4602−//
4603−// if( !hi )
4604−// {
4605−// hi = new HidIn;
4606−// if( !hi->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 ) )
4607−// {
4608−// hi_good = FALSE;
4609−// return;
4610−// }
4611−// }
4612−//
4613−// HidMsg msg;
4614−//
4615−// if( !hi->read( CK_HID_ACCELEROMETER, 0, &msg ) )
4616−// {
4617−// return;
4618−// }
4619−//
4620−// array->set( 0, msg.idata[0] );
4621−// array->set( 1, msg.idata[1] );
4622−// array->set( 2, msg.idata[2] );
4623−//}
4624−//
4625−//CK_DLL_SFUN( HidIn_ctrl_tiltPollRate )
4626−//{
4627−// // get srate
4628−// if( !SHRED || !SHRED->vm_ref )
4629−// {
4630−// // problem
4631−// CK_FPRINTF_STDERR( "[chuck](via HID): can't set tiltPollRate on NULL shred/VM...\n" );
4632−// RETURN->v_dur = 0;
4633−// return;
4634−// }
4635−// t_CKFLOAT srate = SHRED->vm_ref->srate();
4636−//
4637−// // get arg
4638−// t_CKDUR v = GET_NEXT_DUR( ARGS );
4639−//
4640−// // get in microseconds
4641−// t_CKINT usec = (t_CKINT)( v / srate * 1000000 );
4642−//
4643−// // make sure it's nonnegative
4644−// if( usec < 0 ) usec = 0;
4645−//
4646−// // go
4647−// RETURN->v_dur = TiltSensor_setPollRate( usec ) * srate / 1000000;
4648−//}
4649−//
4650−//CK_DLL_SFUN( HidIn_cget_tiltPollRate )
4651−//{
4652−// // get srate
4653−// if( !SHRED || !SHRED->vm_ref )
4654−// {
4655−// // problem
4656−// CK_FPRINTF_STDERR( "[chuck](via HID): can't get tiltPollRate on NULL shred/VM...\n" );
4657−// RETURN->v_dur = 0;
4658−// return;
4659−// }
4660−// t_CKFLOAT srate = SHRED->vm_ref->srate();
4661−//
4662−// RETURN->v_dur = TiltSensor_getPollRate() * srate / 1000000;
4663−//}
4664−//
4665−//CK_DLL_SFUN( HidIn_start_cursor_track )
4666−//{
4667−// RETURN->v_int = !Mouse_start_cursor_track();
4668−//}
4669−//
4670−//CK_DLL_SFUN( HidIn_stop_cursor_track )
4671−//{
4672−// RETURN->v_int = !Mouse_stop_cursor_track();
4673−//}
4674−//
4675−////-----------------------------------------------------------------------------
4676−//// HidOut API
4677−////-----------------------------------------------------------------------------
4678−//CK_DLL_CTOR( HidOut_ctor )
4679−//{
4680−// OBJ_MEMBER_INT(SELF, HidOut_offset_data) = (t_CKUINT)new HidOut;
4681−//}
4682−//
4683−//CK_DLL_DTOR( HidOut_dtor )
4684−//{
4685−// delete (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4686−// OBJ_MEMBER_INT(SELF, HidOut_offset_data) = 0;
4687−//}
4688−//
4689−//CK_DLL_MFUN( HidOut_open )
4690−//{
4691−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4692−// t_CKINT num = GET_CK_INT(ARGS);
4693−// RETURN->v_int = mout->open( num );
4694−//}
4695−//
4696−//CK_DLL_MFUN( HidOut_good )
4697−//{
4698−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4699−// RETURN->v_int = (t_CKINT)mout->good();
4700−//}
4701−//
4702−//CK_DLL_MFUN( HidOut_num )
4703−//{
4704−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4705−// RETURN->v_int = mout->num();
4706−//}
4707−//
4708−//CK_DLL_MFUN( HidOut_name )
4709−//{
4710−// // HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4711−// // TODO: memory leak, please fix, Thanks.
4712−// Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4713−// // only if valid
4714−// // if( mout->good() )
4715−// // a->str = mout->mout->getPortName( mout->num() );
4716−// RETURN->v_string = a;
4717−//}
4718−//
4719−//CK_DLL_MFUN( HidOut_printerr )
4720−//{
4721−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4722−// t_CKINT print_or_not = GET_CK_INT(ARGS);
4723−// mout->set_suppress( !print_or_not );
4724−//}
4725−//
4726−//CK_DLL_MFUN( HidOut_send )
4727−//{
4728−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4729−// // Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4730−// HidMsg the_msg;
4731−// // the_msg.data[0] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data1);
4732−// // the_msg.data[1] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data2);
4733−// // the_msg.data[2] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data3);
4734−// RETURN->v_int = mout->send( &the_msg );
4735−//}
4355+
4356+
4357+#ifndef __DISABLE_HID__
4358+//-----------------------------------------------------------------------------
4359+// HidMsg API
4360+//-----------------------------------------------------------------------------
4361+CK_DLL_MFUN( HidMsg_is_axis_motion )
4362+{
4363+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4364+ CK_HID_JOYSTICK_AXIS ? 1 : 0 );
4365+}
4366+
4367+CK_DLL_MFUN( HidMsg_is_button_down )
4368+{
4369+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4370+ CK_HID_BUTTON_DOWN ? 1 : 0 );
4371+}
4372+
4373+CK_DLL_MFUN( HidMsg_is_button_up )
4374+{
4375+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4376+ CK_HID_BUTTON_UP ? 1 : 0 );
4377+}
4378+
4379+CK_DLL_MFUN( HidMsg_is_mouse_motion )
4380+{
4381+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4382+ CK_HID_MOUSE_MOTION ? 1 : 0 );
4383+}
4384+
4385+CK_DLL_MFUN( HidMsg_is_hat_motion )
4386+{
4387+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4388+ CK_HID_JOYSTICK_HAT ? 1 : 0 );
4389+}
4390+
4391+CK_DLL_MFUN( HidMsg_is_wheel_motion )
4392+{
4393+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4394+ CK_HID_MOUSE_WHEEL ? 1 : 0 );
4395+}
4396+
4397+//-----------------------------------------------------------------------------
4398+// HidIn API
4399+//-----------------------------------------------------------------------------
4400+CK_DLL_CTOR( HidIn_ctor )
4401+{
4402+ HidIn * min = new HidIn;
4403+ min->SELF = SELF;
4404+ OBJ_MEMBER_INT(SELF, HidIn_offset_data) = (t_CKINT)min;
4405+}
4406+
4407+CK_DLL_DTOR( HidIn_dtor )
4408+{
4409+ delete (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4410+ OBJ_MEMBER_INT(SELF, HidIn_offset_data) = 0;
4411+}
4412+
4413+CK_DLL_MFUN( HidIn_open )
4414+{
4415+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4416+ t_CKINT type = GET_NEXT_INT(ARGS);
4417+ t_CKINT num = GET_NEXT_INT(ARGS);
4418+ // CK_FPRINTF_STDERR( "HidIn_open %li %li\n", type, num );
4419+ RETURN->v_int = min->open( SHRED->vm_ref, type, num );
4420+}
4421+
4422+CK_DLL_MFUN( HidIn_open_named )
4423+{
4424+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4425+ Chuck_String * name = GET_NEXT_STRING(ARGS);
4426+ std::string s = name->str();
4427+ RETURN->v_int = min->open( SHRED->vm_ref, s );
4428+}
4429+
4430+CK_DLL_MFUN( HidIn_open_joystick )
4431+{
4432+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4433+ t_CKINT num = GET_NEXT_INT(ARGS);
4434+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_JOYSTICK, num );
4435+}
4436+
4437+CK_DLL_MFUN( HidIn_open_mouse )
4438+{
4439+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4440+ t_CKINT num = GET_NEXT_INT(ARGS);
4441+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_MOUSE, num );
4442+}
4443+
4444+CK_DLL_MFUN( HidIn_open_keyboard )
4445+{
4446+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4447+ t_CKINT num = GET_NEXT_INT(ARGS);
4448+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_KEYBOARD, num );
4449+}
4450+
4451+CK_DLL_MFUN( HidIn_open_tiltsensor )
4452+{
4453+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4454+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 );
4455+}
4456+
4457+CK_DLL_MFUN( HidIn_good )
4458+{
4459+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4460+ RETURN->v_int = (t_CKINT)min->good();
4461+}
4462+
4463+CK_DLL_MFUN( HidIn_num )
4464+{
4465+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4466+ RETURN->v_int = min->num();
4467+}
4468+
4469+CK_DLL_MFUN( HidIn_printerr )
4470+{
4471+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4472+ t_CKINT print_or_not = GET_CK_INT(ARGS);
4473+ min->set_suppress( !print_or_not );
4474+}
4475+
4476+CK_DLL_MFUN( HidIn_name )
4477+{
4478+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4479+ // TODO: memory leak, please fix, Thanks.
4480+ // Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4481+ // only if valid
4482+ // if( min->good() )
4483+ // a->str = min->phin->getPortName( min->num() );
4484+ // TODO: is null problem?
4485+ RETURN->v_string = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4486+ RETURN->v_string->set( min->name() );
4487+}
4488+
4489+CK_DLL_MFUN( HidIn_recv )
4490+{
4491+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4492+ Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4493+ HidMsg the_msg;
4494+ RETURN->v_int = min->recv( &the_msg );
4495+ if( RETURN->v_int )
4496+ {
4497+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4498+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4499+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4500+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4501+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4502+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4503+
4504+ // mouse motion specific member variables
4505+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4506+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4507+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4508+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4509+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4510+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4511+
4512+ // axis motion specific member variables
4513+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4514+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4515+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4516+
4517+ // hat motion specific variables
4518+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4519+
4520+ // keyboard specific variables
4521+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4522+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4523+
4524+ // accelerometer (tilt sensor, wii remote) specific members
4525+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4526+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4527+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4528+
4529+ // multitouch stuff - added 1.3.0.0
4530+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchx) = the_msg.fdata[0];
4531+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchy) = the_msg.fdata[1];
4532+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchsize) = the_msg.fdata[2];
4533+ }
4534+}
4535+
4536+CK_DLL_MFUN( HidIn_read )
4537+{
4538+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4539+ t_CKINT type = GET_NEXT_INT(ARGS);
4540+ t_CKINT num = GET_NEXT_INT(ARGS);
4541+ Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4542+
4543+ HidMsg the_msg;
4544+
4545+ RETURN->v_int = min->read( type, num, &the_msg );
4546+
4547+ if( RETURN->v_int )
4548+ {
4549+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4550+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4551+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4552+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4553+
4554+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4555+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4556+
4557+ // mouse motion specific member members
4558+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4559+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4560+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4561+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4562+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4563+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4564+
4565+ // joystick axis specific member members
4566+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4567+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4568+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4569+
4570+ // joystick hat specific member members
4571+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4572+
4573+ // keyboard specific members
4574+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4575+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4576+
4577+ // accelerometer (tilt sensor, wii remote) specific members
4578+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4579+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4580+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4581+ }
4582+}
4583+
4584+CK_DLL_MFUN( HidIn_send )
4585+{
4586+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4587+ Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4588+
4589+ HidMsg the_msg;
4590+ the_msg.device_type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_type );
4591+ the_msg.device_num = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_num );
4592+ the_msg.type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_type );
4593+ the_msg.eid = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_which );
4594+ the_msg.idata[0] = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_idata );
4595+
4596+ RETURN->v_int = min->send( &the_msg );
4597+}
4598+
4599+CK_DLL_MFUN( HidIn_can_wait )
4600+{
4601+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4602+ RETURN->v_int = min->empty();
4603+}
4604+
4605+CK_DLL_SFUN( HidIn_read_tilt_sensor )
4606+{
4607+ static HidIn * hi;
4608+ static t_CKBOOL hi_good = TRUE;
4609+
4610+ Chuck_Array4 * array = new Chuck_Array4( FALSE, 3 );
4611+ array->set( 0, 0 );
4612+ array->set( 1, 0 );
4613+ array->set( 2, 0 );
4614+
4615+ // TODO: reference count?
4616+ array->add_ref();
4617+ RETURN->v_object = array;
4618+
4619+ if( hi_good == FALSE )
4620+ return;
4621+
4622+ if( !hi )
4623+ {
4624+ hi = new HidIn;
4625+ if( !hi->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 ) )
4626+ {
4627+ hi_good = FALSE;
4628+ return;
4629+ }
4630+ }
4631+
4632+ HidMsg msg;
4633+
4634+ if( !hi->read( CK_HID_ACCELEROMETER, 0, &msg ) )
4635+ {
4636+ return;
4637+ }
4638+
4639+ array->set( 0, msg.idata[0] );
4640+ array->set( 1, msg.idata[1] );
4641+ array->set( 2, msg.idata[2] );
4642+}
4643+
4644+CK_DLL_SFUN( HidIn_ctrl_tiltPollRate )
4645+{
4646+ // get srate
4647+ if( !SHRED || !SHRED->vm_ref )
4648+ {
4649+ // problem
4650+ CK_FPRINTF_STDERR( "[chuck](via HID): can't set tiltPollRate on NULL shred/VM...\n" );
4651+ RETURN->v_dur = 0;
4652+ return;
4653+ }
4654+ t_CKFLOAT srate = SHRED->vm_ref->srate();
4655+
4656+ // get arg
4657+ t_CKDUR v = GET_NEXT_DUR( ARGS );
4658+
4659+ // get in microseconds
4660+ t_CKINT usec = (t_CKINT)( v / srate * 1000000 );
4661+
4662+ // make sure it's nonnegative
4663+ if( usec < 0 ) usec = 0;
4664+
4665+ // go
4666+ RETURN->v_dur = TiltSensor_setPollRate( usec ) * srate / 1000000;
4667+}
4668+
4669+CK_DLL_SFUN( HidIn_cget_tiltPollRate )
4670+{
4671+ // get srate
4672+ if( !SHRED || !SHRED->vm_ref )
4673+ {
4674+ // problem
4675+ CK_FPRINTF_STDERR( "[chuck](via HID): can't get tiltPollRate on NULL shred/VM...\n" );
4676+ RETURN->v_dur = 0;
4677+ return;
4678+ }
4679+ t_CKFLOAT srate = SHRED->vm_ref->srate();
4680+
4681+ RETURN->v_dur = TiltSensor_getPollRate() * srate / 1000000;
4682+}
4683+
4684+CK_DLL_SFUN( HidIn_start_cursor_track )
4685+{
4686+ RETURN->v_int = !Mouse_start_cursor_track();
4687+}
4688+
4689+CK_DLL_SFUN( HidIn_stop_cursor_track )
4690+{
4691+ RETURN->v_int = !Mouse_stop_cursor_track();
4692+}
4693+
4694+//-----------------------------------------------------------------------------
4695+// HidOut API
4696+//-----------------------------------------------------------------------------
4697+CK_DLL_CTOR( HidOut_ctor )
4698+{
4699+ OBJ_MEMBER_INT(SELF, HidOut_offset_data) = (t_CKUINT)new HidOut;
4700+}
4701+
4702+CK_DLL_DTOR( HidOut_dtor )
4703+{
4704+ delete (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4705+ OBJ_MEMBER_INT(SELF, HidOut_offset_data) = 0;
4706+}
4707+
4708+CK_DLL_MFUN( HidOut_open )
4709+{
4710+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4711+ t_CKINT num = GET_CK_INT(ARGS);
4712+ RETURN->v_int = mout->open( num );
4713+}
4714+
4715+CK_DLL_MFUN( HidOut_good )
4716+{
4717+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4718+ RETURN->v_int = (t_CKINT)mout->good();
4719+}
4720+
4721+CK_DLL_MFUN( HidOut_num )
4722+{
4723+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4724+ RETURN->v_int = mout->num();
4725+}
4726+
4727+CK_DLL_MFUN( HidOut_name )
4728+{
4729+ // HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4730+ // TODO: memory leak, please fix, Thanks.
4731+ Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4732+ // only if valid
4733+ // if( mout->good() )
4734+ // a->str = mout->mout->getPortName( mout->num() );
4735+ RETURN->v_string = a;
4736+}
4737+
4738+CK_DLL_MFUN( HidOut_printerr )
4739+{
4740+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4741+ t_CKINT print_or_not = GET_CK_INT(ARGS);
4742+ mout->set_suppress( !print_or_not );
4743+}
4744+
4745+CK_DLL_MFUN( HidOut_send )
4746+{
4747+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4748+ // Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4749+ HidMsg the_msg;
4750+ // the_msg.data[0] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data1);
4751+ // the_msg.data[1] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data2);
4752+ // the_msg.data[2] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data3);
4753+ RETURN->v_int = mout->send( &the_msg );
4754+}
4755+#endif //__DISABLE_HID__
4756+
4757+
47364758
47374759
47384760 //-----------------------------------------------------------------------------

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t