Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualAntiMight

Posted 04 October 2012 - 11:44 AM

I want get input from two keyboards separately, after a lot of search , I find the function EnumDevice() may help. what I'm trying to do is to enumerate all keyboards, and create as many number of instances of DirectInputDevice with each guid, The problem is that when I pass DI8DEVCLASS_KEYBOARD to EnumDevice(), the callback function cannot enum my usb keyboards. I also tried DI8DEVCLASS_DEVICE, it returns me 3 guid, but none of them match my PS/2 guid.I don't know what devices they are exactly. I have 3 keyboards, one of which is PS/2 and the other via USB, any help? Here is my test program,a console project

struct Keyboard

{

IDirectInputDevice8* device;

GUID guid;

};

#define input Input::Instance()

#define MAXDEVICES 5

class Input

{

private:

IDirectInput8* dinput;

std::vector<Keyboard> keyboards;

private:

Input()

{

  DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,

   IID_IDirectInput8,(LPVOID*)&dinput, NULL);

}

Input(const Input&);

Input& operator = (const Input&);

public:

static Input* Instance()

{

  static Input instance;

  return &instance;

}

void EnumKeyboards()

{

  if(dinput)

  {

   dinput->EnumDevices(DI8DEVCLASS_KEYBOARD,

	EnumKeyboardsCallBack,

	NULL,

	DIEDFL_ATTACHEDONLY);

  }

}

static BOOL CALLBACK  EnumKeyboardsCallBack(LPCDIDEVICEINSTANCE lpddi,

			LPVOID pvRef)

{

  static int numdevices = 0;

  if(numdevices < MAXDEVICES)

  {

   IDirectInputDevice8* device;

   input->dinput->CreateDevice(lpddi->guidInstance, &device, NULL);

   Keyboard keyboard = { device, lpddi->guidInstance};

   input->keyboards.push_back(keyboard);

   numdevices++;

   return DIENUM_CONTINUE;

  }

  return DIENUM_STOP;

}

void printKeyboardsInfo()

{

  std::vector<Keyboard>::iterator i = this->keyboards.begin(),

		  end = this->keyboards.end();

  while(i != end)

  {

   std::cout << i->guid.Data1 <<" "<<i->guid.Data2<<" " << i->guid.Data3<<i->guid.Data4<< std::endl;

   ++i;

  }

}

int KeyboardNumber() { return keyboards.size(); }

};

int main()

{

input->EnumKeyboards();

input->printKeyboardsInfo();

system("pause");

return 0;

}


#6AntiMight

Posted 04 October 2012 - 11:42 AM

I want get input from two keyboards seperately, after a lot of search , I find the function EnumDevice() may help. what I'm trying to do is to enumerate all keyboards, and create as many number of instances of DirectInputDevice with each guid, The problem is that when I pass DI8DEVCLASS_KEYBOARD to EnumDevice(), the callback function cannot enum my usb keyboards. I also tried DI8DEVCLASS_DEVICE, it returns me 3 guid, but none of them match my PS/2 guid.I don't know what devices they are exactly. I have 3 keyboards, one of which is PS/2 and the other via USB, any help? Here is my test program,a console project

struct Keyboard

{

IDirectInputDevice8* device;

GUID guid;

};

#define input Input::Instance()

#define MAXDEVICES 5

class Input

{

private:

IDirectInput8* dinput;

std::vector<Keyboard> keyboards;

private:

Input()

{

  DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,

   IID_IDirectInput8,(LPVOID*)&dinput, NULL);

}

Input(const Input&);

Input& operator = (const Input&);

public:

static Input* Instance()

{

  static Input instance;

  return &instance;

}

void EnumKeyboards()

{

  if(dinput)

  {

   dinput->EnumDevices(DI8DEVCLASS_KEYBOARD,

	EnumKeyboardsCallBack,

	NULL,

	DIEDFL_ATTACHEDONLY);

  }

}

static BOOL CALLBACK  EnumKeyboardsCallBack(LPCDIDEVICEINSTANCE lpddi,

			LPVOID pvRef)

{

  static int numdevices = 0;

  if(numdevices < MAXDEVICES)

  {

   IDirectInputDevice8* device;

   input->dinput->CreateDevice(lpddi->guidInstance, &device, NULL);

   Keyboard keyboard = { device, lpddi->guidInstance};

   input->keyboards.push_back(keyboard);

   numdevices++;

   return DIENUM_CONTINUE;

  }

  return DIENUM_STOP;

}

void printKeyboardsInfo()

{

  std::vector<Keyboard>::iterator i = this->keyboards.begin(),

		  end = this->keyboards.end();

  while(i != end)

  {

   std::cout << i->guid.Data1 <<" "<<i->guid.Data2<<" " << i->guid.Data3<<i->guid.Data4<< std::endl;

   ++i;

  }

}

int KeyboardNumber() { return keyboards.size(); }

};

int main()

{

input->EnumKeyboards();

input->printKeyboardsInfo();

system("pause");

return 0;

}


#5AntiMight

Posted 04 October 2012 - 11:40 AM

