/*
    Copyright (c) 2007 SIEGE Development Team
    All rights reserved.
    
    This file is part of libSIEGE.
    
    This software is copyrighted work licensed under the terms of the
    2-clause BSD license. Please consult the file "license.txt" for
    details.
    
    If you did not recieve the file with this program, please email
    Tim Chas <darkuranium@gmail.com>.
*/

#include "keyboard.h"

static PyObject* pysKeyboardKey(PyObject* self, PyObject* args)
{
    SGenum key;
    if(!PyArg_ParseTuple(args, "I", &key))
        return NULL;

    if(sgKeyboardKey(key))
        Py_RETURN_TRUE;
    Py_RETURN_FALSE;
}
static PyObject* pysKeyboardKeyPress(PyObject* self, PyObject* args)
{
    SGenum key;
    if(!PyArg_ParseTuple(args, "I", &key))
        return NULL;

    if(sgKeyboardKeyPress(key))
        Py_RETURN_TRUE;
    Py_RETURN_FALSE;
}
static PyObject* pysKeyboardKeyRelease(PyObject* self, PyObject* args)
{
    SGenum key;
    if(!PyArg_ParseTuple(args, "I", &key))
        return NULL;

    if(sgKeyboardKeyRelease(key))
        Py_RETURN_TRUE;
    Py_RETURN_FALSE;
}

static PyObject* pysKeyboardChar(PyObject* self, PyObject* args)
{
    SGdchar chr;
    if(!PyArg_ParseTuple(args, "I", &chr))
        return NULL;

    if(sgKeyboardChar(chr))
        Py_RETURN_TRUE;
    Py_RETURN_FALSE;
}
static PyObject* pysKeyboardCharPress(PyObject* self, PyObject* args)
{
    SGdchar chr;
    if(!PyArg_ParseTuple(args, "I", &chr))
        return NULL;

    if(sgKeyboardCharPress(chr))
        Py_RETURN_TRUE;
    Py_RETURN_FALSE;
}
static PyObject* pysKeyboardCharRelease(PyObject* self, PyObject* args)
{
    SGdchar chr;
    if(!PyArg_ParseTuple(args, "I", &chr))
        return NULL;

    if(sgKeyboardCharRelease(chr))
        Py_RETURN_TRUE;
    Py_RETURN_FALSE;
}

static PyMethodDef InputKeyboardMethods[] = {
    {"Key", (PyCFunction)pysKeyboardKey, METH_VARARGS, ""},
    {"KeyPress", (PyCFunction)pysKeyboardKeyPress, METH_VARARGS, ""},
    {"KeyRelease", (PyCFunction)pysKeyboardKeyRelease, METH_VARARGS, ""},

    {"Char", (PyCFunction)pysKeyboardChar, METH_VARARGS, ""},
    {"CharPress", (PyCFunction)pysKeyboardCharPress, METH_VARARGS, ""},
    {"CharRelease", (PyCFunction)pysKeyboardCharRelease, METH_VARARGS, ""},
    {NULL, NULL, 0, NULL}
};

void sgpyInitInputKeyboard(PyObject* parent)
{
    PyObject* keyboard = Py_InitModule("siege.input.keyboard", InputKeyboardMethods);
    if(parent != NULL)
        PyModule_AddObject(parent, "keyboard", keyboard);
}
