ffi.cdef[[
short GetKeyState(int nVirtKey);
bool GetKeyboardLayoutNameA(char* pwszKLID);
int GetLocaleInfoA(int Locale, int LCType, char* lpLCData, int cchData);
]]
BuffSize = 32
KeyboardLayoutName = ffi.new("char[?]", BuffSize)
LocalInfo = ffi.new("char[?]", BuffSize)
--usage
local success = ffi.C.GetKeyboardLayoutNameA(KeyboardLayoutName)
local errorCode = ffi.C.GetLocaleInfoA(tonumber(ffi.string(KeyboardLayoutName), 16), 0x00000003, LocalInfo, BuffSize)
local localName = ffi.string(LocalInfo)
print(localName)