I want to make a street fighter like game, and I want get input from two keyboards seperately, after a lot of search , I find the function EnumDevice() may help. what I'm trying to do is to enumerate all keyboards, and create as many number of instances of DirectInputDevice with each guid, The problem is that when I pass DI8DEVCLASS_KEYBOARD to EnumDevice(), the callback function cannot enum my usb keyboards. I also tried DI8DEVCLASS_DEVICE, it returns me 3 guid, but none of them match my PS/2 guid.I don't know what devices they are exactly. I have 3 keyboards, one of which is PS/2 and the other via USB, any help? Here is my test program,a console project

struct Keyboard

{

IDirectInputDevice8* device;

GUID guid;

};

#define input Input::Instance()

#define MAXDEVICES 5

class Input

{

private:

IDirectInput8* dinput;

std::vector<Keyboard> keyboards;

private:

Input()

{

  DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,

   IID_IDirectInput8,(LPVOID*)&dinput, NULL);

}

Input(const Input&);

Input& operator = (const Input&);

public:

static Input* Instance()

{

  static Input instance;

  return &instance;

}

void EnumKeyboards()

{

  if(dinput)

  {

   dinput->EnumDevices(DI8DEVCLASS_KEYBOARD,

	EnumKeyboardsCallBack,

	NULL,

	DIEDFL_ATTACHEDONLY);

  }

}

static BOOL CALLBACK  EnumKeyboardsCallBack(LPCDIDEVICEINSTANCE lpddi,

			LPVOID pvRef)

{

  static int numdevices = 0;

  if(numdevices < MAXDEVICES)

  {

   IDirectInputDevice8* device;

   input->dinput->CreateDevice(lpddi->guidInstance, &device, NULL);

   Keyboard keyboard = { device, lpddi->guidInstance};

   input->keyboards.push_back(keyboard);

   numdevices++;

   return DIENUM_CONTINUE;

  }

  return DIENUM_STOP;

}

void printKeyboardsInfo()

{

  std::vector<Keyboard>::iterator i = this->keyboards.begin(),

		  end = this->keyboards.end();

  while(i != end)

  {

   std::cout << i->guid.Data1 <<" "<<i->guid.Data2<<" " << i->guid.Data3<<i->guid.Data4<< std::endl;

   ++i;

  }

}

int KeyboardNumber() { return keyboards.size(); }

};

int main()

{

input->EnumKeyboards();

input->printKeyboardsInfo();

system("pause");

return 0;

}


#4AntiMight

Posted 04 October 2012 - 11:34 AM

I want to make a street fighter like game, and I want get input from two keyboards seperately, after a lot of search , I find the function EnumDevice() may help. what I'm trying to do is to enumerate all keyboards, and create as many number of instances of DirectInputDevice with each guid, The problem is that when I pass DI8DEVCLASS_KEYBOARD to EnumDevice(), the callback function cannot enum my usb keyboards. I also tried DI8DEVCLASS_DEVICE, it returns me 3 guid, but none of them match my PS/2 guid.I don't know what devices they are exactly. I have 3 keyboards, one of which is PS/2 and the other via USB, any help? Here is my test program,a console project

struct Keyboard

{

IDirectInputDevice8* device;

GUID guid;

};

#define input Input::Instance()

#define MAXDEVICES 5

class Input

{

private:

IDirectInput8* dinput;

std::vector<Keyboard> keyboards;

private:

Input()

{

  DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,

   IID_IDirectInput8,(LPVOID*)&dinput, NULL);

}

Input(const Input&);

Input& operator = (const Input&);

public:

static Input* Instance()

{

  static Input instance;

  return &instance;

}

void EnumKeyboards()

{

  if(dinput)

  {

   dinput->EnumDevices(DI8DEVCLASS_KEYBOARD,

	EnumKeyboardsCallBack,

	NULL,

	DIEDFL_ATTACHEDONLY);

  }

}

static BOOL CALLBACK  EnumKeyboardsCallBack(LPCDIDEVICEINSTANCE lpddi,

			LPVOID pvRef)

{

  static int numdevices = 0;

  if(numdevices < MAXDEVICES)

  {

   IDirectInputDevice8* device;

   input->dinput->CreateDevice(lpddi->guidInstance, &device, NULL);

   Keyboard keyboard = { device, lpddi->guidInstance};

   input->keyboards.push_back(keyboard);

   numdevices++;

   return DIENUM_CONTINUE;

  }

  return DIENUM_STOP;

}

void printKeyboardsInfo()

{

  std::vector<Keyboard>::iterator i = this->keyboards.begin(),

		  end = this->keyboards.end();

  while(i != end)

  {

   std::cout << i->guid.Data1 <<" "<<i->guid.Data2<<" " << i->guid.Data3<<i->guid.Data4<< std::endl;

   ++i;

  }

}

int KeyboardNumber() { return keyboards.size(); }

};

int main()

{

input->EnumKeyboards();

input->printKeyboardsInfo();

system("pause");

return 0;

}


#3AntiMight

