試してみたのですが、現状の動作として"MakeKeyInput"を行ってから
"SetActiveKeyInput"を行うまでのキー入力をすべて拾ってくるようです。
ですので、事前に"MakeKeyInput"を行っておいて、キー入力をトリガーにして
"SetActiveKeyInput"を行うという使い方は出来ないようです。
対策としては"SetActiveKeyInput"を行う直前に"MakeKeyInput"を行い、
"CheckKeyInput"が入力済みになったら"DeleteKeyInput"を行うという方法で回避可能でした。
KeyInput系のこの動作が仕様かバグかは微妙なところだと思います。
管理人さんの見解をお待ちしたほうが良いかもしれません。
//-- テストソース --//
#include "DxLib.h"
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
char String[256];
int InputHandle;
ChangeWindowMode( TRUE );
if ( DxLib_Init( ) == -1 ) return -1;
SetDrawScreen( DX_SCREEN_BACK );
InputHandle = MakeKeyInput( 50, FALSE, FALSE, FALSE );
SetKeyInputString( "test", InputHandle );
while ( !ProcessMessage( ) )
{
if ( CheckHitKey( KEY_INPUT_X ) ) // この時点でX以外のキーを押すとすべて拾ってくる
break;
ClearDrawScreen( );
DrawString( 0, 0, "PUSH X KEY", GetColor( 255, 255, 255 ) );
ScreenFlip( );
}
SetActiveKeyInput( InputHandle );
while ( !ProcessMessage( ) )
{
if ( CheckKeyInput( InputHandle ) != 0 )
break;
ClearDrawScreen( );
DrawKeyInputModeString( 640, 480 );
DrawKeyInputString( 0, 0, InputHandle );
GetKeyInputString( String , InputHandle );
DrawString( 0, 16, String, GetColor( 255, 255, 255 ) );
ScreenFlip( );
}
GetKeyInputString( String , InputHandle );
DeleteKeyInput( InputHandle );
ClearDrawScreen( );
DrawString( 0, 0, "あなたが入力した文字列は" , GetColor( 255, 255, 255 ) );
DrawString( 0, 16, String, GetColor( 255, 255, 255 ) );
ScreenFlip( );
WaitKey( );
DxLib_End( );
return 0;
}