mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 16:24:57 +00:00
More OS4 fixes
This commit is contained in:
parent
6ee29a6b62
commit
80b4e29d0a
142
src/os4_init.c
142
src/os4_init.c
@ -274,10 +274,143 @@ static void closeLibraries(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* get_key_name(int key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
// Printable keys
|
||||||
|
case GLFW_KEY_A: return "A";
|
||||||
|
case GLFW_KEY_B: return "B";
|
||||||
|
case GLFW_KEY_C: return "C";
|
||||||
|
case GLFW_KEY_D: return "D";
|
||||||
|
case GLFW_KEY_E: return "E";
|
||||||
|
case GLFW_KEY_F: return "F";
|
||||||
|
case GLFW_KEY_G: return "G";
|
||||||
|
case GLFW_KEY_H: return "H";
|
||||||
|
case GLFW_KEY_I: return "I";
|
||||||
|
case GLFW_KEY_J: return "J";
|
||||||
|
case GLFW_KEY_K: return "K";
|
||||||
|
case GLFW_KEY_L: return "L";
|
||||||
|
case GLFW_KEY_M: return "M";
|
||||||
|
case GLFW_KEY_N: return "N";
|
||||||
|
case GLFW_KEY_O: return "O";
|
||||||
|
case GLFW_KEY_P: return "P";
|
||||||
|
case GLFW_KEY_Q: return "Q";
|
||||||
|
case GLFW_KEY_R: return "R";
|
||||||
|
case GLFW_KEY_S: return "S";
|
||||||
|
case GLFW_KEY_T: return "T";
|
||||||
|
case GLFW_KEY_U: return "U";
|
||||||
|
case GLFW_KEY_V: return "V";
|
||||||
|
case GLFW_KEY_W: return "W";
|
||||||
|
case GLFW_KEY_X: return "X";
|
||||||
|
case GLFW_KEY_Y: return "Y";
|
||||||
|
case GLFW_KEY_Z: return "Z";
|
||||||
|
case GLFW_KEY_1: return "1";
|
||||||
|
case GLFW_KEY_2: return "2";
|
||||||
|
case GLFW_KEY_3: return "3";
|
||||||
|
case GLFW_KEY_4: return "4";
|
||||||
|
case GLFW_KEY_5: return "5";
|
||||||
|
case GLFW_KEY_6: return "6";
|
||||||
|
case GLFW_KEY_7: return "7";
|
||||||
|
case GLFW_KEY_8: return "8";
|
||||||
|
case GLFW_KEY_9: return "9";
|
||||||
|
case GLFW_KEY_0: return "0";
|
||||||
|
case GLFW_KEY_SPACE: return "SPACE";
|
||||||
|
case GLFW_KEY_MINUS: return "MINUS";
|
||||||
|
case GLFW_KEY_EQUAL: return "EQUAL";
|
||||||
|
case GLFW_KEY_LEFT_BRACKET: return "LEFT BRACKET";
|
||||||
|
case GLFW_KEY_RIGHT_BRACKET: return "RIGHT BRACKET";
|
||||||
|
case GLFW_KEY_BACKSLASH: return "BACKSLASH";
|
||||||
|
case GLFW_KEY_SEMICOLON: return "SEMICOLON";
|
||||||
|
case GLFW_KEY_APOSTROPHE: return "APOSTROPHE";
|
||||||
|
case GLFW_KEY_GRAVE_ACCENT: return "GRAVE ACCENT";
|
||||||
|
case GLFW_KEY_COMMA: return "COMMA";
|
||||||
|
case GLFW_KEY_PERIOD: return "PERIOD";
|
||||||
|
case GLFW_KEY_SLASH: return "SLASH";
|
||||||
|
case GLFW_KEY_WORLD_1: return "WORLD 1";
|
||||||
|
case GLFW_KEY_WORLD_2: return "WORLD 2";
|
||||||
|
|
||||||
|
// Function keys
|
||||||
|
case GLFW_KEY_ESCAPE: return "ESCAPE";
|
||||||
|
case GLFW_KEY_F1: return "F1";
|
||||||
|
case GLFW_KEY_F2: return "F2";
|
||||||
|
case GLFW_KEY_F3: return "F3";
|
||||||
|
case GLFW_KEY_F4: return "F4";
|
||||||
|
case GLFW_KEY_F5: return "F5";
|
||||||
|
case GLFW_KEY_F6: return "F6";
|
||||||
|
case GLFW_KEY_F7: return "F7";
|
||||||
|
case GLFW_KEY_F8: return "F8";
|
||||||
|
case GLFW_KEY_F9: return "F9";
|
||||||
|
case GLFW_KEY_F10: return "F10";
|
||||||
|
case GLFW_KEY_F11: return "F11";
|
||||||
|
case GLFW_KEY_F12: return "F12";
|
||||||
|
case GLFW_KEY_F13: return "F13";
|
||||||
|
case GLFW_KEY_F14: return "F14";
|
||||||
|
case GLFW_KEY_F15: return "F15";
|
||||||
|
case GLFW_KEY_F16: return "F16";
|
||||||
|
case GLFW_KEY_F17: return "F17";
|
||||||
|
case GLFW_KEY_F18: return "F18";
|
||||||
|
case GLFW_KEY_F19: return "F19";
|
||||||
|
case GLFW_KEY_F20: return "F20";
|
||||||
|
case GLFW_KEY_F21: return "F21";
|
||||||
|
case GLFW_KEY_F22: return "F22";
|
||||||
|
case GLFW_KEY_F23: return "F23";
|
||||||
|
case GLFW_KEY_F24: return "F24";
|
||||||
|
case GLFW_KEY_F25: return "F25";
|
||||||
|
case GLFW_KEY_UP: return "UP";
|
||||||
|
case GLFW_KEY_DOWN: return "DOWN";
|
||||||
|
case GLFW_KEY_LEFT: return "LEFT";
|
||||||
|
case GLFW_KEY_RIGHT: return "RIGHT";
|
||||||
|
case GLFW_KEY_LEFT_SHIFT: return "LEFT SHIFT";
|
||||||
|
case GLFW_KEY_RIGHT_SHIFT: return "RIGHT SHIFT";
|
||||||
|
case GLFW_KEY_LEFT_CONTROL: return "LEFT CONTROL";
|
||||||
|
case GLFW_KEY_RIGHT_CONTROL: return "RIGHT CONTROL";
|
||||||
|
case GLFW_KEY_LEFT_ALT: return "LEFT ALT";
|
||||||
|
case GLFW_KEY_RIGHT_ALT: return "RIGHT ALT";
|
||||||
|
case GLFW_KEY_TAB: return "TAB";
|
||||||
|
case GLFW_KEY_ENTER: return "ENTER";
|
||||||
|
case GLFW_KEY_BACKSPACE: return "BACKSPACE";
|
||||||
|
case GLFW_KEY_INSERT: return "INSERT";
|
||||||
|
case GLFW_KEY_DELETE: return "DELETE";
|
||||||
|
case GLFW_KEY_PAGE_UP: return "PAGE UP";
|
||||||
|
case GLFW_KEY_PAGE_DOWN: return "PAGE DOWN";
|
||||||
|
case GLFW_KEY_HOME: return "HOME";
|
||||||
|
case GLFW_KEY_END: return "END";
|
||||||
|
case GLFW_KEY_KP_0: return "KEYPAD 0";
|
||||||
|
case GLFW_KEY_KP_1: return "KEYPAD 1";
|
||||||
|
case GLFW_KEY_KP_2: return "KEYPAD 2";
|
||||||
|
case GLFW_KEY_KP_3: return "KEYPAD 3";
|
||||||
|
case GLFW_KEY_KP_4: return "KEYPAD 4";
|
||||||
|
case GLFW_KEY_KP_5: return "KEYPAD 5";
|
||||||
|
case GLFW_KEY_KP_6: return "KEYPAD 6";
|
||||||
|
case GLFW_KEY_KP_7: return "KEYPAD 7";
|
||||||
|
case GLFW_KEY_KP_8: return "KEYPAD 8";
|
||||||
|
case GLFW_KEY_KP_9: return "KEYPAD 9";
|
||||||
|
case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
|
||||||
|
case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTIPLY";
|
||||||
|
case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
|
||||||
|
case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
|
||||||
|
case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
|
||||||
|
case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL";
|
||||||
|
case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER";
|
||||||
|
case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN";
|
||||||
|
case GLFW_KEY_NUM_LOCK: return "NUM LOCK";
|
||||||
|
case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK";
|
||||||
|
case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK";
|
||||||
|
case GLFW_KEY_PAUSE: return "PAUSE";
|
||||||
|
case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER";
|
||||||
|
case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER";
|
||||||
|
case GLFW_KEY_MENU: return "MENU";
|
||||||
|
|
||||||
|
default: return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void createKeyTables(void)
|
static void createKeyTables(void)
|
||||||
{
|
{
|
||||||
memset(_glfw.os4.keycodes, -1, sizeof(_glfw.os4.keycodes));
|
memset(_glfw.os4.keycodes, -1, sizeof(_glfw.os4.keycodes));
|
||||||
memset(_glfw.os4.scancodes, -1, sizeof(_glfw.os4.scancodes));
|
memset(_glfw.os4.scancodes, -1, sizeof(_glfw.os4.scancodes));
|
||||||
|
memset(_glfw.os4.keynames, 0, sizeof(_glfw.os4.keynames));
|
||||||
|
|
||||||
_glfw.os4.keycodes[0xb] = GLFW_KEY_GRAVE_ACCENT;
|
_glfw.os4.keycodes[0xb] = GLFW_KEY_GRAVE_ACCENT;
|
||||||
_glfw.os4.keycodes[0x1] = GLFW_KEY_1;
|
_glfw.os4.keycodes[0x1] = GLFW_KEY_1;
|
||||||
@ -391,11 +524,14 @@ static void createKeyTables(void)
|
|||||||
*/
|
*/
|
||||||
_glfw.os4.keycodes[RAWKEY_ENTER] = GLFW_KEY_KP_ENTER; //
|
_glfw.os4.keycodes[RAWKEY_ENTER] = GLFW_KEY_KP_ENTER; //
|
||||||
|
|
||||||
for (int scancode = 0; scancode < 512; scancode++)
|
for (int scancode = 0; scancode < 512; scancode++) {
|
||||||
{
|
|
||||||
if (_glfw.os4.keycodes[scancode] > 0)
|
if (_glfw.os4.keycodes[scancode] > 0)
|
||||||
_glfw.os4.scancodes[_glfw.os4.keycodes[scancode]] = scancode;
|
_glfw.os4.scancodes[_glfw.os4.keycodes[scancode]] = scancode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = GLFW_KEY_SPACE; i < GLFW_KEY_LAST; i++) {
|
||||||
|
strncpy(_glfw.os4.keynames[i], get_key_name(_glfw.os4.keycodes[i]), 16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -497,9 +633,7 @@ int _glfwInitOS4(void)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
OS4_LockPubScreen();
|
|
||||||
_glfwPollMonitorsOS4();
|
_glfwPollMonitorsOS4();
|
||||||
OS4_UnlockPubScreen();
|
|
||||||
|
|
||||||
OS4_FindApplicationName();
|
OS4_FindApplicationName();
|
||||||
|
|
||||||
|
@ -58,11 +58,7 @@ AMIGAINPUT_Close(_GLFWjoystick * joystick)
|
|||||||
{
|
{
|
||||||
dprintf("Closing joystick #%d (AI ID=%ld)\n", joystick->os4js.instance_id, joystick->os4js.joystickList[joystick->os4js.instance_id].id);
|
dprintf("Closing joystick #%d (AI ID=%ld)\n", joystick->os4js.instance_id, joystick->os4js.joystickList[joystick->os4js.instance_id].id);
|
||||||
if (joystick->os4js.hwdata) {
|
if (joystick->os4js.hwdata) {
|
||||||
#if OLDSDK
|
|
||||||
GLFW_IAIN->AIN_ReleaseDevice(joystick->os4js.hwdata->context, joystick->os4js.hwdata->handle);
|
GLFW_IAIN->AIN_ReleaseDevice(joystick->os4js.hwdata->context, joystick->os4js.hwdata->handle);
|
||||||
#else
|
|
||||||
GLFW_IAIN->ReleaseDevice(joystick->os4js.hwdata->context, joystick->os4js.hwdata->handle);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_glfw_free(joystick->os4js.hwdata);
|
_glfw_free(joystick->os4js.hwdata);
|
||||||
joystick->os4js.hwdata = NULL;
|
joystick->os4js.hwdata = NULL;
|
||||||
@ -81,13 +77,9 @@ AMIGAINPUT_Open(_GLFWjoystick * joysticks, int device_index)
|
|||||||
AIN_DeviceHandle *handle;
|
AIN_DeviceHandle *handle;
|
||||||
AIN_DeviceID id = joystick->os4js.joystickList[joystick->os4js.instance_id].id;
|
AIN_DeviceID id = joystick->os4js.joystickList[joystick->os4js.instance_id].id;
|
||||||
|
|
||||||
#if OLDSDK
|
|
||||||
handle = GLFW_IAIN->AIN_ObtainDevice(_glfw.os4js.joystickContext, id);
|
handle = GLFW_IAIN->AIN_ObtainDevice(_glfw.os4js.joystickContext, id);
|
||||||
#else
|
|
||||||
handle = GLFW_IAIN->ObtainDevice(_glfw.os4js.joystickContext, id);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
printf("Opening joystick #%ld (AI ID=%ld)\n", joystick->os4js.instance_id, id);
|
dprintf("Opening joystick #%ld (AI ID=%ld)\n", joystick->os4js.instance_id, id);
|
||||||
|
|
||||||
if (handle) {
|
if (handle) {
|
||||||
joystick->os4js.hwdata = _glfw_calloc(1, sizeof(struct joystick_hwdata));
|
joystick->os4js.hwdata = _glfw_calloc(1, sizeof(struct joystick_hwdata));
|
||||||
@ -109,17 +101,11 @@ AMIGAINPUT_Open(_GLFWjoystick * joysticks, int device_index)
|
|||||||
strncpy(joystick->name, joystick->os4js.joystickList[joystick->os4js.instance_id].name, sizeof(joystick->name) - 1);
|
strncpy(joystick->name, joystick->os4js.joystickList[joystick->os4js.instance_id].name, sizeof(joystick->name) - 1);
|
||||||
|
|
||||||
/* Query number of axes, buttons and hats the device has */
|
/* Query number of axes, buttons and hats the device has */
|
||||||
#if OLDSDK
|
|
||||||
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_NUMAXES, 0, &num_axes, 4);
|
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_NUMAXES, 0, &num_axes, 4);
|
||||||
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_NUMBUTTONS, 0, &num_buttons, 4);
|
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_NUMBUTTONS, 0, &num_buttons, 4);
|
||||||
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_NUMHATS, 0, &num_hats, 4);
|
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_NUMHATS, 0, &num_hats, 4);
|
||||||
#else
|
|
||||||
result = result && GLFW_IAIN->Query(joystick->os4js.hwdata->context, id, AINQ_NUMAXES, 0, &num_axes, 4);
|
|
||||||
result = result && GLFW_IAIN->Query(joystick->os4js.hwdata->context, id, AINQ_NUMBUTTONS, 0, &num_buttons, 4);
|
|
||||||
result = result && GLFW_IAIN->Query(joystick->os4js.hwdata->context, id, AINQ_NUMHATS, 0, &num_hats, 4);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
printf ("Found %d axes, %d buttons, %d hats\n", num_axes, num_buttons, num_hats);
|
dprintf ("Found %d axes, %d buttons, %d hats\n", num_axes, num_buttons, num_hats);
|
||||||
|
|
||||||
joystick->axisCount = num_axes < MAX_AXES ? num_axes : MAX_AXES;
|
joystick->axisCount = num_axes < MAX_AXES ? num_axes : MAX_AXES;
|
||||||
joystick->buttonCount = num_buttons < MAX_BUTTONS ? num_buttons : MAX_BUTTONS;
|
joystick->buttonCount = num_buttons < MAX_BUTTONS ? num_buttons : MAX_BUTTONS;
|
||||||
@ -131,13 +117,8 @@ AMIGAINPUT_Open(_GLFWjoystick * joysticks, int device_index)
|
|||||||
|
|
||||||
/* Query offsets in ReadDevice buffer for axes' data */
|
/* Query offsets in ReadDevice buffer for axes' data */
|
||||||
for (i = 0; i < joystick->axisCount; i++) {
|
for (i = 0; i < joystick->axisCount; i++) {
|
||||||
#if OLDSDK
|
|
||||||
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_AXIS_OFFSET, i, &(hwdata->axisBufferOffset[i]), 4);
|
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_AXIS_OFFSET, i, &(hwdata->axisBufferOffset[i]), 4);
|
||||||
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_AXISNAME, i, &(hwdata->axisName[i][0]), 32 );
|
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_AXISNAME, i, &(hwdata->axisName[i][0]), 32 );
|
||||||
#else
|
|
||||||
result = result && GLFW_IAIN->Query(joystick->os4js.hwdata->context, id, AINQ_AXIS_OFFSET, i, &(hwdata->axisBufferOffset[i]), 4);
|
|
||||||
result = result && GLFW_IAIN->Query(joystick->os4js.hwdata->context, id, AINQ_AXISNAME, i, &(hwdata->axisName[i][0]), 32 );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the axes so that X and Y come first
|
// Sort the axes so that X and Y come first
|
||||||
@ -177,20 +158,12 @@ AMIGAINPUT_Open(_GLFWjoystick * joysticks, int device_index)
|
|||||||
|
|
||||||
/* Query offsets in ReadDevice buffer for buttons' data */
|
/* Query offsets in ReadDevice buffer for buttons' data */
|
||||||
for (i = 0; i < joystick->buttonCount; i++) {
|
for (i = 0; i < joystick->buttonCount; i++) {
|
||||||
#if OLDSDK
|
|
||||||
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_BUTTON_OFFSET, i, &(joystick->os4js.hwdata->buttonBufferOffset[i]), 4);
|
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_BUTTON_OFFSET, i, &(joystick->os4js.hwdata->buttonBufferOffset[i]), 4);
|
||||||
#else
|
|
||||||
result = result && GLFW_IAIN->Query(joystick->os4js.hwdata->context, id, AINQ_BUTTON_OFFSET, i, &(joystick->os4js.hwdata->buttonBufferOffset[i]), 4);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Query offsets in ReadDevice buffer for hats' data */
|
/* Query offsets in ReadDevice buffer for hats' data */
|
||||||
for (i = 0; i < joystick->hatCount; i++) {
|
for (i = 0; i < joystick->hatCount; i++) {
|
||||||
#if OLDSDK
|
|
||||||
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_HAT_OFFSET, i, &(hwdata->hatBufferOffset[i]), 4);
|
result = result && GLFW_IAIN->AIN_Query(joystick->os4js.hwdata->context, id, AINQ_HAT_OFFSET, i, &(hwdata->hatBufferOffset[i]), 4);
|
||||||
#else
|
|
||||||
result = result && GLFW_IAIN->Query(joystick->os4js.hwdata->context, id, AINQ_HAT_OFFSET, i, &(hwdata->hatBufferOffset[i]), 4);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -199,19 +172,15 @@ AMIGAINPUT_Open(_GLFWjoystick * joysticks, int device_index)
|
|||||||
sprintf(guid, "78696e707574%02lx000000000000000000", handle->DeviceID & 0xff);
|
sprintf(guid, "78696e707574%02lx000000000000000000", handle->DeviceID & 0xff);
|
||||||
_glfwAllocJoystick(joystick->name, guid, joystick->axisCount, joystick->buttonCount, joystick->hatCount);
|
_glfwAllocJoystick(joystick->name, guid, joystick->axisCount, joystick->buttonCount, joystick->hatCount);
|
||||||
|
|
||||||
printf("Successful\n");
|
dprintf("Successful\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OLDSDK
|
|
||||||
GLFW_IAIN->AIN_ReleaseDevice (_glfw.os4js.joystickContext, handle);
|
GLFW_IAIN->AIN_ReleaseDevice (_glfw.os4js.joystickContext, handle);
|
||||||
#else
|
|
||||||
GLFW_IAIN->ReleaseDevice (_glfw.os4js.joystickContext, handle);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Failed\n");
|
dprintf("Failed\n");
|
||||||
|
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
@ -229,7 +198,7 @@ AMIGAINPUT_EnumerateJoysticks(AIN_Device *device, void *UserData)
|
|||||||
BOOL result = FALSE;
|
BOOL result = FALSE;
|
||||||
|
|
||||||
if (*count < MAX_JOYSTICKS) {
|
if (*count < MAX_JOYSTICKS) {
|
||||||
printf("ENUMJOY: id=%ld, type=%ld, axes=%ld, buttons=%ld\n",
|
dprintf("ENUMJOY: id=%ld, type=%ld, axes=%ld, buttons=%ld\n",
|
||||||
*count,
|
*count,
|
||||||
(int32)device->Type,
|
(int32)device->Type,
|
||||||
(int32)device->NumAxes,
|
(int32)device->NumAxes,
|
||||||
@ -245,35 +214,26 @@ AMIGAINPUT_EnumerateJoysticks(AIN_Device *device, void *UserData)
|
|||||||
if ((device->NumAxes > 0) && (device->NumButtons > 0)) {
|
if ((device->NumAxes > 0) && (device->NumButtons > 0)) {
|
||||||
/* Then, check whether we can actually obtain the device
|
/* Then, check whether we can actually obtain the device
|
||||||
*/
|
*/
|
||||||
#if OLDSDK
|
|
||||||
AIN_DeviceHandle *handle = GLFW_IAIN->AIN_ObtainDevice (context, device->DeviceID);
|
AIN_DeviceHandle *handle = GLFW_IAIN->AIN_ObtainDevice (context, device->DeviceID);
|
||||||
#else
|
|
||||||
AIN_DeviceHandle *handle = GLFW_IAIN->ObtainDevice (context, device->DeviceID);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (handle) {
|
if (handle) {
|
||||||
/* Okay. This appears to be a valid device. We'll report it to GLFW.
|
/* Okay. This appears to be a valid device. We'll report it to GLFW.
|
||||||
*/
|
*/
|
||||||
joy->id = device->DeviceID;
|
joy->id = device->DeviceID;
|
||||||
joy->name = _glfw_strdup(device->DeviceName);
|
joy->name = _glfw_strdup(device->DeviceName);
|
||||||
|
|
||||||
printf("Found joystick #%ld (AI ID=%ld) '%s'\n", *count, joy->id, joy->name);
|
dprintf("Found joystick #%ld (AI ID=%ld) '%s'\n", *count, joy->id, joy->name);
|
||||||
|
|
||||||
(*count)++;
|
(*count)++;
|
||||||
|
|
||||||
#if OLDSDK
|
|
||||||
GLFW_IAIN->AIN_ReleaseDevice (context, handle);
|
GLFW_IAIN->AIN_ReleaseDevice (context, handle);
|
||||||
#else
|
|
||||||
GLFW_IAIN->ReleaseDevice (context, handle);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("Failed to obtain joystick '%s' (AI ID=%ld) - ignoring.\n", device->DeviceName, device->DeviceID);
|
dprintf("Failed to obtain joystick '%s' (AI ID=%ld) - ignoring.\n", device->DeviceName, device->DeviceID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("Joystick '%s' (AI ID=%ld) has no axes/buttons - ignoring.\n", device->DeviceName, device->DeviceID);
|
dprintf("Joystick '%s' (AI ID=%ld) has no axes/buttons - ignoring.\n", device->DeviceName, device->DeviceID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -285,7 +245,7 @@ AMIGAINPUT_EnumerateJoysticks(AIN_Device *device, void *UserData)
|
|||||||
|
|
||||||
GLFWbool _glfwInitJoysticksOS4(void)
|
GLFWbool _glfwInitJoysticksOS4(void)
|
||||||
{
|
{
|
||||||
printf("_glfwInitJoysticksOS4\n");
|
dprintf("_glfwInitJoysticksOS4\n");
|
||||||
GLFW_AIN_Base = IExec->OpenLibrary("AmigaInput.library", 51);
|
GLFW_AIN_Base = IExec->OpenLibrary("AmigaInput.library", 51);
|
||||||
|
|
||||||
if (GLFW_AIN_Base) {
|
if (GLFW_AIN_Base) {
|
||||||
@ -295,11 +255,7 @@ GLFWbool _glfwInitJoysticksOS4(void)
|
|||||||
IExec->CloseLibrary(GLFW_AIN_Base);
|
IExec->CloseLibrary(GLFW_AIN_Base);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
#if OLDSDK
|
|
||||||
_glfw.os4js.joystickContext = GLFW_IAIN->AIN_CreateContext(1, NULL);
|
_glfw.os4js.joystickContext = GLFW_IAIN->AIN_CreateContext(1, NULL);
|
||||||
#else
|
|
||||||
_glfw.os4js.joystickContext = GLFW_IAIN->CreateContext(1, NULL);
|
|
||||||
#endif
|
|
||||||
if (_glfw.os4js.joystickContext) {
|
if (_glfw.os4js.joystickContext) {
|
||||||
struct enumPacket packet = {
|
struct enumPacket packet = {
|
||||||
_glfw.os4js.joystickContext,
|
_glfw.os4js.joystickContext,
|
||||||
@ -307,13 +263,9 @@ GLFWbool _glfwInitJoysticksOS4(void)
|
|||||||
&_glfw.os4js.joystickList[0]
|
&_glfw.os4js.joystickList[0]
|
||||||
};
|
};
|
||||||
|
|
||||||
#if OLDSDK
|
|
||||||
BOOL result = GLFW_IAIN->AIN_EnumDevices(_glfw.os4js.joystickContext, AMIGAINPUT_EnumerateJoysticks, &packet);
|
BOOL result = GLFW_IAIN->AIN_EnumDevices(_glfw.os4js.joystickContext, AMIGAINPUT_EnumerateJoysticks, &packet);
|
||||||
#else
|
dprintf("EnumDevices returned %d\n", result);
|
||||||
BOOL result = GLFW_IAIN->EnumDevices(_glfw.os4js.joystickContext, AMIGAINPUT_EnumerateJoysticks, &packet);
|
dprintf("Found %ld joysticks\n", _glfw.os4js.joystickCount);
|
||||||
#endif
|
|
||||||
printf("EnumDevices returned %d\n", result);
|
|
||||||
printf("Found %ld joysticks\n", _glfw.os4js.joystickCount);
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
/*
|
/*
|
||||||
@ -325,14 +277,14 @@ GLFWbool _glfwInitJoysticksOS4(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < _glfw.os4js.joystickCount; i++) {
|
for (i = 0; i < _glfw.os4js.joystickCount; i++) {
|
||||||
printf("Add joystick %d\n", i);
|
dprintf("Add joystick %d\n", i);
|
||||||
AMIGAINPUT_Open(_glfw.joysticks, i);
|
AMIGAINPUT_Open(_glfw.joysticks, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("Failed to open AmigaInput.library\n");
|
dprintf("Failed to open AmigaInput.library\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
@ -344,7 +296,7 @@ void _glfwTerminateJoysticksOS4(void)
|
|||||||
uint32 i;
|
uint32 i;
|
||||||
|
|
||||||
for (i = 0; i < _glfw.os4js.joystickCount; i++) {
|
for (i = 0; i < _glfw.os4js.joystickCount; i++) {
|
||||||
printf("_glfw_free joystickList[i].name\n");
|
dprintf("_glfw_free joystickList[i].name\n");
|
||||||
AMIGAINPUT_Close(_glfw.joysticks + i);
|
AMIGAINPUT_Close(_glfw.joysticks + i);
|
||||||
_glfw_free((char *)_glfw.os4js.joystickList[i].name);
|
_glfw_free((char *)_glfw.os4js.joystickList[i].name);
|
||||||
}
|
}
|
||||||
@ -352,12 +304,8 @@ void _glfwTerminateJoysticksOS4(void)
|
|||||||
_glfw.os4js.joystickCount = 0;
|
_glfw.os4js.joystickCount = 0;
|
||||||
|
|
||||||
if (_glfw.os4js.joystickContext) {
|
if (_glfw.os4js.joystickContext) {
|
||||||
printf("AIN_DeleteContext\n");
|
dprintf("AIN_DeleteContext\n");
|
||||||
#if OLDSDK
|
|
||||||
GLFW_IAIN->AIN_DeleteContext(_glfw.os4js.joystickContext);
|
GLFW_IAIN->AIN_DeleteContext(_glfw.os4js.joystickContext);
|
||||||
#else
|
|
||||||
GLFW_IAIN->DeleteContext(_glfw.os4js.joystickContext);
|
|
||||||
#endif
|
|
||||||
_glfw.os4js.joystickContext = NULL;
|
_glfw.os4js.joystickContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,16 +318,12 @@ int _glfwPollJoystickOS4(_GLFWjoystick* joystick, int mode)
|
|||||||
struct joystick_hwdata *hwdata = joystick->os4js.hwdata;
|
struct joystick_hwdata *hwdata = joystick->os4js.hwdata;
|
||||||
void *buffer;
|
void *buffer;
|
||||||
|
|
||||||
//printf("Called %p\n", hwdata);
|
//dprintf("Called %p\n", hwdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Poll device for data
|
* Poll device for data
|
||||||
*/
|
*/
|
||||||
#if OLDSDK
|
|
||||||
if (hwdata && GLFW_IAIN->AIN_ReadDevice(hwdata->context, hwdata->handle, &buffer))
|
if (hwdata && GLFW_IAIN->AIN_ReadDevice(hwdata->context, hwdata->handle, &buffer))
|
||||||
#else
|
|
||||||
if (hwdata && GLFW_IAIN->ReadDevice(hwdata->context, hwdata->handle, &buffer))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define OLDSDK 1
|
|
||||||
|
|
||||||
#include <amigainput/amigainput.h>
|
#include <amigainput/amigainput.h>
|
||||||
#include <proto/amigainput.h>
|
#include <proto/amigainput.h>
|
||||||
|
|
||||||
|
@ -119,7 +119,8 @@ void _glfwPollMonitorsOS4(void)
|
|||||||
struct DimensionInfo diminfo;
|
struct DimensionInfo diminfo;
|
||||||
APTR handle;
|
APTR handle;
|
||||||
ULONG modeid;
|
ULONG modeid;
|
||||||
|
_glfw.os4.publicScreen = IIntuition->LockPubScreen(NULL);
|
||||||
|
if (_glfw.os4.publicScreen != NULL) {
|
||||||
IIntuition->GetScreenAttrs(_glfw.os4.publicScreen, SA_DisplayID, &modeid, TAG_DONE);
|
IIntuition->GetScreenAttrs(_glfw.os4.publicScreen, SA_DisplayID, &modeid, TAG_DONE);
|
||||||
|
|
||||||
handle = IGraphics->FindDisplayInfo(modeid);
|
handle = IGraphics->FindDisplayInfo(modeid);
|
||||||
@ -143,6 +144,8 @@ void _glfwPollMonitorsOS4(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IIntuition->UnlockPubScreen(NULL, _glfw.os4.publicScreen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -249,24 +252,3 @@ void _glfwSetGammaRampOS4(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
|||||||
/**********************************************************************************************/
|
/**********************************************************************************************/
|
||||||
/******************************************** PRIVATE METHODS *********************************/
|
/******************************************** PRIVATE METHODS *********************************/
|
||||||
/**********************************************************************************************/
|
/**********************************************************************************************/
|
||||||
|
|
||||||
BOOL
|
|
||||||
OS4_LockPubScreen()
|
|
||||||
{
|
|
||||||
_glfw.os4.publicScreen = IIntuition->LockPubScreen(NULL);
|
|
||||||
|
|
||||||
if (_glfw.os4.publicScreen) {
|
|
||||||
return TRUE;
|
|
||||||
} else {
|
|
||||||
dprintf("Failed to lock Workbench screen\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
OS4_UnlockPubScreen()
|
|
||||||
{
|
|
||||||
if (_glfw.os4.publicScreen) {
|
|
||||||
IIntuition->UnlockPubScreen(NULL, _glfw.os4.publicScreen);
|
|
||||||
}
|
|
||||||
}
|
|
@ -294,7 +294,5 @@ void _glfwUpdateGamepadGUIDOS4(char* guid);
|
|||||||
# define kprintf(format, args...)((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF(format, ## args)
|
# define kprintf(format, args...)((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF(format, ## args)
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
BOOL OS4_LockPubScreen();
|
|
||||||
void OS4_UnlockPubScreen();
|
|
||||||
void OS4_IconifyWindow(_GLFWwindow *window);
|
void OS4_IconifyWindow(_GLFWwindow *window);
|
||||||
void OS4_UniconifyWindow(_GLFWwindow* window);
|
void OS4_UniconifyWindow(_GLFWwindow* window);
|
||||||
|
@ -53,6 +53,7 @@ static void OS4_CreateIconifyGadget(_GLFWwindow * window);
|
|||||||
static struct DiskObject *OS4_GetDiskObject();
|
static struct DiskObject *OS4_GetDiskObject();
|
||||||
static void OS4_HandleAppIcon(struct AppMessage * msg);
|
static void OS4_HandleAppIcon(struct AppMessage * msg);
|
||||||
static ULONG OS4_BackFill(const struct Hook *hook, struct RastPort *rastport, struct BackFillMessage *message);
|
static ULONG OS4_BackFill(const struct Hook *hook, struct RastPort *rastport, struct BackFillMessage *message);
|
||||||
|
static char *UCS4ToUTF8(uint32_t ch, char *dst);
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
@ -923,20 +924,30 @@ void _glfwPollEventsOS4(void)
|
|||||||
|
|
||||||
case IDCMP_RAWKEY:
|
case IDCMP_RAWKEY:
|
||||||
uint8_t rawkey = msg.Code & 0x7F;
|
uint8_t rawkey = msg.Code & 0x7F;
|
||||||
//printf("RAWKEY = 0x%x\n", rawkey);
|
dprintf("RAWKEY = 0x%x\n", rawkey);
|
||||||
int key = _glfw.os4.keycodes[rawkey];
|
int key = _glfw.os4.keycodes[rawkey];
|
||||||
int mods = OS4_TranslateState(msg.Qualifier);
|
int mods = OS4_TranslateState(msg.Qualifier);
|
||||||
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
|
||||||
|
|
||||||
if (imsg->Code < 0x80) {
|
if (imsg->Code < 0x80) {
|
||||||
char text[2];
|
char text[5] ={0};
|
||||||
|
const uint32 unicode = OS4_TranslateUnicode(msg.Code, msg.Qualifier);
|
||||||
|
if (unicode) {
|
||||||
|
UCS4ToUTF8(unicode, text);
|
||||||
|
|
||||||
|
_glfwInputKey(window, key, rawkey, GLFW_PRESS, mods);
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
if (text[0] != '\0')
|
||||||
|
_glfwInputChar(window, text[i], mods, plain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
text[0] = OS4_TranslateUnicode(msg.Code, msg.Qualifier);
|
text[0] = OS4_TranslateUnicode(msg.Code, msg.Qualifier);
|
||||||
text[1] = '\0';
|
text[1] = '\0';
|
||||||
|
|
||||||
_glfwInputKey(window, key, rawkey, GLFW_PRESS, mods);
|
_glfwInputKey(window, key, rawkey, GLFW_PRESS, mods);
|
||||||
|
|
||||||
if (text[0] && text[0] < 0x80) {
|
if (text[0] && text[0] < 0x80)
|
||||||
_glfwInputChar(window, text[0], mods, plain);
|
_glfwInputChar(window, text[0], mods, plain);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -945,14 +956,14 @@ void _glfwPollEventsOS4(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDCMP_MOUSEBUTTONS:
|
case IDCMP_MOUSEBUTTONS:
|
||||||
//OS4_HandleMouseButtons(_this, &msg);
|
|
||||||
int button = OS4_GetButton(imsg->Code);
|
int button = OS4_GetButton(imsg->Code);
|
||||||
int state = OS4_GetButtonState(imsg->Code);
|
int state = OS4_GetButtonState(imsg->Code);
|
||||||
|
int bmods = OS4_TranslateState(msg.Qualifier);
|
||||||
|
|
||||||
_glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
button,
|
button,
|
||||||
state,
|
state,
|
||||||
0);
|
bmods);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDCMP_EXTENDEDMOUSE:
|
case IDCMP_EXTENDEDMOUSE:
|
||||||
@ -1197,12 +1208,12 @@ const char* _glfwGetScancodeNameOS4(int scancode)
|
|||||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid OS4 scancode %i", scancode);
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid OS4 scancode %i", scancode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return _glfw.os4.keynames[_glfw.os4.keycodes[scancode]];
|
return _glfw.os4.keynames[scancode];
|
||||||
}
|
}
|
||||||
|
|
||||||
int _glfwGetKeyScancodeOS4(int key)
|
int _glfwGetKeyScancodeOS4(int key)
|
||||||
{
|
{
|
||||||
return key;
|
return _glfw.os4.scancodes[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwGetRequiredInstanceExtensionsOS4(char** extensions)
|
void _glfwGetRequiredInstanceExtensionsOS4(char** extensions)
|
||||||
@ -1590,3 +1601,29 @@ OS4_BackFill(const struct Hook *hook, struct RastPort *rastport, struct BackFill
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
char *UCS4ToUTF8(uint32_t ch, char *dst)
|
||||||
|
{
|
||||||
|
uint8_t *p = (uint8_t *)dst;
|
||||||
|
if (ch <= 0x7F) {
|
||||||
|
*p = (uint8_t)ch;
|
||||||
|
++dst;
|
||||||
|
} else if (ch <= 0x7FF) {
|
||||||
|
p[0] = 0xC0 | (uint8_t)((ch >> 6) & 0x1F);
|
||||||
|
p[1] = 0x80 | (uint8_t)(ch & 0x3F);
|
||||||
|
dst += 2;
|
||||||
|
} else if (ch <= 0xFFFF) {
|
||||||
|
p[0] = 0xE0 | (uint8_t)((ch >> 12) & 0x0F);
|
||||||
|
p[1] = 0x80 | (uint8_t)((ch >> 6) & 0x3F);
|
||||||
|
p[2] = 0x80 | (uint8_t)(ch & 0x3F);
|
||||||
|
dst += 3;
|
||||||
|
} else {
|
||||||
|
p[0] = 0xF0 | (uint8_t)((ch >> 18) & 0x07);
|
||||||
|
p[1] = 0x80 | (uint8_t)((ch >> 12) & 0x3F);
|
||||||
|
p[2] = 0x80 | (uint8_t)((ch >> 6) & 0x3F);
|
||||||
|
p[3] = 0x80 | (uint8_t)(ch & 0x3F);
|
||||||
|
dst += 4;
|
||||||
|
}
|
||||||
|
return dst;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user