   problem read from the keyboard
  ok I have DirectInput created and the board is acquired the problem I'm getting is when I poll it with GetDeviceState the high bit reads either zero or 128.heres a snippet of my code to explain how I'm doing this:int value;char m_old_keys[256];char m_new_keys[256];// poll and update the keyboardstrcpy(m_old_keys, m_new_keys);m_dikeyboard->GetDeviceState(256, (LPVOID)&m_new_keys);// now when I check a key thats down I get a return value of 128// and old_keys[] always equals zerovalue = (m_new_keys[DIK_S] & 0x80);so am I ready the keys wrong, and why doesn't the array copy over?   
  I'm not sure I follow. Your code fragment doesn't really show any context - is this the body of a function (in which case char m_old_keys[256] will be lost at the end of the block's scope) or a combination of global variables/calls?You're using a string copy function on data that isn't really a string. Try using:if( 0 == memcpy_s( m_new_keys, 256, m_old_keys, 256 ) ){    // Copy failed}Also, the SDK sample code uses a BYTE instead of a char - they aren't quite the same (BYTE is unsigned).If you're getting problems with the DirectInput calls you should AT THE VERY LEAST be checking the return codes - FAILED() is a nice simple way of doing this. Better yet, enable the debug runtimes for DInput via the DirectX control panel.hthJack   ;  It's all part of a Wrapper Class#ifndef _INPUTCORE_H#define _INPUTCORE_H#include &lt;dinput.h&gt;#include &lt;fstream&gt;#include &lt;iostream&gt;#include &lt;string&gt;#include "errorlogger.h"#define BUTTON_DOWN(obj, button) (obj.rgbButtons[button] & 0x80)typedef struct{int x;int y;int button;} sMouse;class CZolo_Input_Core{private:cError m_CError;HWND  m_hWnd;LPDIRECTINPUT8  m_dinput;LPDIRECTINPUTDEVICE8 m_dimouse;LPDIRECTINPUTDEVICE8 m_dikeyboard;DIMOUSESTATE    m_mouse_state;sMouse m_old_mouse;sMouse m_new_mouse;int m_screen_width;int m_screen_height;char m_old_keys[256];char m_new_keys[256];public:bool Init(HWND,int,int);void Update();void Free();sMouse Get_Mouse();bool Mouse_Over_Box(int,int,int,int);bool Mouse_Click_In_Box(int,int,int,int,int);bool Mouse_Button_Pressed(int);bool Mouse_Button_Down(int);bool Mouse_Button_Released(int);bool Key_Pressed(int);bool Key_Down(int);bool Key_Released(int);int Key_Test(int);};#endif#include "inputcore.h"bool CZolo_Input_Core :: Init(HWND hWnd, int width, int height){m_CError.Init("Input_Error_Log.txt");m_hWnd= hWnd;m_screen_width  = width;m_screen_height = height;HRESULT result;result = DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&m_dinput,NULL);if (result != DI_OK)return false;m_CError.Write("Direct Input Device Created", true);result = m_dinput-&gt;CreateDevice(GUID_SysMouse, &m_dimouse, NULL);if (result != DI_OK)return false;m_CError.Write("Mouse Device Created", true);result = m_dimouse-&gt;SetDataFormat(&c_dfDIMouse);if (result != DI_OK)return false;m_CError.Write("Mouse Data Format Set", true);result = m_dimouse-&gt;SetCooperativeLevel(m_hWnd,DISCL_EXCLUSIVE | DISCL_FOREGROUND);if (result != DI_OK)return false;m_CError.Write("Mouse Cooperative Level Set", true);result = m_dimouse-&gt;Acquire();if (result != DI_OK)return false;m_CError.Write("Mouse Acquired", true);result = m_dinput-&gt;CreateDevice(GUID_SysKeyboard, &m_dikeyboard, NULL);if (result != DI_OK)return false;m_CError.Write("Keyboard DEvice Created", true);result = m_dikeyboard-&gt;SetDataFormat(&c_dfDIKeyboard);if (result != DI_OK)return false;m_CError.Write("Keyboard Data Format Set", true);result = m_dikeyboard-&gt;SetCooperativeLevel(m_hWnd,DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);if (result != DI_OK)return false;m_CError.Write("Keyboard Cooperative Level Set", true);result = m_dikeyboard-&gt;Acquire();if (result != DI_OK)return false;m_CError.Write("Keyboard Acquired", true);return true;}void CZolo_Input_Core :: Update(){// poll and update the mousem_old_mouse = m_new_mouse;m_dimouse-&gt;GetDeviceState(sizeof(m_mouse_state), (LPVOID)&m_mouse_state);m_new_mouse.x += m_mouse_state.lX;m_new_mouse.y += m_mouse_state.lY;if (m_new_mouse.x &lt; 0)m_new_mouse.x = 0;if (m_new_mouse.x &gt; m_screen_width)m_new_mouse.x = m_screen_width;if (m_new_mouse.y &lt; 0)m_new_mouse.y = 0;if (m_new_mouse.y &gt; m_screen_height)m_new_mouse.y = m_screen_height;m_new_mouse.button = -1;if (BUTTON_DOWN(m_mouse_state, 0))m_new_mouse.button = 0;if (BUTTON_DOWN(m_mouse_state, 1))m_new_mouse.button = 1;if (BUTTON_DOWN(m_mouse_state, 2))m_new_mouse.button = 2;// poll and update the keyboardstrcpy(m_old_keys, m_new_keys);m_dikeyboard-&gt;GetDeviceState(sizeof(m_new_keys), (LPVOID)&m_new_keys);}void CZolo_Input_Core :: Free(){if (m_dimouse != NULL){m_dimouse-&gt;Unacquire();m_dimouse-&gt;Release();m_dimouse = NULL;m_CError.Write("Mouse Released", true);}if (m_dikeyboard != NULL){m_dikeyboard-&gt;Unacquire();m_dikeyboard-&gt;Release();m_dikeyboard = NULL;m_CError.Write("Keyboard Released", true);}if (m_dinput != NULL){m_dinput-&gt;Release();m_CError.Write("Direct Input Released", true);}}sMouse CZolo_Input_Core :: Get_Mouse(){return m_new_mouse;}bool CZolo_Input_Core :: Mouse_Over_Box(int x1, int y1, int x2, int y2){if ((m_new_mouse.x &gt;= x1 && m_new_mouse.x &lt;= x2) && (m_new_mouse.y &gt;= y1 && m_new_mouse.y &lt;= y2))return true;return false;}bool CZolo_Input_Core :: Mouse_Click_In_Box(int x1, int y1, int x2, int y2, int button){if (((m_new_mouse.x &gt;= x1 && m_new_mouse.x &lt;= x2) && (m_new_mouse.y &gt;= y1 && m_new_mouse.y &lt;= y2)) &&m_new_mouse.button == button)return true;return false;}bool CZolo_Input_Core :: Mouse_Button_Pressed(int button){if (m_new_mouse.button == button && m_old_mouse.button != button)return true;return false;}bool CZolo_Input_Core :: Mouse_Button_Down(int button){if (m_new_mouse.button == button && m_old_mouse.button == button)return true;return false;}bool CZolo_Input_Core :: Mouse_Button_Released(int button){if (m_new_mouse.button != button && m_old_mouse.button == button)return true;return false;}bool CZolo_Input_Core::Key_Pressed(int key){if ((m_new_keys[key] & 0x80) == 1 && (m_old_keys[key] & 0x80) == 0)return true;return false;}bool CZolo_Input_Core::Key_Down(int key){if ((m_new_keys[key] & 0x80) == 1 && (m_old_keys[key] & 0x80) == 1)return true;return false;}bool CZolo_Input_Core::Key_Released(int key){if ((m_new_keys[key] & 0x80) == 0 && (m_old_keys[key] & 0x80) == 1)return true;return false;}int CZolo_Input_Core::Key_Test(int key){return (m_new_keys[key] & 0x80);}every tutorial and book I've read about this, has used an array of chars to read it.   ;  Ok I check for every error an input device could spit out of a call to GetDeviceState and there were none.   ;  Ok i change the key array to a BYTE and now i can read if the key is down but I still can't tell if the key was just pressed or released.I figured this was how I would do it but i doesn't seem to work.bool CZolo_Input_Core::Key_Pressed(int key){if ((m_new_keys[key] & 0x80) && !(m_old_keys[key] & 0x80))return true;return false;}bool CZolo_Input_Core::Key_Down(int key){if ((m_new_keys[key] & 0x80) && (m_old_keys[key] & 0x80))return true;return false;}bool CZolo_Input_Core::Key_Released(int key){if (!(m_new_keys[key] & 0x80) && (m_old_keys[key] & 0x80))return true;return false;}is it just reading it to fast? The Key_Down function works perfectly.   