Thread: \\.\pipe\WinUAE
View Single Post
Old 22 October 2015, 21:11   #15
boir
Registered User
 
Join Date: Aug 2015
Location: europe
Posts: 17
There is now also a working function for the Autohotkey language here.

Autohotkey makes it easy to do macros, multi key combination hotkeys and so on. Below is an example where a joypad button does warp in WinUAE while the button is pressed and stops warp on button release (instead of WinUAE default behaviour one press to toggle on and one press to toggle off).

Code:
#IfWinActive, ahk_Exe WinUAE.exe
Joy4::   ;Y button on the xbox360 controller
GetKeyState, state, %A_ThisHotkey%, P 
if state = U   
  return  
WinUAE("EVT SPC_WARP 1")
KeyWait, %A_ThisHotkey%  ;wait for button release
WinUAE("EVT SPC_WARP 1")
return
#IfWinActive

WinUAE(command) {
    VarSetCapacity(result, 4096)
    if !DllCall("CallNamedPipe", "str", "\\.\pipe\WinUAE"
        , "astr", command, "int", StrPut(command, "cp0")
        , "ptr", &result, "int", 4096
        , "uint*", bytesRead, "uint", 1)
        throw Exception("CallNamedPipe failed with error " A_LastError)
    return RegExReplace(StrGet(&result, bytesRead, "cp0"), "\R$")
}

Toni: the writer of the autohotkey function, lexikos, says he ran into a bug with unicode and ipc in WinUAE (that the autohotkey function then was adapted the work around). He wrote

Quote:
... this version did not work correctly on the Unicode build because of a bug in WinUAE:
Code:
outlen = _tcsclen ((TCHAR*)ipc->outbuf) + sizeof (TCHAR);
For a string of n characters, the code writes n+2 bytes. Since each TCHAR is 2 bytes, the result is truncated. The developers of WinUAE might like to know about this error. Correct code might look like:
Code:
outlen = (_tcsclen ((TCHAR*)ipc->outbuf) + 1) * sizeof (TCHAR);
I think he is refering to this code location
https://github.com/tonioni/WinUAE/bl...aeipc.cpp#L347
boir is offline  
 
Page generated in 0.04914 seconds with 9 queries