Posted 04 October 2012 - 11:33 AM

I want to make a street fighter like game, and I want get input from two keyboards seperately, after a lot of search , I find the function EnumDevice() may help. what I'm trying to do is to enumerate all keyboards, and create as many number of instances of DirectInputDevice with each guid, The problem is that when I pass DI8DEVCLASS_KEYBOARD to EnumDevice(), the callback function cannot enum my usb keyboards. I also tried DI8DEVCLASS_DEVICE, it returns me 3 guid, but none of them match my PS/2 guid.I don't know what device they are exactly. I have 3 keyboards, one of which is PS/2 and the other via USB, any help? Here is my test program,a console project

struct Keyboard

{

IDirectInputDevice8* device;

GUID guid;

};

#define input Input::Instance()

#define MAXDEVICES 5

class Input

{

private:

IDirectInput8* dinput;

std::vector<Keyboard> keyboards;

private:

Input()

{

  DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,

   IID_IDirectInput8,(LPVOID*)&dinput, NULL);

}

Input(const Input&);

Input& operator = (const Input&);

public:

static Input* Instance()

{

  static Input instance;

  return &instance;

}

void EnumKeyboards()

{

  if(dinput)

  {

   dinput->EnumDevices(DI8DEVCLASS_KEYBOARD,

	EnumKeyboardsCallBack,

	NULL,

	DIEDFL_ATTACHEDONLY);

  }

}

static BOOL CALLBACK  EnumKeyboardsCallBack(LPCDIDEVICEINSTANCE lpddi,

			LPVOID pvRef)

{

  static int numdevices = 0;

  if(numdevices < MAXDEVICES)

  {

   IDirectInputDevice8* device;

   input->dinput->CreateDevice(lpddi->guidInstance, &device, NULL);

   Keyboard keyboard = { device, lpddi->guidInstance};

   input->keyboards.push_back(keyboard);

   numdevices++;

   return DIENUM_CONTINUE;

  }

  return DIENUM_STOP;

}

void printKeyboardsInfo()

{

  std::vector<Keyboard>::iterator i = this->keyboards.begin(),

		  end = this->keyboards.end();

  while(i != end)

  {

   std::cout << i->guid.Data1 <<" "<<i->guid.Data2<<" " << i->guid.Data3<<i->guid.Data4<< std::endl;

   ++i;

  }

}

int KeyboardNumber() { return keyboards.size(); }

};

int main()

{

input->EnumKeyboards();

input->printKeyboardsInfo();

system("pause");

return 0;

}


#2AntiMight

Posted 04 October 2012 - 11:31 AM

I want to make a street fighter like game, and I want get input from two keyboards seperately, after I did a lot of search , I found that the function EnumDevice() may help, what I'm trying to do is enumerating all keyboards, and create same number of instances of DirectInputDevice with each guid, The problem is that when I pass DI8DEVCLASS_KEYBOARD to EnumDevice(), the callback function cannot enum my usb keyboards. I also tried DI8DEVCLASS_DEVICE, it returns me 3 guid, but none of them match my PS/2 guid.I don't know what device they are exactly. I have 3 keyboards, one of which is PS/2 and the other via USB, any help? Here is my test program,a console project

struct Keyboard

{

IDirectInputDevice8* device;

GUID guid;

};

#define input Input::Instance()

#define MAXDEVICES 5

class Input

{

private:

IDirectInput8* dinput;

std::vector<Keyboard> keyboards;

private:

Input()

{

  DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,

   IID_IDirectInput8,(LPVOID*)&dinput, NULL);

}

Input(const Input&);

Input& operator = (const Input&);

public:

static Input* Instance()

{

  static Input instance;

  return &instance;

}

void EnumKeyboards()

{

  if(dinput)

  {

   dinput->EnumDevices(DI8DEVCLASS_KEYBOARD,

	EnumKeyboardsCallBack,

	NULL,

	DIEDFL_ATTACHEDONLY);

  }

}

static BOOL CALLBACK  EnumKeyboardsCallBack(LPCDIDEVICEINSTANCE lpddi,

			LPVOID pvRef)

{

  static int numdevices = 0;

  if(numdevices < MAXDEVICES)

  {

   IDirectInputDevice8* device;

   input->dinput->CreateDevice(lpddi->guidInstance, &device, NULL);

   Keyboard keyboard = { device, lpddi->guidInstance};

   input->keyboards.push_back(keyboard);

   numdevices++;

   return DIENUM_CONTINUE;

  }

  return DIENUM_STOP;

}

void printKeyboardsInfo()

{

  std::vector<Keyboard>::iterator i = this->keyboards.begin(),

		  end = this->keyboards.end();

  while(i != end)

  {

   std::cout << i->guid.Data1 <<" "<<i->guid.Data2<<" " << i->guid.Data3<<i->guid.Data4<< std::endl;

   ++i;

  }

}

int KeyboardNumber() { return keyboards.size(); }

};

int main()

{

input->EnumKeyboards();

input->printKeyboardsInfo();

system("pause");

return 0;

}


PARTNERS