mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add ButtonEvent::T_resume_down
This commit is contained in:
parent
a899d41bdb
commit
9e1159afcc
@ -158,6 +158,19 @@ button_down(ButtonHandle button) {
|
|||||||
_button_events.push_back(ButtonEvent(button, ButtonEvent::T_down));
|
_button_events.push_back(ButtonEvent(button, ButtonEvent::T_down));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GraphicsWindowInputDevice::button_resume_down
|
||||||
|
// Access: Public
|
||||||
|
// Description: Records that the indicated button was depressed
|
||||||
|
// earlier, and we only just detected the event after
|
||||||
|
// the fact. This is mainly useful for tracking the
|
||||||
|
// state of modifier keys.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void GraphicsWindowInputDevice::
|
||||||
|
button_resume_down(ButtonHandle button) {
|
||||||
|
_button_events.push_back(ButtonEvent(button, ButtonEvent::T_resume_down));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GraphicsWindowInputDevice::button_up
|
// Function: GraphicsWindowInputDevice::button_up
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
// The following interface is for the various kinds of
|
// The following interface is for the various kinds of
|
||||||
// GraphicsWindows to record the data incoming on the device.
|
// GraphicsWindows to record the data incoming on the device.
|
||||||
void button_down(ButtonHandle button);
|
void button_down(ButtonHandle button);
|
||||||
|
void button_resume_down(ButtonHandle button);
|
||||||
void button_up(ButtonHandle button);
|
void button_up(ButtonHandle button);
|
||||||
void keystroke(int keycode);
|
void keystroke(int keycode);
|
||||||
INLINE void set_pointer_in_window(int x, int y);
|
INLINE void set_pointer_in_window(int x, int y);
|
||||||
|
@ -101,6 +101,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static TypeHandle _type_handle;
|
static TypeHandle _type_handle;
|
||||||
|
|
||||||
friend class wdxGraphicsWindow8;
|
friend class wdxGraphicsWindow8;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -137,8 +137,8 @@ wdxGraphicsWindow8::
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void wdxGraphicsWindow8::
|
void wdxGraphicsWindow8::
|
||||||
make_gsg() {
|
make_gsg() {
|
||||||
wdxGraphicsPipe8 *pipe8;
|
wdxGraphicsPipe8 *dxpipe;
|
||||||
DCAST_INTO_V(pipe8, _pipe);
|
DCAST_INTO_V(dxpipe, _pipe);
|
||||||
|
|
||||||
nassertv(_gsg == (GraphicsStateGuardian *)NULL);
|
nassertv(_gsg == (GraphicsStateGuardian *)NULL);
|
||||||
_dxgsg = new DXGraphicsStateGuardian8(this);
|
_dxgsg = new DXGraphicsStateGuardian8(this);
|
||||||
@ -164,10 +164,10 @@ make_gsg() {
|
|||||||
if (hFind != INVALID_HANDLE_VALUE) {
|
if (hFind != INVALID_HANDLE_VALUE) {
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
_dxgsg->scrn.bIsDX81 = true;
|
_dxgsg->scrn.bIsDX81 = true;
|
||||||
pD3D8 = (*pipe8->_Direct3DCreate8)(D3D_SDK_VERSION_8_1);
|
pD3D8 = (*dxpipe->_Direct3DCreate8)(D3D_SDK_VERSION_8_1);
|
||||||
} else {
|
} else {
|
||||||
_dxgsg->scrn.bIsDX81 = false;
|
_dxgsg->scrn.bIsDX81 = false;
|
||||||
pD3D8 = (*pipe8->_Direct3DCreate8)(D3D_SDK_VERSION_8_0);
|
pD3D8 = (*dxpipe->_Direct3DCreate8)(D3D_SDK_VERSION_8_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pD3D8 == NULL) {
|
if (pD3D8 == NULL) {
|
||||||
@ -703,8 +703,8 @@ choose_adapter(LPDIRECT3D8 pD3D8) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool wdxGraphicsWindow8::
|
bool wdxGraphicsWindow8::
|
||||||
search_for_device(LPDIRECT3D8 pD3D8, DXDeviceInfo *device_info) {
|
search_for_device(LPDIRECT3D8 pD3D8, DXDeviceInfo *device_info) {
|
||||||
wdxGraphicsPipe8 *pipe8;
|
wdxGraphicsPipe8 *dxpipe;
|
||||||
DCAST_INTO_R(pipe8, _pipe, false);
|
DCAST_INTO_R(dxpipe, _pipe, false);
|
||||||
|
|
||||||
DWORD dwRenderWidth = get_properties().get_x_size();
|
DWORD dwRenderWidth = get_properties().get_x_size();
|
||||||
DWORD dwRenderHeight = get_properties().get_y_size();
|
DWORD dwRenderHeight = get_properties().get_y_size();
|
||||||
@ -763,20 +763,20 @@ search_for_device(LPDIRECT3D8 pD3D8, DXDeviceInfo *device_info) {
|
|||||||
UINT IDnum;
|
UINT IDnum;
|
||||||
|
|
||||||
// simple linear search to match DX7 card info w/DX8 card ID
|
// simple linear search to match DX7 card info w/DX8 card ID
|
||||||
for (IDnum=0; IDnum < pipe8->_card_ids.size(); IDnum++) {
|
for (IDnum=0; IDnum < dxpipe->_card_ids.size(); IDnum++) {
|
||||||
// wdxdisplay8_cat.info()
|
// wdxdisplay8_cat.info()
|
||||||
// << "comparing '" << pipe8->_card_ids[IDnum].Driver
|
// << "comparing '" << dxpipe->_card_ids[IDnum].Driver
|
||||||
// << "' to '" << _dxgsg->scrn.DXDeviceID.Driver << "'\n";
|
// << "' to '" << _dxgsg->scrn.DXDeviceID.Driver << "'\n";
|
||||||
if (//(stricmp(pipe8->_card_ids[IDnum].szDriver,device_info->szDriver)==0) &&
|
if (//(stricmp(dxpipe->_card_ids[IDnum].szDriver,device_info->szDriver)==0) &&
|
||||||
(device_info->VendorID==pipe8->_card_ids[IDnum].VendorID) &&
|
(device_info->VendorID==dxpipe->_card_ids[IDnum].VendorID) &&
|
||||||
(device_info->DeviceID==pipe8->_card_ids[IDnum].DeviceID) &&
|
(device_info->DeviceID==dxpipe->_card_ids[IDnum].DeviceID) &&
|
||||||
(device_info->hMon==pipe8->_card_ids[IDnum].hMon))
|
(device_info->hMon==dxpipe->_card_ids[IDnum].hMon))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IDnum < pipe8->_card_ids.size()) {
|
if (IDnum < dxpipe->_card_ids.size()) {
|
||||||
_dxgsg->scrn.MaxAvailVidMem = pipe8->_card_ids[IDnum].MaxAvailVidMem;
|
_dxgsg->scrn.MaxAvailVidMem = dxpipe->_card_ids[IDnum].MaxAvailVidMem;
|
||||||
_dxgsg->scrn.bIsLowVidMemCard = pipe8->_card_ids[IDnum].bIsLowVidMemCard;
|
_dxgsg->scrn.bIsLowVidMemCard = dxpipe->_card_ids[IDnum].bIsLowVidMemCard;
|
||||||
} else {
|
} else {
|
||||||
wdxdisplay8_cat.error()
|
wdxdisplay8_cat.error()
|
||||||
<< "Error: couldnt find a CardID match in DX7 info, assuming card is not a lowmem card\n";
|
<< "Error: couldnt find a CardID match in DX7 info, assuming card is not a lowmem card\n";
|
||||||
|
@ -30,6 +30,10 @@ output(ostream &out) const {
|
|||||||
out << "button " << _button << " down";
|
out << "button " << _button << " down";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_resume_down:
|
||||||
|
out << "button " << _button << " resume down";
|
||||||
|
break;
|
||||||
|
|
||||||
case T_up:
|
case T_up:
|
||||||
out << "button " << _button << " up";
|
out << "button " << _button << " up";
|
||||||
break;
|
break;
|
||||||
|
@ -52,8 +52,21 @@
|
|||||||
class EXPCL_PANDA ButtonEvent {
|
class EXPCL_PANDA ButtonEvent {
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
|
// T_down and T_up represent a button changing state
|
||||||
|
// correspondingly. T_resume_down is a special event that is only
|
||||||
|
// thrown when focus is returned to a window and a button is
|
||||||
|
// detected as being held down at that point; it indicates that
|
||||||
|
// the button should be considered down now (if it wasn't
|
||||||
|
// already), but it didn't just get pressed down at this moment,
|
||||||
|
// it was depressed some time ago. It's mainly used for correct
|
||||||
|
// tracking of modifier keys like shift and control, and can be
|
||||||
|
// ignored for other keys.
|
||||||
T_down,
|
T_down,
|
||||||
|
T_resume_down,
|
||||||
T_up,
|
T_up,
|
||||||
|
|
||||||
|
// T_keystroke is a special keystroke event, and is sent along
|
||||||
|
// with a Unicode keycode value, not a ButtonHandle.
|
||||||
T_keystroke
|
T_keystroke
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,7 +82,8 @@ public:
|
|||||||
|
|
||||||
void output(ostream &out) const;
|
void output(ostream &out) const;
|
||||||
|
|
||||||
// _button will be filled in if type is T_down or T_up.
|
// _button will be filled in if type is T_down, T_resume_down, or
|
||||||
|
// T_up.
|
||||||
ButtonHandle _button;
|
ButtonHandle _button;
|
||||||
|
|
||||||
// _keycode will be filled in if type is T_keystroke. It will be
|
// _keycode will be filled in if type is T_keystroke. It will be
|
||||||
|
@ -370,6 +370,13 @@ do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) {
|
|||||||
_button_events->add_event(be);
|
_button_events->add_event(be);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (be._type == ButtonEvent::T_resume_down) {
|
||||||
|
// Button resume down. The button was pressed at some earlier
|
||||||
|
// time, and the event was only just now detected. Don't
|
||||||
|
// throw an event now (since we already missed it), but do
|
||||||
|
// make sure our modifiers are up-to-date.
|
||||||
|
_mods.button_down(be._button);
|
||||||
|
|
||||||
} else if (be._type == ButtonEvent::T_up) {
|
} else if (be._type == ButtonEvent::T_up) {
|
||||||
// Button up.
|
// Button up.
|
||||||
_mods.button_up(be._button);
|
_mods.button_up(be._button);
|
||||||
|
@ -51,6 +51,20 @@ handle_keypress(ButtonHandle key, int x, int y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: WinGraphicsWindow::handle_keyresume
|
||||||
|
// Access: Private
|
||||||
|
// Description: Indicates we detected a key was already down when the
|
||||||
|
// focus is restored to the window. Mainly useful for
|
||||||
|
// tracking the state of modifier keys.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void WinGraphicsWindow::
|
||||||
|
handle_keyresume(ButtonHandle key) {
|
||||||
|
if (key != ButtonHandle::none()) {
|
||||||
|
_input_devices[0].button_resume_down(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: WinGraphicsWindow::handle_keyrelease
|
// Function: WinGraphicsWindow::handle_keyrelease
|
||||||
// Access: Private
|
// Access: Private
|
||||||
@ -58,7 +72,9 @@ handle_keypress(ButtonHandle key, int x, int y) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void WinGraphicsWindow::
|
INLINE void WinGraphicsWindow::
|
||||||
handle_keyrelease(ButtonHandle key) {
|
handle_keyrelease(ButtonHandle key) {
|
||||||
_input_devices[0].button_up(key);
|
if (key != ButtonHandle::none()) {
|
||||||
|
_input_devices[0].button_up(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -953,10 +953,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
{
|
{
|
||||||
POINT point;
|
|
||||||
GetCursorPos(&point);
|
|
||||||
ScreenToClient(hwnd, &point);
|
|
||||||
|
|
||||||
// When we lose focus, the app may miss key-up events for keys
|
// When we lose focus, the app may miss key-up events for keys
|
||||||
// that were formerly held down (and vice-versa). Therefore,
|
// that were formerly held down (and vice-versa). Therefore,
|
||||||
// when focus is regained, compare the state of the keyboard to
|
// when focus is regained, compare the state of the keyboard to
|
||||||
@ -976,7 +972,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
// This key has changed state.
|
// This key has changed state.
|
||||||
if ((new_keyboard_state[i] & 0x80) != 0) {
|
if ((new_keyboard_state[i] & 0x80) != 0) {
|
||||||
// The key is now held down.
|
// The key is now held down.
|
||||||
handle_keypress(lookup_key(i), point.x, point.y);
|
handle_keyresume(lookup_key(i));
|
||||||
} else {
|
} else {
|
||||||
// The key is now released.
|
// The key is now released.
|
||||||
handle_keyrelease(lookup_key(i));
|
handle_keyrelease(lookup_key(i));
|
||||||
|
@ -83,6 +83,7 @@ private:
|
|||||||
INLINE void handle_mouse_motion(int x, int y);
|
INLINE void handle_mouse_motion(int x, int y);
|
||||||
INLINE void handle_mouse_exit(void);
|
INLINE void handle_mouse_exit(void);
|
||||||
INLINE void handle_keypress(ButtonHandle key, int x, int y);
|
INLINE void handle_keypress(ButtonHandle key, int x, int y);
|
||||||
|
INLINE void handle_keyresume(ButtonHandle key);
|
||||||
INLINE void handle_keyrelease(ButtonHandle key);
|
INLINE void handle_keyrelease(ButtonHandle key);
|
||||||
ButtonHandle lookup_key(WPARAM wparam) const;
|
ButtonHandle lookup_key(WPARAM wparam) const;
|
||||||
INLINE int translate_mouse(int pos) const;
|
INLINE int translate_mouse(int pos) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user