nefunguje lightuserdata

This commit is contained in:
severak 2019-10-11 17:50:06 +02:00
parent dc01074ea3
commit e760115fe9
3 changed files with 39 additions and 1 deletions

View File

@ -41,10 +41,28 @@ static int midiwire_name (lua_State *L) {
return 1;
}
static int midiwire_open_out (lua_State *L) {
unsigned long result;
HMIDIOUT outHandle;
int port = luaL_checkinteger(L, 1);
result = midiOutOpen(&outHandle, port, 0, 0, CALLBACK_NULL);
if (result != 0)
{
luaL_error(L, "There was an error opening MIDI Mapper!");
return 0;
}
printf("outHandle: %p", outHandle);
//luaL_error(L, "Foo");
lua_pushnil (L);
return 1;
}
static const struct luaL_Reg midiwire[] = {
{"sleep", midiwire_sleep},
{"device_count", midiwire_device_count},
{"name", midiwire_name},
{"open_out", midiwire_open_out},
{NULL, NULL},
};

View File

@ -1,12 +1,28 @@
// viz https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/cca27429-5689-4a16-b2b4-9325d93e4ba2
// TCC has no mmsystem.h, so I needed to write my own :-(
// don't try this at home
// see https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dtyp/cca27429-5689-4a16-b2b4-9325d93e4ba2
typedef char CHAR, *PCHAR;
typedef unsigned short WORD, *PWORD, *LPWORD;
typedef unsigned long DWORD, *PDWORD, *LPDWORD;
typedef void* HANDLE;
typedef unsigned int MMVERSION;
typedef HANDLE HMIDIOUT;
// derived from https://github.com/wilkie/djehuty/blob/master/binding/win32/mmsystem.d
#define MAXPNAMELEN 32
const CALLBACK_TYPEMASK = 0x00070000 ; /* callback type mask */
const CALLBACK_NULL = 0x00000000 ; /* no callback */
const CALLBACK_WINDOW = 0x00010000 ; /* dwCallback is a HWND */
const CALLBACK_TASK = 0x00020000 ; /* dwCallback is a HTASK */
const CALLBACK_FUNCTION = 0x00030000 ; /* dwCallback is a FARPROC */
//const CALLBACK_THREAD = (CALLBACK_TASK); /* thread ID replaces 16 bit task */
const CALLBACK_EVENT = 0x00050000 ; /* dwCallback is an EVENT Handle */
typedef struct midi_out_capsa {
WORD wMid; /* manufacturer ID */
WORD wPid; /* product ID */

View File

@ -11,4 +11,8 @@ for i=0,mw.device_count()-1 do
print(i, mw.name(i))
end
print "open port 0:"
port = mw.open_out(0)
print(type(port))
print "Alles gute!"